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

Added Request & Response to API Spec #177

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 2 additions & 96 deletions docs/jsonapi-network-spec.textile
Original file line number Diff line number Diff line change
Expand Up @@ -120,103 +120,9 @@ https://stargate.mycompany.com/my-namespace/users

p. Requests sent to a Collection that does not exist (using a valid namespace name) result in the creation of the Collection and delivery of the message. This may take longer than delivering a message to an existing Collection.

h2(#request-message). Request Message

Request messages contain only a single command. Batch operations such as bulk loading are implementing using commands that support the inclusion of multiple documents in the command. The request message is a single JSON document (a JSON Object) that represents the command to run.

p. _Syntax:_

bc(syntax)..
<request-message> ::= <command>

p. Commands are defined in the "JSON API Query Specification" document. For the purpose of this document we are only concerned that they are well formed JSON documents.

p. _Sample:_

bc(sample)..
{"find" : {
"filter" : {"name": "aaron"},
"projection" : {"name": 1, :"age" : 1}
}
}

p. Top level names in the request document other than a command name are ignored, except where specified in this document.

h3(#request-message-errors). Errors

# A request with more than one command results in a #TODO soft error.

h2(#response-message). Response Message

A single JSON format is used for all response messages, though different fields may be present depending on the command.

p. _Syntax:_

bc(syntax)..
<response-message> ::= (errors (<error>)+)?,
(status (<command-status>)+)?,
(data <response-data>)?,

<<error> ::= message <ascii-string>,
(<error-field>)*
<error-field> ::= <error-field-name> <error-field-value>
<error-field-name> ::= <json-string>
<error-field-value> ::= <json-value>

<command-status> ::= <command-status-name> <command-status-value>
<command-status-name> ::= <json-string>
<command-status-value> ::= <json-value>

<response-data> ::= docs (<document>)*,
(nextPageState <page-state>)?,
(count <document-count>)?
<page-state> ::= <ascii-string>
<document-count> ::= <positive-integer>

p. The contents of the @<response-message>@ depend on the command, in general though:

* A successful command to read documents *must* have @<response-data>@ and *may* have one or more @<command-status>@.
* A successful command to insert or update data that does not return documents *must* have one or more @<command-status>@.
* A successful command to insert or update data that returns documents *must* have one or more @<command-status>@ and *must* have @<response-data>@.
* An unsuccessful command *must* have one or more @<error>@'s and no other items.

Error information or additional status, such as the @_id@s of inserted documents, is included by some commands.

Error responses include one or more @<error-info>@ under the @error@ name. Error info must include a @message@ intended for humans and may include other information.

@<command-status>@ information generally describes the side effects of commands, such as the number of updated documents or the @_id@s of inserted documents.

@<response-data>@ contains zero or more documents returned from the command, if present @<page-state>@ indicates further results are available. See command details for information on how to use the page state.

p. _find Sample:_

bc(sample)..
{
"data" : {
"docs" : [
{"username" : "aaron"}
]
}
}

p. _insertMany Sample:_

bc(sample)..
{
"status" : {
insertedIds : ["doc1", "doc2", "doc3"]
}
}

p. _insertOne with error Sample:_

bc(sample)..
{
"errors" : [
{"message": "_docID cannot be Null"}
]
}

*TODO* : Request and Response messages moved into the API Spec.

h2(#authn-authz). Authentication and Authorization

# TODO - basically we just use the tokens we have now
Loading