Difference between revisions of "Solum/API"
Adrian Otto (talk | contribs) (→Link) |
Adrian Otto (talk | contribs) (→Array) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 105: | Line 105: | ||
== Types == | == Types == | ||
This section details the different data types used by the API. | This section details the different data types used by the API. | ||
+ | === Array === | ||
+ | A JSON Array of JSON objects. For example: the pseudocode text "component[]" refers to an array of component resources expressed as JSON objects. | ||
+ | |||
=== Boolean === | === Boolean === | ||
As defined by JSON [[http://www.ietf.org/rfc/rfc4627.txt RFC4627]], a token having a literal value of either true or false. | As defined by JSON [[http://www.ietf.org/rfc/rfc4627.txt RFC4627]], a token having a literal value of either true or false. | ||
Line 111: | Line 114: | ||
=== URI === | === URI === | ||
A String (see above) that conforms to the syntax defined in [[http://www.ietf.org/rfc/rfc3986.txt RFC3986]]. | A String (see above) that conforms to the syntax defined in [[http://www.ietf.org/rfc/rfc3986.txt RFC3986]]. | ||
+ | |||
== Protocol and Resource Representations == | == Protocol and Resource Representations == | ||
This section shows the representation of each of the resources in JSON format, and how you interact with them through the REST API. | This section shows the representation of each of the resources in JSON format, and how you interact with them through the REST API. | ||
Line 116: | Line 120: | ||
# '''No Links'''. We will not use the Link or Link array types that were proposed in the initial API design documentation. Instead we will use inline objects in the serialized output. For example, an assembly, instead of having links to components, would include an array of component resources that are also serialized in the same JSON. Let's refer to the elements of such an array as "inline-listed-resources". | # '''No Links'''. We will not use the Link or Link array types that were proposed in the initial API design documentation. Instead we will use inline objects in the serialized output. For example, an assembly, instead of having links to components, would include an array of component resources that are also serialized in the same JSON. Let's refer to the elements of such an array as "inline-listed-resources". | ||
− | |||
# '''Limited view by default'''. To keep the size of the result set manageable, we will show only *one* level of detail for inline-listed-resources. If additional detail is required, we can support parameters for showing a configurable depth level, up to a sensible configurable maximum. For example, you might see a list of components as inline-listed-resources, but those listed do not include their own inline-listed-resource lists for additional levels of relations. | # '''Limited view by default'''. To keep the size of the result set manageable, we will show only *one* level of detail for inline-listed-resources. If additional detail is required, we can support parameters for showing a configurable depth level, up to a sensible configurable maximum. For example, you might see a list of components as inline-listed-resources, but those listed do not include their own inline-listed-resource lists for additional levels of relations. | ||
− | |||
# '''Abbreviated Label'''. To indicate that a given inline listed object has additional details that could be queried if that object were loaded using it's URI, we can add an attribute named "abbreviated" that indicates additional fields exist that are not shown in the current view (if it exists and is set to true). This way, if that detail is desired, the object may be accessed individually using its URI, and all the details will be returned. | # '''Abbreviated Label'''. To indicate that a given inline listed object has additional details that could be queried if that object were loaded using it's URI, we can add an attribute named "abbreviated" that indicates additional fields exist that are not shown in the current view (if it exists and is set to true). This way, if that detail is desired, the object may be accessed individually using its URI, and all the details will be returned. | ||
− | |||
# '''Pagination'''. To prevent unreasonably large return sets, Solum should have a configurable maximum number if inline listed objects that it will display by default. For example, we may set that limit at 100, in the Solum configuration file, and when the API is queried for an Assembly that contains more than 100 components, that the list of components will be offered as a paginated collection, like an ATOM feed works so that a Next item can be fetched when the last is reached. | # '''Pagination'''. To prevent unreasonably large return sets, Solum should have a configurable maximum number if inline listed objects that it will display by default. For example, we may set that limit at 100, in the Solum configuration file, and when the API is queried for an Assembly that contains more than 100 components, that the list of components will be offered as a paginated collection, like an ATOM feed works so that a Next item can be fetched when the last is reached. | ||
Latest revision as of 22:08, 30 January 2014
Blueprint: https://blueprints.launchpad.net/solum/+spec/api
Proposed By: Adrian Otto
Review comments here: https://etherpad.openstack.org/p/solum-api-spec-review
Contents
API
Synopsis
Verb | URI | Description |
---|---|---|
GET | / | Get the root Platform resource
|
GET | /assemblies | Get a list of the assembly resources for this tenant
|
POST | /assemblies | Create a new assembly resource
|
GET | /assemblies/{id} | Get a specific assembly resource
|
PUT | /assemblies/{id} | Update a complete assembly resource
|
PATCH | /assemblies/{id} | Update select attributes of an assembly resource
|
DELETE | /assemblies/{id} | Delete this assembly resource.
|
GET | /plans | Get a list of the plan resources for this tenant
|
POST | /plans | Create a new plan resource
|
GET | /plans/{id} | Get a specific plan resource
|
PUT | /plans/{id} | Update a complete plan resource
|
PATCH | /plans/{id} | Update select attributes of a plan resource
|
DELETE | /plans/{id} | Delete this plan resource.
|
GET | /components | Get a list of the component resources for this tenant
|
POST | /components | Create a new component resource
|
GET | /components/{id} | Get a specific component resource
|
PUT | /components/{id} | Update a complete component resource
|
PATCH | /components/{id} | Update select attributes of an component resource
|
DELETE | /components/{id} | Delete this component resource.
|
GET | /services | Get a list of the service resources for this tenant
|
POST | /services | Create a new service resource
|
GET | /services/{id} | Get a specific service resource
|
PUT | /services/{id} | Update a complete service resource
|
PATCH | /services/{id} | Update select attributes of an service resource
|
DELETE | /services/{id} | Delete this service resource.
|
GET | /extensions | Get a list of the extension resources for this tenant
|
GET | /extensions/{id} | Get a specific extension resource
|
API Concepts
This section provides an overview of the different aspects of the API, and what they represent. See also: Definitions with a conceptual diagram.
Basics
Roles
Provider
The organization offering hosted platform services to its customers.
Consumer
The individual customer that uses the hosted Platform.
platform
The platform
resource is the root level resource that refers to all the other resources owned by this tenant. The purpose of this resource is to provide API introspection.
assembly
The assembly
resource represents a group of components that make up a running instance of an application. You may casually refer to this as "the application" but we refer to it as an assembly because most cloud applications are actually a system of multiple service instances that make up a system. For example, a three-tier web application may have a load balancer component, a group of application servers, and a database server all represented as component
resources that make up an assembly
resource. An assembly
resource has at least one component
resource associated with it.
plan
Plan resources are used to create assembly
resources. A plan
resource may be used repeatedly to create an arbitrary number of assembly
instances. It's possible for us to skip the concept of a plan
completely, and just use assemblies
, and pass in Plan files. That would just make the creation of additional assemblies
a bit slower which might be annoying in use cases where you really want to make a whole bunch of them, or you want them to spin up really fast.
component
The component
resource represents one part of an assembly
needed by your application. For example, an instance of a database service may be a component
. A component
resource may also represent a static artifact, such as an archive file that contains data for initializing your application. An assembly
may have different components that represent different processes that run. For example, you may have one component
that represents an API service process, and another that represents a web UI process that consumes that API service. This simplest case is when an assembly
has only one component. For examaple your component may be named "PHP" and refers to the PHP service
offered by the platform for running a PHP application.
service
The service
resource represents a networked service provided by a Platform
Provider. You may create component
resources that refer to service
resources. The component
represents an instance of the service
. Your application may use that service remotely over the network, and the component
is how it gets clues about how to connect to it, such as attributes defining a connection URL. In this usage, the component
is a virtual representation of a service provided elsewhere (by another application, or by a Platform
Provider). For example, the Platform
may offer a default service
named "mysql". You may create multiple component
resources that reference different instances of the "mysql" service. Each component
may represent a multi-tenant instance of a MySQL database (perhaps a logical database) service offered by the Platform for a given assembly
.
Advanced
extension
The extension
resource represents changes that the Provider has added onto a Platform in addition to the ones supplied by Solum by default. This may include additional protocol semantics, resource types, application lifecycle states, etc. Anything may be added, as long as it does not contradict the base functionality offered by Solum.
operation
The operation
resource represents an action that can be taken on a resource. operations can be added to assembly
, component
, or service
resources.
sensor
The sensor
resource represents an dynamic data that can be collected from a resource. For example, statistics about the access rate of a resource (usually a component
). A sensor
resource can be added to assembly
, component
, or service
resources.
Types
This section details the different data types used by the API.
Array
A JSON Array of JSON objects. For example: the pseudocode text "component[]" refers to an array of component resources expressed as JSON objects.
Boolean
As defined by JSON [RFC4627], a token having a literal value of either true or false.
String
A UNICODE string as defined by JSON [RFC4627].
URI
A String (see above) that conforms to the syntax defined in [RFC3986].
Protocol and Resource Representations
This section shows the representation of each of the resources in JSON format, and how you interact with them through the REST API. A "?" character indicates the attribute is optional.
- No Links. We will not use the Link or Link array types that were proposed in the initial API design documentation. Instead we will use inline objects in the serialized output. For example, an assembly, instead of having links to components, would include an array of component resources that are also serialized in the same JSON. Let's refer to the elements of such an array as "inline-listed-resources".
- Limited view by default. To keep the size of the result set manageable, we will show only *one* level of detail for inline-listed-resources. If additional detail is required, we can support parameters for showing a configurable depth level, up to a sensible configurable maximum. For example, you might see a list of components as inline-listed-resources, but those listed do not include their own inline-listed-resource lists for additional levels of relations.
- Abbreviated Label. To indicate that a given inline listed object has additional details that could be queried if that object were loaded using it's URI, we can add an attribute named "abbreviated" that indicates additional fields exist that are not shown in the current view (if it exists and is set to true). This way, if that detail is desired, the object may be accessed individually using its URI, and all the details will be returned.
- Pagination. To prevent unreasonably large return sets, Solum should have a configurable maximum number if inline listed objects that it will display by default. For example, we may set that limit at 100, in the Solum configuration file, and when the API is queried for an Assembly that contains more than 100 components, that the list of components will be offered as a paginated collection, like an ATOM feed works so that a Next item can be fetched when the last is reached.
Platform
The Platform
resource is the root level resource that refers to all the other resources owned by this tenant. The purpose of the Platform
resource is for API introspection.
Verb | URI | Description |
---|---|---|
GET | / | Get the root Platform resource
|
{ "uri": URI, "name": String, "type": "platform", "description": String ?, "extensions_uri": "/extensions", "implementation_version": String ?, "assemblies": assembly[] ?, "components": component[] ?, "services": service[] ?, "parameter_definitions_uri": URI }
assembly
The assembly
resource represents a group of components that make up a running instance of an application. You may casually refer to this as "the application" but we refer to it as an assembly
because most cloud applications are actually a system of multiple service instances that make up a system. For example, a three-tier web application may have a load balancer component, a group of application servers, and a database server all represented as component
resources that make up an assembly
resource. An assembly
resource has at least one component
resource associated with it.
Verb | URI | Description |
---|---|---|
GET | /assemblies | Get a list of the assembly resources for this tenant
|
POST | /assemblies | Create a new assembly resource
|
GET | /assemblies/{id} | Get a specific assembly resource
|
PUT | /assemblies/{id} | Update a complete assembly resource
|
PATCH | /assemblies/{id} | Update select attributes of an assembly resource
|
DELETE | /assemblies/{id} | Delete this assembly resource.
|
{ "uri": URI, "name": String, "type": "assembly", "description": String ?, "components": component[] ?, "operations_uri": URI ?, "sensors_uri": URI ? }
plan
The </code>plan</code> resource is used to create assembly
resources. A plan
resource may be used repeatedly to create an arbitrary number of assembly
instances. It's possible for us to skip the concept of a plan
completely, and just use assemblies
, and pass in Plan files. That would just make the creation of additional assemblies
a bit slower which might be annoying in use cases where you really want to make a whole bunch of them, or you want them to spin up really fast.
Verb | URI | Description |
---|---|---|
GET | /plans | Get a list of the plan resources for this tenant
|
POST | /plans | Create a new plan resource
|
GET | /plans/{id} | Get a specific plan resource
|
PUT | /plans/{id} | Update a complete plan resource
|
PATCH | /plans/{id} | Update select attributes of an plan resource
|
DELETE | /plans/{id} | Delete this plan resource.
|
{ "name": String ? "description": String ? "tags": String[] ? "camp_version": String "origin": String ? "artifacts": ArtifactSpecification[] ? "services": ServiceSpecification[] ? }
Note that the ArtifactSpecification and ServiceSpecification will be detailed in a separate blueprint and specification that describes plan files, which will be used to generate plan resources. That will be linked here upon creation.
component
The component
resource represents one part of an assembly
needed by your application. For example, an instance of a database service may be a component
. A component
resource may also represent a static artifact, such as an archive file that contains data for initializing your application. An assembly
may have different components that represent different processes that run. For example, you may have one component
that represents an API service process, and another that represents a web UI process that consumes that API service. This simplest case is when an assembly
has only one component. For exmaple your component may be named "PHP" and refers to the PHP service
offered by the platform for running a PHP application.
Verb | URI | Description |
---|---|---|
GET | /components | Get a list of the component resources for this tenant
|
POST | /components | Create a new component resource
|
GET | /components/{id} | Get a specific component resource
|
PUT | /components/{id} | Update a complete component resource
|
PATCH | /components/{id} | Update select attributes of an component resource
|
DELETE | /components/{id} | Delete this component resource.
|
{ "uri": URI, "name": String, "type": "component", "description": String ?, "tags": String[] ?, "assembles": assembly[], "components": component[] ?, "services": service[] ?, "operations_uri": URI ?, "sensors_uri": URI ? }
service
The service
resource represents a networked service provided by a Platform
Provider. You may create component
resources that refer to service
resources. The component
represents an instance of the service
. Your application connects to the component that using a network protocol. For example, the Platform
may offer a default service
named "mysql". You may create multiple component
resources that reference different instances of the "mysql" service. Each component
may be a multi-tenant instance of a MySQL database (perhaps a logical database) service offered by the Platform for a given assembly
.
services resource
Verb | URI | Description |
---|---|---|
GET | /services | Get a list of the service resources for this tenant
|
POST | /services | Create a new service resource
|
Plural representation (list):
Request: GET /services ... Response: { "uri": URI, "name": String, "type": "services", "description": String, ? "services": service[] }
service resource
GET | /services/{id} | Get a specific service resource
|
PUT | /services/{id} | Update a complete service resource (subject to access control rules)
|
PATCH | /services/{id} | Update select attributes of an service resource (subject to access control rules)
|
DELETE | /services/{id} | Delete this service resource. (subject to access control rules)
|
Singular representation:
Request: GET /service/{id} ... Response: { "uri": URI, "name": String, "type": "service", "description": String ?, "tags": String[] ?, "operations_uri": URI ?, "sensors_uri": URI ?, "read_only": Boolean }
Note: Solum prohibits PUT, PATCH, and DELETE calls on the </code>services</code> provided as part of the base configuration offered by the Provider. In this case the readOnly attribute will be set to TRUE. Any service
resourcess added by a tenant will have a readOnly attribute set to FALSE, and may be modified or deleted by that same tenant.
extension
The extension
resource represents changes that the Provider has added onto a Platform in addition to the ones supplied by Solum by default. This may include additional protocol semantics, resource types, application lifecycle states, resource attributes, etc. Anything may be added, as long as it does not contradict the base functionality offered by Solum.
extensions resource
Verb | URI | Description |
---|---|---|
GET | /extensions | Get a list of the extension resources for this tenant
|
Plural representation (list):
{ "uri": URI, "name": String, "type": "extensions", "description": String, ? "extensions": extension[] }
extension resource
Verb | URI | Description |
---|---|---|
GET | /extensions/{id} | Get a specific extension resource
|
Singular representation:
{ "uri": URI, "name": String, "type": "extension", "description": String, "version": String, "documentation": URI ? }
operation
An operation
resource represents an operation or action available on a target resource. This is for defining actions that may change the state of the resource they are related to. For example, the API already provides ways to register, start, and stop your application (POST an assembly
to register+start, and DELETE an assembly
to stop) but operations provide a way to extend the system to add your own actions such as "pause" and "resume", or "scale_up" and "scale_down". It has the following representation:
operations resource
Verb | URI | Description |
---|---|---|
GET | /operations | Get a list of the operation resources for this tenant
|
POST | /operations | Create a new operation resource
|
The plural representation (list):
Request: GET /operations ... Response: { "uri": URI, "name": String, "type": "operations", "description": String ?, "target_resource": URI, "operations": operation[] }
operation resource
Verb | URI | Description |
---|---|---|
GET | /operations/{id} | Get a specific operation resource
|
PUT | /operations/{id} | Update a complete operation resource
|
PATCH | /operations/{id} | Update an attribute of an operation resource
|
DELETE | /operations/{id} | Delete a specific operation resource
|
The singular representation:
Request: GET /operations/{id} ... Response: { "uri": URI, "name": String, "type": "operation", "description": String ?, "documentation": URI, "targetResource": URI }
Note that the documentation
attribute is a link to (probably a PDF) document that explains the semantics of the operation you are defining. This is a lightweight method of allowing the API to be extensible without requiring a markup language.
sensor
A sensor
resource represents exactly one supported sensor on one or more resources. sensor
resources represent dynamic data about resources, such as metrics or state. sensor
resources are useful for exposing data that changes rapidly, or that may need to be fetched from a secondary system. It has the following representation:
sensors resource
Verb | URI | Description |
---|---|---|
GET | /sensors | Get a a list of sensor resources for this tenant
|
POST | /sensors | Create a new sensor resource
|
The plural representation (list):
Request: GET /sensors ... Response: { "uri": URI, "name": String, "type": "sensors", "description": String ?, "target_resource": URI, "sensors": sensor[] }
sensor resource
Verb | URI | Description |
---|---|---|
GET | /sensors/{id} | Get a specific sensor resource
|
PUT | /sensors/{id} | Update a complete sensor resource
|
PATCH | /sensors/{id} | Update an attribute of an sensor resource
|
DELETE | /sensors/{id} | Delete a specific sensor resource
|
The singular representation:
Request: GET /sensors/{id} ... Response: { "uri": URI, "name": String, "type": "sensor", "description": String ?, "documentation": URI, "target_resource": URI, "sensor_type": String, "value": <sensor_type> ?, "timestamp": Timestamp ?, "operations_uri": URI ? }