Action specifications
Creating actions for services and links is exactly the same process. Unless stated otherwise, every time we refer to services or service specifications you can automatically assume the same applies to links and link specifications.
Design your action specifications
Now that you have your service specification, you have to bring it to life by designing create, update, and delete actions.
Here are some design questions to answer:
Question | Guidance |
---|---|
Which input parameters do I need to ask to create the service? | This is a central design question that will determine the content of the JSON schema under the attributes field. |
Which parameters will I allow to be edited? | Be mindful of the underlying capabilities of your cloud-based services. Also, be careful not to allow changing parameters which cannot be changed in-place and would trigger a resource re-creation by your IaC tool. |
Which custom actions do I want to provide? | These will be actions that serve a specific operational purpose such as "Manually push an event to the queue". |
Do I need to store results for my action? | Results play a key role as they connect actions to the service specifications. Also, custom action's results are displayed to the end-user for easier interpretation. |
Design all required actions
Services usually require actions to create, update, or delete the service. On top of this, you can also add your own custom actions. This means that you'll likely have to design and create several actions for a service.
Therefore, your actions need to declare one of these action types: create
, update
, and delete
, unless you are
creating a custom action, which requires an action of type custom
.
Parameters and results
For each action, you'll have to define these fields:
-
parameters
: the input requirements for the action , expressed as aJSON schema. -
results
: the expected output of the action, also expressed as a JSON schema.UI SchemaSee the UI schema reference section for more information on how to manipulate the fields in the UI.
Action specifications
To create, update, or destroy a service, you will typically run an action (note that this is optional but very usual).
If you're interacting with the service through the UI, nullplatform will look up for the corresponding action specifications and will create a new action instance. If you're doing a custom integration, you have to call these actions explicitly.
Use the type
field on the action specification to distinguish between create
, update
, delete
, and custom
actions.
In the following subsections we provide examples for each of these action types and review our API reference for more info.
Create
- CLI
- cURL
np service-specification action-specification create \
--serviceSpecificationId $service_spec_id \
--body '{
"name": "Create my service action spec",
"type": "create",
"parameters": { // defines the input requirements for the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
},
"results": { // defines the expected output of the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
}
}'
curl -X POST "https://api.nullplatform.com/service_specification/$service_spec_id/action_specification" \
-H "Content-Type: application/json" \
-d '{
"name": "Create my service action spec",
"type": "create",
"parameters": { // defines the input requirements for the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
},
"results": { // defines the expected output of the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
}
}'
Update
- CLI
- cURL
np service-specification action-specification create \
--serviceSpecificationId $service_spec_id \
--body '{
"name": "Create my service update action spec",
"type": "update",
"parameters": { // defines the input requirements for the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
},
"results": { // defines the expected output of the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
}
}'
curl -X POST "https://api.nullplatform.com/service_specification/$service_spec_id/action_specification" \
-H "Content-Type: application/json" \
-d '{
"name": "Create my service update action spec",
"type": "update",
"parameters": { // defines the input requirements for the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
},
"results": { // defines the expected output of the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
}
}'
Delete
- CLI
- cURL
np service-specification action-specification create \
--serviceSpecificationId $service_spec_id \
--body '{
"name": "Create my service delete action spec",
"type": "delete",
"parameters": { // defines the input requirements for the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
},
"results": { // defines the expected output of the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
}
}'
curl -X POST "https://api.nullplatform.com/service_specification/$service_spec_id/action_specification" \
-H "Content-Type: application/json" \
-d '{
"name": "Create my service delete action spec",
"type": "delete",
"parameters": { // defines the input requirements for the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
},
"results": { // defines the expected output of the action.
"schema": {
"type": "object",
"properties": {}
},
"values": {}
}
}'
Custom
- CLI
- cURL
np service-specification action-specification create \
--serviceSpecificationId $service_spec_id \
--body '{
"name": "Create my service custom action spec",
"type": "custom",
"parameters": { // defines the input requirements for the action.
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"delay_in_seconds": {
"type": "integer",
"default": 0
}
}
},
"values": {}
},
"results": { // defines the expected output of the action.
"schema": {
"type": "object",
"properties": {
"message_id": {
"type": "string"
}
}
},
"values": {}
}
}'
curl -X POST "https://api.nullplatform.com/service_specification/$service_spec_id/action_specification" \
-H "Content-Type: application/json" \
-d '{
"name": "Create my service custom action spec",
"type": "custom",
"parameters": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"delay_in_seconds": {
"type": "integer",
"default": 0
}
}
},
"values": {}
},
"results": {
"schema": {
"type": "object",
"properties": {
"message_id": {
"type": "string"
}
}
},
"values": {}
}
}'