gs1 / EPCIS

Draft files being shared for EPCIS 2.0 development
Other
22 stars 7 forks source link

Custom GS1 header required to negotiate EPC representation #190

Closed shalikasingh closed 3 years ago

shalikasingh commented 3 years ago

Hi @joelvogt, @mgh128

We were analyzing on way to implement the newly introduced feature Digital Link and have found out that in order to negotiate how EPC values must be returned in EPCIS events from any /queries endpoint we need to define a GS1 custom header to support any of these values below

Client expresses its preferences: Always_DL, Always_EPC_URN, Never_Translate, No_Preference

Server expresses its capabilities: Client_Chooses, Always_DL, Always_EPC_URN, Never_Translates

And would also like to know if the client selects No_Preference what should be the default behavior of the server?

joelvogt commented 3 years ago

Hi @shalikasingh , would that be like a URL format? Is this something a DL resolver should handle? Looking at the header you proposed, would GS1-DL-Required = (*|true|false) do the job?

shalikasingh commented 3 years ago

Hi @joelvogt,

With respect to the name of the header, how about keeping it as "GS1-EPC-Format". As true|false is not a relevant value here. We need to support the below keywords as value to the header Always_DL, Always_EPC_URN, Never_Translate, No_Preference, Client_Chooses

And would like to know your thoughts on when a client chooses No_Preference then by default how the server should behave?

mgh128 commented 3 years ago

Hi @shalikasingh, @joelvogt Sorry for thee delay in replying. I agree with @shalikasingh that we probably need to define new headers: The server/repository declares a header to express its capabilities.
If the server/repository expresses 'Client_chooses', then the query client declares a header to express its preferences.
If the client expresses "No_Preference", then the server may express any of Always_DL, Always_EPC_URN, Never_Translate, No_Preference. If the client expresses No_Preference then either the server/repository must choose whether it uses Always_DL , Always_EPC_URN , Never_Translates .
We (GS1, EPCIS standar) could provide guidance that Always_DL would be the forward-looking choice in such situations.

@joelvogt - I'm not sure that this is really an issue for GS1 Digital Link resolvers. I'd be very surprised if any company would support more than one EPCIS repository for a particular purpose and would want to branch between them based on whether the client wanted the results as EPC URNs or as GS1 Digital Link URIs. There would also be the challenge of keeping those two or more EPCIS repositories synchronised. I think it's therefore more likely that each supply chain company would use one EPCIS repository for a particular purpose (even if they're required by some legislation to contribute event data to a government repository in addition) and that they wouldn't be branching at the resolver layer about which repository to redirect to; instead it's just an extended form of content negotiation with an individual EPCIS repository using custom HTTP headers in both the client's request and the server's response.

We probably also need a way to discover the behaviour of the server regarding DL vs EPC URN, just as we provide a mechanism to discover the version number of the EPCIS and CBV standards that the repository claims to support.

For the OpenAPI interface for EPCIS, I agree with @shalikasingh that this means we need:

GS1-EPC-Format as one of the responses within the options tagged 'Discovery' - within lines 54-84 and 110-136 of https://github.com/gs1/EPCIS/blob/master/REST%20Bindings/openapi.yaml
and elsewhere - essentially anywhere where GS1-EPCIS-Version appears, GS1-EPC-Format should probably also appear as a header or parameter.

joelvogt commented 3 years ago

@shalikasingh , which case does Never_Translates cover? Isn't Always_DL or Always_EPC_URN equal Never_Translates?

mgh128 commented 3 years ago

Hi @joelvogt

Never_Translates means that the repository/server never changes the format of the EPC. If an EPC URN is captured, the same EPC URN appears in the query results. If a GS1 Digital Link URI is captured, the same GS1 Digital Link URI appears in the query results.

Always_DL means that even is an EPC URN is captured, it will always be translated to the corresponding GS1 Digital Link URI in the query results.

Always_EPC_URN means that even if a GS1 Digital Link URI is captured, it will always be translated to the corresponding EPC URN in the query results.

Never_Translates means that the repository/server will never translate what is captured when it returns query results (though it should maintain its own internal index to ensure that a query for DL matches the corresponding EPC URN in the data or vice versa)

joelvogt commented 3 years ago

@mgh128 thanks for the explanation! Ah I see, it covers the case to keep the original format in the payload.

domguinard commented 3 years ago

This appears to be a duplicate but do reopen if it turns out not to be.