# API Reference

## Trigger the log/metric analysis&#x20;

<mark style="color:green;">`POST`</mark> `/autopilot/api/v3/registerCanary`

This API used to triggers the log analysis/metric analysis to fetch the logs/metrics according to the parameters configured in the applications.

#### Request Body

| Name                                          | Type   | Description |
| --------------------------------------------- | ------ | ----------- |
| application<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Trigger the approval gate

<mark style="color:green;">`POST`</mark> `/approvalGates/{approvalGateId}/trigger`

This API used to trigger approval gate by Gate ID. It takes input as configured connector details. For example, if a user configured JIRA connector while creating the approval gate, this API will pass the JIRA id(ticket number) when it is triggered.&#x20;

#### Path Parameters

| Name                                             | Type   | Description                        |
| ------------------------------------------------ | ------ | ---------------------------------- |
| approvalGateId<mark style="color:red;">\*</mark> | Number | Approval Identifier for the entity |

#### Request Body

| Name                                                      | Type   | Description |
| --------------------------------------------------------- | ------ | ----------- |
| toolConnectorParameters<mark style="color:red;">\*</mark> | String |             |
| rejectionCallbackURL<mark style="color:red;">\*</mark>    | String |             |
| imageIds<mark style="color:red;">\*</mark>                | String |             |
| executionId<mark style="color:red;">\*</mark>             | String |             |
| approvalCallbackURL<mark style="color:red;">\*</mark>     | String |             |
| connectorType<mark style="color:red;">\*</mark>           | String |             |

{% tabs %}
{% tab title="200: OK activated" %}

```javascript
{
   "id": 16,
   "approvalGateId": 1,
   "activatedTime": "2021-03-31 11:48:48.684.Z",
   "approvalStatus": {
       "status": "activated"
}
```

{% endtab %}
{% endtabs %}

## Get the status of triggered approval gate

<mark style="color:blue;">`GET`</mark> `/approvalGateInstances/{approvalGateInstanceId}/status`

This API used to get status and comment about triggered approval gate. The status for approval gate are  “**not activated**”, “**activated**”, ”**approved**” and “**rejected**”.

#### Path Parameters

| Name                                                     | Type   | Description                        |
| -------------------------------------------------------- | ------ | ---------------------------------- |
| approvalGateInstanceId<mark style="color:red;">\*</mark> | Number | Approval Identifier for the entity |

{% tabs %}
{% tab title="200: OK approved, comment" %}

```javascript
{"status":"approved","comment":""}
```

{% endtab %}
{% endtabs %}

## Capturing Spinnaker-generated events

<mark style="color:green;">`POST`</mark> `/oes/echo (oes-spinnaker)`

This API used to capture all the echo events generated by Spinnaker. (For Example: To synchronize the application and pipelines when an application/pipeline is created)

#### Request Body

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| eventId<mark style="color:red;">\*</mark> | String |             |
| name<mark style="color:red;">\*</mark>    | String |             |

{% tabs %}
{% tab title="200: OK accepted" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Spinnaker triggers during a pipeline event

<mark style="color:green;">`POST`</mark> `/auditservice/v1/echo/events/data`

This API is called when a spinnaker triggers during a pipeline event. Data is saved in the audit database.

#### Request Body

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| content<mark style="color:red;">\*</mark> | String |             |
| details<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## To validate OPA compliance while creating pipeline

<mark style="color:green;">`POST`</mark> `/v1/staticPolicy/eval (oes-policy)`

This API is used by Spinnaker when creating a pipeline to validate against OPA compliance

#### Request Body

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| input<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK Success/ALLOW" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="401: Unauthorized Failure/DENY" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="500: Internal Server Error exception" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## To validate OPA compliance while executing  pipeline

<mark style="color:green;">`POST`</mark> `/v1/data/** (oes-policy)`

This API is used by Spinnaker when executing a pipeline to validate against OPA compliance.

#### Request Body

| Name                                                | Type   | Description |
| --------------------------------------------------- | ------ | ----------- |
| payloadConstraint<mark style="color:red;">\*</mark> | String |             |
| startTime<mark style="color:red;">\*</mark>         | String |             |
| application<mark style="color:red;">\*</mark>       | String |             |
| name<mark style="color:red;">\*</mark>              | String |             |
| stage<mark style="color:red;">\*</mark>             | String |             |
| executionId<mark style="color:red;">\*</mark>       | String |             |
| user<mark style="color:red;">\*</mark>              | String |             |
| imageIds<mark style="color:red;">\*</mark>          | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}
