diff --git a/.apigentools-info b/.apigentools-info index 05aa0d7c579..b93070acae3 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.5", - "regenerated": "2023-07-03 09:29:37.390235", - "spec_repo_commit": "29891cab" + "regenerated": "2023-07-03 17:52:35.742337", + "spec_repo_commit": "0476cb95" }, "v2": { "apigentools_version": "1.6.5", - "regenerated": "2023-07-03 09:29:37.404686", - "spec_repo_commit": "29891cab" + "regenerated": "2023-07-03 17:52:35.756408", + "spec_repo_commit": "0476cb95" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 0869e2ffc44..fc841efd72c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -3684,6 +3684,578 @@ components: type: string x-enum-varnames: - DETAILED_FINDING + DowntimeCreateRequest: + description: Request for creating a downtime. + properties: + data: + $ref: '#/components/schemas/DowntimeCreateRequestData' + required: + - data + type: object + DowntimeCreateRequestAttributes: + description: Downtime details. + properties: + display_timezone: + $ref: '#/components/schemas/DowntimeDisplayTimezone' + message: + $ref: '#/components/schemas/DowntimeMessage' + monitor_identifier: + $ref: '#/components/schemas/DowntimeMonitorIdentifier' + mute_first_recovery_notification: + $ref: '#/components/schemas/DowntimeMuteFirstRecoveryNotification' + notify_end_states: + $ref: '#/components/schemas/DowntimeNotifyEndStates' + notify_end_types: + $ref: '#/components/schemas/DowntimeNotifyEndTypes' + schedule: + $ref: '#/components/schemas/DowntimeScheduleCreateRequest' + scope: + $ref: '#/components/schemas/DowntimeScope' + required: + - scope + - monitor_identifier + type: object + DowntimeCreateRequestData: + description: Object to create a downtime. + properties: + attributes: + $ref: '#/components/schemas/DowntimeCreateRequestAttributes' + type: + $ref: '#/components/schemas/DowntimeResourceType' + required: + - type + - attributes + type: object + DowntimeDisplayTimezone: + 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 + nullable: true + type: string + DowntimeIncludedMonitorType: + default: monitors + description: Monitor resource type. + enum: + - monitors + example: monitors + type: string + x-enum-varnames: + - MONITORS + DowntimeMessage: + 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 + nullable: true + type: string + DowntimeMeta: + description: Pagination metadata returned by the API. + properties: + page: + $ref: '#/components/schemas/DowntimeMetaPage' + type: object + DowntimeMetaPage: + description: Object containing the total filtered count. + properties: + total_filtered_count: + description: Total count of elements matched by the filter. + format: int64 + type: integer + type: object + DowntimeMonitorIdentifier: + description: Monitor identifier for the downtime. + oneOf: + - $ref: '#/components/schemas/DowntimeMonitorIdentifierId' + - $ref: '#/components/schemas/DowntimeMonitorIdentifierTags' + type: object + DowntimeMonitorIdentifierId: + additionalProperties: {} + 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 + DowntimeMonitorIdentifierTags: + additionalProperties: {} + 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. Setting `monitor_tags` + + to `[*]` configures the downtime to mute all monitors for the given scope.' + example: + - service:postgres + - team:frontend + items: + description: A list of monitor tags. + example: service:postgres + type: string + minItems: 1 + type: array + required: + - monitor_tags + type: object + 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 + DowntimeMuteFirstRecoveryNotification: + description: If the first recovery notification during a downtime should be + muted. + example: false + type: boolean + DowntimeNotifyEndStateActions: + 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 + DowntimeNotifyEndStateTypes: + 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 + DowntimeNotifyEndStates: + description: States that will trigger a monitor notification when the `notify_end_types` + action occurs. + example: + - alert + - warn + items: + $ref: '#/components/schemas/DowntimeNotifyEndStateTypes' + type: array + DowntimeNotifyEndTypes: + description: Actions that will trigger a monitor notification if the downtime + is in the `notify_end_types` state. + example: + - canceled + - expired + items: + $ref: '#/components/schemas/DowntimeNotifyEndStateActions' + type: array + 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. + nullable: true + properties: + id: + description: User ID of the downtime creator. + example: 00000000-0000-1234-0000-000000000000 + type: string + type: + $ref: '#/components/schemas/UsersType' + type: object + DowntimeRelationshipsMonitor: + description: The monitor identified by the downtime. + properties: + data: + $ref: '#/components/schemas/DowntimeRelationshipsMonitorData' + type: object + DowntimeRelationshipsMonitorData: + description: Data for the monitor. + nullable: true + 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 + DowntimeResponseAttributes: + description: Downtime details. + properties: + created_at: + description: Creation time of the downtime. + example: 2020-01-02T03:04:05.282979+0000 + format: date-time + type: string + display_timezone: + $ref: '#/components/schemas/DowntimeDisplayTimezone' + message: + $ref: '#/components/schemas/DowntimeMessage' + modified_at: + description: Time that the downtime was last modified. + example: 2020-01-02T03:04:05.282979+0000 + format: date-time + type: string + monitor_identifier: + $ref: '#/components/schemas/DowntimeMonitorIdentifier' + mute_first_recovery_notification: + $ref: '#/components/schemas/DowntimeMuteFirstRecoveryNotification' + notify_end_states: + $ref: '#/components/schemas/DowntimeNotifyEndStates' + notify_end_types: + $ref: '#/components/schemas/DowntimeNotifyEndTypes' + schedule: + $ref: '#/components/schemas/DowntimeScheduleResponse' + scope: + $ref: '#/components/schemas/DowntimeScope' + status: + $ref: '#/components/schemas/DowntimeStatus' + type: object + DowntimeResponseData: + description: Downtime data. + properties: + attributes: + $ref: '#/components/schemas/DowntimeResponseAttributes' + 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 + DowntimeScheduleCreateRequest: + description: Schedule for the downtime. + oneOf: + - $ref: '#/components/schemas/DowntimeScheduleRecurrencesCreateRequest' + - $ref: '#/components/schemas/DowntimeScheduleOneTimeCreateUpdateRequest' + type: object + DowntimeScheduleCurrentDowntimeResponse: + 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 + nullable: true + 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 + DowntimeScheduleOneTimeCreateUpdateRequest: + additionalProperties: {} + 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 + nullable: true + 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 + nullable: true + type: string + type: object + DowntimeScheduleOneTimeResponse: + 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 + nullable: true + 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 + DowntimeScheduleRecurrenceCreateUpdateRequest: + additionalProperties: {} + description: An object defining the recurrence of the downtime. + properties: + duration: + $ref: '#/components/schemas/DowntimeScheduleRecurrenceDuration' + rrule: + $ref: '#/components/schemas/DowntimeScheduleRecurrenceRrule' + 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 + nullable: true + type: string + required: + - duration + - rrule + type: object + DowntimeScheduleRecurrenceDuration: + 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 + DowntimeScheduleRecurrenceResponse: + description: An RRULE-based recurring downtime. + properties: + duration: + $ref: '#/components/schemas/DowntimeScheduleRecurrenceDuration' + rrule: + $ref: '#/components/schemas/DowntimeScheduleRecurrenceRrule' + 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 + DowntimeScheduleRecurrenceRrule: + 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 + DowntimeScheduleRecurrencesCreateRequest: + description: A recurring downtime schedule definition. + properties: + recurrences: + description: A list of downtime recurrences. + items: + $ref: '#/components/schemas/DowntimeScheduleRecurrenceCreateUpdateRequest' + type: array + timezone: + default: UTC + description: The timezone in which to schedule the downtime. + example: America/New_York + type: string + required: + - recurrences + type: object + DowntimeScheduleRecurrencesResponse: + description: A recurring downtime schedule definition. + properties: + current_downtime: + $ref: '#/components/schemas/DowntimeScheduleCurrentDowntimeResponse' + recurrences: + description: A list of downtime recurrences. + items: + $ref: '#/components/schemas/DowntimeScheduleRecurrenceResponse' + maxItems: 5 + minItems: 1 + type: array + timezone: + default: UTC + 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 + required: + - recurrences + type: object + DowntimeScheduleRecurrencesUpdateRequest: + description: A recurring downtime schedule definition. + properties: + recurrences: + description: A list of downtime recurrences. + items: + $ref: '#/components/schemas/DowntimeScheduleRecurrenceCreateUpdateRequest' + type: array + timezone: + default: UTC + description: The timezone in which to schedule the downtime. + example: America/New_York + type: string + type: object + DowntimeScheduleResponse: + 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 are + + provided, the downtime will begin immediately and never end.' + oneOf: + - $ref: '#/components/schemas/DowntimeScheduleRecurrencesResponse' + - $ref: '#/components/schemas/DowntimeScheduleOneTimeResponse' + type: object + DowntimeScheduleUpdateRequest: + description: Schedule for the downtime. + oneOf: + - $ref: '#/components/schemas/DowntimeScheduleRecurrencesUpdateRequest' + - $ref: '#/components/schemas/DowntimeScheduleOneTimeCreateUpdateRequest' + type: object + DowntimeScope: + description: The scope to which the downtime applies. Must follow the [common + search syntax](https://docs.datadoghq.com/logs/explorer/search_syntax/). + example: env:(staging OR prod) AND datacenter:us-east-1 + type: string + DowntimeStatus: + description: The current status of the downtime. + enum: + - active + - canceled + - ended + - scheduled + example: active + type: string + x-enum-varnames: + - ACTIVE + - CANCELED + - ENDED + - SCHEDULED + DowntimeUpdateRequest: + description: Request for editing a downtime. + properties: + data: + $ref: '#/components/schemas/DowntimeUpdateRequestData' + required: + - data + type: object + DowntimeUpdateRequestAttributes: + description: Attributes of the downtime to update. + properties: + display_timezone: + $ref: '#/components/schemas/DowntimeDisplayTimezone' + message: + $ref: '#/components/schemas/DowntimeMessage' + monitor_identifier: + $ref: '#/components/schemas/DowntimeMonitorIdentifier' + mute_first_recovery_notification: + $ref: '#/components/schemas/DowntimeMuteFirstRecoveryNotification' + notify_end_states: + $ref: '#/components/schemas/DowntimeNotifyEndStates' + notify_end_types: + $ref: '#/components/schemas/DowntimeNotifyEndTypes' + schedule: + $ref: '#/components/schemas/DowntimeScheduleUpdateRequest' + scope: + $ref: '#/components/schemas/DowntimeScope' + type: object + DowntimeUpdateRequestData: + description: Object to update a downtime. + properties: + attributes: + $ref: '#/components/schemas/DowntimeUpdateRequestAttributes' + 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 Event: description: The metadata associated with a request. properties: @@ -6920,6 +7492,22 @@ components: $ref: '#/components/schemas/ApplicationKeyResponseIncludedItem' type: array type: object + ListDowntimesResponse: + description: Response for retrieving all downtimes. + properties: + data: + description: An array of downtimes. + items: + $ref: '#/components/schemas/DowntimeResponseData' + type: array + included: + description: Array of objects related to the downtimes. + items: + $ref: '#/components/schemas/DowntimeResponseIncludedItem' + type: array + meta: + $ref: '#/components/schemas/DowntimeMeta' + type: object ListFindingsData: description: Array of findings. items: @@ -9189,6 +9777,66 @@ components: type: string x-enum-varnames: - TAG + MonitorDowntimeMatchResourceType: + default: downtime_match + description: Monitor Downtime Match resource type. + enum: + - downtime_match + example: downtime_match + type: string + x-enum-varnames: + - DOWNTIME_MATCH + MonitorDowntimeMatchResponse: + description: Response for retrieving all downtime matches for a monitor. + properties: + data: + description: An array of downtime matches. + items: + $ref: '#/components/schemas/MonitorDowntimeMatchResponseData' + type: array + meta: + $ref: '#/components/schemas/DowntimeMeta' + type: object + MonitorDowntimeMatchResponseAttributes: + description: Downtime match details. + properties: + end: + description: The end of the downtime. + example: 2020-01-02 03:04:00+00:00 + format: date-time + nullable: true + type: string + groups: + description: An array of groups associated with the downtime. + example: + - service:postgres + - team:frontend + items: + description: An array of groups. + example: service:postgres + type: string + type: array + scope: + $ref: '#/components/schemas/DowntimeScope' + start: + description: The start of the downtime. + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + type: object + MonitorDowntimeMatchResponseData: + description: A downtime match. + properties: + attributes: + $ref: '#/components/schemas/MonitorDowntimeMatchResponseAttributes' + id: + description: The downtime ID. + example: 00000000-0000-1234-0000-000000000000 + nullable: true + type: string + type: + $ref: '#/components/schemas/MonitorDowntimeMatchResourceType' + type: object MonitorType: description: Attributes from the monitor that triggered the event. nullable: true @@ -17786,6 +18434,252 @@ 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 + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListDowntimesResponse' + 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 + x-unstable: '**Note**: This endpoint is in private beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + 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/DowntimeUpdateRequest' + 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. @@ -21317,6 +22211,45 @@ paths: tags: - Monitors x-codegen-request-body-name: body + /api/v2/monitor/{monitor_id}/downtime_matches: + get: + description: Get all active downtimes for the specified monitor. + operationId: ListMonitorDowntimes + parameters: + - description: The id of the monitor. + in: path + name: monitor_id + required: true + schema: + format: int64 + type: integer + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MonitorDowntimeMatchResponse' + description: OK + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Monitor Not Found error + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_read + summary: Get active downtimes for a monitor + 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/permissions: get: description: Returns a list of all permissions, including name, description, @@ -26456,6 +27389,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/examples/v2/downtimes/CancelDowntime.java b/examples/v2/downtimes/CancelDowntime.java new file mode 100644 index 00000000000..5b05778b6e4 --- /dev/null +++ b/examples/v2/downtimes/CancelDowntime.java @@ -0,0 +1,26 @@ +// Cancel a downtime returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DowntimesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.cancelDowntime", true); + DowntimesApi apiInstance = new DowntimesApi(defaultClient); + + // there is a valid "downtime_v2" in the system + String DOWNTIME_V2_DATA_ID = System.getenv("DOWNTIME_V2_DATA_ID"); + + try { + apiInstance.cancelDowntime(DOWNTIME_V2_DATA_ID); + } catch (ApiException e) { + System.err.println("Exception when calling DowntimesApi#cancelDowntime"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/downtimes/CreateDowntime.java b/examples/v2/downtimes/CreateDowntime.java new file mode 100644 index 00000000000..2b4cd1e8136 --- /dev/null +++ b/examples/v2/downtimes/CreateDowntime.java @@ -0,0 +1,51 @@ +// Schedule a downtime returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DowntimesApi; +import com.datadog.api.client.v2.model.DowntimeCreateRequest; +import com.datadog.api.client.v2.model.DowntimeCreateRequestAttributes; +import com.datadog.api.client.v2.model.DowntimeCreateRequestData; +import com.datadog.api.client.v2.model.DowntimeMonitorIdentifier; +import com.datadog.api.client.v2.model.DowntimeMonitorIdentifierTags; +import com.datadog.api.client.v2.model.DowntimeResourceType; +import com.datadog.api.client.v2.model.DowntimeResponse; +import com.datadog.api.client.v2.model.DowntimeScheduleCreateRequest; +import com.datadog.api.client.v2.model.DowntimeScheduleOneTimeCreateUpdateRequest; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.createDowntime", true); + DowntimesApi apiInstance = new DowntimesApi(defaultClient); + + DowntimeCreateRequest body = + new DowntimeCreateRequest() + .data( + new DowntimeCreateRequestData() + .attributes( + new DowntimeCreateRequestAttributes() + .message("dark forest") + .monitorIdentifier( + new DowntimeMonitorIdentifier( + new DowntimeMonitorIdentifierTags() + .monitorTags(Collections.singletonList("cat:hat")))) + .scope("test:exampledowntime") + .schedule( + new DowntimeScheduleCreateRequest( + new DowntimeScheduleOneTimeCreateUpdateRequest().start(null)))) + .type(DowntimeResourceType.DOWNTIME)); + + try { + DowntimeResponse result = apiInstance.createDowntime(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DowntimesApi#createDowntime"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/downtimes/GetDowntime.java b/examples/v2/downtimes/GetDowntime.java new file mode 100644 index 00000000000..e582c5d1dc4 --- /dev/null +++ b/examples/v2/downtimes/GetDowntime.java @@ -0,0 +1,28 @@ +// Get a downtime returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DowntimesApi; +import com.datadog.api.client.v2.model.DowntimeResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.getDowntime", true); + DowntimesApi apiInstance = new DowntimesApi(defaultClient); + + // there is a valid "downtime_v2" in the system + String DOWNTIME_V2_DATA_ID = System.getenv("DOWNTIME_V2_DATA_ID"); + + try { + DowntimeResponse result = apiInstance.getDowntime(DOWNTIME_V2_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DowntimesApi#getDowntime"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/downtimes/ListDowntimes.java b/examples/v2/downtimes/ListDowntimes.java new file mode 100644 index 00000000000..a2746d1074a --- /dev/null +++ b/examples/v2/downtimes/ListDowntimes.java @@ -0,0 +1,25 @@ +// Get all downtimes returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DowntimesApi; +import com.datadog.api.client.v2.model.ListDowntimesResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listDowntimes", true); + DowntimesApi apiInstance = new DowntimesApi(defaultClient); + + try { + ListDowntimesResponse result = apiInstance.listDowntimes(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DowntimesApi#listDowntimes"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/downtimes/ListMonitorDowntimes.java b/examples/v2/downtimes/ListMonitorDowntimes.java new file mode 100644 index 00000000000..e106364a0b8 --- /dev/null +++ b/examples/v2/downtimes/ListMonitorDowntimes.java @@ -0,0 +1,25 @@ +// Get active downtimes for a monitor returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DowntimesApi; +import com.datadog.api.client.v2.model.MonitorDowntimeMatchResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listMonitorDowntimes", true); + DowntimesApi apiInstance = new DowntimesApi(defaultClient); + + try { + MonitorDowntimeMatchResponse result = apiInstance.listMonitorDowntimes(9223372036854775807L); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DowntimesApi#listMonitorDowntimes"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/downtimes/ListMonitorDowntimes_128979780.java b/examples/v2/downtimes/ListMonitorDowntimes_128979780.java new file mode 100644 index 00000000000..1b86e95fc7a --- /dev/null +++ b/examples/v2/downtimes/ListMonitorDowntimes_128979780.java @@ -0,0 +1,25 @@ +// Get all downtimes for a monitor returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DowntimesApi; +import com.datadog.api.client.v2.model.MonitorDowntimeMatchResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listMonitorDowntimes", true); + DowntimesApi apiInstance = new DowntimesApi(defaultClient); + + try { + MonitorDowntimeMatchResponse result = apiInstance.listMonitorDowntimes(35534610L); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DowntimesApi#listMonitorDowntimes"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/downtimes/UpdateDowntime.java b/examples/v2/downtimes/UpdateDowntime.java new file mode 100644 index 00000000000..c2a14ab7695 --- /dev/null +++ b/examples/v2/downtimes/UpdateDowntime.java @@ -0,0 +1,40 @@ +// Update a downtime returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DowntimesApi; +import com.datadog.api.client.v2.model.DowntimeResourceType; +import com.datadog.api.client.v2.model.DowntimeResponse; +import com.datadog.api.client.v2.model.DowntimeUpdateRequest; +import com.datadog.api.client.v2.model.DowntimeUpdateRequestAttributes; +import com.datadog.api.client.v2.model.DowntimeUpdateRequestData; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.updateDowntime", true); + DowntimesApi apiInstance = new DowntimesApi(defaultClient); + + // there is a valid "downtime_v2" in the system + String DOWNTIME_V2_DATA_ID = System.getenv("DOWNTIME_V2_DATA_ID"); + + DowntimeUpdateRequest body = + new DowntimeUpdateRequest() + .data( + new DowntimeUpdateRequestData() + .attributes(new DowntimeUpdateRequestAttributes().message("light speed")) + .id(DOWNTIME_V2_DATA_ID) + .type(DowntimeResourceType.DOWNTIME)); + + try { + DowntimeResponse result = apiInstance.updateDowntime(DOWNTIME_V2_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DowntimesApi#updateDowntime"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 02e7fc7f4a1..298afa2c13a 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -365,6 +365,12 @@ public class ApiClient { protected final Map unstableOperations = new HashMap() { { + put("v2.cancelDowntime", false); + put("v2.createDowntime", false); + put("v2.getDowntime", false); + put("v2.listDowntimes", false); + put("v2.listMonitorDowntimes", false); + put("v2.updateDowntime", false); put("v2.listEvents", false); put("v2.searchEvents", false); put("v2.createIncident", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/DowntimesApi.java b/src/main/java/com/datadog/api/client/v2/api/DowntimesApi.java new file mode 100644 index 00000000000..b6da2d0e207 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/api/DowntimesApi.java @@ -0,0 +1,1098 @@ +package com.datadog.api.client.v2.api; + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.ApiResponse; +import com.datadog.api.client.Pair; +import com.datadog.api.client.v2.model.DowntimeCreateRequest; +import com.datadog.api.client.v2.model.DowntimeResponse; +import com.datadog.api.client.v2.model.DowntimeUpdateRequest; +import com.datadog.api.client.v2.model.ListDowntimesResponse; +import com.datadog.api.client.v2.model.MonitorDowntimeMatchResponse; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.core.GenericType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimesApi { + private ApiClient apiClient; + + public DowntimesApi() { + this(ApiClient.getDefaultApiClient()); + } + + public DowntimesApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Get the API client. + * + * @return API client + */ + public ApiClient getApiClient() { + return apiClient; + } + + /** + * Set the API client. + * + * @param apiClient an instance of API client + */ + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Cancel a downtime. + * + *

See {@link #cancelDowntimeWithHttpInfo}. + * + * @param downtimeId ID of the downtime to cancel. (required) + * @throws ApiException if fails to make API call + */ + public void cancelDowntime(String downtimeId) throws ApiException { + cancelDowntimeWithHttpInfo(downtimeId); + } + + /** + * Cancel a downtime. + * + *

See {@link #cancelDowntimeWithHttpInfoAsync}. + * + * @param downtimeId ID of the downtime to cancel. (required) + * @return CompletableFuture + */ + public CompletableFuture cancelDowntimeAsync(String downtimeId) { + return cancelDowntimeWithHttpInfoAsync(downtimeId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Cancel a downtime. + * + * @param downtimeId ID of the downtime to cancel. (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 OK -
403 Forbidden -
404 Downtime not found -
429 Too many requests -
+ */ + public ApiResponse cancelDowntimeWithHttpInfo(String downtimeId) throws ApiException { + // Check if unstable operation is enabled + String operationId = "cancelDowntime"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'downtimeId' is set + if (downtimeId == null) { + throw new ApiException( + 400, "Missing the required parameter 'downtimeId' when calling cancelDowntime"); + } + // create path and map variables + String localVarPath = + "/api/v2/downtime/{downtime_id}" + .replaceAll( + "\\{" + "downtime_id" + "\\}", apiClient.escapeString(downtimeId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DowntimesApi.cancelDowntime", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Cancel a downtime. + * + *

See {@link #cancelDowntimeWithHttpInfo}. + * + * @param downtimeId ID of the downtime to cancel. (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> cancelDowntimeWithHttpInfoAsync(String downtimeId) { + // Check if unstable operation is enabled + String operationId = "cancelDowntime"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'downtimeId' is set + if (downtimeId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'downtimeId' when calling cancelDowntime")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/downtime/{downtime_id}" + .replaceAll( + "\\{" + "downtime_id" + "\\}", apiClient.escapeString(downtimeId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DowntimesApi.cancelDowntime", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Schedule a downtime. + * + *

See {@link #createDowntimeWithHttpInfo}. + * + * @param body Schedule a downtime request body. (required) + * @return DowntimeResponse + * @throws ApiException if fails to make API call + */ + public DowntimeResponse createDowntime(DowntimeCreateRequest body) throws ApiException { + return createDowntimeWithHttpInfo(body).getData(); + } + + /** + * Schedule a downtime. + * + *

See {@link #createDowntimeWithHttpInfoAsync}. + * + * @param body Schedule a downtime request body. (required) + * @return CompletableFuture<DowntimeResponse> + */ + public CompletableFuture createDowntimeAsync(DowntimeCreateRequest body) { + return createDowntimeWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Schedule a downtime. + * + * @param body Schedule a downtime request body. (required) + * @return ApiResponse<DowntimeResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse createDowntimeWithHttpInfo(DowntimeCreateRequest body) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "createDowntime"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createDowntime"); + } + // create path and map variables + String localVarPath = "/api/v2/downtime"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DowntimesApi.createDowntime", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Schedule a downtime. + * + *

See {@link #createDowntimeWithHttpInfo}. + * + * @param body Schedule a downtime request body. (required) + * @return CompletableFuture<ApiResponse<DowntimeResponse>> + */ + public CompletableFuture> createDowntimeWithHttpInfoAsync( + DowntimeCreateRequest body) { + // Check if unstable operation is enabled + String operationId = "createDowntime"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling createDowntime")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/downtime"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DowntimesApi.createDowntime", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** Manage optional parameters to getDowntime. */ + public static class GetDowntimeOptionalParameters { + private String include; + + /** + * Set include. + * + * @param include Comma-separated list of resource paths for related resources to include in the + * response. Supported resource paths are created_by and monitor. + * (optional) + * @return GetDowntimeOptionalParameters + */ + public GetDowntimeOptionalParameters include(String include) { + this.include = include; + return this; + } + } + + /** + * Get a downtime. + * + *

See {@link #getDowntimeWithHttpInfo}. + * + * @param downtimeId ID of the downtime to fetch. (required) + * @return DowntimeResponse + * @throws ApiException if fails to make API call + */ + public DowntimeResponse getDowntime(String downtimeId) throws ApiException { + return getDowntimeWithHttpInfo(downtimeId, new GetDowntimeOptionalParameters()).getData(); + } + + /** + * Get a downtime. + * + *

See {@link #getDowntimeWithHttpInfoAsync}. + * + * @param downtimeId ID of the downtime to fetch. (required) + * @return CompletableFuture<DowntimeResponse> + */ + public CompletableFuture getDowntimeAsync(String downtimeId) { + return getDowntimeWithHttpInfoAsync(downtimeId, new GetDowntimeOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get a downtime. + * + *

See {@link #getDowntimeWithHttpInfo}. + * + * @param downtimeId ID of the downtime to fetch. (required) + * @param parameters Optional parameters for the request. + * @return DowntimeResponse + * @throws ApiException if fails to make API call + */ + public DowntimeResponse getDowntime(String downtimeId, GetDowntimeOptionalParameters parameters) + throws ApiException { + return getDowntimeWithHttpInfo(downtimeId, parameters).getData(); + } + + /** + * Get a downtime. + * + *

See {@link #getDowntimeWithHttpInfoAsync}. + * + * @param downtimeId ID of the downtime to fetch. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<DowntimeResponse> + */ + public CompletableFuture getDowntimeAsync( + String downtimeId, GetDowntimeOptionalParameters parameters) { + return getDowntimeWithHttpInfoAsync(downtimeId, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get downtime detail by downtime_id. + * + * @param downtimeId ID of the downtime to fetch. (required) + * @param parameters Optional parameters for the request. + * @return ApiResponse<DowntimeResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getDowntimeWithHttpInfo( + String downtimeId, GetDowntimeOptionalParameters parameters) throws ApiException { + // Check if unstable operation is enabled + String operationId = "getDowntime"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'downtimeId' is set + if (downtimeId == null) { + throw new ApiException( + 400, "Missing the required parameter 'downtimeId' when calling getDowntime"); + } + String include = parameters.include; + // create path and map variables + String localVarPath = + "/api/v2/downtime/{downtime_id}" + .replaceAll( + "\\{" + "downtime_id" + "\\}", apiClient.escapeString(downtimeId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DowntimesApi.getDowntime", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get a downtime. + * + *

See {@link #getDowntimeWithHttpInfo}. + * + * @param downtimeId ID of the downtime to fetch. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<DowntimeResponse>> + */ + public CompletableFuture> getDowntimeWithHttpInfoAsync( + String downtimeId, GetDowntimeOptionalParameters parameters) { + // Check if unstable operation is enabled + String operationId = "getDowntime"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'downtimeId' is set + if (downtimeId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'downtimeId' when calling getDowntime")); + return result; + } + String include = parameters.include; + // create path and map variables + String localVarPath = + "/api/v2/downtime/{downtime_id}" + .replaceAll( + "\\{" + "downtime_id" + "\\}", apiClient.escapeString(downtimeId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DowntimesApi.getDowntime", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** Manage optional parameters to listDowntimes. */ + public static class ListDowntimesOptionalParameters { + private Boolean currentOnly; + private String include; + + /** + * Set currentOnly. + * + * @param currentOnly Only return downtimes that are active when the request is made. (optional) + * @return ListDowntimesOptionalParameters + */ + public ListDowntimesOptionalParameters currentOnly(Boolean currentOnly) { + this.currentOnly = currentOnly; + return this; + } + + /** + * Set include. + * + * @param include Comma-separated list of resource paths for related resources to include in the + * response. Supported resource paths are created_by and monitor. + * (optional) + * @return ListDowntimesOptionalParameters + */ + public ListDowntimesOptionalParameters include(String include) { + this.include = include; + return this; + } + } + + /** + * Get all downtimes. + * + *

See {@link #listDowntimesWithHttpInfo}. + * + * @return ListDowntimesResponse + * @throws ApiException if fails to make API call + */ + public ListDowntimesResponse listDowntimes() throws ApiException { + return listDowntimesWithHttpInfo(new ListDowntimesOptionalParameters()).getData(); + } + + /** + * Get all downtimes. + * + *

See {@link #listDowntimesWithHttpInfoAsync}. + * + * @return CompletableFuture<ListDowntimesResponse> + */ + public CompletableFuture listDowntimesAsync() { + return listDowntimesWithHttpInfoAsync(new ListDowntimesOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get all downtimes. + * + *

See {@link #listDowntimesWithHttpInfo}. + * + * @param parameters Optional parameters for the request. + * @return ListDowntimesResponse + * @throws ApiException if fails to make API call + */ + public ListDowntimesResponse listDowntimes(ListDowntimesOptionalParameters parameters) + throws ApiException { + return listDowntimesWithHttpInfo(parameters).getData(); + } + + /** + * Get all downtimes. + * + *

See {@link #listDowntimesWithHttpInfoAsync}. + * + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ListDowntimesResponse> + */ + public CompletableFuture listDowntimesAsync( + ListDowntimesOptionalParameters parameters) { + return listDowntimesWithHttpInfoAsync(parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get all scheduled downtimes. + * + * @param parameters Optional parameters for the request. + * @return ApiResponse<ListDowntimesResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse listDowntimesWithHttpInfo( + ListDowntimesOptionalParameters parameters) throws ApiException { + // Check if unstable operation is enabled + String operationId = "listDowntimes"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + Boolean currentOnly = parameters.currentOnly; + String include = parameters.include; + // create path and map variables + String localVarPath = "/api/v2/downtime"; + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "current_only", currentOnly)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DowntimesApi.listDowntimes", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get all downtimes. + * + *

See {@link #listDowntimesWithHttpInfo}. + * + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<ListDowntimesResponse>> + */ + public CompletableFuture> listDowntimesWithHttpInfoAsync( + ListDowntimesOptionalParameters parameters) { + // Check if unstable operation is enabled + String operationId = "listDowntimes"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + Boolean currentOnly = parameters.currentOnly; + String include = parameters.include; + // create path and map variables + String localVarPath = "/api/v2/downtime"; + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "current_only", currentOnly)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DowntimesApi.listDowntimes", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get active downtimes for a monitor. + * + *

See {@link #listMonitorDowntimesWithHttpInfo}. + * + * @param monitorId The id of the monitor. (required) + * @return MonitorDowntimeMatchResponse + * @throws ApiException if fails to make API call + */ + public MonitorDowntimeMatchResponse listMonitorDowntimes(Long monitorId) throws ApiException { + return listMonitorDowntimesWithHttpInfo(monitorId).getData(); + } + + /** + * Get active downtimes for a monitor. + * + *

See {@link #listMonitorDowntimesWithHttpInfoAsync}. + * + * @param monitorId The id of the monitor. (required) + * @return CompletableFuture<MonitorDowntimeMatchResponse> + */ + public CompletableFuture listMonitorDowntimesAsync(Long monitorId) { + return listMonitorDowntimesWithHttpInfoAsync(monitorId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get all active downtimes for the specified monitor. + * + * @param monitorId The id of the monitor. (required) + * @return ApiResponse<MonitorDowntimeMatchResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
404 Monitor Not Found error -
429 Too many requests -
+ */ + public ApiResponse listMonitorDowntimesWithHttpInfo(Long monitorId) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "listMonitorDowntimes"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'monitorId' is set + if (monitorId == null) { + throw new ApiException( + 400, "Missing the required parameter 'monitorId' when calling listMonitorDowntimes"); + } + // create path and map variables + String localVarPath = + "/api/v2/monitor/{monitor_id}/downtime_matches" + .replaceAll("\\{" + "monitor_id" + "\\}", apiClient.escapeString(monitorId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DowntimesApi.listMonitorDowntimes", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get active downtimes for a monitor. + * + *

See {@link #listMonitorDowntimesWithHttpInfo}. + * + * @param monitorId The id of the monitor. (required) + * @return CompletableFuture<ApiResponse<MonitorDowntimeMatchResponse>> + */ + public CompletableFuture> + listMonitorDowntimesWithHttpInfoAsync(Long monitorId) { + // Check if unstable operation is enabled + String operationId = "listMonitorDowntimes"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'monitorId' is set + if (monitorId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'monitorId' when calling listMonitorDowntimes")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/monitor/{monitor_id}/downtime_matches" + .replaceAll("\\{" + "monitor_id" + "\\}", apiClient.escapeString(monitorId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DowntimesApi.listMonitorDowntimes", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update a downtime. + * + *

See {@link #updateDowntimeWithHttpInfo}. + * + * @param downtimeId ID of the downtime to update. (required) + * @param body Update a downtime request body. (required) + * @return DowntimeResponse + * @throws ApiException if fails to make API call + */ + public DowntimeResponse updateDowntime(String downtimeId, DowntimeUpdateRequest body) + throws ApiException { + return updateDowntimeWithHttpInfo(downtimeId, body).getData(); + } + + /** + * Update a downtime. + * + *

See {@link #updateDowntimeWithHttpInfoAsync}. + * + * @param downtimeId ID of the downtime to update. (required) + * @param body Update a downtime request body. (required) + * @return CompletableFuture<DowntimeResponse> + */ + public CompletableFuture updateDowntimeAsync( + String downtimeId, DowntimeUpdateRequest body) { + return updateDowntimeWithHttpInfoAsync(downtimeId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Update a downtime by downtime_id. + * + * @param downtimeId ID of the downtime to update. (required) + * @param body Update a downtime request body. (required) + * @return ApiResponse<DowntimeResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Downtime not found -
429 Too many requests -
+ */ + public ApiResponse updateDowntimeWithHttpInfo( + String downtimeId, DowntimeUpdateRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "updateDowntime"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'downtimeId' is set + if (downtimeId == null) { + throw new ApiException( + 400, "Missing the required parameter 'downtimeId' when calling updateDowntime"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling updateDowntime"); + } + // create path and map variables + String localVarPath = + "/api/v2/downtime/{downtime_id}" + .replaceAll( + "\\{" + "downtime_id" + "\\}", apiClient.escapeString(downtimeId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DowntimesApi.updateDowntime", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update a downtime. + * + *

See {@link #updateDowntimeWithHttpInfo}. + * + * @param downtimeId ID of the downtime to update. (required) + * @param body Update a downtime request body. (required) + * @return CompletableFuture<ApiResponse<DowntimeResponse>> + */ + public CompletableFuture> updateDowntimeWithHttpInfoAsync( + String downtimeId, DowntimeUpdateRequest body) { + // Check if unstable operation is enabled + String operationId = "updateDowntime"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'downtimeId' is set + if (downtimeId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'downtimeId' when calling updateDowntime")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling updateDowntime")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/downtime/{downtime_id}" + .replaceAll( + "\\{" + "downtime_id" + "\\}", apiClient.escapeString(downtimeId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DowntimesApi.updateDowntime", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequest.java new file mode 100644 index 00000000000..38000d75780 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequest.java @@ -0,0 +1,145 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request for creating a downtime. */ +@JsonPropertyOrder({DowntimeCreateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private DowntimeCreateRequestData data; + + public DowntimeCreateRequest() {} + + @JsonCreator + public DowntimeCreateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) DowntimeCreateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public DowntimeCreateRequest data(DowntimeCreateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object to create a downtime. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DowntimeCreateRequestData getData() { + return data; + } + + public void setData(DowntimeCreateRequestData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeCreateRequest + */ + @JsonAnySetter + public DowntimeCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeCreateRequest downtimeCreateRequest = (DowntimeCreateRequest) o; + return Objects.equals(this.data, downtimeCreateRequest.data) + && Objects.equals(this.additionalProperties, downtimeCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeCreateRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequestAttributes.java new file mode 100644 index 00000000000..267a4923fc8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequestAttributes.java @@ -0,0 +1,407 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Downtime details. */ +@JsonPropertyOrder({ + DowntimeCreateRequestAttributes.JSON_PROPERTY_DISPLAY_TIMEZONE, + DowntimeCreateRequestAttributes.JSON_PROPERTY_MESSAGE, + DowntimeCreateRequestAttributes.JSON_PROPERTY_MONITOR_IDENTIFIER, + DowntimeCreateRequestAttributes.JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION, + DowntimeCreateRequestAttributes.JSON_PROPERTY_NOTIFY_END_STATES, + DowntimeCreateRequestAttributes.JSON_PROPERTY_NOTIFY_END_TYPES, + DowntimeCreateRequestAttributes.JSON_PROPERTY_SCHEDULE, + DowntimeCreateRequestAttributes.JSON_PROPERTY_SCOPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeCreateRequestAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DISPLAY_TIMEZONE = "display_timezone"; + private JsonNullable displayTimezone = JsonNullable.of("UTC"); + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private JsonNullable message = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_MONITOR_IDENTIFIER = "monitor_identifier"; + private DowntimeMonitorIdentifier monitorIdentifier; + + public static final String JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION = + "mute_first_recovery_notification"; + private Boolean muteFirstRecoveryNotification; + + public static final String JSON_PROPERTY_NOTIFY_END_STATES = "notify_end_states"; + private List notifyEndStates = null; + + public static final String JSON_PROPERTY_NOTIFY_END_TYPES = "notify_end_types"; + private List notifyEndTypes = null; + + public static final String JSON_PROPERTY_SCHEDULE = "schedule"; + private DowntimeScheduleCreateRequest schedule; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private String scope; + + public DowntimeCreateRequestAttributes() {} + + @JsonCreator + public DowntimeCreateRequestAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_MONITOR_IDENTIFIER) + DowntimeMonitorIdentifier monitorIdentifier, + @JsonProperty(required = true, value = JSON_PROPERTY_SCOPE) String scope) { + this.monitorIdentifier = monitorIdentifier; + this.unparsed |= monitorIdentifier.unparsed; + this.scope = scope; + } + + public DowntimeCreateRequestAttributes displayTimezone(String displayTimezone) { + this.displayTimezone = JsonNullable.of(displayTimezone); + return this; + } + + /** + * 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. + * + * @return displayTimezone + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getDisplayTimezone() { + return displayTimezone.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DISPLAY_TIMEZONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getDisplayTimezone_JsonNullable() { + return displayTimezone; + } + + @JsonProperty(JSON_PROPERTY_DISPLAY_TIMEZONE) + public void setDisplayTimezone_JsonNullable(JsonNullable displayTimezone) { + this.displayTimezone = displayTimezone; + } + + public void setDisplayTimezone(String displayTimezone) { + this.displayTimezone = JsonNullable.of(displayTimezone); + } + + public DowntimeCreateRequestAttributes message(String message) { + this.message = JsonNullable.of(message); + return this; + } + + /** + * 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. + * + * @return message + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getMessage() { + return message.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getMessage_JsonNullable() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + public void setMessage_JsonNullable(JsonNullable message) { + this.message = message; + } + + public void setMessage(String message) { + this.message = JsonNullable.of(message); + } + + public DowntimeCreateRequestAttributes monitorIdentifier( + DowntimeMonitorIdentifier monitorIdentifier) { + this.monitorIdentifier = monitorIdentifier; + this.unparsed |= monitorIdentifier.unparsed; + return this; + } + + /** + * Monitor identifier for the downtime. + * + * @return monitorIdentifier + */ + @JsonProperty(JSON_PROPERTY_MONITOR_IDENTIFIER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DowntimeMonitorIdentifier getMonitorIdentifier() { + return monitorIdentifier; + } + + public void setMonitorIdentifier(DowntimeMonitorIdentifier monitorIdentifier) { + this.monitorIdentifier = monitorIdentifier; + } + + public DowntimeCreateRequestAttributes muteFirstRecoveryNotification( + Boolean muteFirstRecoveryNotification) { + this.muteFirstRecoveryNotification = muteFirstRecoveryNotification; + return this; + } + + /** + * If the first recovery notification during a downtime should be muted. + * + * @return muteFirstRecoveryNotification + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getMuteFirstRecoveryNotification() { + return muteFirstRecoveryNotification; + } + + public void setMuteFirstRecoveryNotification(Boolean muteFirstRecoveryNotification) { + this.muteFirstRecoveryNotification = muteFirstRecoveryNotification; + } + + public DowntimeCreateRequestAttributes notifyEndStates( + List notifyEndStates) { + this.notifyEndStates = notifyEndStates; + return this; + } + + public DowntimeCreateRequestAttributes addNotifyEndStatesItem( + DowntimeNotifyEndStateTypes notifyEndStatesItem) { + if (this.notifyEndStates == null) { + this.notifyEndStates = new ArrayList<>(); + } + this.notifyEndStates.add(notifyEndStatesItem); + this.unparsed |= !notifyEndStatesItem.isValid(); + return this; + } + + /** + * States that will trigger a monitor notification when the notify_end_types action + * occurs. + * + * @return notifyEndStates + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NOTIFY_END_STATES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getNotifyEndStates() { + return notifyEndStates; + } + + public void setNotifyEndStates(List notifyEndStates) { + this.notifyEndStates = notifyEndStates; + } + + public DowntimeCreateRequestAttributes notifyEndTypes( + List notifyEndTypes) { + this.notifyEndTypes = notifyEndTypes; + return this; + } + + public DowntimeCreateRequestAttributes addNotifyEndTypesItem( + DowntimeNotifyEndStateActions notifyEndTypesItem) { + if (this.notifyEndTypes == null) { + this.notifyEndTypes = new ArrayList<>(); + } + this.notifyEndTypes.add(notifyEndTypesItem); + this.unparsed |= !notifyEndTypesItem.isValid(); + return this; + } + + /** + * Actions that will trigger a monitor notification if the downtime is in the + * notify_end_types state. + * + * @return notifyEndTypes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NOTIFY_END_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getNotifyEndTypes() { + return notifyEndTypes; + } + + public void setNotifyEndTypes(List notifyEndTypes) { + this.notifyEndTypes = notifyEndTypes; + } + + public DowntimeCreateRequestAttributes schedule(DowntimeScheduleCreateRequest schedule) { + this.schedule = schedule; + this.unparsed |= schedule.unparsed; + return this; + } + + /** + * Schedule for the downtime. + * + * @return schedule + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCHEDULE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeScheduleCreateRequest getSchedule() { + return schedule; + } + + public void setSchedule(DowntimeScheduleCreateRequest schedule) { + this.schedule = schedule; + } + + public DowntimeCreateRequestAttributes scope(String scope) { + this.scope = scope; + return this; + } + + /** + * The scope to which the downtime applies. Must follow the common search syntax. + * + * @return scope + */ + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeCreateRequestAttributes + */ + @JsonAnySetter + public DowntimeCreateRequestAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeCreateRequestAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeCreateRequestAttributes downtimeCreateRequestAttributes = + (DowntimeCreateRequestAttributes) o; + return Objects.equals(this.displayTimezone, downtimeCreateRequestAttributes.displayTimezone) + && Objects.equals(this.message, downtimeCreateRequestAttributes.message) + && Objects.equals(this.monitorIdentifier, downtimeCreateRequestAttributes.monitorIdentifier) + && Objects.equals( + this.muteFirstRecoveryNotification, + downtimeCreateRequestAttributes.muteFirstRecoveryNotification) + && Objects.equals(this.notifyEndStates, downtimeCreateRequestAttributes.notifyEndStates) + && Objects.equals(this.notifyEndTypes, downtimeCreateRequestAttributes.notifyEndTypes) + && Objects.equals(this.schedule, downtimeCreateRequestAttributes.schedule) + && Objects.equals(this.scope, downtimeCreateRequestAttributes.scope) + && Objects.equals( + this.additionalProperties, downtimeCreateRequestAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + displayTimezone, + message, + monitorIdentifier, + muteFirstRecoveryNotification, + notifyEndStates, + notifyEndTypes, + schedule, + scope, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeCreateRequestAttributes {\n"); + sb.append(" displayTimezone: ").append(toIndentedString(displayTimezone)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" monitorIdentifier: ").append(toIndentedString(monitorIdentifier)).append("\n"); + sb.append(" muteFirstRecoveryNotification: ") + .append(toIndentedString(muteFirstRecoveryNotification)) + .append("\n"); + sb.append(" notifyEndStates: ").append(toIndentedString(notifyEndStates)).append("\n"); + sb.append(" notifyEndTypes: ").append(toIndentedString(notifyEndTypes)).append("\n"); + sb.append(" schedule: ").append(toIndentedString(schedule)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequestData.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequestData.java new file mode 100644 index 00000000000..c743fafd723 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeCreateRequestData.java @@ -0,0 +1,182 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Object to create a downtime. */ +@JsonPropertyOrder({ + DowntimeCreateRequestData.JSON_PROPERTY_ATTRIBUTES, + DowntimeCreateRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeCreateRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DowntimeCreateRequestAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DowntimeResourceType type = DowntimeResourceType.DOWNTIME; + + public DowntimeCreateRequestData() {} + + @JsonCreator + public DowntimeCreateRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + DowntimeCreateRequestAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DowntimeResourceType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DowntimeCreateRequestData attributes(DowntimeCreateRequestAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Downtime details. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DowntimeCreateRequestAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DowntimeCreateRequestAttributes attributes) { + this.attributes = attributes; + } + + public DowntimeCreateRequestData type(DowntimeResourceType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Downtime resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DowntimeResourceType getType() { + return type; + } + + public void setType(DowntimeResourceType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeCreateRequestData + */ + @JsonAnySetter + public DowntimeCreateRequestData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeCreateRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeCreateRequestData downtimeCreateRequestData = (DowntimeCreateRequestData) o; + return Objects.equals(this.attributes, downtimeCreateRequestData.attributes) + && Objects.equals(this.type, downtimeCreateRequestData.type) + && Objects.equals( + this.additionalProperties, downtimeCreateRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeCreateRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeIncludedMonitorType.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeIncludedMonitorType.java new file mode 100644 index 00000000000..5b7f6e7f962 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeIncludedMonitorType.java @@ -0,0 +1,94 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** Monitor resource type. */ +@JsonSerialize(using = DowntimeIncludedMonitorType.DowntimeIncludedMonitorTypeSerializer.class) +public class DowntimeIncludedMonitorType { + + public static final DowntimeIncludedMonitorType MONITORS = + new DowntimeIncludedMonitorType("monitors"); + + private static final Set allowedValues = new HashSet(Arrays.asList("monitors")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + DowntimeIncludedMonitorType(String value) { + this.value = value; + } + + public static class DowntimeIncludedMonitorTypeSerializer + extends StdSerializer { + public DowntimeIncludedMonitorTypeSerializer(Class t) { + super(t); + } + + public DowntimeIncludedMonitorTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeIncludedMonitorType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this DowntimeIncludedMonitorType object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((DowntimeIncludedMonitorType) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static DowntimeIncludedMonitorType fromValue(String value) { + return new DowntimeIncludedMonitorType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeMeta.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeMeta.java new file mode 100644 index 00000000000..df51ebc9001 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeMeta.java @@ -0,0 +1,136 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Pagination metadata returned by the API. */ +@JsonPropertyOrder({DowntimeMeta.JSON_PROPERTY_PAGE}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeMeta { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_PAGE = "page"; + private DowntimeMetaPage page; + + public DowntimeMeta page(DowntimeMetaPage page) { + this.page = page; + this.unparsed |= page.unparsed; + return this; + } + + /** + * Object containing the total filtered count. + * + * @return page + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeMetaPage getPage() { + return page; + } + + public void setPage(DowntimeMetaPage page) { + this.page = page; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeMeta + */ + @JsonAnySetter + public DowntimeMeta putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeMeta object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeMeta downtimeMeta = (DowntimeMeta) o; + return Objects.equals(this.page, downtimeMeta.page) + && Objects.equals(this.additionalProperties, downtimeMeta.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(page, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeMeta {\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeMetaPage.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeMetaPage.java new file mode 100644 index 00000000000..97446efa1e8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeMetaPage.java @@ -0,0 +1,135 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Object containing the total filtered count. */ +@JsonPropertyOrder({DowntimeMetaPage.JSON_PROPERTY_TOTAL_FILTERED_COUNT}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeMetaPage { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_TOTAL_FILTERED_COUNT = "total_filtered_count"; + private Long totalFilteredCount; + + public DowntimeMetaPage totalFilteredCount(Long totalFilteredCount) { + this.totalFilteredCount = totalFilteredCount; + return this; + } + + /** + * Total count of elements matched by the filter. + * + * @return totalFilteredCount + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TOTAL_FILTERED_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getTotalFilteredCount() { + return totalFilteredCount; + } + + public void setTotalFilteredCount(Long totalFilteredCount) { + this.totalFilteredCount = totalFilteredCount; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeMetaPage + */ + @JsonAnySetter + public DowntimeMetaPage putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeMetaPage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeMetaPage downtimeMetaPage = (DowntimeMetaPage) o; + return Objects.equals(this.totalFilteredCount, downtimeMetaPage.totalFilteredCount) + && Objects.equals(this.additionalProperties, downtimeMetaPage.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(totalFilteredCount, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeMetaPage {\n"); + sb.append(" totalFilteredCount: ").append(toIndentedString(totalFilteredCount)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifier.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifier.java new file mode 100644 index 00000000000..a1b40af0a9b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifier.java @@ -0,0 +1,284 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize(using = DowntimeMonitorIdentifier.DowntimeMonitorIdentifierDeserializer.class) +@JsonSerialize(using = DowntimeMonitorIdentifier.DowntimeMonitorIdentifierSerializer.class) +public class DowntimeMonitorIdentifier extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DowntimeMonitorIdentifier.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DowntimeMonitorIdentifierSerializer + extends StdSerializer { + public DowntimeMonitorIdentifierSerializer(Class t) { + super(t); + } + + public DowntimeMonitorIdentifierSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeMonitorIdentifier value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DowntimeMonitorIdentifierDeserializer + extends StdDeserializer { + public DowntimeMonitorIdentifierDeserializer() { + this(DowntimeMonitorIdentifier.class); + } + + public DowntimeMonitorIdentifierDeserializer(Class vc) { + super(vc); + } + + @Override + public DowntimeMonitorIdentifier deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize DowntimeMonitorIdentifierId + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeMonitorIdentifierId.class.equals(Integer.class) + || DowntimeMonitorIdentifierId.class.equals(Long.class) + || DowntimeMonitorIdentifierId.class.equals(Float.class) + || DowntimeMonitorIdentifierId.class.equals(Double.class) + || DowntimeMonitorIdentifierId.class.equals(Boolean.class) + || DowntimeMonitorIdentifierId.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeMonitorIdentifierId.class.equals(Integer.class) + || DowntimeMonitorIdentifierId.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeMonitorIdentifierId.class.equals(Float.class) + || DowntimeMonitorIdentifierId.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeMonitorIdentifierId.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeMonitorIdentifierId.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DowntimeMonitorIdentifierId.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeMonitorIdentifierId) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DowntimeMonitorIdentifierId'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DowntimeMonitorIdentifierId'", e); + } + + // deserialize DowntimeMonitorIdentifierTags + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeMonitorIdentifierTags.class.equals(Integer.class) + || DowntimeMonitorIdentifierTags.class.equals(Long.class) + || DowntimeMonitorIdentifierTags.class.equals(Float.class) + || DowntimeMonitorIdentifierTags.class.equals(Double.class) + || DowntimeMonitorIdentifierTags.class.equals(Boolean.class) + || DowntimeMonitorIdentifierTags.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeMonitorIdentifierTags.class.equals(Integer.class) + || DowntimeMonitorIdentifierTags.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeMonitorIdentifierTags.class.equals(Float.class) + || DowntimeMonitorIdentifierTags.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeMonitorIdentifierTags.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeMonitorIdentifierTags.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DowntimeMonitorIdentifierTags.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeMonitorIdentifierTags) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DowntimeMonitorIdentifierTags'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DowntimeMonitorIdentifierTags'", e); + } + + DowntimeMonitorIdentifier ret = new DowntimeMonitorIdentifier(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public DowntimeMonitorIdentifier getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DowntimeMonitorIdentifier cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DowntimeMonitorIdentifier() { + super("oneOf", Boolean.FALSE); + } + + public DowntimeMonitorIdentifier(DowntimeMonitorIdentifierId o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DowntimeMonitorIdentifier(DowntimeMonitorIdentifierTags o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("DowntimeMonitorIdentifierId", new GenericType() {}); + schemas.put( + "DowntimeMonitorIdentifierTags", new GenericType() {}); + JSON.registerDescendants(DowntimeMonitorIdentifier.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DowntimeMonitorIdentifier.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: DowntimeMonitorIdentifierId, DowntimeMonitorIdentifierTags + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(DowntimeMonitorIdentifierId.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(DowntimeMonitorIdentifierTags.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException( + "Invalid instance type. Must be DowntimeMonitorIdentifierId," + + " DowntimeMonitorIdentifierTags"); + } + + /** + * Get the actual instance, which can be the following: DowntimeMonitorIdentifierId, + * DowntimeMonitorIdentifierTags + * + * @return The actual instance (DowntimeMonitorIdentifierId, DowntimeMonitorIdentifierTags) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeMonitorIdentifierId`. If the actual instance is not + * `DowntimeMonitorIdentifierId`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeMonitorIdentifierId` + * @throws ClassCastException if the instance is not `DowntimeMonitorIdentifierId` + */ + public DowntimeMonitorIdentifierId getDowntimeMonitorIdentifierId() throws ClassCastException { + return (DowntimeMonitorIdentifierId) super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeMonitorIdentifierTags`. If the actual instance is not + * `DowntimeMonitorIdentifierTags`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeMonitorIdentifierTags` + * @throws ClassCastException if the instance is not `DowntimeMonitorIdentifierTags` + */ + public DowntimeMonitorIdentifierTags getDowntimeMonitorIdentifierTags() + throws ClassCastException { + return (DowntimeMonitorIdentifierTags) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifierId.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifierId.java new file mode 100644 index 00000000000..9af93ff5903 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifierId.java @@ -0,0 +1,89 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** Object of the monitor identifier. */ +@JsonPropertyOrder({DowntimeMonitorIdentifierId.JSON_PROPERTY_MONITOR_ID}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeMonitorIdentifierId { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_MONITOR_ID = "monitor_id"; + private Long monitorId; + + public DowntimeMonitorIdentifierId() {} + + @JsonCreator + public DowntimeMonitorIdentifierId( + @JsonProperty(required = true, value = JSON_PROPERTY_MONITOR_ID) Long monitorId) { + this.monitorId = monitorId; + } + + public DowntimeMonitorIdentifierId monitorId(Long monitorId) { + this.monitorId = monitorId; + return this; + } + + /** + * ID of the monitor to prevent notifications. + * + * @return monitorId + */ + @JsonProperty(JSON_PROPERTY_MONITOR_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getMonitorId() { + return monitorId; + } + + public void setMonitorId(Long monitorId) { + this.monitorId = monitorId; + } + + /** Return true if this DowntimeMonitorIdentifierId object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeMonitorIdentifierId downtimeMonitorIdentifierId = (DowntimeMonitorIdentifierId) o; + return Objects.equals(this.monitorId, downtimeMonitorIdentifierId.monitorId); + } + + @Override + public int hashCode() { + return Objects.hash(monitorId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeMonitorIdentifierId {\n"); + sb.append(" monitorId: ").append(toIndentedString(monitorId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifierTags.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifierTags.java new file mode 100644 index 00000000000..23237d14f2f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIdentifierTags.java @@ -0,0 +1,100 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Object of the monitor tags. */ +@JsonPropertyOrder({DowntimeMonitorIdentifierTags.JSON_PROPERTY_MONITOR_TAGS}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeMonitorIdentifierTags { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_MONITOR_TAGS = "monitor_tags"; + private List monitorTags = new ArrayList<>(); + + public DowntimeMonitorIdentifierTags() {} + + @JsonCreator + public DowntimeMonitorIdentifierTags( + @JsonProperty(required = true, value = JSON_PROPERTY_MONITOR_TAGS) List monitorTags) { + this.monitorTags = monitorTags; + } + + public DowntimeMonitorIdentifierTags monitorTags(List monitorTags) { + this.monitorTags = monitorTags; + return this; + } + + public DowntimeMonitorIdentifierTags addMonitorTagsItem(String monitorTagsItem) { + this.monitorTags.add(monitorTagsItem); + return this; + } + + /** + * 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. Setting monitor_tags to [*] configures the downtime to + * mute all monitors for the given scope. + * + * @return monitorTags + */ + @JsonProperty(JSON_PROPERTY_MONITOR_TAGS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getMonitorTags() { + return monitorTags; + } + + public void setMonitorTags(List monitorTags) { + this.monitorTags = monitorTags; + } + + /** Return true if this DowntimeMonitorIdentifierTags object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeMonitorIdentifierTags downtimeMonitorIdentifierTags = (DowntimeMonitorIdentifierTags) o; + return Objects.equals(this.monitorTags, downtimeMonitorIdentifierTags.monitorTags); + } + + @Override + public int hashCode() { + return Objects.hash(monitorTags); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeMonitorIdentifierTags {\n"); + sb.append(" monitorTags: ").append(toIndentedString(monitorTags)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIncludedAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIncludedAttributes.java new file mode 100644 index 00000000000..d892e9148f4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIncludedAttributes.java @@ -0,0 +1,137 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes of the monitor identified by the downtime. */ +@JsonPropertyOrder({DowntimeMonitorIncludedAttributes.JSON_PROPERTY_NAME}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeMonitorIncludedAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public DowntimeMonitorIncludedAttributes name(String name) { + this.name = name; + return this; + } + + /** + * The name of the monitor identified by the downtime. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeMonitorIncludedAttributes + */ + @JsonAnySetter + public DowntimeMonitorIncludedAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeMonitorIncludedAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeMonitorIncludedAttributes downtimeMonitorIncludedAttributes = + (DowntimeMonitorIncludedAttributes) o; + return Objects.equals(this.name, downtimeMonitorIncludedAttributes.name) + && Objects.equals( + this.additionalProperties, downtimeMonitorIncludedAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeMonitorIncludedAttributes {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIncludedItem.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIncludedItem.java new file mode 100644 index 00000000000..ff4e68d30ed --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeMonitorIncludedItem.java @@ -0,0 +1,197 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Information about the monitor identified by the downtime. */ +@JsonPropertyOrder({ + DowntimeMonitorIncludedItem.JSON_PROPERTY_ATTRIBUTES, + DowntimeMonitorIncludedItem.JSON_PROPERTY_ID, + DowntimeMonitorIncludedItem.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeMonitorIncludedItem { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DowntimeMonitorIncludedAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DowntimeIncludedMonitorType type = DowntimeIncludedMonitorType.MONITORS; + + public DowntimeMonitorIncludedItem attributes(DowntimeMonitorIncludedAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of the monitor identified by the downtime. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeMonitorIncludedAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DowntimeMonitorIncludedAttributes attributes) { + this.attributes = attributes; + } + + public DowntimeMonitorIncludedItem id(Long id) { + this.id = id; + return this; + } + + /** + * ID of the monitor identified by the downtime. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public DowntimeMonitorIncludedItem type(DowntimeIncludedMonitorType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Monitor resource type. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeIncludedMonitorType getType() { + return type; + } + + public void setType(DowntimeIncludedMonitorType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeMonitorIncludedItem + */ + @JsonAnySetter + public DowntimeMonitorIncludedItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeMonitorIncludedItem object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeMonitorIncludedItem downtimeMonitorIncludedItem = (DowntimeMonitorIncludedItem) o; + return Objects.equals(this.attributes, downtimeMonitorIncludedItem.attributes) + && Objects.equals(this.id, downtimeMonitorIncludedItem.id) + && Objects.equals(this.type, downtimeMonitorIncludedItem.type) + && Objects.equals( + this.additionalProperties, downtimeMonitorIncludedItem.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeMonitorIncludedItem {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeNotifyEndStateActions.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeNotifyEndStateActions.java new file mode 100644 index 00000000000..f85a43f0e66 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeNotifyEndStateActions.java @@ -0,0 +1,100 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** + * Action that will trigger a monitor notification if the downtime is in the notify_end_types + * state. + */ +@JsonSerialize(using = DowntimeNotifyEndStateActions.DowntimeNotifyEndStateActionsSerializer.class) +public class DowntimeNotifyEndStateActions { + + public static final DowntimeNotifyEndStateActions CANCELED = + new DowntimeNotifyEndStateActions("canceled"); + public static final DowntimeNotifyEndStateActions EXPIRED = + new DowntimeNotifyEndStateActions("expired"); + + private static final Set allowedValues = + new HashSet(Arrays.asList("canceled", "expired")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + DowntimeNotifyEndStateActions(String value) { + this.value = value; + } + + public static class DowntimeNotifyEndStateActionsSerializer + extends StdSerializer { + public DowntimeNotifyEndStateActionsSerializer(Class t) { + super(t); + } + + public DowntimeNotifyEndStateActionsSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeNotifyEndStateActions value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this DowntimeNotifyEndStateActions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((DowntimeNotifyEndStateActions) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static DowntimeNotifyEndStateActions fromValue(String value) { + return new DowntimeNotifyEndStateActions(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeNotifyEndStateTypes.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeNotifyEndStateTypes.java new file mode 100644 index 00000000000..b6683506930 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeNotifyEndStateTypes.java @@ -0,0 +1,100 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** + * State that will trigger a monitor notification when the notify_end_types action + * occurs. + */ +@JsonSerialize(using = DowntimeNotifyEndStateTypes.DowntimeNotifyEndStateTypesSerializer.class) +public class DowntimeNotifyEndStateTypes { + + public static final DowntimeNotifyEndStateTypes ALERT = new DowntimeNotifyEndStateTypes("alert"); + public static final DowntimeNotifyEndStateTypes NO_DATA = + new DowntimeNotifyEndStateTypes("no data"); + public static final DowntimeNotifyEndStateTypes WARN = new DowntimeNotifyEndStateTypes("warn"); + + private static final Set allowedValues = + new HashSet(Arrays.asList("alert", "no data", "warn")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + DowntimeNotifyEndStateTypes(String value) { + this.value = value; + } + + public static class DowntimeNotifyEndStateTypesSerializer + extends StdSerializer { + public DowntimeNotifyEndStateTypesSerializer(Class t) { + super(t); + } + + public DowntimeNotifyEndStateTypesSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeNotifyEndStateTypes value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this DowntimeNotifyEndStateTypes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((DowntimeNotifyEndStateTypes) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static DowntimeNotifyEndStateTypes fromValue(String value) { + return new DowntimeNotifyEndStateTypes(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationships.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationships.java new file mode 100644 index 00000000000..75140c10299 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationships.java @@ -0,0 +1,166 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** All relationships associated with downtime. */ +@JsonPropertyOrder({ + DowntimeRelationships.JSON_PROPERTY_CREATED_BY, + DowntimeRelationships.JSON_PROPERTY_MONITOR +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeRelationships { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CREATED_BY = "created_by"; + private DowntimeRelationshipsCreatedBy createdBy; + + public static final String JSON_PROPERTY_MONITOR = "monitor"; + private DowntimeRelationshipsMonitor monitor; + + public DowntimeRelationships createdBy(DowntimeRelationshipsCreatedBy createdBy) { + this.createdBy = createdBy; + this.unparsed |= createdBy.unparsed; + return this; + } + + /** + * The user who created the downtime. + * + * @return createdBy + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_BY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeRelationshipsCreatedBy getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(DowntimeRelationshipsCreatedBy createdBy) { + this.createdBy = createdBy; + } + + public DowntimeRelationships monitor(DowntimeRelationshipsMonitor monitor) { + this.monitor = monitor; + this.unparsed |= monitor.unparsed; + return this; + } + + /** + * The monitor identified by the downtime. + * + * @return monitor + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MONITOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeRelationshipsMonitor getMonitor() { + return monitor; + } + + public void setMonitor(DowntimeRelationshipsMonitor monitor) { + this.monitor = monitor; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeRelationships + */ + @JsonAnySetter + public DowntimeRelationships putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeRelationships object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeRelationships downtimeRelationships = (DowntimeRelationships) o; + return Objects.equals(this.createdBy, downtimeRelationships.createdBy) + && Objects.equals(this.monitor, downtimeRelationships.monitor) + && Objects.equals(this.additionalProperties, downtimeRelationships.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createdBy, monitor, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeRelationships {\n"); + sb.append(" createdBy: ").append(toIndentedString(createdBy)).append("\n"); + sb.append(" monitor: ").append(toIndentedString(monitor)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsCreatedBy.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsCreatedBy.java new file mode 100644 index 00000000000..eb0c74b1956 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsCreatedBy.java @@ -0,0 +1,149 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** The user who created the downtime. */ +@JsonPropertyOrder({DowntimeRelationshipsCreatedBy.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeRelationshipsCreatedBy { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private JsonNullable data = + JsonNullable.undefined(); + + public DowntimeRelationshipsCreatedBy data(DowntimeRelationshipsCreatedByData data) { + this.data = JsonNullable.of(data); + return this; + } + + /** + * Data for the user who created the downtime. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonIgnore + public DowntimeRelationshipsCreatedByData getData() { + return data.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getData_JsonNullable() { + return data; + } + + @JsonProperty(JSON_PROPERTY_DATA) + public void setData_JsonNullable(JsonNullable data) { + this.data = data; + } + + public void setData(DowntimeRelationshipsCreatedByData data) { + this.data = JsonNullable.of(data); + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeRelationshipsCreatedBy + */ + @JsonAnySetter + public DowntimeRelationshipsCreatedBy putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeRelationshipsCreatedBy object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeRelationshipsCreatedBy downtimeRelationshipsCreatedBy = + (DowntimeRelationshipsCreatedBy) o; + return Objects.equals(this.data, downtimeRelationshipsCreatedBy.data) + && Objects.equals( + this.additionalProperties, downtimeRelationshipsCreatedBy.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeRelationshipsCreatedBy {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsCreatedByData.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsCreatedByData.java new file mode 100644 index 00000000000..feacd0e39e4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsCreatedByData.java @@ -0,0 +1,170 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Data for the user who created the downtime. */ +@JsonPropertyOrder({ + DowntimeRelationshipsCreatedByData.JSON_PROPERTY_ID, + DowntimeRelationshipsCreatedByData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeRelationshipsCreatedByData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private UsersType type = UsersType.USERS; + + public DowntimeRelationshipsCreatedByData id(String id) { + this.id = id; + return this; + } + + /** + * User ID of the downtime creator. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public DowntimeRelationshipsCreatedByData type(UsersType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Users resource type. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UsersType getType() { + return type; + } + + public void setType(UsersType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeRelationshipsCreatedByData + */ + @JsonAnySetter + public DowntimeRelationshipsCreatedByData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeRelationshipsCreatedByData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeRelationshipsCreatedByData downtimeRelationshipsCreatedByData = + (DowntimeRelationshipsCreatedByData) o; + return Objects.equals(this.id, downtimeRelationshipsCreatedByData.id) + && Objects.equals(this.type, downtimeRelationshipsCreatedByData.type) + && Objects.equals( + this.additionalProperties, downtimeRelationshipsCreatedByData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeRelationshipsCreatedByData {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsMonitor.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsMonitor.java new file mode 100644 index 00000000000..6220bb7d69c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsMonitor.java @@ -0,0 +1,148 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** The monitor identified by the downtime. */ +@JsonPropertyOrder({DowntimeRelationshipsMonitor.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeRelationshipsMonitor { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private JsonNullable data = + JsonNullable.undefined(); + + public DowntimeRelationshipsMonitor data(DowntimeRelationshipsMonitorData data) { + this.data = JsonNullable.of(data); + return this; + } + + /** + * Data for the monitor. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonIgnore + public DowntimeRelationshipsMonitorData getData() { + return data.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getData_JsonNullable() { + return data; + } + + @JsonProperty(JSON_PROPERTY_DATA) + public void setData_JsonNullable(JsonNullable data) { + this.data = data; + } + + public void setData(DowntimeRelationshipsMonitorData data) { + this.data = JsonNullable.of(data); + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeRelationshipsMonitor + */ + @JsonAnySetter + public DowntimeRelationshipsMonitor putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeRelationshipsMonitor object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeRelationshipsMonitor downtimeRelationshipsMonitor = (DowntimeRelationshipsMonitor) o; + return Objects.equals(this.data, downtimeRelationshipsMonitor.data) + && Objects.equals( + this.additionalProperties, downtimeRelationshipsMonitor.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeRelationshipsMonitor {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsMonitorData.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsMonitorData.java new file mode 100644 index 00000000000..8468b97b605 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeRelationshipsMonitorData.java @@ -0,0 +1,170 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Data for the monitor. */ +@JsonPropertyOrder({ + DowntimeRelationshipsMonitorData.JSON_PROPERTY_ID, + DowntimeRelationshipsMonitorData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeRelationshipsMonitorData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DowntimeIncludedMonitorType type = DowntimeIncludedMonitorType.MONITORS; + + public DowntimeRelationshipsMonitorData id(Long id) { + this.id = id; + return this; + } + + /** + * Monitor ID of the downtime. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public DowntimeRelationshipsMonitorData type(DowntimeIncludedMonitorType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Monitor resource type. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeIncludedMonitorType getType() { + return type; + } + + public void setType(DowntimeIncludedMonitorType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeRelationshipsMonitorData + */ + @JsonAnySetter + public DowntimeRelationshipsMonitorData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeRelationshipsMonitorData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeRelationshipsMonitorData downtimeRelationshipsMonitorData = + (DowntimeRelationshipsMonitorData) o; + return Objects.equals(this.id, downtimeRelationshipsMonitorData.id) + && Objects.equals(this.type, downtimeRelationshipsMonitorData.type) + && Objects.equals( + this.additionalProperties, downtimeRelationshipsMonitorData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeRelationshipsMonitorData {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeResourceType.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeResourceType.java new file mode 100644 index 00000000000..bea3716b8e3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeResourceType.java @@ -0,0 +1,92 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** Downtime resource type. */ +@JsonSerialize(using = DowntimeResourceType.DowntimeResourceTypeSerializer.class) +public class DowntimeResourceType { + + public static final DowntimeResourceType DOWNTIME = new DowntimeResourceType("downtime"); + + private static final Set allowedValues = new HashSet(Arrays.asList("downtime")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + DowntimeResourceType(String value) { + this.value = value; + } + + public static class DowntimeResourceTypeSerializer extends StdSerializer { + public DowntimeResourceTypeSerializer(Class t) { + super(t); + } + + public DowntimeResourceTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeResourceType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this DowntimeResourceType object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((DowntimeResourceType) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static DowntimeResourceType fromValue(String value) { + return new DowntimeResourceType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeResponse.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponse.java new file mode 100644 index 00000000000..811936ab858 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponse.java @@ -0,0 +1,180 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 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. + */ +@JsonPropertyOrder({DowntimeResponse.JSON_PROPERTY_DATA, DowntimeResponse.JSON_PROPERTY_INCLUDED}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private DowntimeResponseData data; + + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + + public DowntimeResponse data(DowntimeResponseData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Downtime data. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeResponseData getData() { + return data; + } + + public void setData(DowntimeResponseData data) { + this.data = data; + } + + public DowntimeResponse included(List included) { + this.included = included; + for (DowntimeResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + return this; + } + + public DowntimeResponse addIncludedItem(DowntimeResponseIncludedItem includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * Array of objects related to the downtime that the user requested. + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeResponse + */ + @JsonAnySetter + public DowntimeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeResponse downtimeResponse = (DowntimeResponse) o; + return Objects.equals(this.data, downtimeResponse.data) + && Objects.equals(this.included, downtimeResponse.included) + && Objects.equals(this.additionalProperties, downtimeResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, included, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseAttributes.java new file mode 100644 index 00000000000..9a6b33121ab --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseAttributes.java @@ -0,0 +1,485 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Downtime details. */ +@JsonPropertyOrder({ + DowntimeResponseAttributes.JSON_PROPERTY_CREATED_AT, + DowntimeResponseAttributes.JSON_PROPERTY_DISPLAY_TIMEZONE, + DowntimeResponseAttributes.JSON_PROPERTY_MESSAGE, + DowntimeResponseAttributes.JSON_PROPERTY_MODIFIED_AT, + DowntimeResponseAttributes.JSON_PROPERTY_MONITOR_IDENTIFIER, + DowntimeResponseAttributes.JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION, + DowntimeResponseAttributes.JSON_PROPERTY_NOTIFY_END_STATES, + DowntimeResponseAttributes.JSON_PROPERTY_NOTIFY_END_TYPES, + DowntimeResponseAttributes.JSON_PROPERTY_SCHEDULE, + DowntimeResponseAttributes.JSON_PROPERTY_SCOPE, + DowntimeResponseAttributes.JSON_PROPERTY_STATUS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeResponseAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_DISPLAY_TIMEZONE = "display_timezone"; + private JsonNullable displayTimezone = JsonNullable.of("UTC"); + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private JsonNullable message = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + private OffsetDateTime modifiedAt; + + public static final String JSON_PROPERTY_MONITOR_IDENTIFIER = "monitor_identifier"; + private DowntimeMonitorIdentifier monitorIdentifier; + + public static final String JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION = + "mute_first_recovery_notification"; + private Boolean muteFirstRecoveryNotification; + + public static final String JSON_PROPERTY_NOTIFY_END_STATES = "notify_end_states"; + private List notifyEndStates = null; + + public static final String JSON_PROPERTY_NOTIFY_END_TYPES = "notify_end_types"; + private List notifyEndTypes = null; + + public static final String JSON_PROPERTY_SCHEDULE = "schedule"; + private DowntimeScheduleResponse schedule; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private String scope; + + public static final String JSON_PROPERTY_STATUS = "status"; + private DowntimeStatus status; + + public DowntimeResponseAttributes createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Creation time of the downtime. + * + * @return createdAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public DowntimeResponseAttributes displayTimezone(String displayTimezone) { + this.displayTimezone = JsonNullable.of(displayTimezone); + return this; + } + + /** + * 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. + * + * @return displayTimezone + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getDisplayTimezone() { + return displayTimezone.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DISPLAY_TIMEZONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getDisplayTimezone_JsonNullable() { + return displayTimezone; + } + + @JsonProperty(JSON_PROPERTY_DISPLAY_TIMEZONE) + public void setDisplayTimezone_JsonNullable(JsonNullable displayTimezone) { + this.displayTimezone = displayTimezone; + } + + public void setDisplayTimezone(String displayTimezone) { + this.displayTimezone = JsonNullable.of(displayTimezone); + } + + public DowntimeResponseAttributes message(String message) { + this.message = JsonNullable.of(message); + return this; + } + + /** + * 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. + * + * @return message + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getMessage() { + return message.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getMessage_JsonNullable() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + public void setMessage_JsonNullable(JsonNullable message) { + this.message = message; + } + + public void setMessage(String message) { + this.message = JsonNullable.of(message); + } + + public DowntimeResponseAttributes modifiedAt(OffsetDateTime modifiedAt) { + this.modifiedAt = modifiedAt; + return this; + } + + /** + * Time that the downtime was last modified. + * + * @return modifiedAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getModifiedAt() { + return modifiedAt; + } + + public void setModifiedAt(OffsetDateTime modifiedAt) { + this.modifiedAt = modifiedAt; + } + + public DowntimeResponseAttributes monitorIdentifier(DowntimeMonitorIdentifier monitorIdentifier) { + this.monitorIdentifier = monitorIdentifier; + this.unparsed |= monitorIdentifier.unparsed; + return this; + } + + /** + * Monitor identifier for the downtime. + * + * @return monitorIdentifier + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MONITOR_IDENTIFIER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeMonitorIdentifier getMonitorIdentifier() { + return monitorIdentifier; + } + + public void setMonitorIdentifier(DowntimeMonitorIdentifier monitorIdentifier) { + this.monitorIdentifier = monitorIdentifier; + } + + public DowntimeResponseAttributes muteFirstRecoveryNotification( + Boolean muteFirstRecoveryNotification) { + this.muteFirstRecoveryNotification = muteFirstRecoveryNotification; + return this; + } + + /** + * If the first recovery notification during a downtime should be muted. + * + * @return muteFirstRecoveryNotification + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getMuteFirstRecoveryNotification() { + return muteFirstRecoveryNotification; + } + + public void setMuteFirstRecoveryNotification(Boolean muteFirstRecoveryNotification) { + this.muteFirstRecoveryNotification = muteFirstRecoveryNotification; + } + + public DowntimeResponseAttributes notifyEndStates( + List notifyEndStates) { + this.notifyEndStates = notifyEndStates; + return this; + } + + public DowntimeResponseAttributes addNotifyEndStatesItem( + DowntimeNotifyEndStateTypes notifyEndStatesItem) { + if (this.notifyEndStates == null) { + this.notifyEndStates = new ArrayList<>(); + } + this.notifyEndStates.add(notifyEndStatesItem); + this.unparsed |= !notifyEndStatesItem.isValid(); + return this; + } + + /** + * States that will trigger a monitor notification when the notify_end_types action + * occurs. + * + * @return notifyEndStates + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NOTIFY_END_STATES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getNotifyEndStates() { + return notifyEndStates; + } + + public void setNotifyEndStates(List notifyEndStates) { + this.notifyEndStates = notifyEndStates; + } + + public DowntimeResponseAttributes notifyEndTypes( + List notifyEndTypes) { + this.notifyEndTypes = notifyEndTypes; + return this; + } + + public DowntimeResponseAttributes addNotifyEndTypesItem( + DowntimeNotifyEndStateActions notifyEndTypesItem) { + if (this.notifyEndTypes == null) { + this.notifyEndTypes = new ArrayList<>(); + } + this.notifyEndTypes.add(notifyEndTypesItem); + this.unparsed |= !notifyEndTypesItem.isValid(); + return this; + } + + /** + * Actions that will trigger a monitor notification if the downtime is in the + * notify_end_types state. + * + * @return notifyEndTypes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NOTIFY_END_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getNotifyEndTypes() { + return notifyEndTypes; + } + + public void setNotifyEndTypes(List notifyEndTypes) { + this.notifyEndTypes = notifyEndTypes; + } + + public DowntimeResponseAttributes schedule(DowntimeScheduleResponse schedule) { + this.schedule = schedule; + this.unparsed |= schedule.unparsed; + return this; + } + + /** + * 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 are provided, the downtime will begin immediately and never end. + * + * @return schedule + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCHEDULE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeScheduleResponse getSchedule() { + return schedule; + } + + public void setSchedule(DowntimeScheduleResponse schedule) { + this.schedule = schedule; + } + + public DowntimeResponseAttributes scope(String scope) { + this.scope = scope; + return this; + } + + /** + * The scope to which the downtime applies. Must follow the common search syntax. + * + * @return scope + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public DowntimeResponseAttributes status(DowntimeStatus status) { + this.status = status; + this.unparsed |= !status.isValid(); + return this; + } + + /** + * The current status of the downtime. + * + * @return status + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeStatus getStatus() { + return status; + } + + public void setStatus(DowntimeStatus status) { + if (!status.isValid()) { + this.unparsed = true; + } + this.status = status; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeResponseAttributes + */ + @JsonAnySetter + public DowntimeResponseAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeResponseAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeResponseAttributes downtimeResponseAttributes = (DowntimeResponseAttributes) o; + return Objects.equals(this.createdAt, downtimeResponseAttributes.createdAt) + && Objects.equals(this.displayTimezone, downtimeResponseAttributes.displayTimezone) + && Objects.equals(this.message, downtimeResponseAttributes.message) + && Objects.equals(this.modifiedAt, downtimeResponseAttributes.modifiedAt) + && Objects.equals(this.monitorIdentifier, downtimeResponseAttributes.monitorIdentifier) + && Objects.equals( + this.muteFirstRecoveryNotification, + downtimeResponseAttributes.muteFirstRecoveryNotification) + && Objects.equals(this.notifyEndStates, downtimeResponseAttributes.notifyEndStates) + && Objects.equals(this.notifyEndTypes, downtimeResponseAttributes.notifyEndTypes) + && Objects.equals(this.schedule, downtimeResponseAttributes.schedule) + && Objects.equals(this.scope, downtimeResponseAttributes.scope) + && Objects.equals(this.status, downtimeResponseAttributes.status) + && Objects.equals( + this.additionalProperties, downtimeResponseAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + createdAt, + displayTimezone, + message, + modifiedAt, + monitorIdentifier, + muteFirstRecoveryNotification, + notifyEndStates, + notifyEndTypes, + schedule, + scope, + status, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeResponseAttributes {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" displayTimezone: ").append(toIndentedString(displayTimezone)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); + sb.append(" monitorIdentifier: ").append(toIndentedString(monitorIdentifier)).append("\n"); + sb.append(" muteFirstRecoveryNotification: ") + .append(toIndentedString(muteFirstRecoveryNotification)) + .append("\n"); + sb.append(" notifyEndStates: ").append(toIndentedString(notifyEndStates)).append("\n"); + sb.append(" notifyEndTypes: ").append(toIndentedString(notifyEndTypes)).append("\n"); + sb.append(" schedule: ").append(toIndentedString(schedule)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseData.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseData.java new file mode 100644 index 00000000000..03690a638ff --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseData.java @@ -0,0 +1,224 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Downtime data. */ +@JsonPropertyOrder({ + DowntimeResponseData.JSON_PROPERTY_ATTRIBUTES, + DowntimeResponseData.JSON_PROPERTY_ID, + DowntimeResponseData.JSON_PROPERTY_RELATIONSHIPS, + DowntimeResponseData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeResponseData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DowntimeResponseAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private DowntimeRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DowntimeResourceType type = DowntimeResourceType.DOWNTIME; + + public DowntimeResponseData attributes(DowntimeResponseAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Downtime details. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeResponseAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DowntimeResponseAttributes attributes) { + this.attributes = attributes; + } + + public DowntimeResponseData id(String id) { + this.id = id; + return this; + } + + /** + * The downtime ID. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public DowntimeResponseData relationships(DowntimeRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * All relationships associated with downtime. + * + * @return relationships + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeRelationships getRelationships() { + return relationships; + } + + public void setRelationships(DowntimeRelationships relationships) { + this.relationships = relationships; + } + + public DowntimeResponseData type(DowntimeResourceType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Downtime resource type. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeResourceType getType() { + return type; + } + + public void setType(DowntimeResourceType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeResponseData + */ + @JsonAnySetter + public DowntimeResponseData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeResponseData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeResponseData downtimeResponseData = (DowntimeResponseData) o; + return Objects.equals(this.attributes, downtimeResponseData.attributes) + && Objects.equals(this.id, downtimeResponseData.id) + && Objects.equals(this.relationships, downtimeResponseData.relationships) + && Objects.equals(this.type, downtimeResponseData.type) + && Objects.equals(this.additionalProperties, downtimeResponseData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeResponseData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" relationships: ").append(toIndentedString(relationships)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseIncludedItem.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseIncludedItem.java new file mode 100644 index 00000000000..d77773df2c9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseIncludedItem.java @@ -0,0 +1,278 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize( + using = DowntimeResponseIncludedItem.DowntimeResponseIncludedItemDeserializer.class) +@JsonSerialize(using = DowntimeResponseIncludedItem.DowntimeResponseIncludedItemSerializer.class) +public class DowntimeResponseIncludedItem extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DowntimeResponseIncludedItem.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DowntimeResponseIncludedItemSerializer + extends StdSerializer { + public DowntimeResponseIncludedItemSerializer(Class t) { + super(t); + } + + public DowntimeResponseIncludedItemSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeResponseIncludedItem value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DowntimeResponseIncludedItemDeserializer + extends StdDeserializer { + public DowntimeResponseIncludedItemDeserializer() { + this(DowntimeResponseIncludedItem.class); + } + + public DowntimeResponseIncludedItemDeserializer(Class vc) { + super(vc); + } + + @Override + public DowntimeResponseIncludedItem deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize User + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (User.class.equals(Integer.class) + || User.class.equals(Long.class) + || User.class.equals(Float.class) + || User.class.equals(Double.class) + || User.class.equals(Boolean.class) + || User.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((User.class.equals(Integer.class) || User.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((User.class.equals(Float.class) || User.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (User.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (User.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(User.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((User) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'User'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'User'", e); + } + + // deserialize DowntimeMonitorIncludedItem + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeMonitorIncludedItem.class.equals(Integer.class) + || DowntimeMonitorIncludedItem.class.equals(Long.class) + || DowntimeMonitorIncludedItem.class.equals(Float.class) + || DowntimeMonitorIncludedItem.class.equals(Double.class) + || DowntimeMonitorIncludedItem.class.equals(Boolean.class) + || DowntimeMonitorIncludedItem.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeMonitorIncludedItem.class.equals(Integer.class) + || DowntimeMonitorIncludedItem.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeMonitorIncludedItem.class.equals(Float.class) + || DowntimeMonitorIncludedItem.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeMonitorIncludedItem.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeMonitorIncludedItem.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DowntimeMonitorIncludedItem.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeMonitorIncludedItem) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DowntimeMonitorIncludedItem'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DowntimeMonitorIncludedItem'", e); + } + + DowntimeResponseIncludedItem ret = new DowntimeResponseIncludedItem(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public DowntimeResponseIncludedItem getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "DowntimeResponseIncludedItem cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DowntimeResponseIncludedItem() { + super("oneOf", Boolean.FALSE); + } + + public DowntimeResponseIncludedItem(User o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DowntimeResponseIncludedItem(DowntimeMonitorIncludedItem o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("User", new GenericType() {}); + schemas.put("DowntimeMonitorIncludedItem", new GenericType() {}); + JSON.registerDescendants( + DowntimeResponseIncludedItem.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DowntimeResponseIncludedItem.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: User, DowntimeMonitorIncludedItem + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(User.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(DowntimeMonitorIncludedItem.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException("Invalid instance type. Must be User, DowntimeMonitorIncludedItem"); + } + + /** + * Get the actual instance, which can be the following: User, DowntimeMonitorIncludedItem + * + * @return The actual instance (User, DowntimeMonitorIncludedItem) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `User`. If the actual instance is not `User`, the ClassCastException + * will be thrown. + * + * @return The actual instance of `User` + * @throws ClassCastException if the instance is not `User` + */ + public User getUser() throws ClassCastException { + return (User) super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeMonitorIncludedItem`. If the actual instance is not + * `DowntimeMonitorIncludedItem`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeMonitorIncludedItem` + * @throws ClassCastException if the instance is not `DowntimeMonitorIncludedItem` + */ + public DowntimeMonitorIncludedItem getDowntimeMonitorIncludedItem() throws ClassCastException { + return (DowntimeMonitorIncludedItem) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleCreateRequest.java new file mode 100644 index 00000000000..3b51d7ddfab --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleCreateRequest.java @@ -0,0 +1,308 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize( + using = DowntimeScheduleCreateRequest.DowntimeScheduleCreateRequestDeserializer.class) +@JsonSerialize(using = DowntimeScheduleCreateRequest.DowntimeScheduleCreateRequestSerializer.class) +public class DowntimeScheduleCreateRequest extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DowntimeScheduleCreateRequest.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DowntimeScheduleCreateRequestSerializer + extends StdSerializer { + public DowntimeScheduleCreateRequestSerializer(Class t) { + super(t); + } + + public DowntimeScheduleCreateRequestSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeScheduleCreateRequest value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DowntimeScheduleCreateRequestDeserializer + extends StdDeserializer { + public DowntimeScheduleCreateRequestDeserializer() { + this(DowntimeScheduleCreateRequest.class); + } + + public DowntimeScheduleCreateRequestDeserializer(Class vc) { + super(vc); + } + + @Override + public DowntimeScheduleCreateRequest deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize DowntimeScheduleRecurrencesCreateRequest + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeScheduleRecurrencesCreateRequest.class.equals(Integer.class) + || DowntimeScheduleRecurrencesCreateRequest.class.equals(Long.class) + || DowntimeScheduleRecurrencesCreateRequest.class.equals(Float.class) + || DowntimeScheduleRecurrencesCreateRequest.class.equals(Double.class) + || DowntimeScheduleRecurrencesCreateRequest.class.equals(Boolean.class) + || DowntimeScheduleRecurrencesCreateRequest.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeScheduleRecurrencesCreateRequest.class.equals(Integer.class) + || DowntimeScheduleRecurrencesCreateRequest.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeScheduleRecurrencesCreateRequest.class.equals(Float.class) + || DowntimeScheduleRecurrencesCreateRequest.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeScheduleRecurrencesCreateRequest.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeScheduleRecurrencesCreateRequest.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(DowntimeScheduleRecurrencesCreateRequest.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeScheduleRecurrencesCreateRequest) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, "Input data matches schema 'DowntimeScheduleRecurrencesCreateRequest'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'DowntimeScheduleRecurrencesCreateRequest'", + e); + } + + // deserialize DowntimeScheduleOneTimeCreateUpdateRequest + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Integer.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Long.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Float.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Double.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Boolean.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Integer.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Float.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(DowntimeScheduleOneTimeCreateUpdateRequest.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeScheduleOneTimeCreateUpdateRequest) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'DowntimeScheduleOneTimeCreateUpdateRequest'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'DowntimeScheduleOneTimeCreateUpdateRequest'", + e); + } + + DowntimeScheduleCreateRequest ret = new DowntimeScheduleCreateRequest(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public DowntimeScheduleCreateRequest getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "DowntimeScheduleCreateRequest cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DowntimeScheduleCreateRequest() { + super("oneOf", Boolean.FALSE); + } + + public DowntimeScheduleCreateRequest(DowntimeScheduleRecurrencesCreateRequest o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DowntimeScheduleCreateRequest(DowntimeScheduleOneTimeCreateUpdateRequest o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "DowntimeScheduleRecurrencesCreateRequest", + new GenericType() {}); + schemas.put( + "DowntimeScheduleOneTimeCreateUpdateRequest", + new GenericType() {}); + JSON.registerDescendants( + DowntimeScheduleCreateRequest.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DowntimeScheduleCreateRequest.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: DowntimeScheduleRecurrencesCreateRequest, + * DowntimeScheduleOneTimeCreateUpdateRequest + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf( + DowntimeScheduleRecurrencesCreateRequest.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + DowntimeScheduleOneTimeCreateUpdateRequest.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException( + "Invalid instance type. Must be DowntimeScheduleRecurrencesCreateRequest," + + " DowntimeScheduleOneTimeCreateUpdateRequest"); + } + + /** + * Get the actual instance, which can be the following: DowntimeScheduleRecurrencesCreateRequest, + * DowntimeScheduleOneTimeCreateUpdateRequest + * + * @return The actual instance (DowntimeScheduleRecurrencesCreateRequest, + * DowntimeScheduleOneTimeCreateUpdateRequest) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeScheduleRecurrencesCreateRequest`. If the actual instance + * is not `DowntimeScheduleRecurrencesCreateRequest`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeScheduleRecurrencesCreateRequest` + * @throws ClassCastException if the instance is not `DowntimeScheduleRecurrencesCreateRequest` + */ + public DowntimeScheduleRecurrencesCreateRequest getDowntimeScheduleRecurrencesCreateRequest() + throws ClassCastException { + return (DowntimeScheduleRecurrencesCreateRequest) super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeScheduleOneTimeCreateUpdateRequest`. If the actual instance + * is not `DowntimeScheduleOneTimeCreateUpdateRequest`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeScheduleOneTimeCreateUpdateRequest` + * @throws ClassCastException if the instance is not `DowntimeScheduleOneTimeCreateUpdateRequest` + */ + public DowntimeScheduleOneTimeCreateUpdateRequest getDowntimeScheduleOneTimeCreateUpdateRequest() + throws ClassCastException { + return (DowntimeScheduleOneTimeCreateUpdateRequest) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleCurrentDowntimeResponse.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleCurrentDowntimeResponse.java new file mode 100644 index 00000000000..94a9d03021d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleCurrentDowntimeResponse.java @@ -0,0 +1,183 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** + * 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. + */ +@JsonPropertyOrder({ + DowntimeScheduleCurrentDowntimeResponse.JSON_PROPERTY_END, + DowntimeScheduleCurrentDowntimeResponse.JSON_PROPERTY_START +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeScheduleCurrentDowntimeResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_END = "end"; + private JsonNullable end = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_START = "start"; + private OffsetDateTime start; + + public DowntimeScheduleCurrentDowntimeResponse end(OffsetDateTime end) { + this.end = JsonNullable.of(end); + return this; + } + + /** + * The end of the current downtime. + * + * @return end + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getEnd() { + return end.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_END) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getEnd_JsonNullable() { + return end; + } + + @JsonProperty(JSON_PROPERTY_END) + public void setEnd_JsonNullable(JsonNullable end) { + this.end = end; + } + + public void setEnd(OffsetDateTime end) { + this.end = JsonNullable.of(end); + } + + public DowntimeScheduleCurrentDowntimeResponse start(OffsetDateTime start) { + this.start = start; + return this; + } + + /** + * The start of the current downtime. + * + * @return start + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getStart() { + return start; + } + + public void setStart(OffsetDateTime start) { + this.start = start; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeScheduleCurrentDowntimeResponse + */ + @JsonAnySetter + public DowntimeScheduleCurrentDowntimeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeScheduleCurrentDowntimeResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeScheduleCurrentDowntimeResponse downtimeScheduleCurrentDowntimeResponse = + (DowntimeScheduleCurrentDowntimeResponse) o; + return Objects.equals(this.end, downtimeScheduleCurrentDowntimeResponse.end) + && Objects.equals(this.start, downtimeScheduleCurrentDowntimeResponse.start) + && Objects.equals( + this.additionalProperties, + downtimeScheduleCurrentDowntimeResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(end, start, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeScheduleCurrentDowntimeResponse {\n"); + sb.append(" end: ").append(toIndentedString(end)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleOneTimeCreateUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleOneTimeCreateUpdateRequest.java new file mode 100644 index 00000000000..a63f446f70e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleOneTimeCreateUpdateRequest.java @@ -0,0 +1,135 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** A one-time downtime definition. */ +@JsonPropertyOrder({ + DowntimeScheduleOneTimeCreateUpdateRequest.JSON_PROPERTY_END, + DowntimeScheduleOneTimeCreateUpdateRequest.JSON_PROPERTY_START +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeScheduleOneTimeCreateUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_END = "end"; + private JsonNullable end = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_START = "start"; + private JsonNullable start = JsonNullable.undefined(); + + public DowntimeScheduleOneTimeCreateUpdateRequest end(OffsetDateTime end) { + this.end = JsonNullable.of(end); + return this; + } + + /** + * 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. + * + * @return end + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getEnd() { + return end.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_END) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getEnd_JsonNullable() { + return end; + } + + @JsonProperty(JSON_PROPERTY_END) + public void setEnd_JsonNullable(JsonNullable end) { + this.end = end; + } + + public void setEnd(OffsetDateTime end) { + this.end = JsonNullable.of(end); + } + + public DowntimeScheduleOneTimeCreateUpdateRequest start(OffsetDateTime start) { + this.start = JsonNullable.of(start); + return this; + } + + /** + * 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. + * + * @return start + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getStart() { + return start.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getStart_JsonNullable() { + return start; + } + + @JsonProperty(JSON_PROPERTY_START) + public void setStart_JsonNullable(JsonNullable start) { + this.start = start; + } + + public void setStart(OffsetDateTime start) { + this.start = JsonNullable.of(start); + } + + /** Return true if this DowntimeScheduleOneTimeCreateUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeScheduleOneTimeCreateUpdateRequest downtimeScheduleOneTimeCreateUpdateRequest = + (DowntimeScheduleOneTimeCreateUpdateRequest) o; + return Objects.equals(this.end, downtimeScheduleOneTimeCreateUpdateRequest.end) + && Objects.equals(this.start, downtimeScheduleOneTimeCreateUpdateRequest.start); + } + + @Override + public int hashCode() { + return Objects.hash(end, start); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeScheduleOneTimeCreateUpdateRequest {\n"); + sb.append(" end: ").append(toIndentedString(end)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleOneTimeResponse.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleOneTimeResponse.java new file mode 100644 index 00000000000..8eefbef0fd2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleOneTimeResponse.java @@ -0,0 +1,178 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** A one-time downtime definition. */ +@JsonPropertyOrder({ + DowntimeScheduleOneTimeResponse.JSON_PROPERTY_END, + DowntimeScheduleOneTimeResponse.JSON_PROPERTY_START +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeScheduleOneTimeResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_END = "end"; + private JsonNullable end = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_START = "start"; + private OffsetDateTime start; + + public DowntimeScheduleOneTimeResponse end(OffsetDateTime end) { + this.end = JsonNullable.of(end); + return this; + } + + /** + * ISO-8601 Datetime to end the downtime. + * + * @return end + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getEnd() { + return end.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_END) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getEnd_JsonNullable() { + return end; + } + + @JsonProperty(JSON_PROPERTY_END) + public void setEnd_JsonNullable(JsonNullable end) { + this.end = end; + } + + public void setEnd(OffsetDateTime end) { + this.end = JsonNullable.of(end); + } + + public DowntimeScheduleOneTimeResponse start(OffsetDateTime start) { + this.start = start; + return this; + } + + /** + * ISO-8601 Datetime to start the downtime. + * + * @return start + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getStart() { + return start; + } + + public void setStart(OffsetDateTime start) { + this.start = start; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeScheduleOneTimeResponse + */ + @JsonAnySetter + public DowntimeScheduleOneTimeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeScheduleOneTimeResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeScheduleOneTimeResponse downtimeScheduleOneTimeResponse = + (DowntimeScheduleOneTimeResponse) o; + return Objects.equals(this.end, downtimeScheduleOneTimeResponse.end) + && Objects.equals(this.start, downtimeScheduleOneTimeResponse.start) + && Objects.equals( + this.additionalProperties, downtimeScheduleOneTimeResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(end, start, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeScheduleOneTimeResponse {\n"); + sb.append(" end: ").append(toIndentedString(end)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrenceCreateUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrenceCreateUpdateRequest.java new file mode 100644 index 00000000000..ff0bcba6344 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrenceCreateUpdateRequest.java @@ -0,0 +1,170 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** An object defining the recurrence of the downtime. */ +@JsonPropertyOrder({ + DowntimeScheduleRecurrenceCreateUpdateRequest.JSON_PROPERTY_DURATION, + DowntimeScheduleRecurrenceCreateUpdateRequest.JSON_PROPERTY_RRULE, + DowntimeScheduleRecurrenceCreateUpdateRequest.JSON_PROPERTY_START +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeScheduleRecurrenceCreateUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DURATION = "duration"; + private String duration; + + public static final String JSON_PROPERTY_RRULE = "rrule"; + private String rrule; + + public static final String JSON_PROPERTY_START = "start"; + private JsonNullable start = JsonNullable.undefined(); + + public DowntimeScheduleRecurrenceCreateUpdateRequest() {} + + @JsonCreator + public DowntimeScheduleRecurrenceCreateUpdateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DURATION) String duration, + @JsonProperty(required = true, value = JSON_PROPERTY_RRULE) String rrule) { + this.duration = duration; + this.rrule = rrule; + } + + public DowntimeScheduleRecurrenceCreateUpdateRequest duration(String duration) { + this.duration = duration; + return this; + } + + /** + * The length of the downtime. Must begin with an integer and end with one of 'm', 'h', d', or + * 'w'. + * + * @return duration + */ + @JsonProperty(JSON_PROPERTY_DURATION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public DowntimeScheduleRecurrenceCreateUpdateRequest rrule(String rrule) { + this.rrule = rrule; + return this; + } + + /** + * 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. + * + * @return rrule + */ + @JsonProperty(JSON_PROPERTY_RRULE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRrule() { + return rrule; + } + + public void setRrule(String rrule) { + this.rrule = rrule; + } + + public DowntimeScheduleRecurrenceCreateUpdateRequest start(String start) { + this.start = JsonNullable.of(start); + return this; + } + + /** + * ISO-8601 Datetime to start the downtime. Must not include a UTC offset. If not provided, the + * downtime starts the moment it is created. + * + * @return start + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getStart() { + return start.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getStart_JsonNullable() { + return start; + } + + @JsonProperty(JSON_PROPERTY_START) + public void setStart_JsonNullable(JsonNullable start) { + this.start = start; + } + + public void setStart(String start) { + this.start = JsonNullable.of(start); + } + + /** Return true if this DowntimeScheduleRecurrenceCreateUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeScheduleRecurrenceCreateUpdateRequest downtimeScheduleRecurrenceCreateUpdateRequest = + (DowntimeScheduleRecurrenceCreateUpdateRequest) o; + return Objects.equals(this.duration, downtimeScheduleRecurrenceCreateUpdateRequest.duration) + && Objects.equals(this.rrule, downtimeScheduleRecurrenceCreateUpdateRequest.rrule) + && Objects.equals(this.start, downtimeScheduleRecurrenceCreateUpdateRequest.start); + } + + @Override + public int hashCode() { + return Objects.hash(duration, rrule, start); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeScheduleRecurrenceCreateUpdateRequest {\n"); + sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrenceResponse.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrenceResponse.java new file mode 100644 index 00000000000..9752e7070a6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrenceResponse.java @@ -0,0 +1,205 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** An RRULE-based recurring downtime. */ +@JsonPropertyOrder({ + DowntimeScheduleRecurrenceResponse.JSON_PROPERTY_DURATION, + DowntimeScheduleRecurrenceResponse.JSON_PROPERTY_RRULE, + DowntimeScheduleRecurrenceResponse.JSON_PROPERTY_START +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeScheduleRecurrenceResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DURATION = "duration"; + private String duration; + + public static final String JSON_PROPERTY_RRULE = "rrule"; + private String rrule; + + public static final String JSON_PROPERTY_START = "start"; + private String start; + + public DowntimeScheduleRecurrenceResponse duration(String duration) { + this.duration = duration; + return this; + } + + /** + * The length of the downtime. Must begin with an integer and end with one of 'm', 'h', d', or + * 'w'. + * + * @return duration + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public DowntimeScheduleRecurrenceResponse rrule(String rrule) { + this.rrule = rrule; + return this; + } + + /** + * 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. + * + * @return rrule + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RRULE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRrule() { + return rrule; + } + + public void setRrule(String rrule) { + this.rrule = rrule; + } + + public DowntimeScheduleRecurrenceResponse start(String start) { + this.start = start; + return this; + } + + /** + * ISO-8601 Datetime to start the downtime. Must not include a UTC offset. If not provided, the + * downtime starts the moment it is created. + * + * @return start + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getStart() { + return start; + } + + public void setStart(String start) { + this.start = start; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeScheduleRecurrenceResponse + */ + @JsonAnySetter + public DowntimeScheduleRecurrenceResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeScheduleRecurrenceResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeScheduleRecurrenceResponse downtimeScheduleRecurrenceResponse = + (DowntimeScheduleRecurrenceResponse) o; + return Objects.equals(this.duration, downtimeScheduleRecurrenceResponse.duration) + && Objects.equals(this.rrule, downtimeScheduleRecurrenceResponse.rrule) + && Objects.equals(this.start, downtimeScheduleRecurrenceResponse.start) + && Objects.equals( + this.additionalProperties, downtimeScheduleRecurrenceResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(duration, rrule, start, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeScheduleRecurrenceResponse {\n"); + sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesCreateRequest.java new file mode 100644 index 00000000000..af707508575 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesCreateRequest.java @@ -0,0 +1,189 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A recurring downtime schedule definition. */ +@JsonPropertyOrder({ + DowntimeScheduleRecurrencesCreateRequest.JSON_PROPERTY_RECURRENCES, + DowntimeScheduleRecurrencesCreateRequest.JSON_PROPERTY_TIMEZONE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeScheduleRecurrencesCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RECURRENCES = "recurrences"; + private List recurrences = new ArrayList<>(); + + public static final String JSON_PROPERTY_TIMEZONE = "timezone"; + private String timezone = "UTC"; + + public DowntimeScheduleRecurrencesCreateRequest() {} + + @JsonCreator + public DowntimeScheduleRecurrencesCreateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_RECURRENCES) + List recurrences) { + this.recurrences = recurrences; + } + + public DowntimeScheduleRecurrencesCreateRequest recurrences( + List recurrences) { + this.recurrences = recurrences; + for (DowntimeScheduleRecurrenceCreateUpdateRequest item : recurrences) { + this.unparsed |= item.unparsed; + } + return this; + } + + public DowntimeScheduleRecurrencesCreateRequest addRecurrencesItem( + DowntimeScheduleRecurrenceCreateUpdateRequest recurrencesItem) { + this.recurrences.add(recurrencesItem); + this.unparsed |= recurrencesItem.unparsed; + return this; + } + + /** + * A list of downtime recurrences. + * + * @return recurrences + */ + @JsonProperty(JSON_PROPERTY_RECURRENCES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRecurrences() { + return recurrences; + } + + public void setRecurrences(List recurrences) { + this.recurrences = recurrences; + } + + public DowntimeScheduleRecurrencesCreateRequest timezone(String timezone) { + this.timezone = timezone; + return this; + } + + /** + * The timezone in which to schedule the downtime. + * + * @return timezone + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIMEZONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTimezone() { + return timezone; + } + + public void setTimezone(String timezone) { + this.timezone = timezone; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeScheduleRecurrencesCreateRequest + */ + @JsonAnySetter + public DowntimeScheduleRecurrencesCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeScheduleRecurrencesCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeScheduleRecurrencesCreateRequest downtimeScheduleRecurrencesCreateRequest = + (DowntimeScheduleRecurrencesCreateRequest) o; + return Objects.equals(this.recurrences, downtimeScheduleRecurrencesCreateRequest.recurrences) + && Objects.equals(this.timezone, downtimeScheduleRecurrencesCreateRequest.timezone) + && Objects.equals( + this.additionalProperties, + downtimeScheduleRecurrencesCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(recurrences, timezone, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeScheduleRecurrencesCreateRequest {\n"); + sb.append(" recurrences: ").append(toIndentedString(recurrences)).append("\n"); + sb.append(" timezone: ").append(toIndentedString(timezone)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesResponse.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesResponse.java new file mode 100644 index 00000000000..26f94fb52a5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesResponse.java @@ -0,0 +1,220 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A recurring downtime schedule definition. */ +@JsonPropertyOrder({ + DowntimeScheduleRecurrencesResponse.JSON_PROPERTY_CURRENT_DOWNTIME, + DowntimeScheduleRecurrencesResponse.JSON_PROPERTY_RECURRENCES, + DowntimeScheduleRecurrencesResponse.JSON_PROPERTY_TIMEZONE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeScheduleRecurrencesResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CURRENT_DOWNTIME = "current_downtime"; + private DowntimeScheduleCurrentDowntimeResponse currentDowntime; + + public static final String JSON_PROPERTY_RECURRENCES = "recurrences"; + private List recurrences = new ArrayList<>(); + + public static final String JSON_PROPERTY_TIMEZONE = "timezone"; + private String timezone = "UTC"; + + public DowntimeScheduleRecurrencesResponse() {} + + @JsonCreator + public DowntimeScheduleRecurrencesResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_RECURRENCES) + List recurrences) { + this.recurrences = recurrences; + } + + public DowntimeScheduleRecurrencesResponse currentDowntime( + DowntimeScheduleCurrentDowntimeResponse currentDowntime) { + this.currentDowntime = currentDowntime; + this.unparsed |= currentDowntime.unparsed; + return this; + } + + /** + * 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. + * + * @return currentDowntime + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CURRENT_DOWNTIME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeScheduleCurrentDowntimeResponse getCurrentDowntime() { + return currentDowntime; + } + + public void setCurrentDowntime(DowntimeScheduleCurrentDowntimeResponse currentDowntime) { + this.currentDowntime = currentDowntime; + } + + public DowntimeScheduleRecurrencesResponse recurrences( + List recurrences) { + this.recurrences = recurrences; + for (DowntimeScheduleRecurrenceResponse item : recurrences) { + this.unparsed |= item.unparsed; + } + return this; + } + + public DowntimeScheduleRecurrencesResponse addRecurrencesItem( + DowntimeScheduleRecurrenceResponse recurrencesItem) { + this.recurrences.add(recurrencesItem); + this.unparsed |= recurrencesItem.unparsed; + return this; + } + + /** + * A list of downtime recurrences. + * + * @return recurrences + */ + @JsonProperty(JSON_PROPERTY_RECURRENCES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRecurrences() { + return recurrences; + } + + public void setRecurrences(List recurrences) { + this.recurrences = recurrences; + } + + public DowntimeScheduleRecurrencesResponse timezone(String timezone) { + this.timezone = timezone; + return this; + } + + /** + * The timezone in which to schedule the downtime. This affects recurring start and end dates. + * Must match display_timezone. + * + * @return timezone + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIMEZONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTimezone() { + return timezone; + } + + public void setTimezone(String timezone) { + this.timezone = timezone; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeScheduleRecurrencesResponse + */ + @JsonAnySetter + public DowntimeScheduleRecurrencesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeScheduleRecurrencesResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeScheduleRecurrencesResponse downtimeScheduleRecurrencesResponse = + (DowntimeScheduleRecurrencesResponse) o; + return Objects.equals(this.currentDowntime, downtimeScheduleRecurrencesResponse.currentDowntime) + && Objects.equals(this.recurrences, downtimeScheduleRecurrencesResponse.recurrences) + && Objects.equals(this.timezone, downtimeScheduleRecurrencesResponse.timezone) + && Objects.equals( + this.additionalProperties, downtimeScheduleRecurrencesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(currentDowntime, recurrences, timezone, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeScheduleRecurrencesResponse {\n"); + sb.append(" currentDowntime: ").append(toIndentedString(currentDowntime)).append("\n"); + sb.append(" recurrences: ").append(toIndentedString(recurrences)).append("\n"); + sb.append(" timezone: ").append(toIndentedString(timezone)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesUpdateRequest.java new file mode 100644 index 00000000000..471d9097b49 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleRecurrencesUpdateRequest.java @@ -0,0 +1,183 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A recurring downtime schedule definition. */ +@JsonPropertyOrder({ + DowntimeScheduleRecurrencesUpdateRequest.JSON_PROPERTY_RECURRENCES, + DowntimeScheduleRecurrencesUpdateRequest.JSON_PROPERTY_TIMEZONE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeScheduleRecurrencesUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RECURRENCES = "recurrences"; + private List recurrences = null; + + public static final String JSON_PROPERTY_TIMEZONE = "timezone"; + private String timezone = "UTC"; + + public DowntimeScheduleRecurrencesUpdateRequest recurrences( + List recurrences) { + this.recurrences = recurrences; + for (DowntimeScheduleRecurrenceCreateUpdateRequest item : recurrences) { + this.unparsed |= item.unparsed; + } + return this; + } + + public DowntimeScheduleRecurrencesUpdateRequest addRecurrencesItem( + DowntimeScheduleRecurrenceCreateUpdateRequest recurrencesItem) { + if (this.recurrences == null) { + this.recurrences = new ArrayList<>(); + } + this.recurrences.add(recurrencesItem); + this.unparsed |= recurrencesItem.unparsed; + return this; + } + + /** + * A list of downtime recurrences. + * + * @return recurrences + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RECURRENCES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getRecurrences() { + return recurrences; + } + + public void setRecurrences(List recurrences) { + this.recurrences = recurrences; + } + + public DowntimeScheduleRecurrencesUpdateRequest timezone(String timezone) { + this.timezone = timezone; + return this; + } + + /** + * The timezone in which to schedule the downtime. + * + * @return timezone + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIMEZONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTimezone() { + return timezone; + } + + public void setTimezone(String timezone) { + this.timezone = timezone; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeScheduleRecurrencesUpdateRequest + */ + @JsonAnySetter + public DowntimeScheduleRecurrencesUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeScheduleRecurrencesUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeScheduleRecurrencesUpdateRequest downtimeScheduleRecurrencesUpdateRequest = + (DowntimeScheduleRecurrencesUpdateRequest) o; + return Objects.equals(this.recurrences, downtimeScheduleRecurrencesUpdateRequest.recurrences) + && Objects.equals(this.timezone, downtimeScheduleRecurrencesUpdateRequest.timezone) + && Objects.equals( + this.additionalProperties, + downtimeScheduleRecurrencesUpdateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(recurrences, timezone, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeScheduleRecurrencesUpdateRequest {\n"); + sb.append(" recurrences: ").append(toIndentedString(recurrences)).append("\n"); + sb.append(" timezone: ").append(toIndentedString(timezone)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleResponse.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleResponse.java new file mode 100644 index 00000000000..878386f8d70 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleResponse.java @@ -0,0 +1,295 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize(using = DowntimeScheduleResponse.DowntimeScheduleResponseDeserializer.class) +@JsonSerialize(using = DowntimeScheduleResponse.DowntimeScheduleResponseSerializer.class) +public class DowntimeScheduleResponse extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DowntimeScheduleResponse.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DowntimeScheduleResponseSerializer + extends StdSerializer { + public DowntimeScheduleResponseSerializer(Class t) { + super(t); + } + + public DowntimeScheduleResponseSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeScheduleResponse value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DowntimeScheduleResponseDeserializer + extends StdDeserializer { + public DowntimeScheduleResponseDeserializer() { + this(DowntimeScheduleResponse.class); + } + + public DowntimeScheduleResponseDeserializer(Class vc) { + super(vc); + } + + @Override + public DowntimeScheduleResponse deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize DowntimeScheduleRecurrencesResponse + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeScheduleRecurrencesResponse.class.equals(Integer.class) + || DowntimeScheduleRecurrencesResponse.class.equals(Long.class) + || DowntimeScheduleRecurrencesResponse.class.equals(Float.class) + || DowntimeScheduleRecurrencesResponse.class.equals(Double.class) + || DowntimeScheduleRecurrencesResponse.class.equals(Boolean.class) + || DowntimeScheduleRecurrencesResponse.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeScheduleRecurrencesResponse.class.equals(Integer.class) + || DowntimeScheduleRecurrencesResponse.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeScheduleRecurrencesResponse.class.equals(Float.class) + || DowntimeScheduleRecurrencesResponse.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeScheduleRecurrencesResponse.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeScheduleRecurrencesResponse.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DowntimeScheduleRecurrencesResponse.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeScheduleRecurrencesResponse) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DowntimeScheduleRecurrencesResponse'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'DowntimeScheduleRecurrencesResponse'", + e); + } + + // deserialize DowntimeScheduleOneTimeResponse + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeScheduleOneTimeResponse.class.equals(Integer.class) + || DowntimeScheduleOneTimeResponse.class.equals(Long.class) + || DowntimeScheduleOneTimeResponse.class.equals(Float.class) + || DowntimeScheduleOneTimeResponse.class.equals(Double.class) + || DowntimeScheduleOneTimeResponse.class.equals(Boolean.class) + || DowntimeScheduleOneTimeResponse.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeScheduleOneTimeResponse.class.equals(Integer.class) + || DowntimeScheduleOneTimeResponse.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeScheduleOneTimeResponse.class.equals(Float.class) + || DowntimeScheduleOneTimeResponse.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeScheduleOneTimeResponse.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeScheduleOneTimeResponse.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DowntimeScheduleOneTimeResponse.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeScheduleOneTimeResponse) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DowntimeScheduleOneTimeResponse'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'DowntimeScheduleOneTimeResponse'", e); + } + + DowntimeScheduleResponse ret = new DowntimeScheduleResponse(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public DowntimeScheduleResponse getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DowntimeScheduleResponse cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DowntimeScheduleResponse() { + super("oneOf", Boolean.FALSE); + } + + public DowntimeScheduleResponse(DowntimeScheduleRecurrencesResponse o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DowntimeScheduleResponse(DowntimeScheduleOneTimeResponse o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "DowntimeScheduleRecurrencesResponse", + new GenericType() {}); + schemas.put( + "DowntimeScheduleOneTimeResponse", new GenericType() {}); + JSON.registerDescendants(DowntimeScheduleResponse.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DowntimeScheduleResponse.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: DowntimeScheduleRecurrencesResponse, + * DowntimeScheduleOneTimeResponse + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf( + DowntimeScheduleRecurrencesResponse.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + DowntimeScheduleOneTimeResponse.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException( + "Invalid instance type. Must be DowntimeScheduleRecurrencesResponse," + + " DowntimeScheduleOneTimeResponse"); + } + + /** + * Get the actual instance, which can be the following: DowntimeScheduleRecurrencesResponse, + * DowntimeScheduleOneTimeResponse + * + * @return The actual instance (DowntimeScheduleRecurrencesResponse, + * DowntimeScheduleOneTimeResponse) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeScheduleRecurrencesResponse`. If the actual instance is not + * `DowntimeScheduleRecurrencesResponse`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeScheduleRecurrencesResponse` + * @throws ClassCastException if the instance is not `DowntimeScheduleRecurrencesResponse` + */ + public DowntimeScheduleRecurrencesResponse getDowntimeScheduleRecurrencesResponse() + throws ClassCastException { + return (DowntimeScheduleRecurrencesResponse) super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeScheduleOneTimeResponse`. If the actual instance is not + * `DowntimeScheduleOneTimeResponse`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeScheduleOneTimeResponse` + * @throws ClassCastException if the instance is not `DowntimeScheduleOneTimeResponse` + */ + public DowntimeScheduleOneTimeResponse getDowntimeScheduleOneTimeResponse() + throws ClassCastException { + return (DowntimeScheduleOneTimeResponse) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleUpdateRequest.java new file mode 100644 index 00000000000..b73b047c9c5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeScheduleUpdateRequest.java @@ -0,0 +1,308 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize( + using = DowntimeScheduleUpdateRequest.DowntimeScheduleUpdateRequestDeserializer.class) +@JsonSerialize(using = DowntimeScheduleUpdateRequest.DowntimeScheduleUpdateRequestSerializer.class) +public class DowntimeScheduleUpdateRequest extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DowntimeScheduleUpdateRequest.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DowntimeScheduleUpdateRequestSerializer + extends StdSerializer { + public DowntimeScheduleUpdateRequestSerializer(Class t) { + super(t); + } + + public DowntimeScheduleUpdateRequestSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeScheduleUpdateRequest value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DowntimeScheduleUpdateRequestDeserializer + extends StdDeserializer { + public DowntimeScheduleUpdateRequestDeserializer() { + this(DowntimeScheduleUpdateRequest.class); + } + + public DowntimeScheduleUpdateRequestDeserializer(Class vc) { + super(vc); + } + + @Override + public DowntimeScheduleUpdateRequest deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize DowntimeScheduleRecurrencesUpdateRequest + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeScheduleRecurrencesUpdateRequest.class.equals(Integer.class) + || DowntimeScheduleRecurrencesUpdateRequest.class.equals(Long.class) + || DowntimeScheduleRecurrencesUpdateRequest.class.equals(Float.class) + || DowntimeScheduleRecurrencesUpdateRequest.class.equals(Double.class) + || DowntimeScheduleRecurrencesUpdateRequest.class.equals(Boolean.class) + || DowntimeScheduleRecurrencesUpdateRequest.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeScheduleRecurrencesUpdateRequest.class.equals(Integer.class) + || DowntimeScheduleRecurrencesUpdateRequest.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeScheduleRecurrencesUpdateRequest.class.equals(Float.class) + || DowntimeScheduleRecurrencesUpdateRequest.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeScheduleRecurrencesUpdateRequest.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeScheduleRecurrencesUpdateRequest.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(DowntimeScheduleRecurrencesUpdateRequest.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeScheduleRecurrencesUpdateRequest) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, "Input data matches schema 'DowntimeScheduleRecurrencesUpdateRequest'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'DowntimeScheduleRecurrencesUpdateRequest'", + e); + } + + // deserialize DowntimeScheduleOneTimeCreateUpdateRequest + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Integer.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Long.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Float.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Double.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Boolean.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Integer.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Float.class) + || DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DowntimeScheduleOneTimeCreateUpdateRequest.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(DowntimeScheduleOneTimeCreateUpdateRequest.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((DowntimeScheduleOneTimeCreateUpdateRequest) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'DowntimeScheduleOneTimeCreateUpdateRequest'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'DowntimeScheduleOneTimeCreateUpdateRequest'", + e); + } + + DowntimeScheduleUpdateRequest ret = new DowntimeScheduleUpdateRequest(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public DowntimeScheduleUpdateRequest getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "DowntimeScheduleUpdateRequest cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DowntimeScheduleUpdateRequest() { + super("oneOf", Boolean.FALSE); + } + + public DowntimeScheduleUpdateRequest(DowntimeScheduleRecurrencesUpdateRequest o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DowntimeScheduleUpdateRequest(DowntimeScheduleOneTimeCreateUpdateRequest o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "DowntimeScheduleRecurrencesUpdateRequest", + new GenericType() {}); + schemas.put( + "DowntimeScheduleOneTimeCreateUpdateRequest", + new GenericType() {}); + JSON.registerDescendants( + DowntimeScheduleUpdateRequest.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DowntimeScheduleUpdateRequest.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: DowntimeScheduleRecurrencesUpdateRequest, + * DowntimeScheduleOneTimeCreateUpdateRequest + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf( + DowntimeScheduleRecurrencesUpdateRequest.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + DowntimeScheduleOneTimeCreateUpdateRequest.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException( + "Invalid instance type. Must be DowntimeScheduleRecurrencesUpdateRequest," + + " DowntimeScheduleOneTimeCreateUpdateRequest"); + } + + /** + * Get the actual instance, which can be the following: DowntimeScheduleRecurrencesUpdateRequest, + * DowntimeScheduleOneTimeCreateUpdateRequest + * + * @return The actual instance (DowntimeScheduleRecurrencesUpdateRequest, + * DowntimeScheduleOneTimeCreateUpdateRequest) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeScheduleRecurrencesUpdateRequest`. If the actual instance + * is not `DowntimeScheduleRecurrencesUpdateRequest`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeScheduleRecurrencesUpdateRequest` + * @throws ClassCastException if the instance is not `DowntimeScheduleRecurrencesUpdateRequest` + */ + public DowntimeScheduleRecurrencesUpdateRequest getDowntimeScheduleRecurrencesUpdateRequest() + throws ClassCastException { + return (DowntimeScheduleRecurrencesUpdateRequest) super.getActualInstance(); + } + + /** + * Get the actual instance of `DowntimeScheduleOneTimeCreateUpdateRequest`. If the actual instance + * is not `DowntimeScheduleOneTimeCreateUpdateRequest`, the ClassCastException will be thrown. + * + * @return The actual instance of `DowntimeScheduleOneTimeCreateUpdateRequest` + * @throws ClassCastException if the instance is not `DowntimeScheduleOneTimeCreateUpdateRequest` + */ + public DowntimeScheduleOneTimeCreateUpdateRequest getDowntimeScheduleOneTimeCreateUpdateRequest() + throws ClassCastException { + return (DowntimeScheduleOneTimeCreateUpdateRequest) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeStatus.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeStatus.java new file mode 100644 index 00000000000..0d1577b3685 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeStatus.java @@ -0,0 +1,95 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** The current status of the downtime. */ +@JsonSerialize(using = DowntimeStatus.DowntimeStatusSerializer.class) +public class DowntimeStatus { + + public static final DowntimeStatus ACTIVE = new DowntimeStatus("active"); + public static final DowntimeStatus CANCELED = new DowntimeStatus("canceled"); + public static final DowntimeStatus ENDED = new DowntimeStatus("ended"); + public static final DowntimeStatus SCHEDULED = new DowntimeStatus("scheduled"); + + private static final Set allowedValues = + new HashSet(Arrays.asList("active", "canceled", "ended", "scheduled")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + DowntimeStatus(String value) { + this.value = value; + } + + public static class DowntimeStatusSerializer extends StdSerializer { + public DowntimeStatusSerializer(Class t) { + super(t); + } + + public DowntimeStatusSerializer() { + this(null); + } + + @Override + public void serialize(DowntimeStatus value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this DowntimeStatus object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((DowntimeStatus) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static DowntimeStatus fromValue(String value) { + return new DowntimeStatus(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequest.java new file mode 100644 index 00000000000..73cc8dd5d31 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequest.java @@ -0,0 +1,145 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request for editing a downtime. */ +@JsonPropertyOrder({DowntimeUpdateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private DowntimeUpdateRequestData data; + + public DowntimeUpdateRequest() {} + + @JsonCreator + public DowntimeUpdateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) DowntimeUpdateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public DowntimeUpdateRequest data(DowntimeUpdateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object to update a downtime. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DowntimeUpdateRequestData getData() { + return data; + } + + public void setData(DowntimeUpdateRequestData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeUpdateRequest + */ + @JsonAnySetter + public DowntimeUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeUpdateRequest downtimeUpdateRequest = (DowntimeUpdateRequest) o; + return Objects.equals(this.data, downtimeUpdateRequest.data) + && Objects.equals(this.additionalProperties, downtimeUpdateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeUpdateRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequestAttributes.java new file mode 100644 index 00000000000..e00e22fee05 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequestAttributes.java @@ -0,0 +1,396 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Attributes of the downtime to update. */ +@JsonPropertyOrder({ + DowntimeUpdateRequestAttributes.JSON_PROPERTY_DISPLAY_TIMEZONE, + DowntimeUpdateRequestAttributes.JSON_PROPERTY_MESSAGE, + DowntimeUpdateRequestAttributes.JSON_PROPERTY_MONITOR_IDENTIFIER, + DowntimeUpdateRequestAttributes.JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION, + DowntimeUpdateRequestAttributes.JSON_PROPERTY_NOTIFY_END_STATES, + DowntimeUpdateRequestAttributes.JSON_PROPERTY_NOTIFY_END_TYPES, + DowntimeUpdateRequestAttributes.JSON_PROPERTY_SCHEDULE, + DowntimeUpdateRequestAttributes.JSON_PROPERTY_SCOPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeUpdateRequestAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DISPLAY_TIMEZONE = "display_timezone"; + private JsonNullable displayTimezone = JsonNullable.of("UTC"); + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private JsonNullable message = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_MONITOR_IDENTIFIER = "monitor_identifier"; + private DowntimeMonitorIdentifier monitorIdentifier; + + public static final String JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION = + "mute_first_recovery_notification"; + private Boolean muteFirstRecoveryNotification; + + public static final String JSON_PROPERTY_NOTIFY_END_STATES = "notify_end_states"; + private List notifyEndStates = null; + + public static final String JSON_PROPERTY_NOTIFY_END_TYPES = "notify_end_types"; + private List notifyEndTypes = null; + + public static final String JSON_PROPERTY_SCHEDULE = "schedule"; + private DowntimeScheduleUpdateRequest schedule; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private String scope; + + public DowntimeUpdateRequestAttributes displayTimezone(String displayTimezone) { + this.displayTimezone = JsonNullable.of(displayTimezone); + return this; + } + + /** + * 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. + * + * @return displayTimezone + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getDisplayTimezone() { + return displayTimezone.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DISPLAY_TIMEZONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getDisplayTimezone_JsonNullable() { + return displayTimezone; + } + + @JsonProperty(JSON_PROPERTY_DISPLAY_TIMEZONE) + public void setDisplayTimezone_JsonNullable(JsonNullable displayTimezone) { + this.displayTimezone = displayTimezone; + } + + public void setDisplayTimezone(String displayTimezone) { + this.displayTimezone = JsonNullable.of(displayTimezone); + } + + public DowntimeUpdateRequestAttributes message(String message) { + this.message = JsonNullable.of(message); + return this; + } + + /** + * 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. + * + * @return message + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getMessage() { + return message.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getMessage_JsonNullable() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + public void setMessage_JsonNullable(JsonNullable message) { + this.message = message; + } + + public void setMessage(String message) { + this.message = JsonNullable.of(message); + } + + public DowntimeUpdateRequestAttributes monitorIdentifier( + DowntimeMonitorIdentifier monitorIdentifier) { + this.monitorIdentifier = monitorIdentifier; + this.unparsed |= monitorIdentifier.unparsed; + return this; + } + + /** + * Monitor identifier for the downtime. + * + * @return monitorIdentifier + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MONITOR_IDENTIFIER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeMonitorIdentifier getMonitorIdentifier() { + return monitorIdentifier; + } + + public void setMonitorIdentifier(DowntimeMonitorIdentifier monitorIdentifier) { + this.monitorIdentifier = monitorIdentifier; + } + + public DowntimeUpdateRequestAttributes muteFirstRecoveryNotification( + Boolean muteFirstRecoveryNotification) { + this.muteFirstRecoveryNotification = muteFirstRecoveryNotification; + return this; + } + + /** + * If the first recovery notification during a downtime should be muted. + * + * @return muteFirstRecoveryNotification + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getMuteFirstRecoveryNotification() { + return muteFirstRecoveryNotification; + } + + public void setMuteFirstRecoveryNotification(Boolean muteFirstRecoveryNotification) { + this.muteFirstRecoveryNotification = muteFirstRecoveryNotification; + } + + public DowntimeUpdateRequestAttributes notifyEndStates( + List notifyEndStates) { + this.notifyEndStates = notifyEndStates; + return this; + } + + public DowntimeUpdateRequestAttributes addNotifyEndStatesItem( + DowntimeNotifyEndStateTypes notifyEndStatesItem) { + if (this.notifyEndStates == null) { + this.notifyEndStates = new ArrayList<>(); + } + this.notifyEndStates.add(notifyEndStatesItem); + this.unparsed |= !notifyEndStatesItem.isValid(); + return this; + } + + /** + * States that will trigger a monitor notification when the notify_end_types action + * occurs. + * + * @return notifyEndStates + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NOTIFY_END_STATES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getNotifyEndStates() { + return notifyEndStates; + } + + public void setNotifyEndStates(List notifyEndStates) { + this.notifyEndStates = notifyEndStates; + } + + public DowntimeUpdateRequestAttributes notifyEndTypes( + List notifyEndTypes) { + this.notifyEndTypes = notifyEndTypes; + return this; + } + + public DowntimeUpdateRequestAttributes addNotifyEndTypesItem( + DowntimeNotifyEndStateActions notifyEndTypesItem) { + if (this.notifyEndTypes == null) { + this.notifyEndTypes = new ArrayList<>(); + } + this.notifyEndTypes.add(notifyEndTypesItem); + this.unparsed |= !notifyEndTypesItem.isValid(); + return this; + } + + /** + * Actions that will trigger a monitor notification if the downtime is in the + * notify_end_types state. + * + * @return notifyEndTypes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NOTIFY_END_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getNotifyEndTypes() { + return notifyEndTypes; + } + + public void setNotifyEndTypes(List notifyEndTypes) { + this.notifyEndTypes = notifyEndTypes; + } + + public DowntimeUpdateRequestAttributes schedule(DowntimeScheduleUpdateRequest schedule) { + this.schedule = schedule; + this.unparsed |= schedule.unparsed; + return this; + } + + /** + * Schedule for the downtime. + * + * @return schedule + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCHEDULE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeScheduleUpdateRequest getSchedule() { + return schedule; + } + + public void setSchedule(DowntimeScheduleUpdateRequest schedule) { + this.schedule = schedule; + } + + public DowntimeUpdateRequestAttributes scope(String scope) { + this.scope = scope; + return this; + } + + /** + * The scope to which the downtime applies. Must follow the common search syntax. + * + * @return scope + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeUpdateRequestAttributes + */ + @JsonAnySetter + public DowntimeUpdateRequestAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeUpdateRequestAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeUpdateRequestAttributes downtimeUpdateRequestAttributes = + (DowntimeUpdateRequestAttributes) o; + return Objects.equals(this.displayTimezone, downtimeUpdateRequestAttributes.displayTimezone) + && Objects.equals(this.message, downtimeUpdateRequestAttributes.message) + && Objects.equals(this.monitorIdentifier, downtimeUpdateRequestAttributes.monitorIdentifier) + && Objects.equals( + this.muteFirstRecoveryNotification, + downtimeUpdateRequestAttributes.muteFirstRecoveryNotification) + && Objects.equals(this.notifyEndStates, downtimeUpdateRequestAttributes.notifyEndStates) + && Objects.equals(this.notifyEndTypes, downtimeUpdateRequestAttributes.notifyEndTypes) + && Objects.equals(this.schedule, downtimeUpdateRequestAttributes.schedule) + && Objects.equals(this.scope, downtimeUpdateRequestAttributes.scope) + && Objects.equals( + this.additionalProperties, downtimeUpdateRequestAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + displayTimezone, + message, + monitorIdentifier, + muteFirstRecoveryNotification, + notifyEndStates, + notifyEndTypes, + schedule, + scope, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeUpdateRequestAttributes {\n"); + sb.append(" displayTimezone: ").append(toIndentedString(displayTimezone)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" monitorIdentifier: ").append(toIndentedString(monitorIdentifier)).append("\n"); + sb.append(" muteFirstRecoveryNotification: ") + .append(toIndentedString(muteFirstRecoveryNotification)) + .append("\n"); + sb.append(" notifyEndStates: ").append(toIndentedString(notifyEndStates)).append("\n"); + sb.append(" notifyEndTypes: ").append(toIndentedString(notifyEndTypes)).append("\n"); + sb.append(" schedule: ").append(toIndentedString(schedule)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequestData.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequestData.java new file mode 100644 index 00000000000..b67b9b44c60 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeUpdateRequestData.java @@ -0,0 +1,210 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Object to update a downtime. */ +@JsonPropertyOrder({ + DowntimeUpdateRequestData.JSON_PROPERTY_ATTRIBUTES, + DowntimeUpdateRequestData.JSON_PROPERTY_ID, + DowntimeUpdateRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeUpdateRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DowntimeUpdateRequestAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DowntimeResourceType type = DowntimeResourceType.DOWNTIME; + + public DowntimeUpdateRequestData() {} + + @JsonCreator + public DowntimeUpdateRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + DowntimeUpdateRequestAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DowntimeResourceType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DowntimeUpdateRequestData attributes(DowntimeUpdateRequestAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of the downtime to update. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DowntimeUpdateRequestAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DowntimeUpdateRequestAttributes attributes) { + this.attributes = attributes; + } + + public DowntimeUpdateRequestData id(String id) { + this.id = id; + return this; + } + + /** + * ID of this downtime. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public DowntimeUpdateRequestData type(DowntimeResourceType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Downtime resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DowntimeResourceType getType() { + return type; + } + + public void setType(DowntimeResourceType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DowntimeUpdateRequestData + */ + @JsonAnySetter + public DowntimeUpdateRequestData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DowntimeUpdateRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeUpdateRequestData downtimeUpdateRequestData = (DowntimeUpdateRequestData) o; + return Objects.equals(this.attributes, downtimeUpdateRequestData.attributes) + && Objects.equals(this.id, downtimeUpdateRequestData.id) + && Objects.equals(this.type, downtimeUpdateRequestData.type) + && Objects.equals( + this.additionalProperties, downtimeUpdateRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeUpdateRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ListDowntimesResponse.java b/src/main/java/com/datadog/api/client/v2/model/ListDowntimesResponse.java new file mode 100644 index 00000000000..7a0b00d3ef9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListDowntimesResponse.java @@ -0,0 +1,218 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Response for retrieving all downtimes. */ +@JsonPropertyOrder({ + ListDowntimesResponse.JSON_PROPERTY_DATA, + ListDowntimesResponse.JSON_PROPERTY_INCLUDED, + ListDowntimesResponse.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ListDowntimesResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = null; + + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + + public static final String JSON_PROPERTY_META = "meta"; + private DowntimeMeta meta; + + public ListDowntimesResponse data(List data) { + this.data = data; + for (DowntimeResponseData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ListDowntimesResponse addDataItem(DowntimeResponseData dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * An array of downtimes. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public ListDowntimesResponse included(List included) { + this.included = included; + for (DowntimeResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ListDowntimesResponse addIncludedItem(DowntimeResponseIncludedItem includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * Array of objects related to the downtimes. + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + } + + public ListDowntimesResponse meta(DowntimeMeta meta) { + this.meta = meta; + this.unparsed |= meta.unparsed; + return this; + } + + /** + * Pagination metadata returned by the API. + * + * @return meta + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeMeta getMeta() { + return meta; + } + + public void setMeta(DowntimeMeta meta) { + this.meta = meta; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ListDowntimesResponse + */ + @JsonAnySetter + public ListDowntimesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ListDowntimesResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListDowntimesResponse listDowntimesResponse = (ListDowntimesResponse) o; + return Objects.equals(this.data, listDowntimesResponse.data) + && Objects.equals(this.included, listDowntimesResponse.included) + && Objects.equals(this.meta, listDowntimesResponse.meta) + && Objects.equals(this.additionalProperties, listDowntimesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, included, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListDowntimesResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResourceType.java b/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResourceType.java new file mode 100644 index 00000000000..7a9d89939c4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResourceType.java @@ -0,0 +1,96 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** Monitor Downtime Match resource type. */ +@JsonSerialize( + using = MonitorDowntimeMatchResourceType.MonitorDowntimeMatchResourceTypeSerializer.class) +public class MonitorDowntimeMatchResourceType { + + public static final MonitorDowntimeMatchResourceType DOWNTIME_MATCH = + new MonitorDowntimeMatchResourceType("downtime_match"); + + private static final Set allowedValues = + new HashSet(Arrays.asList("downtime_match")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + MonitorDowntimeMatchResourceType(String value) { + this.value = value; + } + + public static class MonitorDowntimeMatchResourceTypeSerializer + extends StdSerializer { + public MonitorDowntimeMatchResourceTypeSerializer(Class t) { + super(t); + } + + public MonitorDowntimeMatchResourceTypeSerializer() { + this(null); + } + + @Override + public void serialize( + MonitorDowntimeMatchResourceType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this MonitorDowntimeMatchResourceType object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((MonitorDowntimeMatchResourceType) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static MonitorDowntimeMatchResourceType fromValue(String value) { + return new MonitorDowntimeMatchResourceType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponse.java b/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponse.java new file mode 100644 index 00000000000..8bbe6c3a81c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponse.java @@ -0,0 +1,180 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Response for retrieving all downtime matches for a monitor. */ +@JsonPropertyOrder({ + MonitorDowntimeMatchResponse.JSON_PROPERTY_DATA, + MonitorDowntimeMatchResponse.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonitorDowntimeMatchResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = null; + + public static final String JSON_PROPERTY_META = "meta"; + private DowntimeMeta meta; + + public MonitorDowntimeMatchResponse data(List data) { + this.data = data; + for (MonitorDowntimeMatchResponseData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public MonitorDowntimeMatchResponse addDataItem(MonitorDowntimeMatchResponseData dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * An array of downtime matches. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public MonitorDowntimeMatchResponse meta(DowntimeMeta meta) { + this.meta = meta; + this.unparsed |= meta.unparsed; + return this; + } + + /** + * Pagination metadata returned by the API. + * + * @return meta + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DowntimeMeta getMeta() { + return meta; + } + + public void setMeta(DowntimeMeta meta) { + this.meta = meta; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return MonitorDowntimeMatchResponse + */ + @JsonAnySetter + public MonitorDowntimeMatchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this MonitorDowntimeMatchResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonitorDowntimeMatchResponse monitorDowntimeMatchResponse = (MonitorDowntimeMatchResponse) o; + return Objects.equals(this.data, monitorDowntimeMatchResponse.data) + && Objects.equals(this.meta, monitorDowntimeMatchResponse.meta) + && Objects.equals( + this.additionalProperties, monitorDowntimeMatchResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonitorDowntimeMatchResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponseAttributes.java b/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponseAttributes.java new file mode 100644 index 00000000000..19fb5f90e08 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponseAttributes.java @@ -0,0 +1,243 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Downtime match details. */ +@JsonPropertyOrder({ + MonitorDowntimeMatchResponseAttributes.JSON_PROPERTY_END, + MonitorDowntimeMatchResponseAttributes.JSON_PROPERTY_GROUPS, + MonitorDowntimeMatchResponseAttributes.JSON_PROPERTY_SCOPE, + MonitorDowntimeMatchResponseAttributes.JSON_PROPERTY_START +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonitorDowntimeMatchResponseAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_END = "end"; + private JsonNullable end = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_GROUPS = "groups"; + private List groups = null; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private String scope; + + public static final String JSON_PROPERTY_START = "start"; + private OffsetDateTime start; + + public MonitorDowntimeMatchResponseAttributes end(OffsetDateTime end) { + this.end = JsonNullable.of(end); + return this; + } + + /** + * The end of the downtime. + * + * @return end + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getEnd() { + return end.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_END) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getEnd_JsonNullable() { + return end; + } + + @JsonProperty(JSON_PROPERTY_END) + public void setEnd_JsonNullable(JsonNullable end) { + this.end = end; + } + + public void setEnd(OffsetDateTime end) { + this.end = JsonNullable.of(end); + } + + public MonitorDowntimeMatchResponseAttributes groups(List groups) { + this.groups = groups; + return this; + } + + public MonitorDowntimeMatchResponseAttributes addGroupsItem(String groupsItem) { + if (this.groups == null) { + this.groups = new ArrayList<>(); + } + this.groups.add(groupsItem); + return this; + } + + /** + * An array of groups associated with the downtime. + * + * @return groups + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_GROUPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + + public MonitorDowntimeMatchResponseAttributes scope(String scope) { + this.scope = scope; + return this; + } + + /** + * The scope to which the downtime applies. Must follow the common search syntax. + * + * @return scope + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public MonitorDowntimeMatchResponseAttributes start(OffsetDateTime start) { + this.start = start; + return this; + } + + /** + * The start of the downtime. + * + * @return start + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getStart() { + return start; + } + + public void setStart(OffsetDateTime start) { + this.start = start; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return MonitorDowntimeMatchResponseAttributes + */ + @JsonAnySetter + public MonitorDowntimeMatchResponseAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this MonitorDowntimeMatchResponseAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonitorDowntimeMatchResponseAttributes monitorDowntimeMatchResponseAttributes = + (MonitorDowntimeMatchResponseAttributes) o; + return Objects.equals(this.end, monitorDowntimeMatchResponseAttributes.end) + && Objects.equals(this.groups, monitorDowntimeMatchResponseAttributes.groups) + && Objects.equals(this.scope, monitorDowntimeMatchResponseAttributes.scope) + && Objects.equals(this.start, monitorDowntimeMatchResponseAttributes.start) + && Objects.equals( + this.additionalProperties, monitorDowntimeMatchResponseAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(end, groups, scope, start, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonitorDowntimeMatchResponseAttributes {\n"); + sb.append(" end: ").append(toIndentedString(end)).append("\n"); + sb.append(" groups: ").append(toIndentedString(groups)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponseData.java b/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponseData.java new file mode 100644 index 00000000000..367daae1620 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonitorDowntimeMatchResponseData.java @@ -0,0 +1,210 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** A downtime match. */ +@JsonPropertyOrder({ + MonitorDowntimeMatchResponseData.JSON_PROPERTY_ATTRIBUTES, + MonitorDowntimeMatchResponseData.JSON_PROPERTY_ID, + MonitorDowntimeMatchResponseData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonitorDowntimeMatchResponseData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private MonitorDowntimeMatchResponseAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private JsonNullable id = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_TYPE = "type"; + private MonitorDowntimeMatchResourceType type = MonitorDowntimeMatchResourceType.DOWNTIME_MATCH; + + public MonitorDowntimeMatchResponseData attributes( + MonitorDowntimeMatchResponseAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Downtime match details. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MonitorDowntimeMatchResponseAttributes getAttributes() { + return attributes; + } + + public void setAttributes(MonitorDowntimeMatchResponseAttributes attributes) { + this.attributes = attributes; + } + + public MonitorDowntimeMatchResponseData id(String id) { + this.id = JsonNullable.of(id); + return this; + } + + /** + * The downtime ID. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getId() { + return id.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getId_JsonNullable() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + public void setId_JsonNullable(JsonNullable id) { + this.id = id; + } + + public void setId(String id) { + this.id = JsonNullable.of(id); + } + + public MonitorDowntimeMatchResponseData type(MonitorDowntimeMatchResourceType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Monitor Downtime Match resource type. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MonitorDowntimeMatchResourceType getType() { + return type; + } + + public void setType(MonitorDowntimeMatchResourceType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return MonitorDowntimeMatchResponseData + */ + @JsonAnySetter + public MonitorDowntimeMatchResponseData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this MonitorDowntimeMatchResponseData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonitorDowntimeMatchResponseData monitorDowntimeMatchResponseData = + (MonitorDowntimeMatchResponseData) o; + return Objects.equals(this.attributes, monitorDowntimeMatchResponseData.attributes) + && Objects.equals(this.id, monitorDowntimeMatchResponseData.id) + && Objects.equals(this.type, monitorDowntimeMatchResponseData.type) + && Objects.equals( + this.additionalProperties, monitorDowntimeMatchResponseData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonitorDowntimeMatchResponseData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_Downtime_not_found_response.freeze b/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_Downtime_not_found_response.freeze new file mode 100644 index 00000000000..a90a96a7544 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_Downtime_not_found_response.freeze @@ -0,0 +1 @@ +2023-05-25T20:24:18.346Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_Downtime_not_found_response.json b/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_Downtime_not_found_response.json new file mode 100644 index 00000000000..bc8c6fa4111 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_Downtime_not_found_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/downtime/00000000-0000-1234-0000-000000000000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Downtime 00000000-0000-1234-0000-000000000000 not found\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6f61ec7b-7481-b4da-4ba0-5c26e31ed656" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_OK_response.freeze new file mode 100644 index 00000000000..dadcb98638c --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-06-02T20:53:22.584Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_OK_response.json new file mode 100644 index 00000000000..1d8450b3ffb --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Cancel_a_downtime_returns_OK_response.json @@ -0,0 +1,82 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"message\":\"test message\",\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"start\":null},\"scope\":\"test:testcanceladowntimereturnsokresponse1685739202\"},\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/downtime", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"downtime\",\"attributes\":{\"mute_first_recovery_notification\":false,\"status\":\"active\",\"created\":\"2023-06-02T20:53:23.252025+00:00\",\"notify_end_states\":[\"alert\",\"no data\",\"warn\"],\"canceled\":null,\"display_timezone\":\"UTC\",\"modified\":\"2023-06-02T20:53:23.252025+00:00\",\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"scope\":\"test:testcanceladowntimereturnsokresponse1685739202\",\"schedule\":{\"start\":\"2023-06-02T20:53:23.238403+00:00\",\"end\":null},\"message\":\"test message\",\"notify_end_types\":[\"expired\"]},\"id\":\"83718756-0187-11ee-8c18-da7ad0900002\",\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}},\"monitor\":{\"data\":null}}},\"included\":[{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"created_at\":\"2019-10-02T08:15:39.795051+00:00\",\"modified_at\":\"2020-06-15T12:33:12.884459+00:00\",\"email\":\"frog@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\"}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e6defbed-aa54-a33f-1975-47e4369f0742" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/downtime/83718756-0187-11ee-8c18-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "3db26238-8ae8-98bb-d300-58dcf2b742f5" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/downtime/83718756-0187-11ee-8c18-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "3db26238-8ae8-98bb-d300-58dcf2b742f6" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..868fa23055b --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2023-05-25T20:24:19.765Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Bad_Request_response.json new file mode 100644 index 00000000000..2613856f8a4 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Bad_Request_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/downtime/INVALID_UUID_LENGTH", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Invalid URL param: downtime_id must be an uuid\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "75bc6d37-c97b-e38e-03a3-476e399608ca" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..4e1511c89b0 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2023-05-25T20:24:20.021Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Not_Found_response.json new file mode 100644 index 00000000000..99f93909f9e --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_Not_Found_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/downtime/00000000-0000-1234-0000-000000000000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Downtime not found\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "f710484c-d90f-0a6c-158b-c1d175a36a71" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_OK_response.freeze new file mode 100644 index 00000000000..c8b3ce717dc --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-06-02T20:53:24.573Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_OK_response.json new file mode 100644 index 00000000000..f43c75dfe28 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_a_downtime_returns_OK_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"message\":\"test message\",\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"start\":null},\"scope\":\"test:testgetadowntimereturnsokresponse1685739204\"},\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/downtime", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"downtime\",\"attributes\":{\"display_timezone\":\"UTC\",\"scope\":\"test:testgetadowntimereturnsokresponse1685739204\",\"notify_end_states\":[\"warn\",\"alert\",\"no data\"],\"message\":\"test message\",\"created\":\"2023-06-02T20:53:24.806100+00:00\",\"status\":\"active\",\"modified\":\"2023-06-02T20:53:24.806100+00:00\",\"canceled\":null,\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"end\":null,\"start\":\"2023-06-02T20:53:24.791647+00:00\"},\"notify_end_types\":[\"expired\"],\"mute_first_recovery_notification\":false},\"relationships\":{\"monitor\":{\"data\":null},\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}},\"id\":\"845e9a1e-0187-11ee-817a-da7ad0900002\"},\"included\":[{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"created_at\":\"2019-10-02T08:15:39.795051+00:00\",\"modified_at\":\"2020-06-15T12:33:12.884459+00:00\",\"email\":\"frog@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\"}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "f5fbbdaa-b123-2c3b-e3ce-5514febf5148" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/downtime/845e9a1e-0187-11ee-817a-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"downtime\",\"attributes\":{\"notify_end_types\":[\"expired\"],\"modified\":\"2023-06-02T20:53:24.806100+00:00\",\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"scope\":\"test:testgetadowntimereturnsokresponse1685739204\",\"schedule\":{\"end\":null,\"start\":\"2023-06-02T20:53:24.791647+00:00\"},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2023-06-02T20:53:24.806100+00:00\",\"canceled\":null,\"mute_first_recovery_notification\":false,\"message\":\"test message\",\"display_timezone\":\"UTC\",\"status\":\"active\"},\"id\":\"845e9a1e-0187-11ee-817a-da7ad0900002\"}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "efd91a76-39a6-ad32-7004-59f97f75b358" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/downtime/845e9a1e-0187-11ee-817a-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "3d2c5398-6e5a-9451-c2dd-aa907fb25163" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_Monitor_Not_Found_error_response.freeze b/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_Monitor_Not_Found_error_response.freeze new file mode 100644 index 00000000000..51753661d66 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_Monitor_Not_Found_error_response.freeze @@ -0,0 +1 @@ +2023-06-09T18:54:40.002Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_Monitor_Not_Found_error_response.json b/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_Monitor_Not_Found_error_response.json new file mode 100644 index 00000000000..eb5fb0c9fd6 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_Monitor_Not_Found_error_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/monitor/0/downtime_matches", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Monitor with id 0 not found\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "75d9e727-c60f-6cf9-33b2-cba1c56ef231" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_OK_response.freeze new file mode 100644 index 00000000000..6525ff095c5 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-06-28T17:25:38.832Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_OK_response.json new file mode 100644 index 00000000000..73dbc895e2a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_all_downtimes_for_a_monitor_returns_OK_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/monitor/35534610/downtime_matches", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[{\"type\":\"downtime_match\",\"id\":\"aeefc6a8-15d8-11ee-a8ef-da7ad0900002\",\"attributes\":{\"groups\":[\"*\"],\"scope\":\"*\",\"start\":\"2023-06-28T17:23:57.324000+00:00\",\"end\":null}}],\"meta\":{\"page\":{\"total_filtered_count\":1}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6cee0725-d8bf-888a-4568-44604a4a6896" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_all_downtimes_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_all_downtimes_returns_OK_response.freeze new file mode 100644 index 00000000000..34a6dce0e0c --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_all_downtimes_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-05-25T20:24:20.897Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_all_downtimes_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_all_downtimes_returns_OK_response.json new file mode 100644 index 00000000000..4d5b68dd803 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_all_downtimes_returns_OK_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/downtime", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-28T14:17:52.420429+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-28T14:17:52.420429+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635430672\",\"schedule\":{\"end\":null,\"start\":\"2021-10-28T14:17:52.399817+00:00\"},\"status\":\"active\"},\"id\":\"1d9e7eee-b23a-11ed-a0dc-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-28T14:33:48.622821+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-28T14:33:48.622821+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635431628\",\"schedule\":{\"end\":null,\"start\":\"2021-10-28T14:33:48.620257+00:00\"},\"status\":\"active\"},\"id\":\"1d9ec3cc-b23a-11ed-a0ea-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-28T14:48:50.581496+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-28T14:48:50.581496+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635432530\",\"schedule\":{\"end\":null,\"start\":\"2021-10-28T14:48:50.575549+00:00\"},\"status\":\"active\"},\"id\":\"1da042ec-b23a-11ed-a16b-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-28T14:56:22.879389+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-28T14:56:22.879389+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635432982\",\"schedule\":{\"end\":null,\"start\":\"2021-10-28T14:56:22.875090+00:00\"},\"status\":\"active\"},\"id\":\"1da0495e-b23a-11ed-a16c-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-28T15:16:54.480401+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-28T15:16:54.480401+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635434214\",\"schedule\":{\"end\":null,\"start\":\"2021-10-28T15:16:54.477880+00:00\"},\"status\":\"active\"},\"id\":\"1da06d30-b23a-11ed-a178-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-28T16:08:31.571892+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-28T16:08:31.571892+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635437311\",\"schedule\":{\"end\":null,\"start\":\"2021-10-28T16:08:31.562562+00:00\"},\"status\":\"active\"},\"id\":\"1da0eabc-b23a-11ed-a193-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-29T03:11:14.667351+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-29T03:11:14.667351+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635477074\",\"schedule\":{\"end\":null,\"start\":\"2021-10-29T03:11:14.662838+00:00\"},\"status\":\"active\"},\"id\":\"1da8e726-b23a-11ed-a3ab-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-29T08:07:08.893065+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-29T08:07:08.893065+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635494828\",\"schedule\":{\"end\":null,\"start\":\"2021-10-29T08:07:08.868526+00:00\"},\"status\":\"active\"},\"id\":\"1db7e4f6-b23a-11ed-a86e-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-29T08:41:03.157018+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-29T08:41:03.157018+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635496863\",\"schedule\":{\"end\":null,\"start\":\"2021-10-29T08:41:03.154098+00:00\"},\"status\":\"active\"},\"id\":\"1db8d8ac-b23a-11ed-a879-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-29T17:21:23.756952+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-29T17:21:23.756952+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635528083\",\"schedule\":{\"end\":null,\"start\":\"2021-10-29T17:21:23.754124+00:00\"},\"status\":\"active\"},\"id\":\"1dc7e13a-b23a-11ed-ad75-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-30T03:11:07.935370+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-30T03:11:07.935370+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635563467\",\"schedule\":{\"end\":null,\"start\":\"2021-10-30T03:11:07.931742+00:00\"},\"status\":\"active\"},\"id\":\"1dcb33f8-b23a-11ed-ae77-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-30T16:06:10.276649+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-30T16:06:10.276649+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635609970\",\"schedule\":{\"end\":null,\"start\":\"2021-10-30T16:06:10.273151+00:00\"},\"status\":\"active\"},\"id\":\"1dcd0b9c-b23a-11ed-af06-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-10-31T03:11:11.316510+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-10-31T03:11:11.316510+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635649871\",\"schedule\":{\"end\":null,\"start\":\"2021-10-31T03:11:11.312216+00:00\"},\"status\":\"active\"},\"id\":\"1dce8d64-b23a-11ed-af88-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-01T03:08:39.804462+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-01T03:08:39.804462+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635736119\",\"schedule\":{\"end\":null,\"start\":\"2021-11-01T03:08:39.802027+00:00\"},\"status\":\"active\"},\"id\":\"1dd35b50-b23a-11ed-b0e9-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T03:10:15.532889+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T03:10:15.532889+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635822615\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T03:10:15.528871+00:00\"},\"status\":\"active\"},\"id\":\"1de58d3e-b23a-11ed-b608-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T09:20:28.614860+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T09:20:28.614860+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635844828\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T09:20:28.611532+00:00\"},\"status\":\"active\"},\"id\":\"1de8bb30-b23a-11ed-b6d9-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T09:34:53.765122+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T09:34:53.765122+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635845693\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T09:34:53.761176+00:00\"},\"status\":\"active\"},\"id\":\"1de8f14a-b23a-11ed-b6e7-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T09:48:14.313975+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T09:48:14.313975+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635846494\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T09:48:14.311153+00:00\"},\"status\":\"active\"},\"id\":\"1de919c2-b23a-11ed-b6f4-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T09:55:05.587914+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T09:55:05.587914+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635846905\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T09:55:05.584723+00:00\"},\"status\":\"active\"},\"id\":\"1de92250-b23a-11ed-b6f8-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T10:45:12.687669+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T10:45:12.687669+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635849912\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T10:45:12.683837+00:00\"},\"status\":\"active\"},\"id\":\"1de9870e-b23a-11ed-b70e-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T10:57:27.536018+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T10:57:27.536018+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635850647\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T10:57:27.532780+00:00\"},\"status\":\"active\"},\"id\":\"1de99172-b23a-11ed-b713-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T11:07:15.081382+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T11:07:15.081382+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635851234\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T11:07:15.078037+00:00\"},\"status\":\"active\"},\"id\":\"1de9e398-b23a-11ed-b72e-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T11:15:16.847749+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T11:15:16.847749+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635851716\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T11:15:16.845135+00:00\"},\"status\":\"active\"},\"id\":\"1de9e5be-b23a-11ed-b72f-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T14:12:24.714186+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T14:12:24.714186+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635862344\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T14:12:24.710625+00:00\"},\"status\":\"active\"},\"id\":\"1deb279e-b23a-11ed-b784-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T14:46:14.802545+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T14:46:14.802545+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635864374\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T14:46:14.800340+00:00\"},\"status\":\"active\"},\"id\":\"1deb73a2-b23a-11ed-b797-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T15:16:48.477972+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T15:16:48.477972+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635866208\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T15:16:48.469517+00:00\"},\"status\":\"active\"},\"id\":\"1debd126-b23a-11ed-b7b0-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-02T18:28:35.537425+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-02T18:28:35.537425+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635877715\",\"schedule\":{\"end\":null,\"start\":\"2021-11-02T18:28:35.532968+00:00\"},\"status\":\"active\"},\"id\":\"1deefd9c-b23a-11ed-b8b8-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-03T03:08:05.553644+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-03T03:08:05.553644+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635908885\",\"schedule\":{\"end\":null,\"start\":\"2021-11-03T03:08:05.547972+00:00\"},\"status\":\"active\"},\"id\":\"1df2a096-b23a-11ed-b9b4-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-03T08:58:07.316209+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-03T08:58:07.316209+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635929887\",\"schedule\":{\"end\":null,\"start\":\"2021-11-03T08:58:07.312866+00:00\"},\"status\":\"active\"},\"id\":\"1df51538-b23a-11ed-ba64-da7ad0900002\"},{\"type\":\"downtime\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"*\"]},\"notify_end_states\":[\"warn\",\"no data\",\"alert\"],\"created\":\"2021-11-03T10:28:12.844618+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_types\":[\"expired\"],\"message\":null,\"canceled\":null,\"modified\":\"2021-11-03T10:28:12.844618+00:00\",\"scope\":\"host:java-hostsMuteErrorsTest-local-1635935292\",\"schedule\":{\"end\":null,\"start\":\"2021-11-03T10:28:12.841116+00:00\"},\"status\":\"active\"},\"id\":\"1df5e13e-b23a-11ed-baa2-da7ad0900002\"}],\"meta\":{\"page\":{\"total_filtered_count\":1049}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d1561834-c5af-2aae-7c82-6a887493b31b" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..23e427ac1cd --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2023-06-02T20:53:25.827Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_Bad_Request_response.json new file mode 100644 index 00000000000..1e8e1e09ea2 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_Bad_Request_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"start\":null},\"scope\":\"BAD_SCOPE_MISSING_KEY_VALUE_FORMAT\"},\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/downtime", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"All values must have a key\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "40f86a25-8635-75fd-cb5c-7cdbef41c692" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_OK_response.freeze new file mode 100644 index 00000000000..73fc56694e2 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-06-02T20:53:26.050Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_OK_response.json new file mode 100644 index 00000000000..55cd1a1eae0 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Schedule_a_downtime_returns_OK_response.json @@ -0,0 +1,57 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"message\":\"dark forest\",\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"start\":null},\"scope\":\"test:testscheduleadowntimereturnsokresponse1685739206\"},\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/downtime", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"downtime\",\"attributes\":{\"display_timezone\":\"UTC\",\"scope\":\"test:testscheduleadowntimereturnsokresponse1685739206\",\"notify_end_states\":[\"warn\",\"alert\",\"no data\"],\"message\":\"dark forest\",\"created\":\"2023-06-02T20:53:26.300497+00:00\",\"status\":\"active\",\"modified\":\"2023-06-02T20:53:26.300497+00:00\",\"canceled\":null,\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"end\":null,\"start\":\"2023-06-02T20:53:26.286133+00:00\"},\"notify_end_types\":[\"expired\"],\"mute_first_recovery_notification\":false},\"relationships\":{\"monitor\":{\"data\":null},\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}},\"id\":\"85428b34-0187-11ee-bb05-da7ad0900002\"},\"included\":[{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"created_at\":\"2019-10-02T08:15:39.795051+00:00\",\"modified_at\":\"2020-06-15T12:33:12.884459+00:00\",\"email\":\"frog@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\"}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d694f391-c987-3573-6dbb-d73d81065907" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/downtime/85428b34-0187-11ee-bb05-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "b3bc9b53-8a30-6c94-36ad-2c48a358169a" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..206adccca8e --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2023-06-02T20:53:26.666Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Bad_Request_response.json new file mode 100644 index 00000000000..2605116af2e --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Bad_Request_response.json @@ -0,0 +1,87 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"message\":\"test message\",\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"start\":null},\"scope\":\"test:testupdateadowntimereturnsbadrequestresponse1685739206\"},\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/downtime", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"downtime\",\"attributes\":{\"schedule\":{\"start\":\"2023-06-02T20:53:26.854449+00:00\",\"end\":null},\"canceled\":null,\"modified\":\"2023-06-02T20:53:26.869296+00:00\",\"created\":\"2023-06-02T20:53:26.869296+00:00\",\"status\":\"active\",\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"scope\":\"test:testupdateadowntimereturnsbadrequestresponse1685739206\",\"message\":\"test message\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_states\":[\"no data\",\"warn\",\"alert\"],\"notify_end_types\":[\"expired\"]},\"relationships\":{\"monitor\":{\"data\":null},\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}},\"id\":\"85997dfe-0187-11ee-a1c1-da7ad0900002\"},\"included\":[{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"created_at\":\"2019-10-02T08:15:39.795051+00:00\",\"modified_at\":\"2020-06-15T12:33:12.884459+00:00\",\"email\":\"frog@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\"}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "c8e639c2-df31-d4c2-a2f9-c916cb22951e" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"invalid_field\":\"sophon\"},\"id\":\"85997dfe-0187-11ee-a1c1-da7ad0900002\",\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/downtime/85997dfe-0187-11ee-a1c1-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Additional properties are not allowed ('invalid_field' was unexpected)\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "9ba97ebb-2c39-5ae7-5c9d-9f8cbd7344d5" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/downtime/85997dfe-0187-11ee-a1c1-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "7a579640-4431-3d02-459f-91a959c6a6e5" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Downtime_not_found_response.freeze b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Downtime_not_found_response.freeze new file mode 100644 index 00000000000..91f2c6b32f3 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Downtime_not_found_response.freeze @@ -0,0 +1 @@ +2023-05-25T20:24:22.729Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Downtime_not_found_response.json b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Downtime_not_found_response.json new file mode 100644 index 00000000000..27a176245df --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_Downtime_not_found_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"message\":\"test msg\"},\"id\":\"00000000-0000-1234-0000-000000000000\",\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/downtime/00000000-0000-1234-0000-000000000000", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Downtime not found\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "aff714ec-f657-3a9d-cd32-612c038d5cce" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_OK_response.freeze new file mode 100644 index 00000000000..d484e57c55d --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-06-02T20:53:27.909Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_OK_response.json new file mode 100644 index 00000000000..72f8a3242a6 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_a_downtime_returns_OK_response.json @@ -0,0 +1,87 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"message\":\"test message\",\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"start\":null},\"scope\":\"test:testupdateadowntimereturnsokresponse1685739207\"},\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/downtime", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"downtime\",\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}},\"monitor\":{\"data\":null}},\"id\":\"865c7f20-0187-11ee-ac0a-da7ad0900002\",\"attributes\":{\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"status\":\"active\",\"message\":\"test message\",\"created\":\"2023-06-02T20:53:28.147387+00:00\",\"schedule\":{\"end\":null,\"start\":\"2023-06-02T20:53:28.134493+00:00\"},\"modified\":\"2023-06-02T20:53:28.147387+00:00\",\"display_timezone\":\"UTC\",\"mute_first_recovery_notification\":false,\"notify_end_states\":[\"no data\",\"warn\",\"alert\"],\"scope\":\"test:testupdateadowntimereturnsokresponse1685739207\",\"notify_end_types\":[\"expired\"],\"canceled\":null}},\"included\":[{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"created_at\":\"2019-10-02T08:15:39.795051+00:00\",\"modified_at\":\"2020-06-15T12:33:12.884459+00:00\",\"email\":\"frog@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\"}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "75d9b76c-7db5-0cb1-fe15-dd3de6e34baa" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"message\":\"light speed\"},\"id\":\"865c7f20-0187-11ee-ac0a-da7ad0900002\",\"type\":\"downtime\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/downtime/865c7f20-0187-11ee-ac0a-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"downtime\",\"attributes\":{\"display_timezone\":\"UTC\",\"status\":\"active\",\"message\":\"light speed\",\"created\":\"2023-06-02T20:53:28.147387+00:00\",\"canceled\":null,\"modified\":\"2023-06-02T20:53:28.386158+00:00\",\"notify_end_types\":[\"expired\"],\"mute_first_recovery_notification\":false,\"notify_end_states\":[\"no data\",\"alert\",\"warn\"],\"monitor_identifier\":{\"monitor_tags\":[\"cat:hat\"]},\"schedule\":{\"end\":null,\"start\":\"2023-06-02T20:53:28.134493+00:00\"},\"scope\":\"test:testupdateadowntimereturnsokresponse1685739207\"},\"id\":\"865c7f20-0187-11ee-ac0a-da7ad0900002\",\"relationships\":{\"monitor\":{\"data\":null},\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}}},\"included\":[{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"created_at\":\"2019-10-02T08:15:39.795051+00:00\",\"modified_at\":\"2020-06-15T12:33:12.884459+00:00\",\"email\":\"frog@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\"}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "a42a553f-b4f2-7769-8aa5-315f4c0437d7" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/downtime/865c7f20-0187-11ee-ac0a-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "3585ddc4-a58f-36c3-fd9e-5b50c88606a3" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/downtimes.feature b/src/test/resources/com/datadog/api/client/v2/api/downtimes.feature new file mode 100644 index 00000000000..7f8a5bcdbd6 --- /dev/null +++ b/src/test/resources/com/datadog/api/client/v2/api/downtimes.feature @@ -0,0 +1,146 @@ +@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 + + @skip-validation @team:DataDog/monitor-app + Scenario: Cancel a downtime returns "Downtime not found" response + Given new "CancelDowntime" request + And operation "CancelDowntime" enabled + 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 operation "CancelDowntime" enabled + And new "CancelDowntime" request + And request contains "downtime_id" parameter from "downtime_v2.data.id" + When the request is sent + Then the response status is 204 OK + + @skip-validation @team:DataDog/monitor-app + Scenario: Get a downtime returns "Bad Request" response + Given new "GetDowntime" request + And operation "GetDowntime" enabled + And request contains "downtime_id" parameter with value "INVALID_UUID_LENGTH" + When the request is sent + Then the response status is 400 Bad Request + + @skip-validation @team:DataDog/monitor-app + Scenario: Get a downtime returns "Not Found" response + Given new "GetDowntime" request + And operation "GetDowntime" enabled + 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 operation "GetDowntime" enabled + And new "GetDowntime" request + And request contains "downtime_id" parameter from "downtime_v2.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" + + @generated @skip @team:DataDog/monitor-app + Scenario: Get active downtimes for a monitor returns "Monitor Not Found error" response + Given operation "ListMonitorDowntimes" enabled + And new "ListMonitorDowntimes" request + And request contains "monitor_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Monitor Not Found error + + @generated @skip @team:DataDog/monitor-app + Scenario: Get active downtimes for a monitor returns "OK" response + Given operation "ListMonitorDowntimes" enabled + And new "ListMonitorDowntimes" request + And request contains "monitor_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @team:DataDog/monitor-app + Scenario: Get all downtimes for a monitor returns "Monitor Not Found error" response + Given new "ListMonitorDowntimes" request + And operation "ListMonitorDowntimes" enabled + And request contains "monitor_id" parameter with value 0 + When the request is sent + Then the response status is 404 Monitor Not Found error + + @replay-only @team:DataDog/monitor-app + Scenario: Get all downtimes for a monitor returns "OK" response + Given new "ListMonitorDowntimes" request + And operation "ListMonitorDowntimes" enabled + And request contains "monitor_id" parameter with value 35534610 + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data" has item with field "id" with value "aeefc6a8-15d8-11ee-a8ef-da7ad0900002" + + @replay-only @team:DataDog/monitor-app + Scenario: Get all downtimes returns "OK" response + Given new "ListDowntimes" request + And operation "ListDowntimes" enabled + When the request is sent + Then the response status is 200 OK + And the response "data" has item with field "id" with value "1dcb33f8-b23a-11ed-ae77-da7ad0900002" + + @skip-validation @team:DataDog/monitor-app + Scenario: Schedule a downtime returns "Bad Request" response + Given new "CreateDowntime" request + And operation "CreateDowntime" enabled + And body with value { "data": { "attributes": { "monitor_identifier": { "monitor_tags": ["cat:hat"] }, "scope": "BAD_SCOPE_MISSING_KEY_VALUE_FORMAT", "schedule": {"start": null } }, "type": "downtime" } } + 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 operation "CreateDowntime" enabled + And body with value { "data": { "attributes": { "message": "dark forest", "monitor_identifier": { "monitor_tags": ["cat:hat"] }, "scope": "test:{{ unique_lower_alnum }}", "schedule": {"start": null } }, "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" + + @skip-java @skip-python @skip-ruby @skip-typescript @skip-validation @team:DataDog/monitor-app + Scenario: Update a downtime returns "Bad Request" response + Given there is a valid "downtime_v2" in the system + And operation "UpdateDowntime" enabled + And new "UpdateDowntime" request + And request contains "downtime_id" parameter from "downtime_v2.data.id" + And body with value {"data": {"attributes": {"invalid_field": "sophon"}, "id": "{{ downtime_v2.data.id }}", "type": "downtime"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip-validation @team:DataDog/monitor-app + Scenario: Update a downtime returns "Downtime not found" response + Given new "UpdateDowntime" request + And operation "UpdateDowntime" enabled + 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 operation "UpdateDowntime" enabled + And new "UpdateDowntime" request + And request contains "downtime_id" parameter from "downtime_v2.data.id" + And body with value {"data": {"attributes": {"message": "light speed"}, "id": "{{ downtime_v2.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/src/test/resources/com/datadog/api/client/v2/api/given.json b/src/test/resources/com/datadog/api/client/v2/api/given.json index b876dde97dd..ba3358dfd46 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/given.json +++ b/src/test/resources/com/datadog/api/client/v2/api/given.json @@ -79,6 +79,18 @@ "tag": "Dashboard Lists", "operationId": "CreateDashboardListItems" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"message\": \"test message\",\n \"monitor_identifier\": {\n \"monitor_tags\": [\"cat:hat\"]\n },\n \"scope\": \"test:{{ unique_lower_alnum }}\",\n \"schedule\": {\n \"start\": null\n }\n },\n \"type\": \"downtime\"\n }\n}" + } + ], + "step": "there is a valid \"downtime_v2\" in the system", + "key": "downtime_v2", + "tag": "Downtimes", + "operationId": "CreateDowntime" + }, { "parameters": [ { diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index c770cdf5c29..8c6fff4f43d 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -249,6 +249,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": { @@ -913,6 +950,12 @@ "type": "idempotent" } }, + "ListMonitorDowntimes": { + "tag": "Downtimes", + "undo": { + "type": "safe" + } + }, "ListPermissions": { "tag": "Roles", "undo": {