REST procedures


Procedures are collections of steps that you can reuse in multiple requests and associate with applications.

GET /v1/procedures

Returns all procedures.

Filters

  • aasm_state  String name of a valid status of object state 

    Warning

    Note

    Valid status of object states are draft, pending, released, retired, and archived. By default, the aasm_state is Draft.

  • name — String for the procedure name
  • app_id — Integer for the related application ID
  • archived — Boolean value for showing the archived status (can be combined with unarchived to show both)
  • unarchived — Boolean value for showing the unarchived status (on by default, can be combined with archived to show both)

Common attributes

  • format — Be sure to include this as an accept header or add .xml or .json to the last path element
  • token — Your API token for authentication

Errors caused

  • ERROR 403 Forbidden — Occurs when the token is invalid
  • ERROR 404 Not Found — Occurs when no records are found

Examples

To test this method, insert this URL or your valid API key and application host into a browser or HTTP client like wget or curl. For example:

curl -i -H "accept: text/xml" -X GET http://[rails_host]/v1/procedures?token=[api_token]
curl -i -H "accept: application/json" -X GET http://[rails_host]/v1/procedures?token=[api_token]

The following example shows filters:

curl -i -H "accept: application/json" -H "Content-type: application/json" -X GET -d '{ "filters": { "name":"Sample Procedure" } }' http://[rails_host]/v1/procedures?token=[api_token]

GET /v1/procedures/[id]

Returns a procedure by ID.

Common attributes

  • id — Unique numerical ID for a procedure
  • format — Be sure to include this as an accept header or add .xml or .json to the last path element
  • token — Your API token for authentication

Errors caused

  • ERROR 403 Forbidden — Occurs when the token is invalid
  • ERROR 404 Not found — Occurs when the record to show is not found

Examples

To test this method, insert this URL or your valid API key and application host into a browser or HTTP client like wget or curl. For example:

curl -i -H "accept: text/xml" -X GET http://[rails_host]/v1/procedures/[id]?token=[api_token]
curl -i -H "accept: application/json" -X GET http://[rails_host]/v1/procedures/[id]?token=[api_token]

POST /v1/procedures

Creates a new procedure from posted data.

Required attribute

  • name — String name of the procedure

Optional attributes

  • aasm_state  String name of a valid status of object state

    Warning

    Note

    For a POST operation, only the Draft state is allowed. By default, the aasm_state is Draft.

  • description — String description of the procedure
  • app_ids — Array of integer values for the related application IDs
  • step_ids — Array of integer values for the related step IDs

    Error
    Warning

    Do not use step_ids to add steps to a procedure, because they will be linked directly rather than cloned. Use step_ids_to_clone to clone existing steps and add them to a procedure.

  • step_ids_to_clone — Array of integer related step IDs to be cloned and associated with the procedure. Fields to be cloned are controlled by the metadata list titled IncludeInSteps

    Warning

    Note

    When you create or update procedures, you can clone a set of existing steps and assign the clones — not the original steps — to the step_ids attribute. Use step_ids_to_clone, not step_ids, to add steps to a procedure. If steps are already associated with the procedure, the clones are added to that array.

Common attributes

  • format — Be sure to include this as an accept header or add .xml or .json to the last path element
  • token — Your API token for authentication

Errors caused

  • ERROR 403 Forbidden — Occurs when the token is invalid
  • ERROR 422 Unprocessable entity — Occurs when validation fails; objects and errors are returned

Examples

To test this method, insert this URL or your valid API key and application host into a browser or HTTP client like wget or curl. For example:

curl -i -H "accept: text/xml" -H "Content-type: text/xml" -X POST -d '<procedure><name>REST Procedure</name><app_ids>1</app_ids><app_ids>2</app_ids><step_ids_to_clone>8</step_ids_to_clone><step_ids_to_clone>11</step_ids_to_clone></procedure>' http://[rails_host]/v1/procedures?token=[api_token]
curl -i -H "accept: application/json" -H "Content-type: application/json"  -X POST -d '{"name":"Rest Procedure", "app_ids":[1,2], "step_ids_to_clone":[10,11,12,13]}' http://[rails_host]/v1/procedures/?token=[api_token]

PUT /v1/procedures/[id]

Updates an existing procedure with values from a posted document.

Editable attributes

  • name — String name of the procedure
  • description — String description of the procedure
  • aasm_state — String name of a valid status of object state

    Warning

    Note

    Valid status of object states are draft, pending, released, retired, and archived. The aasm_state Archived can only be reached if the current aasm_state is Retired. If the current aasm_state is Archived, the only available state is Retired. By default, the aasm_state is Draft.

  • app_ids — Array of integer values for the related application IDs
  • step_ids — Array of integer values for the related step IDs

    Error
    Warning

    Do not use step_ids to add steps to a procedure, because they will be linked directly rather than cloned. Use step_ids_to_clone to clone existing steps and add them to a procedure.

  • step_ids_to_clone — Array of integer related step IDs to be cloned and associated with the procedure. Fields to be cloned are controlled by the metadata list titled IncludeInSteps

    Warning

    Note

    When you create or update procedures, you can clone a set of existing steps and assign the clones — not the original steps — to the step_ids attribute. Use step_ids_to_clone, not step_ids, to add steps to a procedure. If steps are already associated with the procedure, the clones are added to that array.

Toggle archival status

  • toggle_archive — Boolean value that toggles the archive status of an object

    Warning

    Note

    You can only toggle the archive status when the state is Archived or Retired.

Common attributes

  • format — Be sure to include an accept header or add  .xml or .json to the last path element
  • token — Your API token for authentication

Errors caused

  • ERROR 403 Forbidden — Occurs when the token is invalid
  • ERROR 404 Not found — Occurs when the record to update is not found
  • ERROR 422 Unprocessable entity — Occurs when validation fails; objects and errors are returned

Examples

To test this method, insert this URL or your valid API key and application host into a browser or HTTP client like wget or curl. For example:

curl -i -H "accept: text/xml" -H "Content-type: text/xml" -X PUT -d '<procedure><name>Renamed Procedure</name></procedure>' http://[rails_host]/v1/procedures/[id]?token=[api_token]
curl -i -H "accept: application/json" -H "Content-type: application/json" -X PUT -d '{ "procedure": { "name" : "Renamed Procedure"}}'  http://[rails_host]/v1/procedures/[id]?token=[api_token]

The following example toggles the archive status of an object:

curl -i -H "accept: application/json" -H "Content-type: application/json" -X PUT -d '{ "toggle_archive": true }'  http://[rails_host]/v1/procedures/[id]?token=[api_token]

DELETE /v1/procedures/[id]

Deletes a procedure.

Common attributes

  • id — Unique numerical ID of the procedure
  • format — Be sure to include an accept header or add  .xml or .json to the last path element
  • token — Your API token for authentication

Errors caused

  • ERROR 403 Forbidden — Occurs when the token is invalid
  • ERROR 404 Not found — Occurs when no records are found

Examples

To test this method, insert this URL or your valid API key and application host into a browser or HTTP client like wget or curl. For example:

curl -i -H "accept: text/xml" -X DELETE http://[rails_host]/v1/procedures/[id]?token=[api_token]
curl -i -H "accept: application/json" -X DELETE http://[rails_host]/v1/procedures/[id]?token=[api_token]

Sample output

The following JSON is sample output from GET /v1/procedures:

[{
"archive_number": null,
"archived_at": null,
"created_at": "2012-08-29T21:41:02-04:00",
"description": "Steps from request #1001",
"id": 1,
"name": "Sample Procedure",
"updated_at": "2012-08-29T21:41:02-04:00",
"steps": [{
"aasm_state": "locked",
"id": 8,
"name": "Step 1"
}, {
"aasm_state": "locked",
"id": 9,
"name": "Step 2"
}, {
"aasm_state": "locked",
"id": 10,
"name": "Step 3"
}, {
"aasm_state": "locked",
"id": 11,
"name": "Step 2"
}, {
"aasm_state": "locked",
"id": 12,
"name": "Step 4"
}, {
"aasm_state": "locked",
"id": 13,
"name": "Step 7"
}]
}]

The following XML is sample output from GET /v1/procedures/1:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-UA-Compatible: IE=Edge
ETag: "c9ff133fb107fb979f3b1002e8c69afe"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 3aab000dde7aa338dc5ba841145dd885
X-Runtime: 0.167000
Content-Type: application/xml;charset=utf-8
Content-Length: 1172
Date: Thu, 30 Aug 2012 02:16:37 GMT

<?xml version="1.0" encoding="UTF-8"?>
<procedure>
 <archive-number nil="true"></archive-number>
 <archived-at type="datetime" nil="true"></archived-at>
 <created-at type="datetime">2012-08-29T21:41:02-04:00</created-at>
 <description>Steps from request #1001</description>
 <id type="integer">1</id>
 <name>Sample Procedure</name>
 <updated-at type="datetime">2012-08-29T21:41:02-04:00</updated-at>
 <steps type="array">
   <step>
     <aasm-state>locked</aasm-state>
     <id type="integer">8</id>
     <name>Step 1</name>
   </step>
   <step>
     <aasm-state>locked</aasm-state>
     <id type="integer">9</id>
     <name>Step 2</name>
   </step>
   <step>
     <aasm-state>locked</aasm-state>
     <id type="integer">10</id>
     <name>Step 3</name>
   </step>
   <step>
     <aasm-state>locked</aasm-state>
     <id type="integer">11</id>
     <name>Step 2</name>
   </step>
   <step>
     <aasm-state>locked</aasm-state>
     <id type="integer">12</id>
     <name>Step 4</name>
   </step>
   <step>
     <aasm-state>locked</aasm-state>
     <id type="integer">13</id>
     <name>Step 7</name>
   </step>
 </steps>
</procedure>

Related topic

Managing-procedures

 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Release Process Management 4.8