|
| 1 | +""" |
| 2 | +Create degradation returns "Created" response |
| 3 | +""" |
| 4 | + |
| 5 | +from os import environ |
| 6 | +from datadog_api_client import ApiClient, Configuration |
| 7 | +from datadog_api_client.v2.api.status_pages_api import StatusPagesApi |
| 8 | +from datadog_api_client.v2.model.create_degradation_request import CreateDegradationRequest |
| 9 | +from datadog_api_client.v2.model.create_degradation_request_data import CreateDegradationRequestData |
| 10 | +from datadog_api_client.v2.model.create_degradation_request_data_attributes import ( |
| 11 | + CreateDegradationRequestDataAttributes, |
| 12 | +) |
| 13 | +from datadog_api_client.v2.model.create_degradation_request_data_attributes_components_affected_items import ( |
| 14 | + CreateDegradationRequestDataAttributesComponentsAffectedItems, |
| 15 | +) |
| 16 | +from datadog_api_client.v2.model.create_degradation_request_data_attributes_status import ( |
| 17 | + CreateDegradationRequestDataAttributesStatus, |
| 18 | +) |
| 19 | +from datadog_api_client.v2.model.patch_degradation_request_data_type import PatchDegradationRequestDataType |
| 20 | +from datadog_api_client.v2.model.status_pages_component_data_attributes_status import ( |
| 21 | + StatusPagesComponentDataAttributesStatus, |
| 22 | +) |
| 23 | + |
| 24 | +# there is a valid "status_page" in the system |
| 25 | +STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID = environ[ |
| 26 | + "STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID" |
| 27 | +] |
| 28 | +STATUS_PAGE_DATA_ID = environ["STATUS_PAGE_DATA_ID"] |
| 29 | + |
| 30 | +body = CreateDegradationRequest( |
| 31 | + data=CreateDegradationRequestData( |
| 32 | + attributes=CreateDegradationRequestDataAttributes( |
| 33 | + components_affected=[ |
| 34 | + CreateDegradationRequestDataAttributesComponentsAffectedItems( |
| 35 | + id=STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID, |
| 36 | + status=StatusPagesComponentDataAttributesStatus.MAJOR_OUTAGE, |
| 37 | + ), |
| 38 | + ], |
| 39 | + description="Our API is experiencing elevated latency. We are investigating the issue.", |
| 40 | + status=CreateDegradationRequestDataAttributesStatus.INVESTIGATING, |
| 41 | + title="Elevated API Latency", |
| 42 | + ), |
| 43 | + type=PatchDegradationRequestDataType.DEGRADATIONS, |
| 44 | + ), |
| 45 | +) |
| 46 | + |
| 47 | +configuration = Configuration() |
| 48 | +with ApiClient(configuration) as api_client: |
| 49 | + api_instance = StatusPagesApi(api_client) |
| 50 | + response = api_instance.create_degradation(page_id=STATUS_PAGE_DATA_ID, body=body) |
| 51 | + |
| 52 | + print(response) |
0 commit comments