ericblade / mws-advanced

Javascript (node) Amazon Merchant Web Services (MWS) code with mws-simple as it's underpinnings
Apache License 2.0
41 stars 11 forks source link

GetServiceStatus #171

Open over-engineer opened 4 years ago

over-engineer commented 4 years ago

Hello there 👋

Is there a way to get the status of each MWS service separately?

For example, both the Orders API and the Fulfillment Inventory API contain a GetServiceStatus operation which returns the operational Status of the API.

I couldn't find a method that wraps those endpoints, nor a way to specify the API when requesting it via .callEndpoint() 😕

So, I could do:

(async () => {
  const results = await mws.callEndpoint('GetServiceStatus');
})();

which returns an object like this:

{ Status: 'GREEN', Timestamp: '2020-07-24T09:52:45.785Z' }

However, it's unclear which API this GetServiceStatus operation belongs to.

ericblade commented 4 years ago

That's actually a really good question, and something that I've noted as a possibility of running into issue with in the code itself.

I've not actually used those APIs -- do they actually produce different results? It shouldn't be too difficult to put a wrapper on those functions, so that you can differentiate between them.

Taking a quick look through the docs, the following sections have GetServiceStatus: Easy Ship, Finances, Fulfillment Inbound, Fulfillment Inventory, Fulfillment Outbound, Merchant Fulfillment, Orders, Products, Recommendations, Sellers, Shipment Invoicing, Subscriptions

These sections do NOT have a GetServiceStatus: Feeds, Reports

Perhaps a mws.getServiceStatus(some indicator of which section you want) ? I'm actually thinking perhaps a bit-flag type of thing in case you want multiple sections, ie mws.getServiceStatus(INBOUND & OUTBOUND) or even mws.getServiceStatus(ALL) ..

Noting that it does have a max request quota of basically 2 requests every ten minutes, it might take a little while to test. I hope that that quota isn't shared across all of them!

ericblade commented 4 years ago

@over-engineer hi there :) If you have any input as to how you'd like to see it work, I'd love to hear :) thanks!

over-engineer commented 4 years ago

Hello again,

thanks for the prompt reply! I’m currently working on multiple projects, so I didn’t get a chance to look into this sooner.

I've not actually used those APIs -- do they actually produce different results?

MWS docs state (emphasis mine):

The GetServiceStatus operation returns the operational status of the Orders API section of Amazon Marketplace Web Service.

The GetServiceStatus operation returns the operational status of the Fulfillment Inbound Shipment API section of Amazon Marketplace Web Service.

So, I’d guess they do produce different results. Though, I always get a “GREEN status” so I’ve never confirmed it myself.

Perhaps a mws.getServiceStatus(some indicator of which section you want) ?

That sounds great!

I'm actually thinking perhaps a bit-flag type of thing in case you want multiple sections, ie mws.getServiceStatus(INBOUND & OUTBOUND) or even mws.getServiceStatus(ALL)

That’s reasonable, and since all of them seem to have a maximum request quota of two and a restore rate of one request every five minutes, we don’t even have to worry about running out of requests for one operation.

As long as what .getServiceStatus() returns indicates which service(s) are degraded/unavailble.

Noting that it does have a max request quota of basically 2 requests every ten minutes, it might take a little while to test.

Yeah, testing rate limited APIs is a PITA, thanks for doing this 😄

ericblade commented 4 years ago

heh, sure. shouldn't take too much to put together, though actually verifying it works well without an outage isn't going to happen :-D