API
Information about the ion GraphQL API and example queries
Developers: How to create an API Key:
API KeysGetting started
To get started with the ION API, we recommend learning about GraphQL and playing around with the interactive API explorer in the ION web application.
Once you've played around a bit, you can request an API key and access token through this self-service process.
Example queries
Change Run Step status
Find the id of the runStep you want to change, replacing the run id below with the run ID you are changing.
You will see a response like the following. Notice the run step that is failed. That's the one we want to change in the subsequent mutation
Once you've found the id
and _etag
for the runStep you want to move back to "todo", use the following mutation to affect the change. You will also need to define the variables in the "Query Variables" section below the query explorer.
Query variables:
After you submit the query, you will get a response containing the run step's ID and the newly set status.
Redlines
Redlines are used to demarcate any deviation a particular run has from the procedure that created the run. Redlining a step allows an engineer to edit a step or its fields. Redlining also allows for the creation of additional steps and modifying the dependency graph of the steps downstream from the step being redlined. This powerful feature allows an engineer to alter branches of a run, while not affecting other branches which are running concurrent to the step or steps being redlined. To show how redlines work in ION we will imagine a run with the execution graph below.
Creating a Redline
A redline is created by updating a step to the status of redline. You must have the "engineer" role to do this.
Query variables:
Now the run execution graph has entered a redline state, steps 2 and 3 are still able to be executed since they are on a different branch than the redlined step. All steps downstream from the step in redline
cannot be executed and have entered a special dag_modifiable
(previously, content_locked
) state which will be described in further detail below.
Editing a Step in Redline
Now that step 4 is in redline, we can edit the step by altering its content, title, or fields. Using the above defined UpateRunStep mutation with the below variables we edit the title of the step.
Query variables:
Adding a new Step (Redlined step)
We can also create a new step within the run. Below we will discuss how to add this new step to run execution graph. The new step will be created with the status of redline, so that it can be altered after creation.
Query variables:
The run execution graph would now look like the diagram below.
Editing the Graph
When a step is put in redline, all of its downstream steps which have the status of todo
or in_progress
are put into a special status known as content_locked. This dag_modifiable
status prevents a user from altering any of the content within a run step, but does allow the user to edit its graph edges. We will use the below mutations to add the newly created step into our run execution graph.
Query variables:
After creating the new edges, we will remove the existing edge between steps 6 and 7.
Query variables:
Now step 8 is within the run execution graph and the current state is reflected below.
Finishing a Redline
A redline is completed by updating the status of a run step being redlined to todo. Completing the redline will allow the user to see a diff of what was altered during the redline. Ending a redline also converts all downstream steps which have the status dag_modifiable
back into the status of todo
. Using the UpdateRunStep
mutation defined above with the below query variables will finish a redline.
Steps 4, 5, and 6 have moved back to the status of todo.
Because there are two steps in redline, we also have to update step 8 to a status of todo so that the run no longer has any steps in redline.
Canceling a Redline
If no edges were added or removed within a redline, then that redline can be canceled and all changes will be reverted to their original state. If the execution graph edges have been altered than the user must revert the edges to their original state before a redline can be canceled. Below is the mutations to cancel a redline.
Query variables (id
and etag
of the run step)
File Attachments and Assets
The ION API differentiates between files into two different types: assets and file attachments. The driving force behind this separation is to provide greater access control and validation to file handling. For instance when a procedure is instantiated as a run, all the procedure steps' assets that were created by an engineer are copied over to that run, and any files attached by an operator during the run execution are saved as file attachments. Another way to think about the difference is that assets are defined while file attachments are collected.
Getting a File
Getting a file attachment or asset can be done with the same query which returns the filename and other meta data about the file. It does not return the file itself, but along with the metadata it returns a signed URL which provides temporary and secure access to the file within the ION file storage system.
Assets
All asset mutations require the user to have the "engineer" role. The two places assets can be added and deleted are on procedure steps and run steps when the run step is in redline. To create an asset you can make a request with the entityId
of the object to attach the asset to. Below is an example of creating an asset for a step with entity id 1. The response will contain a secure link to upload your file to using the HTTP PUT
method.
Create Asset
Delete Asset
Creating an asset creates a file object with an ID. To delete an asset, use the below mutation with the new file object id and the steps entity id.
File Attachments
File attachments are used to attach files to a run or run step during a run's execution, as well as to parts.
Create File Attachment
Uploading files directly using our API has been deprecated and will be removed in the future. The preferred way is to use a signed s3 URL which allows a user to upload a file directly to s3. This is done be creating a file attachment in our system and then using the returned URL to post the file to s3.
Deprecated:
Delete File Attachment
Unattached Files
There are some situations, such as for the thumbnail of a part or a file for a run step field which require a file to be uploaded without attaching it to an object. To do this use the same create file attachment mutation above, but do not include an entity id. As is the case with other file uploads, you will receive a secure link to upload the file to using the HTTP PUT
method.
Reviews Requests and Reviews
Before a procedure is released it must go through a review process. The number of reviewers required to release a procedure can be set in an organization's settings. A procedure is put into review by changing its status to in_review via an update procedure mutation.
Once a procedure is in review it cannot be edited. Review requests can be sent out with the following mutation. Each review request will also send out notification to the user whom you requested a review from.
Once a review has been requested that user can leave a review of pending, approved or rejected. To leave a review that is just a comment, use the status pending as it will neither reject nor approve the procedure.
You cannot delete reviews, but if someone should not review a procedure you can delete their review request using the following mutation.
Once all requested reviewers have approved, and the minimum number of reviewers required has been met than a procedure is automatically released.
You can list all the existing review requests with a few filters, the query below lists all requested reviews for a specific procedure.
Along with listing review requests, you can also list all the reviews.
Issues
ION's issue system is rather flexible and has several controls within an organization's settings. There are settings to automatically create issues when a step fails, to prevent a step from being moved back to todo while open issues exist, and to set the number of approvals required till an issue can be marked as resolved. Below is an diagram that shows the non-conformance workflow of issues and each disposition type.
You can use a series of filters to list current issues by status, disposition type, and a few other filters. The query below lists all issues related to a specific run step.
To create an issue, you can use the following mutation. An issue is required to be linked to a run step.
Once an issue is created you can update it's values using the following mutation.
When an issue is created, its status defaults to "pending". An issue can have its status moved to in_progress, in_review or resolved using the above update mutation. An issue has an approval process very similar to that of procedures. And an issue cannot be moved into resolved until all the requested reviews have been approved and the minimum number of approvals has been met. Lastly an issue cannot be resolved without setting its disposition type.
Errors
Any errors happening on the API will be returned in the errors
array following the GraphQL convention.
Known errors
Known errors are extended with an error code
and their payload will look as follows :
Clients using the API can use the error code to respond accordingly. We currently support the following error codes:
VALIDATION_ERROR
- Request to server is not valid (e.g. out of range numbers, parameters omitted, etc)AUTHORIZATION_ERROR
- API caller is not authorized to perform actionNOT_FOUND_ERROR
- Resource is not found in the databaseEXTERNAL_SERVICE_ERROR
- An external service is not responding as expected (e.g. email service)CONCURRENCY_ERROR
- Multiple clients modifying the same resource against outdated data is prevented in the API
Unexpected errors
Unexpected errors might not have an extensions
attribute and therefore might no include an error code
. Client's using the API should guard against this and handle unexpected errors accordingly.
Last updated