Trigger an Impact Analysis

Use the Continuous Delivery API to trigger an impact analysis on the module of a control repo.

Before you begin:
In order to trigger an Impact Analysis run of your code changes, you need to collect the following:
data="$(cat <<EOF
{
  "workspaceId": "<workspace ID>", 
  "projectName": "control-repo",
  "projectType": "CONTROL_REPO",
  "settings": {
    "environments": [
      {
        "nodeGroupId": "<environment node group ID>",
        "peCredentialsId": {
          "name": "example-pe",
          "domain": "<workspace ID>"
        }
      },
      {
        "nodeGroupId": "defcea94-e7e5-4fe3-b971-1acd44785695",
        "peCredentialsId": {
          "name": "example-pe",
          "domain": "<workspace ID>"
        }
      }
    ],
    "sourceBranch": "<branch to test>",
    "sourceSha": "<SHA to test>",
    "analyzeAllDeployments": false,
    "compileBatchSize": 10,
    "controlRepoId": {
      "name": "control-repo",
      "domain": "<workspace ID>"
    }
  }
}
EOF
)"
type_header='Content-Type: application/json'
auth_header="Authorization: <authorization token>"
uri="https://<cd4pe host>/cd4pe/api/v1/impact-analysis/trigger"
curl --insecure --header "$type_header" --header "$auth_header" --request POST "$uri" --data "$data"

This returns something similar to the following:

{
  "appEventId" : 18900, 
  "baseTaskUrl" : "https://<cd4pe host>/cd4pe/root/deployments",
  "domain" : "d5",
  "id" : 110,
  ...data repeated from request...
  "state" : "QUEUED"
}

Once the impact analysis has finished, you might want to check the state of the run and fetch the analysis report, to do so use the ID of the response that was returned like so:

type_header='Content-Type: application/json'
auth_header="Authorization: <API token>"
uri="https://<cd4pe host>/cd4pe/api/v1/impact-analysis/<IA run ID>/csv?workspaceId=<workspace ID>"
curl --insecure --header "$type_header" --header "$auth_header" --request GET "$uri"