Create

This method allows you to add a new environment.

Method URL
POST /api/v1/environments

Parameters

Param Type Required Notes
name string Yes The name of the environment
short_description string No A short description about the environment
node_rules string No A newline delimited list of regular expressions that can be used to intelligently match node names to be added to this environment

Example Submitted Payload

{
    "environment": {
        "name": "Production",
        "short_description": "CryptoCurrencyPopularAtTheMoment Miner",
        "node_rules": "miner[0-9]+[.]example[.]com"
    }
}

Example Response

Code Status
201 Created

Example Response JSON

{
    "name": "Production",
    "short_description": "CryptoCurrencyPopularAtTheMoment Miner",
    "node_rules": "miner[0-9]+[.]example[.]com",
    "organisation_id": 123
}

Show

This method returns the details of the environment specified by the ID given in the URL.

Method URL
GET /api/v1/environments/[environment_id].json
Example Request URL

Example Response

Code Status
200 OK

Example Response JSON

{
    "id": 30,
    "organisation_id": 123,
    "name": "Production",
    "short_description": "ForEx Trading Production",
    "node_rules": ""
}

Index

This method returns a list of environments created by the organization.

Method URL
GET /api/v1/environments.json
GET /api/v1/environments.json?page=1&per_page=2

Example Response

Code Status
200 OK

Example Response JSON

[
    {
        "id": 30,
        "name": "production",
        "short_description": "ForEx Trading Production",
        "node_rules": "",
        "url": "https://guardrail.scriptrock.com/api/v1/environments/30.json"
    },
    {
        "id": 31,
        "name": "staging",
        "short_description": "ForEx Trading Staging",
        "node_rules": "",
        "url": "https://guardrail.scriptrock.com/api/v1/environments/31.json"
    }
]

New

This method returns a skeleton payload format that can subsequently be submitted to create a new environment.

Method URL
GET /api/v1/environments/new.json
Example Response

Example Response

Code Status
200 OK

Example Response JSON

{
    "environment": {
        "name": null,
        "short_description": null,
        "node_rules": null
    }
}

Update

This method allows you to update properties of a node.

Method URL
PUT /api/v1/environments/[environment_id].json

Example Submitted Payload

{
    "environment": {
        "name": "New Environment Name"
    }
}

Example Response

Code Status
204 No Content

Delete

This method allows you to update properties of a node.

Method URL
DELETE /api/v1/environments/[environment_id].json

Example Response

Code Status
204 No Content

Lookup

This method allows you to lookup the Environment ID by name.

Method URL
GET /api/v1/environments/lookup.json?name=[environment_name]

Parameters

Param Type Required Notes
name string Yes The name of the environment

Example Response

Code Status
200 OK

Example Response JSON

{
    "environment_id": 123
}

Error Cases

Code Status Cause
404 Not Found There are no environments in your account that match the search parameters.
422 Unprocessable Entity No supported search parameters were found in the request. You need to supply name= as a method parameter.

Nodes

This method allows you to list all nodes within an environment.

Method URL
GET /api/v1/environments/[environment_id]/nodes.json
GET /api/v1/environments/[environment_id]/nodes.json?page=1&per_page=2

Example Response

Code Status
200 OK

Example Response JSON

[
    {
        "id": 311,
        "name": "ugv1laptop",
        "description": "Unmanned Ground Vehicle 1 Laptop",
        "url": "https://guardrail.scriptrock.com/api/v1/nodes/311.json"
    },
    {
        "id": 439,
        "name": "solarisbox",
        "description": "Solaris Intel Testing box 34",
        "url": "https://guardrail.scriptrock.com/api/v1/nodes/439.json"
    }
]

Report

This method allows you to retrieve the last scheduled scan report for the environment (ie: the data you get sent by email showing added/removed/changed counts).

Method URL
GET /api/v1/environments/[environment_id]/report.json

Example Response

Code Status
200 OK

Example Response JSON

{
  "date": "2014-04-15T00:08:02-07:00",
  "report": {
    "job_id": 27793663,
    "nodes": [
      {
        "node_id": 26,
        "node_name": "bluthcompanydirectory",
        "date_previous": "2014-04-14T07:06:02Z",
        "date_latest": "2014-04-15T07:06:04Z",
        "previous_scan_id": 15676,
        "latest_scan_id": 15847,
        "stats": {
          "summary": {
            "total": 611,
            "added": 0,
            "deleted": 0,
            "updated": 0
          },
        ....
}
Tags: environments