diff --git a/.apigentools-info b/.apigentools-info index 093c1aaba1..82c7c5351b 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-05-24 14:57:13.521035", - "spec_repo_commit": "a5ef3fab" + "regenerated": "2023-05-25 15:21:20.481818", + "spec_repo_commit": "40436e2b" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-05-24 14:57:13.535784", - "spec_repo_commit": "a5ef3fab" + "regenerated": "2023-05-25 15:21:20.493966", + "spec_repo_commit": "40436e2b" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c9edd31819..dc6bd3def5 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2966,6 +2966,551 @@ components: type: string x-enum-varnames: - DETAILED_FINDING + DowntimeAttributeCreateRequest: + description: Downtime details. + properties: + display_timezone: + $ref: '#/components/schemas/DowntimeAttributeDisplayTimezone' + message: + $ref: '#/components/schemas/DowntimeAttributeMessage' + monitor_identifier: + $ref: '#/components/schemas/DowntimeAttributeMonitorIdentifier' + mute_first_recovery_notification: + $ref: '#/components/schemas/DowntimeAttributeMuteFirstRecoveryNotification' + notify_end_states: + $ref: '#/components/schemas/DowntimeAttributeNotifyEndStates' + notify_end_types: + $ref: '#/components/schemas/DowntimeAttributeNotifyEndTypes' + schedule: + $ref: '#/components/schemas/DowntimeAttributeScheduleCreateRequest' + scope: + $ref: '#/components/schemas/DowntimeAttributeScope' + required: + - scope + - monitor_identifier + type: object + DowntimeAttributeDisplayTimezone: + default: UTC + description: 'The timezone in which to display the downtime''s start and end + times in Datadog applications. This is not used + + as an offset for scheduling.' + example: America/New_York + type: string + DowntimeAttributeEditRequest: + description: Attributes of the downtime to update. + properties: + display_timezone: + $ref: '#/components/schemas/DowntimeAttributeDisplayTimezone' + message: + $ref: '#/components/schemas/DowntimeAttributeMessage' + monitor_identifier: + $ref: '#/components/schemas/DowntimeAttributeMonitorIdentifier' + mute_first_recovery_notification: + $ref: '#/components/schemas/DowntimeAttributeMuteFirstRecoveryNotification' + notify_end_states: + $ref: '#/components/schemas/DowntimeAttributeNotifyEndStates' + notify_end_types: + $ref: '#/components/schemas/DowntimeAttributeNotifyEndTypes' + schedule: + $ref: '#/components/schemas/DowntimeAttributeScheduleEditRequest' + scope: + $ref: '#/components/schemas/DowntimeAttributeScope' + type: object + DowntimeAttributeMessage: + description: 'A message to include with notifications for this downtime. Email + notifications can be sent to specific users + + by using the same `@username` notation as events.' + example: Message about the downtime + type: string + DowntimeAttributeMonitorIdentifier: + description: Monitor identifier for the downtime + oneOf: + - $ref: '#/components/schemas/DowntimeAttributeMonitorIdentifierId' + - $ref: '#/components/schemas/DowntimeAttributeMonitorIdentifierTags' + type: object + DowntimeAttributeMonitorIdentifierId: + description: Object of the monitor identifier. + properties: + monitor_id: + description: ID of the monitor to prevent notifications. + example: 123 + format: int64 + type: integer + required: + - monitor_id + type: object + DowntimeAttributeMonitorIdentifierTags: + description: Object of the monitor tags. + properties: + monitor_tags: + description: 'A list of monitor tags. For example, tags that are applied + directly to monitors, + + not tags that are used in monitor queries (which are filtered by the scope + parameter), to which the downtime applies. + + The resulting downtime applies to monitors that match ALL provided monitor + tags.' + example: + - service:postgres + - team:frontend + items: + description: A list of monitor tags. + example: service:postgres + type: string + type: array + required: + - monitor_tags + type: object + DowntimeAttributeMuteFirstRecoveryNotification: + description: If the first recovery notification during a downtime should be + muted. + example: false + type: boolean + DowntimeAttributeNotifyEndStates: + description: States that will trigger a monitor notification when the `notify_end_types` + action occurs. + example: + - alert + - warn + items: + description: State that will trigger a monitor notification when the `notify_end_types` + action occurs. + enum: + - alert + - no data + - warn + example: alert + type: string + x-enum-varnames: + - ALERT + - NO_DATA + - WARN + type: array + DowntimeAttributeNotifyEndTypes: + description: Actions that will trigger a monitor notification if the downtime + is in the `notify_end_types` state. + example: + - canceled + - expired + items: + description: Action that will trigger a monitor notification if the downtime + is in the `notify_end_types` state. + enum: + - canceled + - expired + example: canceled + type: string + x-enum-varnames: + - CANCELED + - EXPIRED + type: array + DowntimeAttributeResponse: + description: Downtime details. + properties: + created_at: + description: Creation time of the downtime. + example: '2020-01-02T03:04:05.282979+00:00' + format: date-time + type: string + display_timezone: + $ref: '#/components/schemas/DowntimeAttributeDisplayTimezone' + message: + $ref: '#/components/schemas/DowntimeAttributeMessage' + modified_at: + description: Time that the downtime was last modified. + example: '2020-01-02T03:04:05.282979+00:00' + format: date-time + type: string + monitor_identifier: + $ref: '#/components/schemas/DowntimeAttributeMonitorIdentifier' + mute_first_recovery_notification: + $ref: '#/components/schemas/DowntimeAttributeMuteFirstRecoveryNotification' + notify_end_states: + $ref: '#/components/schemas/DowntimeAttributeNotifyEndStates' + notify_end_types: + $ref: '#/components/schemas/DowntimeAttributeNotifyEndTypes' + schedule: + $ref: '#/components/schemas/DowntimeAttributeScheduleResponse' + scope: + $ref: '#/components/schemas/DowntimeAttributeScope' + status: + $ref: '#/components/schemas/DowntimeStatusEnum' + type: object + DowntimeAttributeScheduleCreateRequest: + description: Schedule for the downtime. + oneOf: + - $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrencesCreateRequest' + - $ref: '#/components/schemas/DowntimeAttributeScheduleOneTimeCreateEditRequest' + type: object + DowntimeAttributeScheduleCurrentDowntimeResponse: + description: 'The most recent actual start and end dates for a recurring downtime. + For a canceled downtime, + + this is the previously occurring downtime. For active downtimes, this is the + ongoing downtime, and for scheduled + + downtimes it is the upcoming downtime.' + properties: + end: + description: The end of the current downtime. + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + start: + description: The start of the current downtime. + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + type: object + DowntimeAttributeScheduleEditRequest: + description: Schedule for the downtime. + oneOf: + - $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrencesEditRequest' + - $ref: '#/components/schemas/DowntimeAttributeScheduleOneTimeCreateEditRequest' + type: object + DowntimeAttributeScheduleOneTimeCreateEditRequest: + description: A one-time downtime definition. + properties: + end: + description: 'ISO-8601 Datetime to end the downtime. Must include a UTC + offset of zero. If not provided, the + + downtime starts the moment it is created.' + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + start: + description: 'ISO-8601 Datetime to start the downtime. Must include a UTC + offset of zero. If not provided, the + + downtime starts the moment it is created.' + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + type: object + DowntimeAttributeScheduleOneTimeResponse: + description: A one-time downtime definition. + properties: + end: + description: ISO-8601 Datetime to end the downtime. + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + start: + description: ISO-8601 Datetime to start the downtime. + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + type: object + DowntimeAttributeScheduleRecurrenceCreateEditRequest: + description: An object defining the recurrence of the downtime. + properties: + duration: + $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrenceDuration' + rrule: + $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrenceRrule' + start: + description: 'ISO-8601 Datetime to start the downtime. Must not include + a UTC offset. If not provided, the + + downtime starts the moment it is created.' + example: 2020-01-02T03:04 + type: string + required: + - duration + - rrule + type: object + DowntimeAttributeScheduleRecurrenceDuration: + description: The length of the downtime. Must begin with an integer and end + with one of 'm', 'h', d', or 'w'. + example: 123d + type: string + DowntimeAttributeScheduleRecurrenceResponse: + description: An RRULE-based recurring downtime. + properties: + duration: + $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrenceDuration' + rrule: + $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrenceRrule' + start: + description: 'ISO-8601 Datetime to start the downtime. Must not include + a UTC offset. If not provided, the + + downtime starts the moment it is created.' + example: 2020-01-02T03:04 + type: string + type: object + DowntimeAttributeScheduleRecurrenceRrule: + description: 'The `RRULE` standard for defining recurring events. + + For example, to have a recurring event on the first day of each month, set + the type to `rrule` and set the `FREQ` to `MONTHLY` and `BYMONTHDAY` to `1`. + + Most common `rrule` options from the [iCalendar Spec](https://tools.ietf.org/html/rfc5545) + are supported. + + + **Note**: Attributes specifying the duration in `RRULE` are not supported + (for example, `DTSTART`, `DTEND`, `DURATION`). + + More examples available in this [downtime guide](https://docs.datadoghq.com/monitors/guide/suppress-alert-with-downtimes/?tab=api).' + example: FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1 + type: string + DowntimeAttributeScheduleRecurrencesCreateRequest: + description: A recurring downtime schedule definition. + properties: + recurrences: + description: A list of downtime recurrences. + items: + $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrenceCreateEditRequest' + type: array + timezone: + default: UTC + description: The timezone in which to schedule the downtime. + example: America/New_York + type: string + required: + - recurrences + type: object + DowntimeAttributeScheduleRecurrencesEditRequest: + description: A recurring downtime schedule definition. + properties: + recurrences: + description: A list of downtime recurrences. + items: + $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrenceCreateEditRequest' + type: array + timezone: + default: UTC + description: The timezone in which to schedule the downtime. + example: America/New_York + type: string + type: object + DowntimeAttributeScheduleRecurrencesResponse: + description: A recurring downtime schedule definition. + properties: + current_downtime: + $ref: '#/components/schemas/DowntimeAttributeScheduleCurrentDowntimeResponse' + recurrences: + description: A list of downtime recurrences. + items: + $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrenceResponse' + maxItems: 5 + minItems: 1 + type: array + timezone: + description: 'The timezone in which to schedule the downtime. This affects + recurring start and end dates. + + Must match `display_timezone`.' + example: America/New_York + type: string + type: object + DowntimeAttributeScheduleResponse: + description: 'The schedule that defines when the monitor starts, stops, and + recurs. There are two types of schedules: + + one-time and recurring. Recurring schedules may have up to five RRULE-based + recurrences. If no schedules is + + provided, the downtime will begin immediately and never end.' + oneOf: + - $ref: '#/components/schemas/DowntimeAttributeScheduleRecurrencesResponse' + - $ref: '#/components/schemas/DowntimeAttributeScheduleOneTimeResponse' + type: object + DowntimeAttributeScope: + description: 'The scope to which the downtime applies. Must be in + + [simple grammar syntax](https://docs.datadoghq.com/logs/explorer/search_syntax/).' + example: env:(staging OR prod) AND datacenter:us-east-1 + type: string + DowntimeCreateData: + description: Object to create a downtime. + properties: + attributes: + $ref: '#/components/schemas/DowntimeAttributeCreateRequest' + type: + $ref: '#/components/schemas/DowntimeResourceType' + required: + - type + - attributes + type: object + DowntimeCreateRequest: + description: Request for creating a downtime. + properties: + data: + $ref: '#/components/schemas/DowntimeCreateData' + required: + - data + type: object + DowntimeEditData: + description: Object to update a downtime. + properties: + attributes: + $ref: '#/components/schemas/DowntimeAttributeEditRequest' + id: + description: ID of this downtime. + example: 00000000-0000-1234-0000-000000000000 + type: string + type: + $ref: '#/components/schemas/DowntimeResourceType' + required: + - id + - type + - attributes + type: object + DowntimeEditRequest: + description: Request for editing a downtime. + properties: + data: + $ref: '#/components/schemas/DowntimeEditData' + required: + - data + type: object + DowntimeIncludedMonitorType: + default: monitors + description: Monitor resource type. + enum: + - monitors + example: monitors + type: string + x-enum-varnames: + - MONITORS + DowntimeMonitorIncludedAttributes: + description: Attributes of the monitor identified by the downtime. + properties: + name: + description: The name of the monitor identified by the downtime. + example: A monitor name + type: string + type: object + DowntimeMonitorIncludedItem: + description: Information about the monitor identified by the downtime. + properties: + attributes: + $ref: '#/components/schemas/DowntimeMonitorIncludedAttributes' + id: + description: ID of the monitor identified by the downtime. + example: 12345 + format: int64 + type: integer + type: + $ref: '#/components/schemas/DowntimeIncludedMonitorType' + type: object + DowntimeRelationships: + description: All relationships associated with downtime. + properties: + created_by: + $ref: '#/components/schemas/DowntimeRelationshipsCreatedBy' + monitor: + $ref: '#/components/schemas/DowntimeRelationshipsMonitor' + type: object + DowntimeRelationshipsCreatedBy: + description: The user who created the downtime. + properties: + data: + $ref: '#/components/schemas/DowntimeRelationshipsCreatedByData' + type: object + DowntimeRelationshipsCreatedByData: + description: Data for the user who created the downtime. + properties: + id: + description: User ID of the downtime creator. + example: 00000000-0000-1234-0000-000000000000 + type: string + type: + $ref: '#/components/schemas/DowntimeUserType' + type: object + DowntimeRelationshipsMonitor: + description: The monitor identified by the downtime. + properties: + data: + $ref: '#/components/schemas/DowntimeRelationshipsMonitorData' + type: object + DowntimeRelationshipsMonitorData: + description: Data for the monitor. + properties: + id: + description: Monitor ID of the downtime. + example: 12345 + format: int64 + type: integer + type: + $ref: '#/components/schemas/DowntimeIncludedMonitorType' + type: object + DowntimeResourceType: + default: downtime + description: Downtime resource type. + enum: + - downtime + example: downtime + type: string + x-enum-varnames: + - DOWNTIME + DowntimeResponse: + description: 'Downtiming gives you greater control over monitor notifications + by + + allowing you to globally exclude scopes from alerting. + + Downtime settings, which can be scheduled with start and end times, + + prevent all alerting related to specified Datadog tags.' + properties: + data: + $ref: '#/components/schemas/DowntimeResponseData' + included: + description: Array of objects related to the downtime that the user requested. + items: + $ref: '#/components/schemas/DowntimeResponseIncludedItem' + type: array + type: object + DowntimeResponseData: + description: Downtime data. + properties: + attributes: + $ref: '#/components/schemas/DowntimeAttributeResponse' + id: + description: The downtime ID. + example: 00000000-0000-1234-0000-000000000000 + type: string + relationships: + $ref: '#/components/schemas/DowntimeRelationships' + type: + $ref: '#/components/schemas/DowntimeResourceType' + type: object + DowntimeResponseIncludedItem: + description: An object related to a downtime. + oneOf: + - $ref: '#/components/schemas/User' + - $ref: '#/components/schemas/DowntimeMonitorIncludedItem' + type: object + DowntimeStatusEnum: + description: The current status of the downtime + enum: + - active + - canceled + - ended + - scheduled + example: active + type: string + x-enum-varnames: + - ACTIVE + - CANCELED + - ENDED + - SCHEDULED + DowntimeUserType: + default: users + description: User resource type. + enum: + - users + example: users + type: string + x-enum-varnames: + - USERS Event: description: The metadata associated with a request. properties: @@ -16051,6 +16596,254 @@ paths: tags: - Dashboard Lists x-codegen-request-body-name: body + /api/v2/downtime: + get: + description: Get all scheduled downtimes. + operationId: ListDowntimes + parameters: + - description: Only return downtimes that are active when the request is made. + in: query + name: current_only + required: false + schema: + type: boolean + - description: 'Comma separated list of resource paths for related resources + to include in the response. Supported resource + + paths are `created_by` and `monitor`.' + in: query + name: include + required: false + schema: + example: created_by,monitor + type: string + x-unstable: '**Note**: This endpoint is in private beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + responses: + '200': + content: + application/json: + schema: + items: + $ref: '#/components/schemas/DowntimeResponse' + type: array + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_read + summary: Get all downtimes + tags: + - Downtimes + post: + description: Schedule a downtime. + operationId: CreateDowntime + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DowntimeCreateRequest' + description: Schedule a downtime request body. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DowntimeResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_downtime + summary: Schedule a downtime + tags: + - Downtimes + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in private beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/)' + /api/v2/downtime/{downtime_id}: + delete: + description: Cancel a downtime. + operationId: CancelDowntime + parameters: + - description: ID of the downtime to cancel. + in: path + name: downtime_id + required: true + schema: + example: 00000000-0000-1234-0000-000000000000 + type: string + responses: + '204': + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Downtime not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_downtime + summary: Cancel a downtime + tags: + - Downtimes + x-unstable: '**Note**: This endpoint is in private beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/)' + get: + description: Get downtime detail by `downtime_id`. + operationId: GetDowntime + parameters: + - description: ID of the downtime to fetch. + in: path + name: downtime_id + required: true + schema: + example: 00000000-0000-1234-0000-000000000000 + type: string + - description: 'Comma separated list of resource paths for related resources + to include in the response. Supported resource + + paths are `created_by` and `monitor`.' + in: query + name: include + required: false + schema: + example: created_by,monitor + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DowntimeResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_read + summary: Get a downtime + tags: + - Downtimes + x-unstable: '**Note**: This endpoint is in private beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/)' + patch: + description: Update a downtime by `downtime_id`. + operationId: UpdateDowntime + parameters: + - description: ID of the downtime to update. + in: path + name: downtime_id + required: true + schema: + example: 00e000000-0000-1234-0000-000000000000 + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DowntimeEditRequest' + description: Update a downtime request body. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DowntimeResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Downtime not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_downtime + summary: Update a downtime + tags: + - Downtimes + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in private beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/)' /api/v2/events: get: description: 'List endpoint returns events that match an events search query. @@ -24339,6 +25132,18 @@ tags: organization.' name: Dashboard Lists +- description: '**Note**: Downtime V2 is currently in private beta. To request access, + contact [Datadog support](https://docs.datadoghq.com/help/). + + + [Downtiming](https://docs.datadoghq.com/monitors/notify/downtimes) gives + + you greater control over monitor notifications by allowing you to globally exclude + + scopes from alerting. Downtime settings, which can be scheduled with start and + + end times, prevent all alerting related to specified Datadog tags.' + name: Downtimes - description: 'The events service allows you to programmatically post events to the event stream diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index 8234a3babb..6d247f6863 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -57,6 +57,13 @@ dashboard\_lists\_api :members: :show-inheritance: +downtimes\_api +-------------- + +.. automodule:: datadog_api_client.v2.api.downtimes_api + :members: + :show-inheritance: + events\_api ----------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 2289980635..aba92cc989 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -1184,6 +1184,265 @@ detailed\_finding\_type :members: :show-inheritance: +downtime\_attribute\_create\_request +------------------------------------ + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_create_request + :members: + :show-inheritance: + +downtime\_attribute\_edit\_request +---------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_edit_request + :members: + :show-inheritance: + +downtime\_attribute\_monitor\_identifier +---------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_monitor_identifier + :members: + :show-inheritance: + +downtime\_attribute\_monitor\_identifier\_id +-------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_monitor_identifier_id + :members: + :show-inheritance: + +downtime\_attribute\_monitor\_identifier\_tags +---------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_monitor_identifier_tags + :members: + :show-inheritance: + +downtime\_attribute\_notify\_end\_states\_item +---------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_notify_end_states_item + :members: + :show-inheritance: + +downtime\_attribute\_notify\_end\_types\_item +--------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_notify_end_types_item + :members: + :show-inheritance: + +downtime\_attribute\_response +----------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_response + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_create\_request +---------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_create_request + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_current\_downtime\_response +---------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_current_downtime_response + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_edit\_request +-------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_edit_request + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_one\_time\_create\_edit\_request +--------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_one_time_create_edit_request + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_one\_time\_response +-------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_one_time_response + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_recurrence\_create\_edit\_request +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_create_edit_request + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_recurrence\_response +--------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_response + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_recurrences\_create\_request +----------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_create_request + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_recurrences\_edit\_request +--------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_edit_request + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_recurrences\_response +---------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_response + :members: + :show-inheritance: + +downtime\_attribute\_schedule\_response +--------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_attribute_schedule_response + :members: + :show-inheritance: + +downtime\_create\_data +---------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_create_data + :members: + :show-inheritance: + +downtime\_create\_request +------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_create_request + :members: + :show-inheritance: + +downtime\_edit\_data +-------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_edit_data + :members: + :show-inheritance: + +downtime\_edit\_request +----------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_edit_request + :members: + :show-inheritance: + +downtime\_included\_monitor\_type +--------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_included_monitor_type + :members: + :show-inheritance: + +downtime\_monitor\_included\_attributes +--------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_monitor_included_attributes + :members: + :show-inheritance: + +downtime\_monitor\_included\_item +--------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_monitor_included_item + :members: + :show-inheritance: + +downtime\_relationships +----------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_relationships + :members: + :show-inheritance: + +downtime\_relationships\_created\_by +------------------------------------ + +.. automodule:: datadog_api_client.v2.model.downtime_relationships_created_by + :members: + :show-inheritance: + +downtime\_relationships\_created\_by\_data +------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.downtime_relationships_created_by_data + :members: + :show-inheritance: + +downtime\_relationships\_monitor +-------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_relationships_monitor + :members: + :show-inheritance: + +downtime\_relationships\_monitor\_data +-------------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_relationships_monitor_data + :members: + :show-inheritance: + +downtime\_resource\_type +------------------------ + +.. automodule:: datadog_api_client.v2.model.downtime_resource_type + :members: + :show-inheritance: + +downtime\_response +------------------ + +.. automodule:: datadog_api_client.v2.model.downtime_response + :members: + :show-inheritance: + +downtime\_response\_data +------------------------ + +.. automodule:: datadog_api_client.v2.model.downtime_response_data + :members: + :show-inheritance: + +downtime\_response\_included\_item +---------------------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_response_included_item + :members: + :show-inheritance: + +downtime\_status\_enum +---------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_status_enum + :members: + :show-inheritance: + +downtime\_user\_type +-------------------- + +.. automodule:: datadog_api_client.v2.model.downtime_user_type + :members: + :show-inheritance: + event ----- diff --git a/examples/v2/downtimes/CancelDowntime.py b/examples/v2/downtimes/CancelDowntime.py new file mode 100644 index 0000000000..1952f59457 --- /dev/null +++ b/examples/v2/downtimes/CancelDowntime.py @@ -0,0 +1,17 @@ +""" +Cancel a downtime returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.downtimes_api import DowntimesApi + +# there is a valid "downtime_v2" in the system +DOWNTIME_DATA_ID = environ["DOWNTIME_DATA_ID"] + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = DowntimesApi(api_client) + api_instance.cancel_downtime( + downtime_id=DOWNTIME_DATA_ID, + ) diff --git a/examples/v2/downtimes/CreateDowntime.py b/examples/v2/downtimes/CreateDowntime.py new file mode 100644 index 0000000000..2b435f70e4 --- /dev/null +++ b/examples/v2/downtimes/CreateDowntime.py @@ -0,0 +1,61 @@ +""" +Schedule a downtime returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.downtimes_api import DowntimesApi +from datadog_api_client.v2.model.downtime_attribute_create_request import DowntimeAttributeCreateRequest +from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_tags import ( + DowntimeAttributeMonitorIdentifierTags, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_create_edit_request import ( + DowntimeAttributeScheduleRecurrenceCreateEditRequest, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_create_request import ( + DowntimeAttributeScheduleRecurrencesCreateRequest, +) +from datadog_api_client.v2.model.downtime_create_data import DowntimeCreateData +from datadog_api_client.v2.model.downtime_create_request import DowntimeCreateRequest +from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType + +body = DowntimeCreateRequest( + data=DowntimeCreateData( + attributes=DowntimeAttributeCreateRequest( + display_timezone="America/New_York", + message="dark forest", + monitor_identifier=DowntimeAttributeMonitorIdentifierTags( + monitor_tags=[ + "cat:hat", + ], + ), + mute_first_recovery_notification=False, + notify_end_states=[ + None.ALERT, + None.WARN, + ], + notify_end_types=[ + None.CANCELED, + None.EXPIRED, + ], + schedule=DowntimeAttributeScheduleRecurrencesCreateRequest( + recurrences=[ + DowntimeAttributeScheduleRecurrenceCreateEditRequest( + duration="123d", + rrule="FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1", + start="3020-01-02T03:04", + ), + ], + timezone="America/New_York", + ), + scope="test:exampledowntime", + ), + type=DowntimeResourceType.DOWNTIME, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = DowntimesApi(api_client) + response = api_instance.create_downtime(body=body) + + print(response) diff --git a/examples/v2/downtimes/GetDowntime.py b/examples/v2/downtimes/GetDowntime.py new file mode 100644 index 0000000000..d2410b3323 --- /dev/null +++ b/examples/v2/downtimes/GetDowntime.py @@ -0,0 +1,19 @@ +""" +Get a downtime returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.downtimes_api import DowntimesApi + +# there is a valid "downtime_v2" in the system +DOWNTIME_DATA_ID = environ["DOWNTIME_DATA_ID"] + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = DowntimesApi(api_client) + response = api_instance.get_downtime( + downtime_id=DOWNTIME_DATA_ID, + ) + + print(response) diff --git a/examples/v2/downtimes/ListDowntimes.py b/examples/v2/downtimes/ListDowntimes.py new file mode 100644 index 0000000000..cb5b87a494 --- /dev/null +++ b/examples/v2/downtimes/ListDowntimes.py @@ -0,0 +1,13 @@ +""" +Get all downtimes returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.downtimes_api import DowntimesApi + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = DowntimesApi(api_client) + response = api_instance.list_downtimes() + + print(response) diff --git a/examples/v2/downtimes/UpdateDowntime.py b/examples/v2/downtimes/UpdateDowntime.py new file mode 100644 index 0000000000..37fa83217f --- /dev/null +++ b/examples/v2/downtimes/UpdateDowntime.py @@ -0,0 +1,31 @@ +""" +Update a downtime returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.downtimes_api import DowntimesApi +from datadog_api_client.v2.model.downtime_attribute_edit_request import DowntimeAttributeEditRequest +from datadog_api_client.v2.model.downtime_edit_data import DowntimeEditData +from datadog_api_client.v2.model.downtime_edit_request import DowntimeEditRequest +from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType + +# there is a valid "downtime_v2" in the system +DOWNTIME_DATA_ID = environ["DOWNTIME_DATA_ID"] + +body = DowntimeEditRequest( + data=DowntimeEditData( + attributes=DowntimeAttributeEditRequest( + message="light speed", + ), + id=DOWNTIME_DATA_ID, + type=DowntimeResourceType.DOWNTIME, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = DowntimesApi(api_client) + response = api_instance.update_downtime(downtime_id=DOWNTIME_DATA_ID, body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 93afa0b436..fc5ec7780c 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -221,6 +221,10 @@ def __init__( # Keep track of unstable operations self.unstable_operations = _UnstableOperations( { + "v2.cancel_downtime": False, + "v2.create_downtime": False, + "v2.get_downtime": False, + "v2.update_downtime": False, "v2.list_events": False, "v2.search_events": False, "v2.create_incident": False, diff --git a/src/datadog_api_client/v2/api/downtimes_api.py b/src/datadog_api_client/v2/api/downtimes_api.py new file mode 100644 index 0000000000..4397a1d575 --- /dev/null +++ b/src/datadog_api_client/v2/api/downtimes_api.py @@ -0,0 +1,271 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Any, Dict, List, Union + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.model_utils import ( + UnsetType, + unset, +) +from datadog_api_client.v2.model.downtime_response import DowntimeResponse +from datadog_api_client.v2.model.downtime_create_request import DowntimeCreateRequest +from datadog_api_client.v2.model.downtime_edit_request import DowntimeEditRequest + + +class DowntimesApi: + """ + **Note** : Downtime V2 is currently in private beta. To request access, contact `Datadog support `_. + + `Downtiming `_ gives + you greater control over monitor notifications by allowing you to globally exclude + scopes from alerting. Downtime settings, which can be scheduled with start and + end times, prevent all alerting related to specified Datadog tags. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._cancel_downtime_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/downtime/{downtime_id}", + "operation_id": "cancel_downtime", + "http_method": "DELETE", + "version": "v2", + "servers": None, + }, + params_map={ + "downtime_id": { + "required": True, + "openapi_types": (str,), + "attribute": "downtime_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["*/*"], + "content_type": [], + }, + api_client=api_client, + ) + + self._create_downtime_endpoint = _Endpoint( + settings={ + "response_type": (DowntimeResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/downtime", + "operation_id": "create_downtime", + "http_method": "POST", + "version": "v2", + "servers": None, + }, + params_map={ + "body": { + "required": True, + "openapi_types": (DowntimeCreateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + self._get_downtime_endpoint = _Endpoint( + settings={ + "response_type": (DowntimeResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/downtime/{downtime_id}", + "operation_id": "get_downtime", + "http_method": "GET", + "version": "v2", + "servers": None, + }, + params_map={ + "downtime_id": { + "required": True, + "openapi_types": (str,), + "attribute": "downtime_id", + "location": "path", + }, + "include": { + "openapi_types": (str,), + "attribute": "include", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json"], + "content_type": [], + }, + api_client=api_client, + ) + + self._list_downtimes_endpoint = _Endpoint( + settings={ + "response_type": ([DowntimeResponse],), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/downtime", + "operation_id": "list_downtimes", + "http_method": "GET", + "version": "v2", + "servers": None, + }, + params_map={ + "current_only": { + "openapi_types": (bool,), + "attribute": "current_only", + "location": "query", + }, + "include": { + "openapi_types": (str,), + "attribute": "include", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json"], + "content_type": [], + }, + api_client=api_client, + ) + + self._update_downtime_endpoint = _Endpoint( + settings={ + "response_type": (DowntimeResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/downtime/{downtime_id}", + "operation_id": "update_downtime", + "http_method": "PATCH", + "version": "v2", + "servers": None, + }, + params_map={ + "downtime_id": { + "required": True, + "openapi_types": (str,), + "attribute": "downtime_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (DowntimeEditRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + def cancel_downtime( + self, + downtime_id: str, + ) -> None: + """Cancel a downtime. + + Cancel a downtime. + + :param downtime_id: ID of the downtime to cancel. + :type downtime_id: str + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["downtime_id"] = downtime_id + + return self._cancel_downtime_endpoint.call_with_http_info(**kwargs) + + def create_downtime( + self, + body: DowntimeCreateRequest, + ) -> DowntimeResponse: + """Schedule a downtime. + + Schedule a downtime. + + :param body: Schedule a downtime request body. + :type body: DowntimeCreateRequest + :rtype: DowntimeResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._create_downtime_endpoint.call_with_http_info(**kwargs) + + def get_downtime( + self, + downtime_id: str, + *, + include: Union[str, UnsetType] = unset, + ) -> DowntimeResponse: + """Get a downtime. + + Get downtime detail by ``downtime_id``. + + :param downtime_id: ID of the downtime to fetch. + :type downtime_id: str + :param include: Comma separated list of resource paths for related resources to include in the response. Supported resource + paths are ``created_by`` and ``monitor``. + :type include: str, optional + :rtype: DowntimeResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["downtime_id"] = downtime_id + + if include is not unset: + kwargs["include"] = include + + return self._get_downtime_endpoint.call_with_http_info(**kwargs) + + def list_downtimes( + self, + *, + current_only: Union[bool, UnsetType] = unset, + include: Union[str, UnsetType] = unset, + ) -> List[DowntimeResponse]: + """Get all downtimes. + + Get all scheduled downtimes. + + :param current_only: Only return downtimes that are active when the request is made. + :type current_only: bool, optional + :param include: Comma separated list of resource paths for related resources to include in the response. Supported resource + paths are ``created_by`` and ``monitor``. + :type include: str, optional + :rtype: [DowntimeResponse] + """ + kwargs: Dict[str, Any] = {} + if current_only is not unset: + kwargs["current_only"] = current_only + + if include is not unset: + kwargs["include"] = include + + return self._list_downtimes_endpoint.call_with_http_info(**kwargs) + + def update_downtime( + self, + downtime_id: str, + body: DowntimeEditRequest, + ) -> DowntimeResponse: + """Update a downtime. + + Update a downtime by ``downtime_id``. + + :param downtime_id: ID of the downtime to update. + :type downtime_id: str + :param body: Update a downtime request body. + :type body: DowntimeEditRequest + :rtype: DowntimeResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["downtime_id"] = downtime_id + + kwargs["body"] = body + + return self._update_downtime_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index f420992825..8a984e7108 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -6,6 +6,7 @@ from datadog_api_client.v2.api.cloudflare_integration_api import CloudflareIntegrationApi from datadog_api_client.v2.api.confluent_cloud_api import ConfluentCloudApi from datadog_api_client.v2.api.dashboard_lists_api import DashboardListsApi +from datadog_api_client.v2.api.downtimes_api import DowntimesApi from datadog_api_client.v2.api.events_api import EventsApi from datadog_api_client.v2.api.fastly_integration_api import FastlyIntegrationApi from datadog_api_client.v2.api.ip_allowlist_api import IPAllowlistApi diff --git a/src/datadog_api_client/v2/model/downtime_attribute_create_request.py b/src/datadog_api_client/v2/model/downtime_attribute_create_request.py new file mode 100644 index 0000000000..156350e1eb --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_create_request.py @@ -0,0 +1,131 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier import DowntimeAttributeMonitorIdentifier + from datadog_api_client.v2.model.downtime_attribute_schedule_create_request import ( + DowntimeAttributeScheduleCreateRequest, + ) + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_id import ( + DowntimeAttributeMonitorIdentifierId, + ) + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_tags import ( + DowntimeAttributeMonitorIdentifierTags, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_create_request import ( + DowntimeAttributeScheduleRecurrencesCreateRequest, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_one_time_create_edit_request import ( + DowntimeAttributeScheduleOneTimeCreateEditRequest, + ) + + +class DowntimeAttributeCreateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier import DowntimeAttributeMonitorIdentifier + from datadog_api_client.v2.model.downtime_attribute_schedule_create_request import ( + DowntimeAttributeScheduleCreateRequest, + ) + + return { + "display_timezone": (str,), + "message": (str,), + "monitor_identifier": (DowntimeAttributeMonitorIdentifier,), + "mute_first_recovery_notification": (bool,), + "notify_end_states": ([str],), + "notify_end_types": ([str],), + "schedule": (DowntimeAttributeScheduleCreateRequest,), + "scope": (str,), + } + + attribute_map = { + "display_timezone": "display_timezone", + "message": "message", + "monitor_identifier": "monitor_identifier", + "mute_first_recovery_notification": "mute_first_recovery_notification", + "notify_end_states": "notify_end_states", + "notify_end_types": "notify_end_types", + "schedule": "schedule", + "scope": "scope", + } + + def __init__( + self_, + monitor_identifier: Union[ + DowntimeAttributeMonitorIdentifier, + DowntimeAttributeMonitorIdentifierId, + DowntimeAttributeMonitorIdentifierTags, + ], + scope: str, + display_timezone: Union[str, UnsetType] = unset, + message: Union[str, UnsetType] = unset, + mute_first_recovery_notification: Union[bool, UnsetType] = unset, + notify_end_states: Union[List[str], UnsetType] = unset, + notify_end_types: Union[List[str], UnsetType] = unset, + schedule: Union[ + DowntimeAttributeScheduleCreateRequest, + DowntimeAttributeScheduleRecurrencesCreateRequest, + DowntimeAttributeScheduleOneTimeCreateEditRequest, + UnsetType, + ] = unset, + **kwargs, + ): + """ + Downtime details. + + :param display_timezone: The timezone in which to display the downtime's start and end times in Datadog applications. This is not used + as an offset for scheduling. + :type display_timezone: str, optional + + :param message: A message to include with notifications for this downtime. Email notifications can be sent to specific users + by using the same ``@username`` notation as events. + :type message: str, optional + + :param monitor_identifier: Monitor identifier for the downtime + :type monitor_identifier: DowntimeAttributeMonitorIdentifier + + :param mute_first_recovery_notification: If the first recovery notification during a downtime should be muted. + :type mute_first_recovery_notification: bool, optional + + :param notify_end_states: States that will trigger a monitor notification when the ``notify_end_types`` action occurs. + :type notify_end_states: [str], optional + + :param notify_end_types: Actions that will trigger a monitor notification if the downtime is in the ``notify_end_types`` state. + :type notify_end_types: [str], optional + + :param schedule: Schedule for the downtime. + :type schedule: DowntimeAttributeScheduleCreateRequest, optional + + :param scope: The scope to which the downtime applies. Must be in + `simple grammar syntax `_. + :type scope: str + """ + if display_timezone is not unset: + kwargs["display_timezone"] = display_timezone + if message is not unset: + kwargs["message"] = message + if mute_first_recovery_notification is not unset: + kwargs["mute_first_recovery_notification"] = mute_first_recovery_notification + if notify_end_states is not unset: + kwargs["notify_end_states"] = notify_end_states + if notify_end_types is not unset: + kwargs["notify_end_types"] = notify_end_types + if schedule is not unset: + kwargs["schedule"] = schedule + super().__init__(kwargs) + + self_.monitor_identifier = monitor_identifier + self_.scope = scope diff --git a/src/datadog_api_client/v2/model/downtime_attribute_edit_request.py b/src/datadog_api_client/v2/model/downtime_attribute_edit_request.py new file mode 100644 index 0000000000..0abe6f14d6 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_edit_request.py @@ -0,0 +1,133 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier import DowntimeAttributeMonitorIdentifier + from datadog_api_client.v2.model.downtime_attribute_schedule_edit_request import ( + DowntimeAttributeScheduleEditRequest, + ) + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_id import ( + DowntimeAttributeMonitorIdentifierId, + ) + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_tags import ( + DowntimeAttributeMonitorIdentifierTags, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_edit_request import ( + DowntimeAttributeScheduleRecurrencesEditRequest, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_one_time_create_edit_request import ( + DowntimeAttributeScheduleOneTimeCreateEditRequest, + ) + + +class DowntimeAttributeEditRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier import DowntimeAttributeMonitorIdentifier + from datadog_api_client.v2.model.downtime_attribute_schedule_edit_request import ( + DowntimeAttributeScheduleEditRequest, + ) + + return { + "display_timezone": (str,), + "message": (str,), + "monitor_identifier": (DowntimeAttributeMonitorIdentifier,), + "mute_first_recovery_notification": (bool,), + "notify_end_states": ([str],), + "notify_end_types": ([str],), + "schedule": (DowntimeAttributeScheduleEditRequest,), + "scope": (str,), + } + + attribute_map = { + "display_timezone": "display_timezone", + "message": "message", + "monitor_identifier": "monitor_identifier", + "mute_first_recovery_notification": "mute_first_recovery_notification", + "notify_end_states": "notify_end_states", + "notify_end_types": "notify_end_types", + "schedule": "schedule", + "scope": "scope", + } + + def __init__( + self_, + display_timezone: Union[str, UnsetType] = unset, + message: Union[str, UnsetType] = unset, + monitor_identifier: Union[ + DowntimeAttributeMonitorIdentifier, + DowntimeAttributeMonitorIdentifierId, + DowntimeAttributeMonitorIdentifierTags, + UnsetType, + ] = unset, + mute_first_recovery_notification: Union[bool, UnsetType] = unset, + notify_end_states: Union[List[str], UnsetType] = unset, + notify_end_types: Union[List[str], UnsetType] = unset, + schedule: Union[ + DowntimeAttributeScheduleEditRequest, + DowntimeAttributeScheduleRecurrencesEditRequest, + DowntimeAttributeScheduleOneTimeCreateEditRequest, + UnsetType, + ] = unset, + scope: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Attributes of the downtime to update. + + :param display_timezone: The timezone in which to display the downtime's start and end times in Datadog applications. This is not used + as an offset for scheduling. + :type display_timezone: str, optional + + :param message: A message to include with notifications for this downtime. Email notifications can be sent to specific users + by using the same ``@username`` notation as events. + :type message: str, optional + + :param monitor_identifier: Monitor identifier for the downtime + :type monitor_identifier: DowntimeAttributeMonitorIdentifier, optional + + :param mute_first_recovery_notification: If the first recovery notification during a downtime should be muted. + :type mute_first_recovery_notification: bool, optional + + :param notify_end_states: States that will trigger a monitor notification when the ``notify_end_types`` action occurs. + :type notify_end_states: [str], optional + + :param notify_end_types: Actions that will trigger a monitor notification if the downtime is in the ``notify_end_types`` state. + :type notify_end_types: [str], optional + + :param schedule: Schedule for the downtime. + :type schedule: DowntimeAttributeScheduleEditRequest, optional + + :param scope: The scope to which the downtime applies. Must be in + `simple grammar syntax `_. + :type scope: str, optional + """ + if display_timezone is not unset: + kwargs["display_timezone"] = display_timezone + if message is not unset: + kwargs["message"] = message + if monitor_identifier is not unset: + kwargs["monitor_identifier"] = monitor_identifier + if mute_first_recovery_notification is not unset: + kwargs["mute_first_recovery_notification"] = mute_first_recovery_notification + if notify_end_states is not unset: + kwargs["notify_end_states"] = notify_end_states + if notify_end_types is not unset: + kwargs["notify_end_types"] = notify_end_types + if schedule is not unset: + kwargs["schedule"] = schedule + if scope is not unset: + kwargs["scope"] = scope + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier.py b/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier.py new file mode 100644 index 0000000000..5e952350f4 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier.py @@ -0,0 +1,49 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class DowntimeAttributeMonitorIdentifier(ModelComposed): + def __init__(self, **kwargs): + """ + Monitor identifier for the downtime + + :param monitor_id: ID of the monitor to prevent notifications. + :type monitor_id: int + + :param monitor_tags: A list of monitor tags. For example, tags that are applied directly to monitors, + not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. + The resulting downtime applies to monitors that match ALL provided monitor tags. + :type monitor_tags: [str] + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_id import ( + DowntimeAttributeMonitorIdentifierId, + ) + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_tags import ( + DowntimeAttributeMonitorIdentifierTags, + ) + + return { + "oneOf": [ + DowntimeAttributeMonitorIdentifierId, + DowntimeAttributeMonitorIdentifierTags, + ], + } diff --git a/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier_id.py b/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier_id.py new file mode 100644 index 0000000000..74d7bd46e1 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier_id.py @@ -0,0 +1,33 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class DowntimeAttributeMonitorIdentifierId(ModelNormal): + @cached_property + def openapi_types(_): + return { + "monitor_id": (int,), + } + + attribute_map = { + "monitor_id": "monitor_id", + } + + def __init__(self_, monitor_id: int, **kwargs): + """ + Object of the monitor identifier. + + :param monitor_id: ID of the monitor to prevent notifications. + :type monitor_id: int + """ + super().__init__(kwargs) + + self_.monitor_id = monitor_id diff --git a/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier_tags.py b/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier_tags.py new file mode 100644 index 0000000000..288347a513 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_monitor_identifier_tags.py @@ -0,0 +1,36 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class DowntimeAttributeMonitorIdentifierTags(ModelNormal): + @cached_property + def openapi_types(_): + return { + "monitor_tags": ([str],), + } + + attribute_map = { + "monitor_tags": "monitor_tags", + } + + def __init__(self_, monitor_tags: List[str], **kwargs): + """ + Object of the monitor tags. + + :param monitor_tags: A list of monitor tags. For example, tags that are applied directly to monitors, + not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. + The resulting downtime applies to monitors that match ALL provided monitor tags. + :type monitor_tags: [str] + """ + super().__init__(kwargs) + + self_.monitor_tags = monitor_tags diff --git a/src/datadog_api_client/v2/model/downtime_attribute_notify_end_states_item.py b/src/datadog_api_client/v2/model/downtime_attribute_notify_end_states_item.py new file mode 100644 index 0000000000..62a7876e13 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_notify_end_states_item.py @@ -0,0 +1,41 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class DowntimeAttributeNotifyEndStatesItem(ModelSimple): + """ + State that will trigger a monitor notification when the `notify_end_types` action occurs. + + :param value: Must be one of ["alert", "no data", "warn"]. + :type value: str + """ + + allowed_values = { + "alert", + "no data", + "warn", + } + ALERT: ClassVar["DowntimeAttributeNotifyEndStatesItem"] + NO_DATA: ClassVar["DowntimeAttributeNotifyEndStatesItem"] + WARN: ClassVar["DowntimeAttributeNotifyEndStatesItem"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DowntimeAttributeNotifyEndStatesItem.ALERT = DowntimeAttributeNotifyEndStatesItem("alert") +DowntimeAttributeNotifyEndStatesItem.NO_DATA = DowntimeAttributeNotifyEndStatesItem("no data") +DowntimeAttributeNotifyEndStatesItem.WARN = DowntimeAttributeNotifyEndStatesItem("warn") diff --git a/src/datadog_api_client/v2/model/downtime_attribute_notify_end_types_item.py b/src/datadog_api_client/v2/model/downtime_attribute_notify_end_types_item.py new file mode 100644 index 0000000000..cdd4f2736e --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_notify_end_types_item.py @@ -0,0 +1,38 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class DowntimeAttributeNotifyEndTypesItem(ModelSimple): + """ + Action that will trigger a monitor notification if the downtime is in the `notify_end_types` state. + + :param value: Must be one of ["canceled", "expired"]. + :type value: str + """ + + allowed_values = { + "canceled", + "expired", + } + CANCELED: ClassVar["DowntimeAttributeNotifyEndTypesItem"] + EXPIRED: ClassVar["DowntimeAttributeNotifyEndTypesItem"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DowntimeAttributeNotifyEndTypesItem.CANCELED = DowntimeAttributeNotifyEndTypesItem("canceled") +DowntimeAttributeNotifyEndTypesItem.EXPIRED = DowntimeAttributeNotifyEndTypesItem("expired") diff --git a/src/datadog_api_client/v2/model/downtime_attribute_response.py b/src/datadog_api_client/v2/model/downtime_attribute_response.py new file mode 100644 index 0000000000..58392d762b --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_response.py @@ -0,0 +1,158 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier import DowntimeAttributeMonitorIdentifier + from datadog_api_client.v2.model.downtime_attribute_schedule_response import DowntimeAttributeScheduleResponse + from datadog_api_client.v2.model.downtime_status_enum import DowntimeStatusEnum + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_id import ( + DowntimeAttributeMonitorIdentifierId, + ) + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_tags import ( + DowntimeAttributeMonitorIdentifierTags, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_response import ( + DowntimeAttributeScheduleRecurrencesResponse, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_one_time_response import ( + DowntimeAttributeScheduleOneTimeResponse, + ) + + +class DowntimeAttributeResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_monitor_identifier import DowntimeAttributeMonitorIdentifier + from datadog_api_client.v2.model.downtime_attribute_schedule_response import DowntimeAttributeScheduleResponse + from datadog_api_client.v2.model.downtime_status_enum import DowntimeStatusEnum + + return { + "created_at": (datetime,), + "display_timezone": (str,), + "message": (str,), + "modified_at": (datetime,), + "monitor_identifier": (DowntimeAttributeMonitorIdentifier,), + "mute_first_recovery_notification": (bool,), + "notify_end_states": ([str],), + "notify_end_types": ([str],), + "schedule": (DowntimeAttributeScheduleResponse,), + "scope": (str,), + "status": (DowntimeStatusEnum,), + } + + attribute_map = { + "created_at": "created_at", + "display_timezone": "display_timezone", + "message": "message", + "modified_at": "modified_at", + "monitor_identifier": "monitor_identifier", + "mute_first_recovery_notification": "mute_first_recovery_notification", + "notify_end_states": "notify_end_states", + "notify_end_types": "notify_end_types", + "schedule": "schedule", + "scope": "scope", + "status": "status", + } + + def __init__( + self_, + created_at: Union[datetime, UnsetType] = unset, + display_timezone: Union[str, UnsetType] = unset, + message: Union[str, UnsetType] = unset, + modified_at: Union[datetime, UnsetType] = unset, + monitor_identifier: Union[ + DowntimeAttributeMonitorIdentifier, + DowntimeAttributeMonitorIdentifierId, + DowntimeAttributeMonitorIdentifierTags, + UnsetType, + ] = unset, + mute_first_recovery_notification: Union[bool, UnsetType] = unset, + notify_end_states: Union[List[str], UnsetType] = unset, + notify_end_types: Union[List[str], UnsetType] = unset, + schedule: Union[ + DowntimeAttributeScheduleResponse, + DowntimeAttributeScheduleRecurrencesResponse, + DowntimeAttributeScheduleOneTimeResponse, + UnsetType, + ] = unset, + scope: Union[str, UnsetType] = unset, + status: Union[DowntimeStatusEnum, UnsetType] = unset, + **kwargs, + ): + """ + Downtime details. + + :param created_at: Creation time of the downtime. + :type created_at: datetime, optional + + :param display_timezone: The timezone in which to display the downtime's start and end times in Datadog applications. This is not used + as an offset for scheduling. + :type display_timezone: str, optional + + :param message: A message to include with notifications for this downtime. Email notifications can be sent to specific users + by using the same ``@username`` notation as events. + :type message: str, optional + + :param modified_at: Time that the downtime was last modified. + :type modified_at: datetime, optional + + :param monitor_identifier: Monitor identifier for the downtime + :type monitor_identifier: DowntimeAttributeMonitorIdentifier, optional + + :param mute_first_recovery_notification: If the first recovery notification during a downtime should be muted. + :type mute_first_recovery_notification: bool, optional + + :param notify_end_states: States that will trigger a monitor notification when the ``notify_end_types`` action occurs. + :type notify_end_states: [str], optional + + :param notify_end_types: Actions that will trigger a monitor notification if the downtime is in the ``notify_end_types`` state. + :type notify_end_types: [str], optional + + :param schedule: The schedule that defines when the monitor starts, stops, and recurs. There are two types of schedules: + one-time and recurring. Recurring schedules may have up to five RRULE-based recurrences. If no schedules is + provided, the downtime will begin immediately and never end. + :type schedule: DowntimeAttributeScheduleResponse, optional + + :param scope: The scope to which the downtime applies. Must be in + `simple grammar syntax `_. + :type scope: str, optional + + :param status: The current status of the downtime + :type status: DowntimeStatusEnum, optional + """ + if created_at is not unset: + kwargs["created_at"] = created_at + if display_timezone is not unset: + kwargs["display_timezone"] = display_timezone + if message is not unset: + kwargs["message"] = message + if modified_at is not unset: + kwargs["modified_at"] = modified_at + if monitor_identifier is not unset: + kwargs["monitor_identifier"] = monitor_identifier + if mute_first_recovery_notification is not unset: + kwargs["mute_first_recovery_notification"] = mute_first_recovery_notification + if notify_end_states is not unset: + kwargs["notify_end_states"] = notify_end_states + if notify_end_types is not unset: + kwargs["notify_end_types"] = notify_end_types + if schedule is not unset: + kwargs["schedule"] = schedule + if scope is not unset: + kwargs["scope"] = scope + if status is not unset: + kwargs["status"] = status + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_create_request.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_create_request.py new file mode 100644 index 0000000000..f32dd0b45b --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_create_request.py @@ -0,0 +1,55 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class DowntimeAttributeScheduleCreateRequest(ModelComposed): + def __init__(self, **kwargs): + """ + Schedule for the downtime. + + :param recurrences: A list of downtime recurrences. + :type recurrences: [DowntimeAttributeScheduleRecurrenceCreateEditRequest] + + :param timezone: The timezone in which to schedule the downtime. + :type timezone: str, optional + + :param end: ISO-8601 Datetime to end the downtime. Must include a UTC offset of zero. If not provided, the + downtime starts the moment it is created. + :type end: datetime, optional + + :param start: ISO-8601 Datetime to start the downtime. Must include a UTC offset of zero. If not provided, the + downtime starts the moment it is created. + :type start: datetime, optional + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_create_request import ( + DowntimeAttributeScheduleRecurrencesCreateRequest, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_one_time_create_edit_request import ( + DowntimeAttributeScheduleOneTimeCreateEditRequest, + ) + + return { + "oneOf": [ + DowntimeAttributeScheduleRecurrencesCreateRequest, + DowntimeAttributeScheduleOneTimeCreateEditRequest, + ], + } diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_current_downtime_response.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_current_downtime_response.py new file mode 100644 index 0000000000..442873d88a --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_current_downtime_response.py @@ -0,0 +1,46 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + unset, + UnsetType, +) + + +class DowntimeAttributeScheduleCurrentDowntimeResponse(ModelNormal): + @cached_property + def openapi_types(_): + return { + "end": (datetime,), + "start": (datetime,), + } + + attribute_map = { + "end": "end", + "start": "start", + } + + def __init__(self_, end: Union[datetime, UnsetType] = unset, start: Union[datetime, UnsetType] = unset, **kwargs): + """ + The most recent actual start and end dates for a recurring downtime. For a canceled downtime, + this is the previously occurring downtime. For active downtimes, this is the ongoing downtime, and for scheduled + downtimes it is the upcoming downtime. + + :param end: The end of the current downtime. + :type end: datetime, optional + + :param start: The start of the current downtime. + :type start: datetime, optional + """ + if end is not unset: + kwargs["end"] = end + if start is not unset: + kwargs["start"] = start + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_edit_request.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_edit_request.py new file mode 100644 index 0000000000..be8ee2cfde --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_edit_request.py @@ -0,0 +1,55 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class DowntimeAttributeScheduleEditRequest(ModelComposed): + def __init__(self, **kwargs): + """ + Schedule for the downtime. + + :param recurrences: A list of downtime recurrences. + :type recurrences: [DowntimeAttributeScheduleRecurrenceCreateEditRequest], optional + + :param timezone: The timezone in which to schedule the downtime. + :type timezone: str, optional + + :param end: ISO-8601 Datetime to end the downtime. Must include a UTC offset of zero. If not provided, the + downtime starts the moment it is created. + :type end: datetime, optional + + :param start: ISO-8601 Datetime to start the downtime. Must include a UTC offset of zero. If not provided, the + downtime starts the moment it is created. + :type start: datetime, optional + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_edit_request import ( + DowntimeAttributeScheduleRecurrencesEditRequest, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_one_time_create_edit_request import ( + DowntimeAttributeScheduleOneTimeCreateEditRequest, + ) + + return { + "oneOf": [ + DowntimeAttributeScheduleRecurrencesEditRequest, + DowntimeAttributeScheduleOneTimeCreateEditRequest, + ], + } diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_one_time_create_edit_request.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_one_time_create_edit_request.py new file mode 100644 index 0000000000..5bdd8bd3fc --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_one_time_create_edit_request.py @@ -0,0 +1,46 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + unset, + UnsetType, +) + + +class DowntimeAttributeScheduleOneTimeCreateEditRequest(ModelNormal): + @cached_property + def openapi_types(_): + return { + "end": (datetime,), + "start": (datetime,), + } + + attribute_map = { + "end": "end", + "start": "start", + } + + def __init__(self_, end: Union[datetime, UnsetType] = unset, start: Union[datetime, UnsetType] = unset, **kwargs): + """ + A one-time downtime definition. + + :param end: ISO-8601 Datetime to end the downtime. Must include a UTC offset of zero. If not provided, the + downtime starts the moment it is created. + :type end: datetime, optional + + :param start: ISO-8601 Datetime to start the downtime. Must include a UTC offset of zero. If not provided, the + downtime starts the moment it is created. + :type start: datetime, optional + """ + if end is not unset: + kwargs["end"] = end + if start is not unset: + kwargs["start"] = start + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_one_time_response.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_one_time_response.py new file mode 100644 index 0000000000..1013d69bf4 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_one_time_response.py @@ -0,0 +1,44 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + unset, + UnsetType, +) + + +class DowntimeAttributeScheduleOneTimeResponse(ModelNormal): + @cached_property + def openapi_types(_): + return { + "end": (datetime,), + "start": (datetime,), + } + + attribute_map = { + "end": "end", + "start": "start", + } + + def __init__(self_, end: Union[datetime, UnsetType] = unset, start: Union[datetime, UnsetType] = unset, **kwargs): + """ + A one-time downtime definition. + + :param end: ISO-8601 Datetime to end the downtime. + :type end: datetime, optional + + :param start: ISO-8601 Datetime to start the downtime. + :type start: datetime, optional + """ + if end is not unset: + kwargs["end"] = end + if start is not unset: + kwargs["start"] = start + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrence_create_edit_request.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrence_create_edit_request.py new file mode 100644 index 0000000000..b43966f070 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrence_create_edit_request.py @@ -0,0 +1,55 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class DowntimeAttributeScheduleRecurrenceCreateEditRequest(ModelNormal): + @cached_property + def openapi_types(_): + return { + "duration": (str,), + "rrule": (str,), + "start": (str,), + } + + attribute_map = { + "duration": "duration", + "rrule": "rrule", + "start": "start", + } + + def __init__(self_, duration: str, rrule: str, start: Union[str, UnsetType] = unset, **kwargs): + """ + An object defining the recurrence of the downtime. + + :param duration: The length of the downtime. Must begin with an integer and end with one of 'm', 'h', d', or 'w'. + :type duration: str + + :param rrule: The ``RRULE`` standard for defining recurring events. + For example, to have a recurring event on the first day of each month, set the type to ``rrule`` and set the ``FREQ`` to ``MONTHLY`` and ``BYMONTHDAY`` to ``1``. + Most common ``rrule`` options from the `iCalendar Spec `_ are supported. + + **Note** : Attributes specifying the duration in ``RRULE`` are not supported (for example, ``DTSTART`` , ``DTEND`` , ``DURATION`` ). + More examples available in this `downtime guide `_. + :type rrule: str + + :param start: ISO-8601 Datetime to start the downtime. Must not include a UTC offset. If not provided, the + downtime starts the moment it is created. + :type start: str, optional + """ + if start is not unset: + kwargs["start"] = start + super().__init__(kwargs) + + self_.duration = duration + self_.rrule = rrule diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrence_response.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrence_response.py new file mode 100644 index 0000000000..99e5e03df6 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrence_response.py @@ -0,0 +1,62 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class DowntimeAttributeScheduleRecurrenceResponse(ModelNormal): + @cached_property + def openapi_types(_): + return { + "duration": (str,), + "rrule": (str,), + "start": (str,), + } + + attribute_map = { + "duration": "duration", + "rrule": "rrule", + "start": "start", + } + + def __init__( + self_, + duration: Union[str, UnsetType] = unset, + rrule: Union[str, UnsetType] = unset, + start: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + An RRULE-based recurring downtime. + + :param duration: The length of the downtime. Must begin with an integer and end with one of 'm', 'h', d', or 'w'. + :type duration: str, optional + + :param rrule: The ``RRULE`` standard for defining recurring events. + For example, to have a recurring event on the first day of each month, set the type to ``rrule`` and set the ``FREQ`` to ``MONTHLY`` and ``BYMONTHDAY`` to ``1``. + Most common ``rrule`` options from the `iCalendar Spec `_ are supported. + + **Note** : Attributes specifying the duration in ``RRULE`` are not supported (for example, ``DTSTART`` , ``DTEND`` , ``DURATION`` ). + More examples available in this `downtime guide `_. + :type rrule: str, optional + + :param start: ISO-8601 Datetime to start the downtime. Must not include a UTC offset. If not provided, the + downtime starts the moment it is created. + :type start: str, optional + """ + if duration is not unset: + kwargs["duration"] = duration + if rrule is not unset: + kwargs["rrule"] = rrule + if start is not unset: + kwargs["start"] = start + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_create_request.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_create_request.py new file mode 100644 index 0000000000..145fc3ea5f --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_create_request.py @@ -0,0 +1,58 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_create_edit_request import ( + DowntimeAttributeScheduleRecurrenceCreateEditRequest, + ) + + +class DowntimeAttributeScheduleRecurrencesCreateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_create_edit_request import ( + DowntimeAttributeScheduleRecurrenceCreateEditRequest, + ) + + return { + "recurrences": ([DowntimeAttributeScheduleRecurrenceCreateEditRequest],), + "timezone": (str,), + } + + attribute_map = { + "recurrences": "recurrences", + "timezone": "timezone", + } + + def __init__( + self_, + recurrences: List[DowntimeAttributeScheduleRecurrenceCreateEditRequest], + timezone: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + A recurring downtime schedule definition. + + :param recurrences: A list of downtime recurrences. + :type recurrences: [DowntimeAttributeScheduleRecurrenceCreateEditRequest] + + :param timezone: The timezone in which to schedule the downtime. + :type timezone: str, optional + """ + if timezone is not unset: + kwargs["timezone"] = timezone + super().__init__(kwargs) + + self_.recurrences = recurrences diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_edit_request.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_edit_request.py new file mode 100644 index 0000000000..b79b4fa56e --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_edit_request.py @@ -0,0 +1,58 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_create_edit_request import ( + DowntimeAttributeScheduleRecurrenceCreateEditRequest, + ) + + +class DowntimeAttributeScheduleRecurrencesEditRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_create_edit_request import ( + DowntimeAttributeScheduleRecurrenceCreateEditRequest, + ) + + return { + "recurrences": ([DowntimeAttributeScheduleRecurrenceCreateEditRequest],), + "timezone": (str,), + } + + attribute_map = { + "recurrences": "recurrences", + "timezone": "timezone", + } + + def __init__( + self_, + recurrences: Union[List[DowntimeAttributeScheduleRecurrenceCreateEditRequest], UnsetType] = unset, + timezone: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + A recurring downtime schedule definition. + + :param recurrences: A list of downtime recurrences. + :type recurrences: [DowntimeAttributeScheduleRecurrenceCreateEditRequest], optional + + :param timezone: The timezone in which to schedule the downtime. + :type timezone: str, optional + """ + if recurrences is not unset: + kwargs["recurrences"] = recurrences + if timezone is not unset: + kwargs["timezone"] = timezone + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_response.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_response.py new file mode 100644 index 0000000000..638544d10c --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_recurrences_response.py @@ -0,0 +1,82 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_schedule_current_downtime_response import ( + DowntimeAttributeScheduleCurrentDowntimeResponse, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_response import ( + DowntimeAttributeScheduleRecurrenceResponse, + ) + + +class DowntimeAttributeScheduleRecurrencesResponse(ModelNormal): + validations = { + "recurrences": { + "max_items": 5, + "min_items": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_schedule_current_downtime_response import ( + DowntimeAttributeScheduleCurrentDowntimeResponse, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_response import ( + DowntimeAttributeScheduleRecurrenceResponse, + ) + + return { + "current_downtime": (DowntimeAttributeScheduleCurrentDowntimeResponse,), + "recurrences": ([DowntimeAttributeScheduleRecurrenceResponse],), + "timezone": (str,), + } + + attribute_map = { + "current_downtime": "current_downtime", + "recurrences": "recurrences", + "timezone": "timezone", + } + + def __init__( + self_, + current_downtime: Union[DowntimeAttributeScheduleCurrentDowntimeResponse, UnsetType] = unset, + recurrences: Union[List[DowntimeAttributeScheduleRecurrenceResponse], UnsetType] = unset, + timezone: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + A recurring downtime schedule definition. + + :param current_downtime: The most recent actual start and end dates for a recurring downtime. For a canceled downtime, + this is the previously occurring downtime. For active downtimes, this is the ongoing downtime, and for scheduled + downtimes it is the upcoming downtime. + :type current_downtime: DowntimeAttributeScheduleCurrentDowntimeResponse, optional + + :param recurrences: A list of downtime recurrences. + :type recurrences: [DowntimeAttributeScheduleRecurrenceResponse], optional + + :param timezone: The timezone in which to schedule the downtime. This affects recurring start and end dates. + Must match ``display_timezone``. + :type timezone: str, optional + """ + if current_downtime is not unset: + kwargs["current_downtime"] = current_downtime + if recurrences is not unset: + kwargs["recurrences"] = recurrences + if timezone is not unset: + kwargs["timezone"] = timezone + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_attribute_schedule_response.py b/src/datadog_api_client/v2/model/downtime_attribute_schedule_response.py new file mode 100644 index 0000000000..0b8b4aa80f --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_attribute_schedule_response.py @@ -0,0 +1,61 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class DowntimeAttributeScheduleResponse(ModelComposed): + def __init__(self, **kwargs): + """ + The schedule that defines when the monitor starts, stops, and recurs. There are two types of schedules: + one-time and recurring. Recurring schedules may have up to five RRULE-based recurrences. If no schedules is + provided, the downtime will begin immediately and never end. + + :param current_downtime: The most recent actual start and end dates for a recurring downtime. For a canceled downtime, + this is the previously occurring downtime. For active downtimes, this is the ongoing downtime, and for scheduled + downtimes it is the upcoming downtime. + :type current_downtime: DowntimeAttributeScheduleCurrentDowntimeResponse, optional + + :param recurrences: A list of downtime recurrences. + :type recurrences: [DowntimeAttributeScheduleRecurrenceResponse], optional + + :param timezone: The timezone in which to schedule the downtime. This affects recurring start and end dates. + Must match `display_timezone`. + :type timezone: str, optional + + :param end: ISO-8601 Datetime to end the downtime. + :type end: datetime, optional + + :param start: ISO-8601 Datetime to start the downtime. + :type start: datetime, optional + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_response import ( + DowntimeAttributeScheduleRecurrencesResponse, + ) + from datadog_api_client.v2.model.downtime_attribute_schedule_one_time_response import ( + DowntimeAttributeScheduleOneTimeResponse, + ) + + return { + "oneOf": [ + DowntimeAttributeScheduleRecurrencesResponse, + DowntimeAttributeScheduleOneTimeResponse, + ], + } diff --git a/src/datadog_api_client/v2/model/downtime_create_data.py b/src/datadog_api_client/v2/model/downtime_create_data.py new file mode 100644 index 0000000000..3cdc92ae89 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_create_data.py @@ -0,0 +1,48 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_create_request import DowntimeAttributeCreateRequest + from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType + + +class DowntimeCreateData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_create_request import DowntimeAttributeCreateRequest + from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType + + return { + "attributes": (DowntimeAttributeCreateRequest,), + "type": (DowntimeResourceType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__(self_, attributes: DowntimeAttributeCreateRequest, type: DowntimeResourceType, **kwargs): + """ + Object to create a downtime. + + :param attributes: Downtime details. + :type attributes: DowntimeAttributeCreateRequest + + :param type: Downtime resource type. + :type type: DowntimeResourceType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/downtime_create_request.py b/src/datadog_api_client/v2/model/downtime_create_request.py new file mode 100644 index 0000000000..43a398bc5d --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_create_request.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_create_data import DowntimeCreateData + + +class DowntimeCreateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_create_data import DowntimeCreateData + + return { + "data": (DowntimeCreateData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: DowntimeCreateData, **kwargs): + """ + Request for creating a downtime. + + :param data: Object to create a downtime. + :type data: DowntimeCreateData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/downtime_edit_data.py b/src/datadog_api_client/v2/model/downtime_edit_data.py new file mode 100644 index 0000000000..7f98b4741a --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_edit_data.py @@ -0,0 +1,54 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_edit_request import DowntimeAttributeEditRequest + from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType + + +class DowntimeEditData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_edit_request import DowntimeAttributeEditRequest + from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType + + return { + "attributes": (DowntimeAttributeEditRequest,), + "id": (str,), + "type": (DowntimeResourceType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: DowntimeAttributeEditRequest, id: str, type: DowntimeResourceType, **kwargs): + """ + Object to update a downtime. + + :param attributes: Attributes of the downtime to update. + :type attributes: DowntimeAttributeEditRequest + + :param id: ID of this downtime. + :type id: str + + :param type: Downtime resource type. + :type type: DowntimeResourceType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/downtime_edit_request.py b/src/datadog_api_client/v2/model/downtime_edit_request.py new file mode 100644 index 0000000000..49f0dd9bd6 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_edit_request.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_edit_data import DowntimeEditData + + +class DowntimeEditRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_edit_data import DowntimeEditData + + return { + "data": (DowntimeEditData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: DowntimeEditData, **kwargs): + """ + Request for editing a downtime. + + :param data: Object to update a downtime. + :type data: DowntimeEditData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/downtime_included_monitor_type.py b/src/datadog_api_client/v2/model/downtime_included_monitor_type.py new file mode 100644 index 0000000000..cc187ff30d --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_included_monitor_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class DowntimeIncludedMonitorType(ModelSimple): + """ + Monitor resource type. + + :param value: If omitted defaults to "monitors". Must be one of ["monitors"]. + :type value: str + """ + + allowed_values = { + "monitors", + } + MONITORS: ClassVar["DowntimeIncludedMonitorType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DowntimeIncludedMonitorType.MONITORS = DowntimeIncludedMonitorType("monitors") diff --git a/src/datadog_api_client/v2/model/downtime_monitor_included_attributes.py b/src/datadog_api_client/v2/model/downtime_monitor_included_attributes.py new file mode 100644 index 0000000000..56c587068d --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_monitor_included_attributes.py @@ -0,0 +1,36 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class DowntimeMonitorIncludedAttributes(ModelNormal): + @cached_property + def openapi_types(_): + return { + "name": (str,), + } + + attribute_map = { + "name": "name", + } + + def __init__(self_, name: Union[str, UnsetType] = unset, **kwargs): + """ + Attributes of the monitor identified by the downtime. + + :param name: The name of the monitor identified by the downtime. + :type name: str, optional + """ + if name is not unset: + kwargs["name"] = name + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_monitor_included_item.py b/src/datadog_api_client/v2/model/downtime_monitor_included_item.py new file mode 100644 index 0000000000..b15216036a --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_monitor_included_item.py @@ -0,0 +1,64 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_monitor_included_attributes import DowntimeMonitorIncludedAttributes + from datadog_api_client.v2.model.downtime_included_monitor_type import DowntimeIncludedMonitorType + + +class DowntimeMonitorIncludedItem(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_monitor_included_attributes import DowntimeMonitorIncludedAttributes + from datadog_api_client.v2.model.downtime_included_monitor_type import DowntimeIncludedMonitorType + + return { + "attributes": (DowntimeMonitorIncludedAttributes,), + "id": (int,), + "type": (DowntimeIncludedMonitorType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: Union[DowntimeMonitorIncludedAttributes, UnsetType] = unset, + id: Union[int, UnsetType] = unset, + type: Union[DowntimeIncludedMonitorType, UnsetType] = unset, + **kwargs, + ): + """ + Information about the monitor identified by the downtime. + + :param attributes: Attributes of the monitor identified by the downtime. + :type attributes: DowntimeMonitorIncludedAttributes, optional + + :param id: ID of the monitor identified by the downtime. + :type id: int, optional + + :param type: Monitor resource type. + :type type: DowntimeIncludedMonitorType, optional + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_relationships.py b/src/datadog_api_client/v2/model/downtime_relationships.py new file mode 100644 index 0000000000..38491f1770 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_relationships.py @@ -0,0 +1,56 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_relationships_created_by import DowntimeRelationshipsCreatedBy + from datadog_api_client.v2.model.downtime_relationships_monitor import DowntimeRelationshipsMonitor + + +class DowntimeRelationships(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_relationships_created_by import DowntimeRelationshipsCreatedBy + from datadog_api_client.v2.model.downtime_relationships_monitor import DowntimeRelationshipsMonitor + + return { + "created_by": (DowntimeRelationshipsCreatedBy,), + "monitor": (DowntimeRelationshipsMonitor,), + } + + attribute_map = { + "created_by": "created_by", + "monitor": "monitor", + } + + def __init__( + self_, + created_by: Union[DowntimeRelationshipsCreatedBy, UnsetType] = unset, + monitor: Union[DowntimeRelationshipsMonitor, UnsetType] = unset, + **kwargs, + ): + """ + All relationships associated with downtime. + + :param created_by: The user who created the downtime. + :type created_by: DowntimeRelationshipsCreatedBy, optional + + :param monitor: The monitor identified by the downtime. + :type monitor: DowntimeRelationshipsMonitor, optional + """ + if created_by is not unset: + kwargs["created_by"] = created_by + if monitor is not unset: + kwargs["monitor"] = monitor + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_relationships_created_by.py b/src/datadog_api_client/v2/model/downtime_relationships_created_by.py new file mode 100644 index 0000000000..c01b9964f3 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_relationships_created_by.py @@ -0,0 +1,44 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_relationships_created_by_data import DowntimeRelationshipsCreatedByData + + +class DowntimeRelationshipsCreatedBy(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_relationships_created_by_data import ( + DowntimeRelationshipsCreatedByData, + ) + + return { + "data": (DowntimeRelationshipsCreatedByData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[DowntimeRelationshipsCreatedByData, UnsetType] = unset, **kwargs): + """ + The user who created the downtime. + + :param data: Data for the user who created the downtime. + :type data: DowntimeRelationshipsCreatedByData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_relationships_created_by_data.py b/src/datadog_api_client/v2/model/downtime_relationships_created_by_data.py new file mode 100644 index 0000000000..5531ffe1c6 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_relationships_created_by_data.py @@ -0,0 +1,49 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_user_type import DowntimeUserType + + +class DowntimeRelationshipsCreatedByData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_user_type import DowntimeUserType + + return { + "id": (str,), + "type": (DowntimeUserType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__(self_, id: Union[str, UnsetType] = unset, type: Union[DowntimeUserType, UnsetType] = unset, **kwargs): + """ + Data for the user who created the downtime. + + :param id: User ID of the downtime creator. + :type id: str, optional + + :param type: User resource type. + :type type: DowntimeUserType, optional + """ + if id is not unset: + kwargs["id"] = id + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_relationships_monitor.py b/src/datadog_api_client/v2/model/downtime_relationships_monitor.py new file mode 100644 index 0000000000..c21132659a --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_relationships_monitor.py @@ -0,0 +1,42 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_relationships_monitor_data import DowntimeRelationshipsMonitorData + + +class DowntimeRelationshipsMonitor(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_relationships_monitor_data import DowntimeRelationshipsMonitorData + + return { + "data": (DowntimeRelationshipsMonitorData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[DowntimeRelationshipsMonitorData, UnsetType] = unset, **kwargs): + """ + The monitor identified by the downtime. + + :param data: Data for the monitor. + :type data: DowntimeRelationshipsMonitorData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_relationships_monitor_data.py b/src/datadog_api_client/v2/model/downtime_relationships_monitor_data.py new file mode 100644 index 0000000000..cc2079c233 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_relationships_monitor_data.py @@ -0,0 +1,51 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_included_monitor_type import DowntimeIncludedMonitorType + + +class DowntimeRelationshipsMonitorData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_included_monitor_type import DowntimeIncludedMonitorType + + return { + "id": (int,), + "type": (DowntimeIncludedMonitorType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__( + self_, id: Union[int, UnsetType] = unset, type: Union[DowntimeIncludedMonitorType, UnsetType] = unset, **kwargs + ): + """ + Data for the monitor. + + :param id: Monitor ID of the downtime. + :type id: int, optional + + :param type: Monitor resource type. + :type type: DowntimeIncludedMonitorType, optional + """ + if id is not unset: + kwargs["id"] = id + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_resource_type.py b/src/datadog_api_client/v2/model/downtime_resource_type.py new file mode 100644 index 0000000000..38c39211f3 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_resource_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class DowntimeResourceType(ModelSimple): + """ + Downtime resource type. + + :param value: If omitted defaults to "downtime". Must be one of ["downtime"]. + :type value: str + """ + + allowed_values = { + "downtime", + } + DOWNTIME: ClassVar["DowntimeResourceType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DowntimeResourceType.DOWNTIME = DowntimeResourceType("downtime") diff --git a/src/datadog_api_client/v2/model/downtime_response.py b/src/datadog_api_client/v2/model/downtime_response.py new file mode 100644 index 0000000000..ccf3ce61f5 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_response.py @@ -0,0 +1,63 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_response_data import DowntimeResponseData + from datadog_api_client.v2.model.downtime_response_included_item import DowntimeResponseIncludedItem + from datadog_api_client.v2.model.user import User + from datadog_api_client.v2.model.downtime_monitor_included_item import DowntimeMonitorIncludedItem + + +class DowntimeResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_response_data import DowntimeResponseData + from datadog_api_client.v2.model.downtime_response_included_item import DowntimeResponseIncludedItem + + return { + "data": (DowntimeResponseData,), + "included": ([DowntimeResponseIncludedItem],), + } + + attribute_map = { + "data": "data", + "included": "included", + } + + def __init__( + self_, + data: Union[DowntimeResponseData, UnsetType] = unset, + included: Union[ + List[Union[DowntimeResponseIncludedItem, User, DowntimeMonitorIncludedItem]], UnsetType + ] = unset, + **kwargs, + ): + """ + Downtiming gives you greater control over monitor notifications by + allowing you to globally exclude scopes from alerting. + Downtime settings, which can be scheduled with start and end times, + prevent all alerting related to specified Datadog tags. + + :param data: Downtime data. + :type data: DowntimeResponseData, optional + + :param included: Array of objects related to the downtime that the user requested. + :type included: [DowntimeResponseIncludedItem], optional + """ + if data is not unset: + kwargs["data"] = data + if included is not unset: + kwargs["included"] = included + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_response_data.py b/src/datadog_api_client/v2/model/downtime_response_data.py new file mode 100644 index 0000000000..5d20143cc7 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_response_data.py @@ -0,0 +1,74 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.downtime_attribute_response import DowntimeAttributeResponse + from datadog_api_client.v2.model.downtime_relationships import DowntimeRelationships + from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType + + +class DowntimeResponseData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.downtime_attribute_response import DowntimeAttributeResponse + from datadog_api_client.v2.model.downtime_relationships import DowntimeRelationships + from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType + + return { + "attributes": (DowntimeAttributeResponse,), + "id": (str,), + "relationships": (DowntimeRelationships,), + "type": (DowntimeResourceType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + attributes: Union[DowntimeAttributeResponse, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + relationships: Union[DowntimeRelationships, UnsetType] = unset, + type: Union[DowntimeResourceType, UnsetType] = unset, + **kwargs, + ): + """ + Downtime data. + + :param attributes: Downtime details. + :type attributes: DowntimeAttributeResponse, optional + + :param id: The downtime ID. + :type id: str, optional + + :param relationships: All relationships associated with downtime. + :type relationships: DowntimeRelationships, optional + + :param type: Downtime resource type. + :type type: DowntimeResourceType, optional + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + if relationships is not unset: + kwargs["relationships"] = relationships + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/downtime_response_included_item.py b/src/datadog_api_client/v2/model/downtime_response_included_item.py new file mode 100644 index 0000000000..8f2715415c --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_response_included_item.py @@ -0,0 +1,49 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class DowntimeResponseIncludedItem(ModelComposed): + def __init__(self, **kwargs): + """ + An object related to a downtime. + + :param attributes: Attributes of user object returned by the API. + :type attributes: UserAttributes, optional + + :param id: ID of the user. + :type id: str, optional + + :param relationships: Relationships of the user object returned by the API. + :type relationships: UserResponseRelationships, optional + + :param type: Users resource type. + :type type: UsersType, optional + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.user import User + from datadog_api_client.v2.model.downtime_monitor_included_item import DowntimeMonitorIncludedItem + + return { + "oneOf": [ + User, + DowntimeMonitorIncludedItem, + ], + } diff --git a/src/datadog_api_client/v2/model/downtime_status_enum.py b/src/datadog_api_client/v2/model/downtime_status_enum.py new file mode 100644 index 0000000000..0ce0521186 --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_status_enum.py @@ -0,0 +1,44 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class DowntimeStatusEnum(ModelSimple): + """ + The current status of the downtime + + :param value: Must be one of ["active", "canceled", "ended", "scheduled"]. + :type value: str + """ + + allowed_values = { + "active", + "canceled", + "ended", + "scheduled", + } + ACTIVE: ClassVar["DowntimeStatusEnum"] + CANCELED: ClassVar["DowntimeStatusEnum"] + ENDED: ClassVar["DowntimeStatusEnum"] + SCHEDULED: ClassVar["DowntimeStatusEnum"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DowntimeStatusEnum.ACTIVE = DowntimeStatusEnum("active") +DowntimeStatusEnum.CANCELED = DowntimeStatusEnum("canceled") +DowntimeStatusEnum.ENDED = DowntimeStatusEnum("ended") +DowntimeStatusEnum.SCHEDULED = DowntimeStatusEnum("scheduled") diff --git a/src/datadog_api_client/v2/model/downtime_user_type.py b/src/datadog_api_client/v2/model/downtime_user_type.py new file mode 100644 index 0000000000..61f5c4836d --- /dev/null +++ b/src/datadog_api_client/v2/model/downtime_user_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class DowntimeUserType(ModelSimple): + """ + User resource type. + + :param value: If omitted defaults to "users". Must be one of ["users"]. + :type value: str + """ + + allowed_values = { + "users", + } + USERS: ClassVar["DowntimeUserType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DowntimeUserType.USERS = DowntimeUserType("users") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 885de7a3e5..2c0295e198 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -207,6 +207,63 @@ from datadog_api_client.v2.model.detailed_finding import DetailedFinding from datadog_api_client.v2.model.detailed_finding_attributes import DetailedFindingAttributes from datadog_api_client.v2.model.detailed_finding_type import DetailedFindingType +from datadog_api_client.v2.model.downtime_attribute_create_request import DowntimeAttributeCreateRequest +from datadog_api_client.v2.model.downtime_attribute_edit_request import DowntimeAttributeEditRequest +from datadog_api_client.v2.model.downtime_attribute_monitor_identifier import DowntimeAttributeMonitorIdentifier +from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_id import DowntimeAttributeMonitorIdentifierId +from datadog_api_client.v2.model.downtime_attribute_monitor_identifier_tags import ( + DowntimeAttributeMonitorIdentifierTags, +) +from datadog_api_client.v2.model.downtime_attribute_notify_end_states_item import DowntimeAttributeNotifyEndStatesItem +from datadog_api_client.v2.model.downtime_attribute_notify_end_types_item import DowntimeAttributeNotifyEndTypesItem +from datadog_api_client.v2.model.downtime_attribute_response import DowntimeAttributeResponse +from datadog_api_client.v2.model.downtime_attribute_schedule_create_request import ( + DowntimeAttributeScheduleCreateRequest, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_current_downtime_response import ( + DowntimeAttributeScheduleCurrentDowntimeResponse, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_edit_request import DowntimeAttributeScheduleEditRequest +from datadog_api_client.v2.model.downtime_attribute_schedule_one_time_create_edit_request import ( + DowntimeAttributeScheduleOneTimeCreateEditRequest, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_one_time_response import ( + DowntimeAttributeScheduleOneTimeResponse, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_create_edit_request import ( + DowntimeAttributeScheduleRecurrenceCreateEditRequest, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_recurrence_response import ( + DowntimeAttributeScheduleRecurrenceResponse, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_create_request import ( + DowntimeAttributeScheduleRecurrencesCreateRequest, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_edit_request import ( + DowntimeAttributeScheduleRecurrencesEditRequest, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_recurrences_response import ( + DowntimeAttributeScheduleRecurrencesResponse, +) +from datadog_api_client.v2.model.downtime_attribute_schedule_response import DowntimeAttributeScheduleResponse +from datadog_api_client.v2.model.downtime_create_data import DowntimeCreateData +from datadog_api_client.v2.model.downtime_create_request import DowntimeCreateRequest +from datadog_api_client.v2.model.downtime_edit_data import DowntimeEditData +from datadog_api_client.v2.model.downtime_edit_request import DowntimeEditRequest +from datadog_api_client.v2.model.downtime_included_monitor_type import DowntimeIncludedMonitorType +from datadog_api_client.v2.model.downtime_monitor_included_attributes import DowntimeMonitorIncludedAttributes +from datadog_api_client.v2.model.downtime_monitor_included_item import DowntimeMonitorIncludedItem +from datadog_api_client.v2.model.downtime_relationships import DowntimeRelationships +from datadog_api_client.v2.model.downtime_relationships_created_by import DowntimeRelationshipsCreatedBy +from datadog_api_client.v2.model.downtime_relationships_created_by_data import DowntimeRelationshipsCreatedByData +from datadog_api_client.v2.model.downtime_relationships_monitor import DowntimeRelationshipsMonitor +from datadog_api_client.v2.model.downtime_relationships_monitor_data import DowntimeRelationshipsMonitorData +from datadog_api_client.v2.model.downtime_resource_type import DowntimeResourceType +from datadog_api_client.v2.model.downtime_response import DowntimeResponse +from datadog_api_client.v2.model.downtime_response_data import DowntimeResponseData +from datadog_api_client.v2.model.downtime_response_included_item import DowntimeResponseIncludedItem +from datadog_api_client.v2.model.downtime_status_enum import DowntimeStatusEnum +from datadog_api_client.v2.model.downtime_user_type import DowntimeUserType from datadog_api_client.v2.model.event import Event from datadog_api_client.v2.model.event_attributes import EventAttributes from datadog_api_client.v2.model.event_priority import EventPriority diff --git a/tests/v2/features/downtimes.feature b/tests/v2/features/downtimes.feature new file mode 100644 index 0000000000..c1bacc6833 --- /dev/null +++ b/tests/v2/features/downtimes.feature @@ -0,0 +1,100 @@ +@endpoint(downtimes) @endpoint(downtimes-v2) +Feature: Downtimes + **Note**: Downtime V2 is currently in private beta. To request access, + contact [Datadog support](https://docs.datadoghq.com/help/). + [Downtiming](https://docs.datadoghq.com/monitors/notify/downtimes) gives + you greater control over monitor notifications by allowing you to globally + exclude scopes from alerting. Downtime settings, which can be scheduled + with start and end times, prevent all alerting related to specified + Datadog tags. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "Downtimes" API + + @team:DataDog/monitor-app + Scenario: Cancel a downtime returns "Downtime not found" response + Given new "CancelDowntime" request + And request contains "downtime_id" parameter with value "00000000-0000-1234-0000-000000000000" + When the request is sent + Then the response status is 404 Downtime not found + + @team:DataDog/monitor-app + Scenario: Cancel a downtime returns "OK" response + Given there is a valid "downtime_v2" in the system + And new "CancelDowntime" request + And request contains "downtime_id" parameter from "downtime.data.id" + When the request is sent + Then the response status is 204 OK + + @team:DataDog/monitor-app + Scenario: Get a downtime returns "Bad Request" response + Given new "GetDowntime" request + And request contains "downtime_id" parameter with value "INVALID_UUID_LENGTH" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/monitor-app + Scenario: Get a downtime returns "Not Found" response + Given new "GetDowntime" request + And request contains "downtime_id" parameter with value "00000000-0000-1234-0000-000000000000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/monitor-app + Scenario: Get a downtime returns "OK" response + Given there is a valid "downtime_v2" in the system + And new "GetDowntime" request + And request contains "downtime_id" parameter from "downtime.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.message" is equal to "test message" + + @team:DataDog/monitor-app + Scenario: Get all downtimes returns "OK" response + Given new "ListDowntimes" request + When the request is sent + Then the response status is 200 OK + + @team:DataDog/monitor-app + Scenario: Schedule a downtime returns "Bad Request" response + Given new "CreateDowntime" request + And body with value {"data": {"type": "downtime", "attributes": {"key_dne": "dark forest"}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/monitor-app + Scenario: Schedule a downtime returns "OK" response + Given new "CreateDowntime" request + And body with value {"data": {"attributes": {"display_timezone": "America/New_York", "message": "dark forest", "monitor_identifier": {"monitor_tags": ["cat:hat"]}, "mute_first_recovery_notification": false, "notify_end_states": ["alert", "warn"], "notify_end_types": ["canceled", "expired"], "schedule": {"recurrences": [{"duration": "123d", "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1", "start": "3020-01-02T03:04"}], "timezone": "America/New_York"}, "scope": "test:{{ unique_lower_alnum }}"}, "type": "downtime"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.message" is equal to "dark forest" + + @team:DataDog/monitor-app + Scenario: Update a downtime returns "Bad Request" response + Given there is a valid "downtime_v2" in the system + And new "UpdateDowntime" request + And request contains "downtime_id" parameter from "downtime.data.id" + And body with value {"data": {"attributes": {"invalid_field": "sophon"}, "id": "{{ downtime.data.id }}", "type": "downtime"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/monitor-app + Scenario: Update a downtime returns "Downtime not found" response + Given new "UpdateDowntime" request + And request contains "downtime_id" parameter with value "00000000-0000-1234-0000-000000000000" + And body with value {"data": {"attributes": {"message": "test msg"}, "id": "00000000-0000-1234-0000-000000000000", "type": "downtime"}} + When the request is sent + Then the response status is 404 Downtime not found + + @team:DataDog/monitor-app + Scenario: Update a downtime returns "OK" response + Given there is a valid "downtime_v2" in the system + And new "UpdateDowntime" request + And request contains "downtime_id" parameter from "downtime.data.id" + And body with value {"data": {"attributes": {"message": "light speed"}, "id": "{{ downtime.data.id }}", "type": "downtime"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.message" is equal to "light speed" diff --git a/tests/v2/features/given.json b/tests/v2/features/given.json index 15db40f70c..810d2476cf 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -79,6 +79,18 @@ "tag": "Dashboard Lists", "operationId": "CreateDashboardListItems" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n\t\"data\": {\n\t\t\"attributes\": {\n \"message\": \"test message\",\n\t\t\t\"monitor_identifier\": {\n\t\t\t\t\"monitor_tags\": [\"cat:hat\"]\n\t\t\t},\n\t\t\t\"scope\": \"test:{{ unique_lower_alnum }}\"\n\t\t},\n\t\t\"type\": \"downtime\"\n\t}\n}" + } + ], + "step": "there is a valid \"downtime_v2\" in the system", + "key": "downtime", + "tag": "Downtimes", + "operationId": "CreateDowntime" + }, { "parameters": [ { diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 30378f78d5..52784c2f03 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -243,6 +243,43 @@ "type": "safe" } }, + "ListDowntimes": { + "tag": "Downtimes", + "undo": { + "type": "safe" + } + }, + "CreateDowntime": { + "tag": "Downtimes", + "undo": { + "operationId": "CancelDowntime", + "parameters": [ + { + "name": "downtime_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "CancelDowntime": { + "tag": "Downtimes", + "undo": { + "type": "idempotent" + } + }, + "GetDowntime": { + "tag": "Downtimes", + "undo": { + "type": "safe" + } + }, + "UpdateDowntime": { + "tag": "Downtimes", + "undo": { + "type": "idempotent" + } + }, "ListEvents": { "tag": "Events", "undo": {