Last active
August 6, 2020 23:23
-
-
Save stmcallister/0eddf0e25b20db19fa9c2a8a38244e7d to your computer and use it in GitHub Desktop.
Python script for creating an AppDynamics integration for a PagerDuty service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pdpyras import APISession | |
import os | |
# api_token: an API key for the PagerDuty account with read/write access | |
# - To create API key see https://support.pagerduty.com/docs/generating-api-keys | |
api_token = os.getenv('PD_API_KEY') | |
session = APISession(api_token) | |
# Sample to create an AppDynamics Integration | |
serviceID = 'PBXDLG9' | |
# This vendor id is unique to AppDynamics. The id tells PagerDuty which vendor | |
# to use in the integration. | |
appDynamicsVendorID = 'P3H374T' | |
# API call to create a service integration. You can read more about this endpoint | |
# here: https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1services~1%7Bid%7D~1integrations/post | |
integration = session.rpost( | |
'/services/'+serviceID+'/integrations', | |
json={ | |
'type': 'generic_events_api_inbound_integration_reference', | |
'name': 'AppDynamics', | |
'vendor': { | |
'id': appDynamicsVendorID, | |
'type': 'vendor_reference' | |
} | |
} | |
) | |
print("Integration %s was created for the service."%integration['id']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment