diff --git a/artifacts/CAMARA_common.json b/artifacts/CAMARA_common.json new file mode 100644 index 00000000..d7d8b8a5 --- /dev/null +++ b/artifacts/CAMARA_common.json @@ -0,0 +1,359 @@ +{ + "info": { + "description": "Common data and errors for CAMARA APIs", + "version": "0.3.0", + "title": "Common data and errors for CAMARA APIs" + }, + "components": { + "schemas": { + "TimePeriod": { + "properties": { + "startDate": { + "type": "string", + "format": "date-time", + "description": "An instant of time, starting of the TimePeriod" + }, + "endDate": { + "type": "string", + "format": "date-time", + "description": "An instant of time, ending of the TimePeriod. If not included, then the period has no ending date" + } + }, + "required": [ + "startDate" + ] + }, + "ErrorInfo": { + "type": "object", + "required": [ + "message", + "status", + "code" + ], + "properties": { + "message": { + "type": "string", + "description": "A human readable description of what the event represent" + }, + "status": { + "type": "integer", + "description": "HTTP response status code" + }, + "code": { + "type": "string", + "description": "Friendly Code to describe the error" + } + } + } + } + }, + "responses": { + "InvalidArgument": { + "description": "Invalid Argument", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 400, + "code": "INVALID_INPUT", + "message": "Schema validation failed at ..." + } + } + } + }, + "Conflict": { + "description": "conflict", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 409, + "code": "CONFLICT", + "message": "Schema validation failed at ..." + } + } + } + }, + "FailedPrecondition": { + "description": "Failed precondition", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 400, + "code": "FAILED_PRECONDITION", + "message": "Schema validation failed at ..." + } + } + } + }, + "OutOfRange": { + "description": "Out of Range", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 400, + "code": "OUT_OF_RANGE", + "message": "Schema validation failed at ..." + } + } + } + }, + "Unauthenticated": { + "description": "Not Authenticated", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 401, + "code": "UNAUTHENTICATED", + "message": "Request not authenticated due to missing, invalid, or expired" + } + } + } + }, + "PermissionDenied": { + "description": "Permission denied", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 403, + "code": "PERMISSION_DENIED", + "message": "Client does not have sufficient permissions to perform" + } + } + } + }, + "NotFound": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 404, + "code": "NOT_FOUND", + "message": "The specified resource is not found" + } + } + } + }, + "Aborted": { + "description": "Aborted", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 409, + "code": "ABORTED", + "message": "Concurrency conflict." + } + } + } + }, + "AlreadyExists": { + "description": "Already Exists", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 409, + "code": "ALREADY_EXISTS", + "message": "The resource that a client tried to create already exists." + } + } + } + }, + "TooManyRequests": { + "description": "Already Exists", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 429, + "code": "TOO_MANY_REQUESTS", + "message": "Either out of resource quota or reaching rate limiting." + } + } + } + }, + "Internal": { + "description": "Internal Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 500, + "code": "INTERNAL", + "message": "Unknown server error.Typically a server bug." + } + } + } + }, + "BadGateway": { + "description": "Bad Gateway", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 502, + "code": "BAD_GATEWAY", + "message": "Couldn't reach an upstream internal service." + } + } + } + }, + "Unavailable": { + "description": "Service Unavailable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 504, + "code": "UNAVAILABLE", + "message": "Request timeout exceeded" + } + } + } + }, + "Timeout": { + "description": "Timeout", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 503, + "code": "TIMEOUT", + "message": "Request timeout exceeded" + } + } + } + }, + "NotImplemented": { + "description": "Not Implemented", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 501, + "code": "NOT_IMPLEMENTED", + "message": "This functionality is not implemented yet" + } + } + } + }, + "AuthenticationRequired": { + "description": "Authentication Required", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 401, + "code": "AUTHENTICATION_REQUIRED", + "message": "New authentication is required" + } + } + } + }, + "NotFoundAndOutOfRange": { + "description": "Out Of Range and Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": [ + { + "status": 404, + "code": "OUT_OF_RANGE", + "message": "Out Of Range" + }, + { + "status": 404, + "code": "NOT_FOUND", + "message": "Not found" + } + ] + } + } + }, + "MethodNotAllowed": { + "description": "Method not allowed", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 405, + "code": "METHOD_NOT_ALLOWED", + "message": "The requested method is not allowed/supported on the target" + } + } + } + }, + "NotAcceptable": { + "description": "Not Acceptable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 406, + "code": "NOT_ACCEPTABLE", + "message": "The server can't produce a response matching the content requested by the client through Accept-* headers" + } + } + } + }, + "UnsupportedMediaType": { + "description": "Unsupported Media Type", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorInfo" + }, + "example": { + "status": 415, + "code": "UNSUPPORTED_MEDIA_TYPE", + "message": "The server refuses to accept the request because the payload format is in an unsupported format." + } + } + } + } + } +} diff --git a/artifacts/Github_templates/.github/ISSUE_TEMPLATE/config.yml b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..0067a970 --- /dev/null +++ b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: 🗣 Subproject discussions + url: https://github.com/camaraproject/Commonalities/discussions + about: Please ask and answer questions here. + - name: 📖 CAMARA API Design Guidelines + url: https://github.com/camaraproject/Commonalities/blob/main/documentation/API-design-guidelines.md + about: Please refer to the design guidelines. diff --git a/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_bug_template.md b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_bug_template.md new file mode 100644 index 00000000..74b42179 --- /dev/null +++ b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_bug_template.md @@ -0,0 +1,33 @@ +--- +name: ‼ Bug 🐛 +about: Describe the bug in Provider Implementation +title: '' +labels: 'implementation:bug' +assignees: '' + +--- + +**Describe the bug** + + +**To Reproduce** + + +**Expected behavior** + + +**Screenshots** + + +**Environment:** + + +**Additional context** + diff --git a/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_correction_template.md b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_correction_template.md new file mode 100644 index 00000000..488e70b5 --- /dev/null +++ b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_correction_template.md @@ -0,0 +1,21 @@ +--- +name: ❗ Correction 👣 +about: Suggest the correction of an issue in API specification or a misalignment with API design guidelines +title: '' +labels: 'correction' +assignees: '' + +--- + +**Problem description** + + +**Expected behavior** + + + +**Alternative solution** + + +**Additional context** + diff --git a/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_documentation_template.md b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_documentation_template.md new file mode 100644 index 00000000..f7b8de02 --- /dev/null +++ b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_documentation_template.md @@ -0,0 +1,18 @@ +--- +name: ❕ Documentation 📝 +about: Indicate an issue with API documentation or supplementary documents +title: '' +labels: 'documentation' +assignees: '' + +--- + +**Problem description** + + +**Expected action** + + + +**Additional context** + diff --git a/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_enhancement_template.md b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_enhancement_template.md new file mode 100644 index 00000000..279ce49a --- /dev/null +++ b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_enhancement_template.md @@ -0,0 +1,20 @@ +--- +name: 💡 Enhancement 🌟 +about: Suggest an idea for a new API feature or pose a question on directions for API evolution +title: '' +labels: 'enhancement' +assignees: '' + +--- + +**Problem description** + + +**Possible evolution** + + +**Alternative solution** + + +**Additional context** + diff --git a/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_pm_template.md b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_pm_template.md new file mode 100644 index 00000000..210a2f06 --- /dev/null +++ b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_pm_template.md @@ -0,0 +1,18 @@ +--- +name: ☁ Subproject management 🎂 +about: Indicate an issue with subproject repository or release management +title: '' +labels: 'subproject management' +assignees: '' + +--- + +**Problem description** + + +**Expected action** + + + +**Additional context** + diff --git a/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_tests_template.md b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_tests_template.md new file mode 100644 index 00000000..170874a8 --- /dev/null +++ b/artifacts/Github_templates/.github/ISSUE_TEMPLATE/issue_tests_template.md @@ -0,0 +1,18 @@ +--- +name: ⁉ Tests 🔎 +about: Indicate an issue with API tests +title: '' +labels: 'tests' +assignees: '' + +--- + +**Problem description** + + +**Expected action** + + + +**Additional context** + diff --git a/artifacts/Github_templates/.github/pull_request_template.md b/artifacts/Github_templates/.github/pull_request_template.md new file mode 100644 index 00000000..cdebc5af --- /dev/null +++ b/artifacts/Github_templates/.github/pull_request_template.md @@ -0,0 +1,46 @@ + +#### What type of PR is this? + +Add one of the following kinds: +* bug +* correction +* enhancement/feature +* cleanup +* documentation +* subproject management +* tests + + +#### What this PR does / why we need it: + + + + +#### Which issue(s) this PR fixes: + + + +Fixes # + +#### Special notes for reviewers: + + + +#### Changelog input + +``` + release-note + +``` + +#### Additional documentation + +This section can be blank. + + + +``` +docs + +``` diff --git a/code/API_definitions/README.MD b/code/API_definitions/README.MD deleted file mode 100644 index 04313f15..00000000 --- a/code/API_definitions/README.MD +++ /dev/null @@ -1 +0,0 @@ -Here you can add your definitions and delete this README.MD file diff --git a/documentation/API-DocumentationTemplate.md b/documentation/API-DocumentationTemplate.md new file mode 100644 index 00000000..e36601ec --- /dev/null +++ b/documentation/API-DocumentationTemplate.md @@ -0,0 +1,17 @@ +# API documentation template + +| Section | Sub-section | Description | Mandatory | +|----|---|---|-| +| Overview | Introduction | This section gives an overview of the API. It explains the use of the API and gives an insight on its benefits. A few lines on some standard use cases can help better explain the API | Yes | +|| Quick Start|It explains how developers can get started with this API. A good example is the Stripe-API documentation: https://stripe.com/docs/api || +|Authentication and/or Authorization | |It explains how developers/consumers can access the API. Failure to document the authN-authZ schema in a simple and precise way can deter first time API users . |Yes| +|Documentation|Details|This is an optional section/placeholder. It could include some detailed descriptions or diagrams explaining things in further details and the subsection heading could be changed accordingly.| | +| |Endpoint definitions | What does each endpoint do is a critical part of the API documentation. It explains the consumer/developer your internal system. The documentation should explain what an endpoint is for and how it relates to other endpoints. It should also document: - HTTP verb methods supported. - Parameters along with description - HTTP codes expected + HTTP response bodies - HTTP Request and Response headers - Pagination details if applicable If there are any constraints for an endpoint, it should be documented in this section. It should be made clear if certain endpoints are restricted to only certain roles/users. | Yes | +| |Errors|Error types along with error codes summary table can offer a good reference for the developers working with the API | Yes | +| |Policies|How the developer can discover the usage policy for each endpoint - e.g. limits on requests per second, any regional limitations on what can be returrned in the resource representation, etc. These policies will be operator-specific but the mechanism to discover them should be consistent | No | +| |Code snippets| Copy-paste sample code snippets help developers to get started right away. It helps provide a rich developer experience. This can include sample request examples, and the ability to execute samples directly from the documentation Web page (as per Open API). | No | +| |FAQs| List of frequently asked questions by the early developers/users of the API |No | +| |Terms|Terms of Service |No (N/A for Camara| +| |Release Notes|Listof all changes included in the release |Yes| +| |Pricing |Details about pricing |No (N/A for Camara)| +|API Spec || Complete API Spec in YAML format | Yes | diff --git a/documentation/API-Readiness-Checklist.md b/documentation/API-Readiness-Checklist.md new file mode 100644 index 00000000..a07b1261 --- /dev/null +++ b/documentation/API-Readiness-Checklist.md @@ -0,0 +1,11 @@ +# API Readiness minimum criteria checklist +| No | Deliverables/Criteria | Mandatory | Reference template | +|----|-------------- |-----------|-------------------- | +| 1 |API Spec | Y | OAS3 (https://spec.openapis.org/oas/v3.0.3)| +| 2 |API Implementation | N | | +| 3 |API Documentation | Y |https://github.com/camaraproject/Commonalities/blob/main/documentation/API-DocumentationTemplate.md | +|4 |User Stories | Y | https://github.com/camaraproject/Commonalities/blob/main/documentation/Userstory-template.md | +| 5 |API test cases and documentation | Y | TBD | +| 6 |Tested by atleast 2 operators | Y | | +| 7 |Security review | Y | Spec contributions should include a security scheme section that complies with the AuthN&AuthZ techniques agreed in Commonalities. | + diff --git a/documentation/API-design-guidelines.md b/documentation/API-design-guidelines.md new file mode 100644 index 00000000..ee454c41 --- /dev/null +++ b/documentation/API-design-guidelines.md @@ -0,0 +1,1396 @@ +# API design guidelines + +This document captures guidelines for the API design in CAMARA project. These guidelines are applicable to every API to be worked out under the CAMARA initiative. + +## Table of Contents + +- [API design guidelines](#api-design-guidelines) + - [Table of Contents](#table-of-contents) + - [Common Vocabulary and Acronyms](#common-vocabulary-and-acronyms) + - [1. Introduction](#1-introduction) + - [2. APIfication Principles](#2-apification-principles) + - [2.1 Domain Driven Design](#21-domain-driven-design) + - [2.2 API First](#22-api-first) + - [2.3 Interface standardization. Standardization fora.](#23-interface-standardization-standardization-fora) + - [2.4 Information Representation Standard](#24-information-representation-standard) + - [2.5 Reduce telco-specific terminology in API definitions](#25-reduce-telco-specific-terminology-in-api-definitions) + - [3. API Definition](#3-api-definition) + - [3.1 API REST](#31-api-rest) + - [3.2 HTTP Response Codes](#32-http-response-codes) + - [3.3 Query Parameters Use](#33-query-parameters-use) + - [3.4 Path Parameters Use](#34-path-parameters-use) + - [3.5 HTTP Headers Definition](#35-http-headers-definition) + - [3.6 MIME Types](#36-mime-types) + - [4. API Resource Definition](#4-api-resource-definition) + - [4.1 URL Definition](#41-url-definition) + - [4.2 Input/Output Resource Definition](#42-inputoutput-resource-definition) + - [5. Versioning](#5-versioning) + - [5.1 Versioning Strategy](#51-versioning-strategy) + - [5.2 Backwards and Forward Compatibility](#52-backwards-and-forward-compatibility) + - [6. Error Responses](#6-error-responses) + - [7. Common Data Types](#7-common-data-types) + - [8. Pagination, Sorting and Filtering](#8-pagination-sorting-and-filtering) + - [8.1 Pagination](#81-pagination) + - [8.2 Sorting](#82-sorting) + - [8.3 Filtering](#83-filtering) + - [9. Architecture Headers](#9-architecture-headers) + - [10. Security](#10-security) + - [10.1 API REST Security](#101-api-rest-security) + - [10.2 Security Implementation](#102-security-implementation) + - [11. Definition in OpenAPI](#11-definition-in-openapi) + - [11.1 General Information](#111-general-information) + - [11.2 Published Routes](#112-published-routes) + - [11.3 Request Parameters](#113-request-parameters) + - [11.4 Response Structure](#114-response-structure) + - [11.5 Data Definitions](#115-data-definitions) + - [11.6 OAuth Definition](#116-oauth-definition) + - [12. Subscription, Notification \& Event](#12-subscription-notification--event) + - [12.1 Subscription](#121-subscription) + - [12.2 Event notification](#122-event-notification) + + +## Common Vocabulary and Acronyms + +| **Term** | Description | +| --- | --- | +|**API** | Application Programming Interface. It is a rule & specification group (code) that applications follow to comunicate between them, used as interface among programs developed with different technologies.| +|**Body**| HTTP Message body (If exists) is used to carry the entity data associated with the request or response.| +|**Camel Case**| It is a kind of define the fields’ compound name or phrases without whitespaces among words. It uses a capital letter at the beginning of each word. There are two different uses:
+ +
+ +An **array** is a collection of values. An array starts with “`[`“ left bracket and ends with “`]`” right bracket. Values are separated by "`,`" comma. ++ +
+ +A **value** can be a string with double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested. ++ +
+ +A **character string** is a collection of zero or more Unicode characters, enclosed in double quotes, using backslash escaping. A character is represented by a character string of a single character. A character string is similar to a C or Java character string. ++ +
+ + +A **number** is similar to a C or Java number, except that octal and hexadecimal formats are not used. ++ +
+ +**White spaces** can be inserted between any pair of symbols. ++ +
+ +Except for minor enconding details, the above-mentioned structures provide a full description of JSON language. + +## 2.5 Reduce telco-specific terminology in API definitions +CAMARA aims to produce 'intent-based' APIs, which have two key benefits: +- for the developer: it does not assume familiarity with the network that will fulfil the API. +- for the operator: it avoids tight-coupling, meaning the API can be fulfilled by various networks (mobile, fixed, satellite etc.) and network versions (4/5/6G etc.) + +To realise these benefits it is important to reduce the use of telco-specific terminolgy/acronyms in developer-facing APIs. + +CAMARA API designers should: +- Consider and account for how the API can be fulfilled on a range of network types +- Avoid terms/types specific to a given telco domain. For example the acronym 'UE': in 3GPP terminology this refers to 'User Equipment', but 'UE' means 'User Experience' for most Web developers: 'Terminal' would be a more appropriate, and unambiguous, term. If use of a telco-specific term is unavoidable, either: +- - allow a choice, so the developer can utilise other types. E.g. `MSISDN` should not be the _only_ way to identify an end user. +- - use abstractions, which can evolve: e.g. an `endUserIdentifier` enumeration can support mulitple identifiers. +- - explain the telco-specific term in the documentation, and any constraints it brings. + + +## 3. API Definition + +API definition aims to capture 100% of the functional, syntax and semantic documentation of a contract. It is a critical element for the business strategy and will tag the product offered success. + +Outstanding aspects in the API definition are: + +- API must be defined from a product view focused to API consumers. It means, it should be prepared a top-down definition of all APIs. +- Product should be focused on the usability. +- API contract must be correctly documented, and it will be published in a shared catalog. +- API exposure definition will be based on “resources could be used by different services and product consumers”. That means, API definition should be a 360-degree product view. + +API definition must consider the next assertions: + +- API resources definition contains the URI and enterprise resources. +- REST specification compliance aims make the API fully interoperable. +- API resource security. +- Product consumption experience. +- API measurement over how many, who and when it is used. +- API must be versioned, and version must figure in all operations URL. It allows a better last develops management and surveillance, it avoids out of date URLs request and it makes available coexistence of more than one version productive in the same environment. +- Expose the required fields by the API consumers only. Sometimes, all the response body is not necessary for consumers. Allows more security, less the network traffic and agile the API usability. +- One of the API Quality requirements will be the evolution and management scalability, lined with versioning and backward compatibility considerations detailed in this document. +- At API definition time is necessary include audit parameters to allow make surveillance and next maintenances. +- English use must be applied in the OpenAPI definition. + +### 3.1 API REST + +Representational state transfer (REST) is a software architectural style that was created to guide the design and development of the architecture for the World Wide Web. REST defines a set of constraints for how the architecture of an Internet-scale distributed hypermedia system, such as the Web, should behave. + +The formal REST constraints are as follows: + +- **Client–server architecture**. The client-server design pattern enforces the principle of separation of concerns: separating the user interface concerns from the data storage concerns. Portability of the user interface is thus improved. In the case of the Web, a plethora of web browsers have been developed for most platforms without the need for knowledge of any server implementations. Separation also simplifies the server components, improving scalability, but more importantly it allows components to evolve independently (anarchic scalability), which is necessary in an Internet-scale environment that involves multiple organisational domains. +- **Statelessness**. In computing, a stateless protocol is a communications protocol in which no session information is retained by the receiver, usually a server. Relevant session data is sent to the receiver by the client in such a way that every packet of information transferred can be understood in isolation, without context information from previous packets in the session. This property of stateless protocols makes them ideal in high volume applications, increasing performance by removing server load caused by retention of session information. +- **Cacheability**: As on the World Wide Web, clients and intermediaries can cache responses. Responses must, implicitly or explicitly, define themselves as either cacheable or non-cacheable to prevent clients from providing stale or inappropriate data in response to further requests. Well-managed caching partially or eliminates some client–server interactions, further improving scalability and performance. +- **Layered system**: A client cannot ordinarily tell whether it is connected directly to the end server or to an intermediary along the way. If a proxy or load balancer is placed between the client and server, it won't affect their communications, and there won't be a need to update the client or server code. +- **Uniform interface**: The uniform interface constraint is fundamental to the design of any RESTful system. It simplifies and decouples the architecture, which enables each part to evolve independently. The four constraints for this uniform interface are: + - Resource identification in requests. Individual resources are identified in requests, for example using URIs in RESTful Web services. The resources themselves are conceptually separate from the representations that are returned to the client. For example, the server could send data from its database as HTML, XML or as JSON—none of which are the server's internal representation. + - Resource manipulation through representations. When a client holds a representation of a resource, including any metadata attached, it has enough information to modify or delete the resource's state. + - Self-descriptive messages. Each message includes enough information to describe how to process the message. For example, which parser to invoke can be specified by a media type. + - Hypermedia as the engine of application state (HATEOAS). Having accessed an initial URI for the REST application) analogous to a human Web user accessing the home page of a website) a REST client should then be able to use server-provided links dynamically to discover all the available resources it needs. As access proceeds, the server responds with text that includes hyperlinks to other resources that are currently available. There is no need for the client to be hard-coded with information regarding the structure or dynamics of the application. + + HTTP verbs + +HTTP standard should be followed to the verbs usability, resulting an API definition oriented to the RESTful design. Any HTTP correct verb usability are allowed. + +Principal methods (Verbs) available to use are next ones: + +| **HTTP Verb** | **CRUD operation** | **Description** | +| ---- | ----| ----| +GET | Read | Retrieve the actual resource status | +POST | Create | Creates a new resource in the collection. Returns the resource URL when the creation ends.| +PUT | Update | Replaces a specific resource. Returns the resource URL when the replace ends. | +DELETE | Delete | Delete a specific resource. | +PATCH | Update | Updates a specific resource, applying all changes at the same time. If resource does not exist, it will be created. Returns the resource URL when the update ends. If any error occurs during the update, all of them will be cancelled. | +OPTIONS | Read | Returns a 200 OK with an allowed methods list in the specific resource destined to the header allowed joined to an HTML document about the resource + an API Doc link. | +HEAD | Read | Returns the resource actual status without message body. | + +In this document will be defined the principal verbs to use in the API definition. + +- `POST`: it is used to send date to the server. +- `GET`: it allows performing all the read and retrieve operations. GET operation should be based on data retrieving, that’s why the retrieve operation must be realized directly from the URI including some identifiers and query params. +- `PUT`: it allows update entity data, deleting one or more fields from this entity body if there are not informed. New information to update must be informed by JSON language sent in the body request. If operation requires extra information, Query params could be used. PUT case, if registry does not exist in server data storage, it will be created, that means this operation could be used to create new resources. +- `DELETE`: it allows deleting full entities from server. From consumer perspective, it is not a reversible action. (Rollback action is not available). +- `PATCH`: it allows updating partial fields of a resource. + ++ +
+ +If you want to add multiple query parameters, an "`&`" is placed between them to form a query string. You can present lot of objects types with different lengths, such as arrays, strings, and numbers. + +### 3.4 Path Parameters Use + +A path param is a unique identifier for the resource. For example: + +- ```/users/{userId}``` + +Multiple path params can be entered if there is a logical path of mutually dependent resources. +- ```/users/{userId}/documents/{documentId}``` + + Good Practices + + +1. Path params cannot be concatenated. A path param must be preceded by the resource represented. If we did this, the URL would be incomprehensible: + - ```/users/{userId}/{documentId}``` + - ```/users/13225365/647658``` +