Skip to main content

Becasue of the number of services we have, we are looking at a way of creating a dynamic method of creating change events from our release tool, and this is the order of events we want to happen:



  1. Identify the name of the service that is being deployed

  2. Execute a get API call to retrieve the change integration key for that service.

  3. Create the POST API call to post the change event to PagerDuty


the first is within our hands, and the last is a standard API call using the events API, but number 2 is the difficult one right now… any help or advice is very gratefully received - thanks

Hi @alan bustin


You’ll want to append the included] option to your query to find the key. So your endpoint will look like:

/services/{ID}?included]=integrations


You’ll find a key in the json output for integrations (it’s an array, so you’ll want to iterate over it if you have multiple integrations on a service). Change events then have a type key value of change_event_transform_inbound_integration and you’ll find the integration key as integration_key.


In Python, using pdpyras, it would look a bit like:


endpoint = f"/services/{service_id}?included]=integrations"
response = session.rget(endpoint)

for integration in responsen'integrations']:
if integrationn'type'] == "change_event_transform_inbound_integration":
print(integrationn'integration_key'])

HTH,

–mandi


Reply