# Integrations

After projects, integrations is one of the primary forms to distinguish data. Currently we support Azure, Jira and Jenkins as types of integrations. An integration is an encapsulation of the data retrieved from its respective service and has different data depending on what type it is.

Given a project id, you can retrieve integrations for that project like so:

curl -H "X-API-Key: <your token goes here>" \
https://api.accidentalquality.com/api/integrations/<project_id>
fetch('https://api.accidentalquality.com/api/integrations/<project_id>', {
  method: "GET",
  headers: {"Content-type": "application/json;charset=UTF-8", "X-API-Key": "<your-token-goes-here>"}
})
.then(response => response.json()) 
.then(json => console.log(json)) 
.catch(err => console.log(err));

The data returned is in json format and structured as follows:

  • (array)
    • id integer - The id of the integration. You will need this to query other data.
    • integration_type *string - either "jira", "azure" or "jenkins"
    • name string - The name of the integration.
    • url string - The url the integration uses to scrape the data for processing. This can either be reachable or locked behind your firewall.

Example:

        [
            {
                "id": "1",
                "integration_type": "jira",
                "name": "Project manager said it would take 9 women 1 month to make the baby!",
                "url": "jira.company.com/rest/api/latest/search?jql=filter=12345"
            },
            {
                "id": "2", 
                "integration_type": "azure",
                "name": "I connected my phone to the cloud, but it mist calls",
                "url": "https://dev.azure.com/company/newtwitterclone"
            },
            {
                "id": "3", 
                "integration_type": "jenkins",
                "name": "Master Bruce, have you seen the pipelines lately?",
                "url": "jenkins.company.com/job/pipeline_1"
            },
            ...
        ]

# Creating integrations programmatically

You can opt to create integrations programmatically. You will need a token and to know which type of integration you want - current options are Jenkins and Jira. Azure and Github are on the way, but have a vastly different flow and are therefore not included yet.

The parameters required to create an integration are:

    {
        "integration": {
            "integration_type": "options are 'jira', 'jenkins'", 
            "name": "A descriptive name", 
            "project_id": "The project the integration should belong to",
            "token_id": "The id of a token that allows access to the data the integration processes.", 
            "url": "The URL which data will be drawn from. For Jira it is a filter in the endpoint, for Jenkins it is the base of a job."
        }
    }

With above paramters you can create an integration like this:

curl -X POST -H "X-API-Key: <your token goes here>" \
https://api.accidentalquality.com/api/integrations
fetch('https://api.accidentalquality.com/api/integrations', {
  method: "POST",
  headers: {"Content-type": "application/json;charset=UTF-8", "X-API-Key": "<your-token-goes-here>"}
})
.then(response => response.json()) 
.then(json => console.log(json)) 
.catch(err => console.log(err));

If it goes well, you should get a status '201' (created).