Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example URL scheme with POST for Health #217

Closed
wants to merge 8 commits into from
Closed

Conversation

cookeac
Copy link
Collaborator

@cookeac cookeac commented May 20, 2021

This is a first experiment with a separate URL scheme for the tag ADE-1.x-health.
It covers health diagnosis, treatment, and treatment programme.
Methods supported are

  • GET (collection)
  • POST (to collection - single event)
  • POST (batches)

This implements SOME of the thinking in #154 but is not yet a fix. More work to be done on Error handling, for example.

cookeac and others added 3 commits May 20, 2021 17:28
@cookeac
Copy link
Collaborator Author

cookeac commented May 20, 2021

Created this for discussion/comment at the meeting. It can be removed after if on the wrong track.

Copy link
Contributor

@ahokkonen ahokkonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some review comments.

Our main concern is that this approach would fit perfectly atomic operations, but in our solution, we need to support non-atomic scenarios where party failure/success is allowed. For that we need a mechanism to determinate statuses of the sent resources back from the service response.
So, it is not enough to just have a same resource back in response, but also a status and possible error array for failed resources.

@cookeac
Copy link
Collaborator Author

cookeac commented Jun 14, 2021 via email

@ahokkonen
Copy link
Contributor

ahokkonen commented Jun 15, 2021

@cookeac
that is true - our case and requirements are a bit out of specs. For https statuses and response we where thinking about the following approach:

  1. Batch operation must return a success status code (200) only if processing of all resources is succeeded.
  2. If any single resource handling fails the whole batch operation must return the failure status code (4xx)
  3. Service response must contain processing information about every resource from batch request including successed and failed. For successed we need to get back server updated information (server generated identifier, for example) and for failed we need to get an information about the failure.

Example for the batch response for one successed and one failed resource handling response

[
    {
        "id": null,
        "meta": {
            "source": "XXXX",
        },
        "errors": [
            {
                "id": null,
                "status": 400,
                "code": null,
                "title": null,
                "detail": "Required field cannot be null: Meta.SourceId",
                "meta": null
            }
        ]
    },
    {
        "id": "5",
        "meta": {
            "source": "XXXX",
            "sourceId": "352178635217635126783",
            "modified": "2021-06-15T11:12:10.7779154Z",
            "creator": "iDDEN.Stub"
        },
        "errors": null
    }
]

@alamers alamers linked an issue Jun 17, 2021 that may be closed by this pull request
@ghost
Copy link

ghost commented Jun 17, 2021

As discussed in our meeting, it would be nice if we could add "warnings" (similar to errors) so that the receiving system can add those to entities that were accepted, but still something important needs to be reported back. In general, this could also be interesting for a single post as well.

@cookeac
Copy link
Collaborator Author

cookeac commented Jul 1, 2021

We should revisit batches. Maybe a REST compliant single item POST and a /batches/ post that does not attempt to be compliant with REST norms but instead returns a special purpose result that deals with the identifiers, errors and warnings as discussed. A sort of morph of problem details and success. It should support multi-value error returns.

@cookeac cookeac marked this pull request as draft July 1, 2021 06:07
@cookeac
Copy link
Collaborator Author

cookeac commented Jul 1, 2021

Changed /batches/ POST to return an array of icarBatchResult instead (in case of both 200 and error). This will contain:

  • id - issued id
  • meta - incl source/sourceId
  • errors (array of icarErrorResource)
  • warnings (array of icarErrorResource that represents warning messages)

@cookeac cookeac marked this pull request as ready for review July 1, 2021 07:58
@cookeac cookeac requested a review from ahokkonen July 15, 2021 05:50
Copy link
Contributor

@ahokkonen ahokkonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some comments/questions

"$ref": "../types/icarMetaDataType.json",
"description": "Metadata for the posted resource. Allows specification of the source, source Id to synchronise data."
},
"errors": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could errors and warnings be combines under one field ("norifications") and icarErrorResource (maybe then resource name should be different) have an additional field "severity" to identify the severity level of the message? with that approach we could pass errors, warning and infos withint the same set of resources?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered that too - I separated them because then the client can quickly check to see if an array is empty or not rather than having to look at each item for severity, but I'm open to doing it the other way as well.

Copy link
Contributor

@ahokkonen ahokkonen Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have any strong feelings about it :) both solutions would be fine in my opinion.
If we'll decide to go with the combined list then we'll need to define enumeration for severity levels - Info, Warning, Error (maybe Critical?) - where "Error" is an indication for event failure and other are just an additional notification for successed processing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed icarErrorResource to icarBatchResultMessage, and added icarBatchResultSeverityType enum. Removed errors[] and warnings[] arrays and replaced with messages[].

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the rename was not fully done yet? When I run java -jar ~/local/openapi-generator-cli-5.2.0.jar generate -g jaxrs-resteasy -i https://raw.githubusercontent.com/cookeac/ICAR/master/url-schemes/healthURLScheme.json I get a lot of messages stating:
Caused by: java.io.FileNotFoundException: https://raw.githubusercontent.com/cookeac/ICAR/master/resources/icarErrorResource.json

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(exampleUrlScheme.json generates fine)

cookeac added 3 commits July 26, 2021 20:28
Renamed icarErrorResource to icarBatchResultMessage, and added icarBatchResultSeverityType enum.
Batch POSTS now always return an array of icarBatchResult, each of which may contain an array of icarErrorWarningMessageResource.

Single POSTs if successful return the posted object (ID filled in), otherwise they return an errors array of icarErrorWarningMessageResource.

Sorry for renaming the file, but it helped to clarify its purpose.
@cookeac cookeac closed this Jul 30, 2021
@cookeac cookeac reopened this Jul 30, 2021
@cookeac cookeac closed this Jul 30, 2021
@cookeac cookeac deleted the master branch August 27, 2021 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Semantics for POST method
3 participants