def _get_domain_api_client_(self): if 'alerts' in self.url: return opsgenie_sdk.AlertApi(api_client=self.api_client) elif 'incident' in self.url: return opsgenie_sdk.IncidentApi(api_client=self.api_client) else: raise ApiException(reason='Short polling is not currently supported for this domain')
def createOpsgenie(self): api_key = self.getOpsgenieKey() self.conf = self.conf = opsgenie_sdk.configuration.Configuration() self.conf.api_key['Authorization'] = api_key self.api_client = opsgenie_sdk.api_client.ApiClient( configuration=self.conf) self.alert_api = opsgenie_sdk.AlertApi(api_client=self.api_client) body = opsgenie_sdk.CreateAlertPayload( message='AirFlow Job: activision_file_drop is failed', description= 'Please check the activision_file_drop dag logs in the airflow', responders=[{ 'name': 'DevOps', 'type': 'team' }], priority='P3') try: create_response = self.alert_api.create_alert( create_alert_payload=body) logger.info( "Sent opsgenie notification!. Response Code - {}".format( create_response)) time.sleep(3) alertID = create_response.id success_response = self.alert_api.add_attachment( identifier=alertID, file='activision_report.html') return create_response except opsgenie_sdk.ApiException as err: logger.error( "Exception when calling Opsgenie AlertApi->create_alert: {}". format(err)) raise err
def __init__(self): self.conf = self.conf = opsgenie_sdk.configuration.Configuration() self.conf.api_key['Authorization'] = '<YOUR_API_KEY_HERE' self.api_client = opsgenie_sdk.api_client.ApiClient( configuration=self.conf) self.alert_api = opsgenie_sdk.AlertApi(api_client=self.api_client)
def __init__(self, opsgenie_api_key: str, eu_host: bool): api_configuration = opsgenie_sdk.configuration.Configuration() api_configuration.api_key['Authorization'] = opsgenie_api_key api_configuration.host = "https://api.eu.opsgenie.com" if eu_host \ else "https://api.opsgenie.com" self._client = opsgenie_sdk.api_client.ApiClient( configuration=api_configuration) self._alert_api = opsgenie_sdk.AlertApi(api_client=self._client)
def create_alert_exception(self): # create an instance of the API class alert_api = opsgenie_sdk.AlertApi(opsgenie_sdk.ApiClient(self.configuration)) # CreateAlertPayload | Request payload of created alert create_alert_payload = opsgenie_sdk.CreateAlertPayload( message="test-alert-exception", description="Zero Division exception occured in the division operation" ) # create alert api_response = alert_api.create_alert(create_alert_payload) pprint(api_response)
def __init__(self, opsgenie_api_key): self.conf = self.conf = opsgenie_sdk.configuration.Configuration() self.conf.api_key['Authorization'] = opsgenie_api_key self.conf.debug = False self.conf.retry_count = 5 self.conf.retry_http_response = ['4xx', '5xx'] self.conf.retry_delay = 2 self.conf.retry_enabled = True self.api_client = opsgenie_sdk.api_client.ApiClient( configuration=self.conf) self.alert_api = opsgenie_sdk.AlertApi(api_client=self.api_client)
def __init__(self): self.conf = self.conf = opsgenie_sdk.configuration.Configuration() self.conf.host = 'https://api.eu.opsgenie.com' self.conf.api_key['Authorization'] = os.environ['ops_genie'] self.conf.debug = False self.conf.retry_count = 5 self.conf.retry_http_response = ['4xx', '5xx'] self.conf.retry_delay = 2 self.conf.retry_enabled = True self.api_client = opsgenie_sdk.api_client.ApiClient( configuration=self.conf) self.alert_api = opsgenie_sdk.AlertApi(api_client=self.api_client)
def __init__(self, apikey): self.conf = opsgenie_sdk.configuration.Configuration() self.conf.api_key['Authorization'] = apikey self.api_client = opsgenie_sdk.api_client.ApiClient(configuration=self.conf) self.alert_api = opsgenie_sdk.AlertApi(api_client=self.api_client)
def __init__(self): self.conf = opsgenie_sdk.configuration.Configuration() self.conf.api_key['Authorization'] = settings.OPSGENIE_API self.api_client = opsgenie_sdk.api_client.ApiClient(configuration=self.conf) self.alert_api = opsgenie_sdk.AlertApi(api_client=self.api_client)