diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 196165112da..f2a1dc5e082 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -13374,6 +13374,40 @@ components: - name - targets type: object + CreateOnCallNotificationRuleRequest: + description: A top-level wrapper for creating a notification rule for a user + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/CreateOnCallNotificationRuleRequestData' + required: + - data + type: object + CreateOnCallNotificationRuleRequestData: + description: Data for creating an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/OnCallNotificationRuleRequestAttributes' + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object CreateOpenAPIResponse: description: Response for `CreateOpenAPI` operation. properties: @@ -30599,6 +30633,18 @@ components: $ref: '#/components/schemas/NotificationChannelData' type: array type: object + ListOnCallNotificationRulesResponse: + description: Response type for listing notification rules for a user + properties: + data: + items: + $ref: '#/components/schemas/OnCallNotificationRuleData' + type: array + included: + items: + $ref: '#/components/schemas/OnCallNotificationRulesIncluded' + type: array + type: object ListPipelinesResponse: description: Represents the response payload containing a list of pipelines and associated metadata. @@ -39053,6 +39099,130 @@ components: required: - type type: object + OnCallNotificationRule: + description: A top-level wrapper for a notification rule + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + id: 27590dae-47be-4a7d-9abf-8f4e45124020 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/OnCallNotificationRuleData' + included: + items: + $ref: '#/components/schemas/OnCallNotificationRulesIncluded' + type: array + required: + - data + type: object + OnCallNotificationRuleAttributes: + description: Attributes for an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + OnCallNotificationRuleCategory: + default: high_urgency + description: Specifies the category a notification rule will apply to + enum: + - high_urgency + - low_urgency + type: string + x-enum-varnames: + - HIGH_URGENCY + - LOW_URGENCY + OnCallNotificationRuleChannelRelationship: + description: Relationship object for creating a notification rule + properties: + data: + $ref: '#/components/schemas/OnCallNotificationRuleChannelRelationshipData' + required: + - data + type: object + OnCallNotificationRuleChannelRelationshipData: + description: Channel relationship data for creating a notification rule + properties: + id: + description: ID of the notification channel + type: string + type: + $ref: '#/components/schemas/NotificationChannelType' + type: object + OnCallNotificationRuleChannelSettings: + description: Defines the configuration for a channel associated with a notification + rule + oneOf: + - $ref: '#/components/schemas/OnCallPhoneNotificationRuleSettings' + OnCallNotificationRuleData: + description: Data for an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/OnCallNotificationRuleAttributes' + id: + description: Unique identifier for the rule + type: string + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object + OnCallNotificationRuleRelationships: + description: Relationship object for creating a notification rule + properties: + channel: + $ref: '#/components/schemas/OnCallNotificationRuleChannelRelationship' + type: object + OnCallNotificationRuleRequestAttributes: + description: Attributes for creating or modifying an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + OnCallNotificationRuleType: + default: notification_rules + description: Indicates that the resource is of type 'notification_rules'. + enum: + - notification_rules + example: notification_rules + type: string + x-enum-varnames: + - NOTIFICATION_RULES + OnCallNotificationRulesIncluded: + description: Represents additional included resources for a on-call notification + rules + oneOf: + - $ref: '#/components/schemas/NotificationChannelData' OnCallPageTargetType: description: The kind of target, `team_id` | `team_handle` | `user_id`. enum: @@ -39065,6 +39235,29 @@ components: - TEAM_ID - TEAM_HANDLE - USER_ID + OnCallPhoneNotificationRuleMethod: + description: Specifies the method in which a phone is used in a notification + rule + enum: + - sms + - voice + example: sms + type: string + x-enum-varnames: + - SMS + - VOICE + OnCallPhoneNotificationRuleSettings: + description: Configuration for using a phone notification channel in a notification + rule + properties: + method: + $ref: '#/components/schemas/OnCallPhoneNotificationRuleMethod' + type: + $ref: '#/components/schemas/NotificationChannelPhoneConfigType' + required: + - type + - method + type: object OnDemandConcurrencyCap: description: On-demand concurrency cap. properties: @@ -56304,6 +56497,59 @@ components: - name - options type: object + UpdateOnCallNotificationRuleRequest: + description: A top-level wrapper for updating a notification rule for a user + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + id: 2462ace1-49e2-aab1-xc4f-29cc4ae1105n7 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequestData' + required: + - data + type: object + UpdateOnCallNotificationRuleRequestAttributes: + description: Attributes for creating or modifying an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + UpdateOnCallNotificationRuleRequestData: + description: Data for updating an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequestAttributes' + id: + description: Unique identifier for the rule + type: string + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object UpdateOpenAPIResponse: description: Response for `UpdateOpenAPI`. properties: @@ -76343,6 +76589,255 @@ paths: operator: AND permissions: - on_call_read + /api/v2/on-call/users/{user_id}/notification-rules: + get: + description: List the notification rules for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: ListUserNotificationRules + parameters: + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListOnCallNotificationRulesResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: List On-Call notification rules for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_read + post: + description: Create a new notification rule for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: CreateUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateOnCallNotificationRuleRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Create an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_respond + /api/v2/on-call/users/{user_id}/notification-rules/{rule_id}: + delete: + description: Delete a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: DeleteUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Delete an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: OR + permissions: + - on_call_respond + get: + description: Get a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: GetUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: OR + permissions: + - on_call_read + put: + description: Update a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: UpdateUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Update an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: OR + permissions: + - on_call_read /api/v2/org_configs: get: description: Returns all Org Configs (name, description, and value). diff --git a/cassettes/features/v2/on-call/Create-an-On-Call-notification-rule-for-a-user-returns-Created-response.frozen b/cassettes/features/v2/on-call/Create-an-On-Call-notification-rule-for-a-user-returns-Created-response.frozen new file mode 100644 index 00000000000..fd26d2eef23 --- /dev/null +++ b/cassettes/features/v2/on-call/Create-an-On-Call-notification-rule-for-a-user-returns-Created-response.frozen @@ -0,0 +1 @@ +2025-12-16T19:30:04.834Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/Create-an-On-Call-notification-rule-for-a-user-returns-Created-response.yml b/cassettes/features/v2/on-call/Create-an-On-Call-notification-rule-for-a-user-returns-Created-response.yml new file mode 100644 index 00000000000..c2d713b2610 --- /dev/null +++ b/cassettes/features/v2/on-call/Create-an-On-Call-notification-rule-for-a-user-returns-Created-response.yml @@ -0,0 +1,88 @@ +http_interactions: +- recorded_at: Tue, 16 Dec 2025 19:30:04 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Create_an_On_Call_notification_rule_for_a_user_returns_Created_response-1765913404@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + encoding: UTF-8 + string: '{"data":{"type":"users","id":"2ab53f07-289f-4060-b21a-3d704096aadf","attributes":{"name":null,"handle":"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com","created_at":"2025-12-16T19:30:05.014723+00:00","modified_at":"2025-12-16T19:30:05.014723+00:00","email":"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com","icon":"https://secure.gravatar.com/avatar/c5ddb15c50d998db06711e0a31591216?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 19:30:04 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/2ab53f07-289f-4060-b21a-3d704096aadf/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"ca8520ce-27e0-4bba-997f-004047cda45d","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 19:30:04 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"ca8520ce-27e0-4bba-997f-004047cda45d","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/2ab53f07-289f-4060-b21a-3d704096aadf/notification-rules + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"4e551e4f-d1aa-4fce-8cc7-c6bf98925efe","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"ca8520ce-27e0-4bba-997f-004047cda45d","type":"notification_channels"}}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 19:30:04 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/2ab53f07-289f-4060-b21a-3d704096aadf + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/on-call/Delete-an-On-Call-notification-rule-for-a-user-returns-No-Content-response.frozen b/cassettes/features/v2/on-call/Delete-an-On-Call-notification-rule-for-a-user-returns-No-Content-response.frozen new file mode 100644 index 00000000000..3b1ee11b9e9 --- /dev/null +++ b/cassettes/features/v2/on-call/Delete-an-On-Call-notification-rule-for-a-user-returns-No-Content-response.frozen @@ -0,0 +1 @@ +2025-12-16T19:29:36.256Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/Delete-an-On-Call-notification-rule-for-a-user-returns-No-Content-response.yml b/cassettes/features/v2/on-call/Delete-an-On-Call-notification-rule-for-a-user-returns-No-Content-response.yml new file mode 100644 index 00000000000..63b35abbbc6 --- /dev/null +++ b/cassettes/features/v2/on-call/Delete-an-On-Call-notification-rule-for-a-user-returns-No-Content-response.yml @@ -0,0 +1,104 @@ +http_interactions: +- recorded_at: Tue, 16 Dec 2025 19:29:36 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response-1765913376@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + encoding: UTF-8 + string: '{"data":{"type":"users","id":"5ebbe76d-c072-4909-ba24-ffa71f4597a0","attributes":{"name":null,"handle":"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com","created_at":"2025-12-16T19:29:36.461504+00:00","modified_at":"2025-12-16T19:29:36.461504+00:00","email":"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com","icon":"https://secure.gravatar.com/avatar/dad7a8a5508730e67ad8dea90bcc189c?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 19:29:36 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"a557eb68-8b0a-48cf-ac65-73aede790994","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 19:29:36 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"a557eb68-8b0a-48cf-ac65-73aede790994","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-rules + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"71e9f009-5a69-4946-992e-d76b05d1ae61","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"a557eb68-8b0a-48cf-ac65-73aede790994","type":"notification_channels"}}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 19:29:36 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/on-call/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-rules/71e9f009-5a69-4946-992e-d76b05d1ae61 + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +- recorded_at: Tue, 16 Dec 2025 19:29:36 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0 + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/on-call/Get-an-On-Call-notification-rule-for-a-user-returns-OK-response.frozen b/cassettes/features/v2/on-call/Get-an-On-Call-notification-rule-for-a-user-returns-OK-response.frozen new file mode 100644 index 00000000000..d938f1a43ed --- /dev/null +++ b/cassettes/features/v2/on-call/Get-an-On-Call-notification-rule-for-a-user-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-12-16T21:16:24.271Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/Get-an-On-Call-notification-rule-for-a-user-returns-OK-response.yml b/cassettes/features/v2/on-call/Get-an-On-Call-notification-rule-for-a-user-returns-OK-response.yml new file mode 100644 index 00000000000..0be49b7b22e --- /dev/null +++ b/cassettes/features/v2/on-call/Get-an-On-Call-notification-rule-for-a-user-returns-OK-response.yml @@ -0,0 +1,106 @@ +http_interactions: +- recorded_at: Tue, 16 Dec 2025 21:16:24 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Get_an_On_Call_notification_rule_for_a_user_returns_OK_response-1765919784@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + encoding: UTF-8 + string: '{"data":{"type":"users","id":"b2a555c9-ac2d-430d-b321-10e4c0201ce3","attributes":{"name":null,"handle":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com","created_at":"2025-12-16T21:16:24.480454+00:00","modified_at":"2025-12-16T21:16:24.480454+00:00","email":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com","icon":"https://secure.gravatar.com/avatar/8e38ab440c2cdd2808a61dfa83f734d7?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 21:16:24 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 21:16:24 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-rules + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"d07cc90b-4fc5-455f-8f57-45d48a658bc6","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels"}}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 21:16:24 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/on-call/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-rules/d07cc90b-4fc5-455f-8f57-45d48a658bc6?include=channel + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"d07cc90b-4fc5-455f-8f57-45d48a658bc6","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels"}}}},"included":[{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com","formats":["html"]}}}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Tue, 16 Dec 2025 21:16:24 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3 + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/on-call/List-On-Call-notification-rules-for-a-user-returns-OK-response.frozen b/cassettes/features/v2/on-call/List-On-Call-notification-rules-for-a-user-returns-OK-response.frozen new file mode 100644 index 00000000000..11e9c7c90b2 --- /dev/null +++ b/cassettes/features/v2/on-call/List-On-Call-notification-rules-for-a-user-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-12-16T21:16:48.356Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/List-On-Call-notification-rules-for-a-user-returns-OK-response.yml b/cassettes/features/v2/on-call/List-On-Call-notification-rules-for-a-user-returns-OK-response.yml new file mode 100644 index 00000000000..c843ec8ffd4 --- /dev/null +++ b/cassettes/features/v2/on-call/List-On-Call-notification-rules-for-a-user-returns-OK-response.yml @@ -0,0 +1,106 @@ +http_interactions: +- recorded_at: Tue, 16 Dec 2025 21:16:48 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-List_On_Call_notification_rules_for_a_user_returns_OK_response-1765919808@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + encoding: UTF-8 + string: '{"data":{"type":"users","id":"0730802a-ee45-404b-a21d-5908d4c6b3c4","attributes":{"name":null,"handle":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com","created_at":"2025-12-16T21:16:48.579239+00:00","modified_at":"2025-12-16T21:16:48.579239+00:00","email":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com","icon":"https://secure.gravatar.com/avatar/c2f584fb6a42fbc0f0aad204ea40c0fc?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 21:16:48 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 21:16:48 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-rules + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"d93215d1-85c1-4528-a92f-1b604c1f4b2a","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels"}}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 16 Dec 2025 21:16:48 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/on-call/users/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-rules?include=channel + response: + body: + encoding: UTF-8 + string: '{"data":[{"id":"d93215d1-85c1-4528-a92f-1b604c1f4b2a","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels"}}}}],"included":[{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com","formats":["html"]}}}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Tue, 16 Dec 2025 21:16:48 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/0730802a-ee45-404b-a21d-5908d4c6b3c4 + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/on-call/Update-an-On-Call-notification-rule-for-a-user-returns-OK-response.frozen b/cassettes/features/v2/on-call/Update-an-On-Call-notification-rule-for-a-user-returns-OK-response.frozen new file mode 100644 index 00000000000..f55a35ff1b8 --- /dev/null +++ b/cassettes/features/v2/on-call/Update-an-On-Call-notification-rule-for-a-user-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-12-17T01:04:35.713Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/Update-an-On-Call-notification-rule-for-a-user-returns-OK-response.yml b/cassettes/features/v2/on-call/Update-an-On-Call-notification-rule-for-a-user-returns-OK-response.yml new file mode 100644 index 00000000000..4b7089ba623 --- /dev/null +++ b/cassettes/features/v2/on-call/Update-an-On-Call-notification-rule-for-a-user-returns-OK-response.yml @@ -0,0 +1,110 @@ +http_interactions: +- recorded_at: Wed, 17 Dec 2025 01:04:35 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Update_an_On_Call_notification_rule_for_a_user_returns_OK_response-1765933475@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + encoding: UTF-8 + string: '{"data":{"type":"users","id":"4ef9cf45-30a8-4117-9b56-adba96671dff","attributes":{"name":null,"handle":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com","created_at":"2025-12-17T01:04:36.246950+00:00","modified_at":"2025-12-17T01:04:36.246950+00:00","email":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com","icon":"https://secure.gravatar.com/avatar/53cbcba1803f4569f759fcc6b3f90bb6?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Wed, 17 Dec 2025 01:04:35 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Wed, 17 Dec 2025 01:04:35 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-rules + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"c7b724f1-eb73-43d4-889f-d8f3e6fbe664","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels"}}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Wed, 17 Dec 2025 01:04:35 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":1},"id":"c7b724f1-eb73-43d4-889f-d8f3e6fbe664","relationships":{"channel":{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: PUT + uri: https://api.datadoghq.com/api/v2/on-call/users/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-rules/c7b724f1-eb73-43d4-889f-d8f3e6fbe664?include=channel + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"c7b724f1-eb73-43d4-889f-d8f3e6fbe664","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":1},"relationships":{"channel":{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels"}}}},"included":[{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com","formats":["html"]}}}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Wed, 17 Dec 2025 01:04:35 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/4ef9cf45-30a8-4117-9b56-adba96671dff + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/examples/v2/on-call/CreateUserNotificationRule.rb b/examples/v2/on-call/CreateUserNotificationRule.rb new file mode 100644 index 00000000000..5e8fc97cc0f --- /dev/null +++ b/examples/v2/on-call/CreateUserNotificationRule.rb @@ -0,0 +1,29 @@ +# Create an On-Call notification rule for a user returns "Created" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OnCallAPI.new + +# there is a valid "user" in the system +USER_DATA_ID = ENV["USER_DATA_ID"] + +# there is a valid "oncall_email_notification_channel" in the system +ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID = ENV["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"] + +body = DatadogAPIClient::V2::CreateOnCallNotificationRuleRequest.new({ + data: DatadogAPIClient::V2::CreateOnCallNotificationRuleRequestData.new({ + attributes: DatadogAPIClient::V2::OnCallNotificationRuleRequestAttributes.new({ + category: DatadogAPIClient::V2::OnCallNotificationRuleCategory::HIGH_URGENCY, + delay_minutes: 0, + }), + relationships: DatadogAPIClient::V2::OnCallNotificationRuleRelationships.new({ + channel: DatadogAPIClient::V2::OnCallNotificationRuleChannelRelationship.new({ + data: DatadogAPIClient::V2::OnCallNotificationRuleChannelRelationshipData.new({ + id: ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID, + type: DatadogAPIClient::V2::NotificationChannelType::NOTIFICATION_CHANNELS, + }), + }), + }), + type: DatadogAPIClient::V2::OnCallNotificationRuleType::NOTIFICATION_RULES, + }), +}) +p api_instance.create_user_notification_rule(USER_DATA_ID, body) diff --git a/examples/v2/on-call/DeleteUserNotificationRule.rb b/examples/v2/on-call/DeleteUserNotificationRule.rb new file mode 100644 index 00000000000..744cf751908 --- /dev/null +++ b/examples/v2/on-call/DeleteUserNotificationRule.rb @@ -0,0 +1,11 @@ +# Delete an On-Call notification rule for a user returns "No Content" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OnCallAPI.new + +# there is a valid "user" in the system +USER_DATA_ID = ENV["USER_DATA_ID"] + +# there is a valid "oncall_email_notification_rule" in the system +ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = ENV["ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"] +api_instance.delete_user_notification_rule(USER_DATA_ID, ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID) diff --git a/examples/v2/on-call/GetUserNotificationRule.rb b/examples/v2/on-call/GetUserNotificationRule.rb new file mode 100644 index 00000000000..52f42d5b6ab --- /dev/null +++ b/examples/v2/on-call/GetUserNotificationRule.rb @@ -0,0 +1,14 @@ +# Get an On-Call notification rule for a user returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OnCallAPI.new + +# there is a valid "user" in the system +USER_DATA_ID = ENV["USER_DATA_ID"] + +# there is a valid "oncall_email_notification_rule" in the system +ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = ENV["ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"] +opts = { + include: "channel", +} +p api_instance.get_user_notification_rule(USER_DATA_ID, ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, opts) diff --git a/examples/v2/on-call/ListUserNotificationRules.rb b/examples/v2/on-call/ListUserNotificationRules.rb new file mode 100644 index 00000000000..55d291be31b --- /dev/null +++ b/examples/v2/on-call/ListUserNotificationRules.rb @@ -0,0 +1,11 @@ +# List On-Call notification rules for a user returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OnCallAPI.new + +# there is a valid "user" in the system +USER_DATA_ID = ENV["USER_DATA_ID"] +opts = { + include: "channel", +} +p api_instance.list_user_notification_rules(USER_DATA_ID, opts) diff --git a/examples/v2/on-call/UpdateUserNotificationRule.rb b/examples/v2/on-call/UpdateUserNotificationRule.rb new file mode 100644 index 00000000000..179d5a528f8 --- /dev/null +++ b/examples/v2/on-call/UpdateUserNotificationRule.rb @@ -0,0 +1,36 @@ +# Update an On-Call notification rule for a user returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OnCallAPI.new + +# there is a valid "user" in the system +USER_DATA_ID = ENV["USER_DATA_ID"] + +# there is a valid "oncall_email_notification_rule" in the system +ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = ENV["ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"] + +# there is a valid "oncall_email_notification_channel" in the system +ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID = ENV["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"] + +body = DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequest.new({ + data: DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequestData.new({ + attributes: DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequestAttributes.new({ + category: DatadogAPIClient::V2::OnCallNotificationRuleCategory::HIGH_URGENCY, + delay_minutes: 1, + }), + id: ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, + relationships: DatadogAPIClient::V2::OnCallNotificationRuleRelationships.new({ + channel: DatadogAPIClient::V2::OnCallNotificationRuleChannelRelationship.new({ + data: DatadogAPIClient::V2::OnCallNotificationRuleChannelRelationshipData.new({ + id: ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID, + type: DatadogAPIClient::V2::NotificationChannelType::NOTIFICATION_CHANNELS, + }), + }), + }), + type: DatadogAPIClient::V2::OnCallNotificationRuleType::NOTIFICATION_RULES, + }), +}) +opts = { + include: "channel", +} +p api_instance.update_user_notification_rule(USER_DATA_ID, ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, body, opts) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 3a27e10133c..4f064f4d793 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2679,6 +2679,29 @@ "user_id" => "String", "channel_id" => "String", }, + "v2.ListUserNotificationRules" => { + "include" => "String", + "user_id" => "String", + }, + "v2.CreateUserNotificationRule" => { + "user_id" => "String", + "body" => "CreateOnCallNotificationRuleRequest", + }, + "v2.DeleteUserNotificationRule" => { + "user_id" => "String", + "rule_id" => "String", + }, + "v2.GetUserNotificationRule" => { + "user_id" => "String", + "rule_id" => "String", + "include" => "String", + }, + "v2.UpdateUserNotificationRule" => { + "user_id" => "String", + "rule_id" => "String", + "include" => "String", + "body" => "UpdateOnCallNotificationRuleRequest", + }, "v2.CreateOnCallPage" => { "body" => "CreatePageRequest", }, diff --git a/features/v2/given.json b/features/v2/given.json index 8cf1925f45e..4651a346eb1 100644 --- a/features/v2/given.json +++ b/features/v2/given.json @@ -799,6 +799,22 @@ "tag": "On-Call", "operationId": "CreateUserNotificationChannel" }, + { + "parameters": [ + { + "name": "user_id", + "source": "user.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"notification_rules\",\n \"attributes\": {\n \"delay_minutes\": 0,\n \"category\": \"high_urgency\"\n },\n \"relationships\": {\n \"channel\": {\n \"data\": {\n \"id\": \"{{ oncall_email_notification_channel.data.id }}\",\n \"type\": \"notification_channels\"\n }\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"oncall_email_notification_rule\" in the system", + "key": "oncall_email_notification_rule", + "tag": "On-Call", + "operationId": "CreateUserNotificationRule" + }, { "parameters": [ { diff --git a/features/v2/on-call.feature b/features/v2/on-call.feature index 9f4750eef79..0f4b2a0e340 100644 --- a/features/v2/on-call.feature +++ b/features/v2/on-call.feature @@ -70,6 +70,32 @@ Feature: On-Call When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification rule for a user returns "Bad Request" response + Given new "CreateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/on-call + Scenario: Create an On-Call notification rule for a user returns "Created" response + Given new "CreateUserNotificationRule" request + And there is a valid "user" in the system + And request contains "user_id" parameter from "user.data.id" + And there is a valid "oncall_email_notification_channel" in the system + And body with value {"data": {"attributes": {"category": "high_urgency", "delay_minutes": 0}, "relationships": {"channel": {"data": {"id": "{{ oncall_email_notification_channel.data.id }}", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification rule for a user returns "Not Found" response + Given new "CreateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/on-call Scenario: Delete On-Call escalation policy returns "No Content" response Given new "DeleteOnCallEscalationPolicy" request @@ -130,6 +156,33 @@ Feature: On-Call When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call + Scenario: Delete an On-Call notification rule for a user returns "Bad Request" response + Given new "DeleteUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/on-call + Scenario: Delete an On-Call notification rule for a user returns "No Content" response + Given new "DeleteUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.data.id" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/on-call + Scenario: Delete an On-Call notification rule for a user returns "Not Found" response + Given new "DeleteUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call Scenario: Get On-Call escalation policy returns "Bad Request" response Given new "GetOnCallEscalationPolicy" request @@ -207,6 +260,36 @@ Feature: On-Call And the response "data.attributes.config.type" is equal to "email" And the response "data.attributes.config.address" is equal to "{{ user.data.attributes.email }}" + @generated @skip @team:DataDog/on-call + Scenario: Get an On-Call notification rule for a user returns "Bad Request" response + Given new "GetUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: Get an On-Call notification rule for a user returns "Not Found" response + Given new "GetUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: Get an On-Call notification rule for a user returns "OK" response + Given new "GetUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.data.id" + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.category" is equal to "high_urgency" + And the response "included" has length 1 + @generated @skip @team:DataDog/on-call Scenario: Get scheduled on-call user returns "Bad Request" response Given new "GetScheduleOnCallUser" request @@ -283,6 +366,33 @@ Feature: On-Call And the response "data[0].attributes.config.type" is equal to "email" And the response "data[0].attributes.config.address" is equal to "{{ user.data.attributes.email }}" + @generated @skip @team:DataDog/on-call + Scenario: List On-Call notification rules for a user returns "Bad Request" response + Given new "ListUserNotificationRules" request + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: List On-Call notification rules for a user returns "Not Found" response + Given new "ListUserNotificationRules" request + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: List On-Call notification rules for a user returns "OK" response + Given new "ListUserNotificationRules" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "included" has length 1 + @skip-python @team:DataDog/on-call Scenario: Set On-Call team routing rules returns "OK" response Given new "SetOnCallTeamRoutingRules" request @@ -350,3 +460,36 @@ Feature: On-Call And body with value {"data": { "id": "{{ schedule.data.id }}", "attributes": {"layers": [{"id": "{{ schedule.data.relationships.layers.data[0].id }}" , "effective_date": "{{ timeISO('now - 10d') }}", "end_date": "{{ timeISO('now + 10d') }}", "interval": {"seconds": 3600}, "members": [{"user": {"id": "{{user.data.id}}"}}], "name": "Layer 1", "restrictions": [{"end_day": "friday", "end_time": "17:00:00", "start_day": "monday", "start_time": "09:00:00"}], "rotation_start": "{{ timeISO('now - 5d') }}"}], "name": "{{ unique }}", "time_zone": "America/New_York"}, "relationships": {"teams": {"data": [{"id": "{{dd_team.data.id}}", "type": "teams"}]}}, "type": "schedules"}} When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "Bad Request" response + Given new "UpdateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "id": "2462ace1-49e2-aab1-xc4f-29cc4ae1105n7", "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "Not Found" response + Given new "UpdateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "id": "2462ace1-49e2-aab1-xc4f-29cc4ae1105n7", "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "OK" response + Given new "UpdateUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.data.id" + And body with value {"data": {"attributes": {"category": "high_urgency", "delay_minutes": 1}, "id": "{{ oncall_email_notification_rule.data.id }}", "relationships": {"channel": {"data": {"id": "{{ oncall_email_notification_channel.data.id }}", "type": "notification_channels"}}}, "type": "notification_rules"}} + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "included" has length 1 + And the response "data.attributes.delay_minutes" is equal to 1 diff --git a/features/v2/undo.json b/features/v2/undo.json index e0f0b98d0c9..d398c05fc13 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2964,6 +2964,36 @@ "type": "safe" } }, + "ListUserNotificationRules": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "CreateUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "DeleteUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "idempotent" + } + }, + "GetUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "UpdateUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, "ListOrgConfigs": { "tag": "Organizations", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 3e6e421122a..1074fff95bd 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1721,6 +1721,8 @@ def overrides "v2.create_notification_rule_parameters" => "CreateNotificationRuleParameters", "v2.create_notification_rule_parameters_data" => "CreateNotificationRuleParametersData", "v2.create_notification_rule_parameters_data_attributes" => "CreateNotificationRuleParametersDataAttributes", + "v2.create_on_call_notification_rule_request" => "CreateOnCallNotificationRuleRequest", + "v2.create_on_call_notification_rule_request_data" => "CreateOnCallNotificationRuleRequestData", "v2.create_open_api_response" => "CreateOpenAPIResponse", "v2.create_open_api_response_attributes" => "CreateOpenAPIResponseAttributes", "v2.create_open_api_response_data" => "CreateOpenAPIResponseData", @@ -2820,6 +2822,7 @@ def overrides "v2.list_findings_response" => "ListFindingsResponse", "v2.list_kind_catalog_response" => "ListKindCatalogResponse", "v2.list_notification_channels_response" => "ListNotificationChannelsResponse", + "v2.list_on_call_notification_rules_response" => "ListOnCallNotificationRulesResponse", "v2.list_pipelines_response" => "ListPipelinesResponse", "v2.list_pipelines_response_meta" => "ListPipelinesResponseMeta", "v2.list_powerpacks_response" => "ListPowerpacksResponse", @@ -3372,7 +3375,20 @@ def overrides "v2.okta_integration" => "OktaIntegration", "v2.okta_integration_type" => "OktaIntegrationType", "v2.okta_integration_update" => "OktaIntegrationUpdate", + "v2.on_call_notification_rule" => "OnCallNotificationRule", + "v2.on_call_notification_rule_attributes" => "OnCallNotificationRuleAttributes", + "v2.on_call_notification_rule_category" => "OnCallNotificationRuleCategory", + "v2.on_call_notification_rule_channel_relationship" => "OnCallNotificationRuleChannelRelationship", + "v2.on_call_notification_rule_channel_relationship_data" => "OnCallNotificationRuleChannelRelationshipData", + "v2.on_call_notification_rule_channel_settings" => "OnCallNotificationRuleChannelSettings", + "v2.on_call_notification_rule_data" => "OnCallNotificationRuleData", + "v2.on_call_notification_rule_relationships" => "OnCallNotificationRuleRelationships", + "v2.on_call_notification_rule_request_attributes" => "OnCallNotificationRuleRequestAttributes", + "v2.on_call_notification_rules_included" => "OnCallNotificationRulesIncluded", + "v2.on_call_notification_rule_type" => "OnCallNotificationRuleType", "v2.on_call_page_target_type" => "OnCallPageTargetType", + "v2.on_call_phone_notification_rule_method" => "OnCallPhoneNotificationRuleMethod", + "v2.on_call_phone_notification_rule_settings" => "OnCallPhoneNotificationRuleSettings", "v2.on_demand_concurrency_cap" => "OnDemandConcurrencyCap", "v2.on_demand_concurrency_cap_attributes" => "OnDemandConcurrencyCapAttributes", "v2.on_demand_concurrency_cap_response" => "OnDemandConcurrencyCapResponse", @@ -4496,6 +4512,9 @@ def overrides "v2.update_deployment_rule_params" => "UpdateDeploymentRuleParams", "v2.update_deployment_rule_params_data" => "UpdateDeploymentRuleParamsData", "v2.update_deployment_rule_params_data_attributes" => "UpdateDeploymentRuleParamsDataAttributes", + "v2.update_on_call_notification_rule_request" => "UpdateOnCallNotificationRuleRequest", + "v2.update_on_call_notification_rule_request_attributes" => "UpdateOnCallNotificationRuleRequestAttributes", + "v2.update_on_call_notification_rule_request_data" => "UpdateOnCallNotificationRuleRequestData", "v2.update_open_api_response" => "UpdateOpenAPIResponse", "v2.update_open_api_response_attributes" => "UpdateOpenAPIResponseAttributes", "v2.update_open_api_response_data" => "UpdateOpenAPIResponseData", diff --git a/lib/datadog_api_client/v2/api/on_call_api.rb b/lib/datadog_api_client/v2/api/on_call_api.rb index f3be233f273..1ad0475daab 100644 --- a/lib/datadog_api_client/v2/api/on_call_api.rb +++ b/lib/datadog_api_client/v2/api/on_call_api.rb @@ -233,6 +233,78 @@ def create_user_notification_channel_with_http_info(user_id, body, opts = {}) return data, status_code, headers end + # Create an On-Call notification rule for a user. + # + # @see #create_user_notification_rule_with_http_info + def create_user_notification_rule(user_id, body, opts = {}) + data, _status_code, _headers = create_user_notification_rule_with_http_info(user_id, body, opts) + data + end + + # Create an On-Call notification rule for a user. + # + # Create a new notification rule for a user. The authenticated user must be the target user or have the `on_call_admin` permission + # + # @param user_id [String] The user ID + # @param body [CreateOnCallNotificationRuleRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(OnCallNotificationRule, Integer, Hash)>] OnCallNotificationRule data, response status code and response headers + def create_user_notification_rule_with_http_info(user_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.create_user_notification_rule ...' + end + # verify the required parameter 'user_id' is set + if @api_client.config.client_side_validation && user_id.nil? + fail ArgumentError, "Missing the required parameter 'user_id' when calling OnCallAPI.create_user_notification_rule" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling OnCallAPI.create_user_notification_rule" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-rules'.sub('{user_id}', CGI.escape(user_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'OnCallNotificationRule' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :create_user_notification_rule, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OnCallAPI#create_user_notification_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete On-Call escalation policy. # # @see #delete_on_call_escalation_policy_with_http_info @@ -433,6 +505,76 @@ def delete_user_notification_channel_with_http_info(user_id, channel_id, opts = return data, status_code, headers end + # Delete an On-Call notification rule for a user. + # + # @see #delete_user_notification_rule_with_http_info + def delete_user_notification_rule(user_id, rule_id, opts = {}) + delete_user_notification_rule_with_http_info(user_id, rule_id, opts) + nil + end + + # Delete an On-Call notification rule for a user. + # + # Delete a notification rule for a user. The authenticated user must be the target user or have the `on_call_admin` permission + # + # @param user_id [String] The user ID + # @param rule_id [String] The rule ID + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_user_notification_rule_with_http_info(user_id, rule_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.delete_user_notification_rule ...' + end + # verify the required parameter 'user_id' is set + if @api_client.config.client_side_validation && user_id.nil? + fail ArgumentError, "Missing the required parameter 'user_id' when calling OnCallAPI.delete_user_notification_rule" + end + # verify the required parameter 'rule_id' is set + if @api_client.config.client_side_validation && rule_id.nil? + fail ArgumentError, "Missing the required parameter 'rule_id' when calling OnCallAPI.delete_user_notification_rule" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}'.sub('{user_id}', CGI.escape(user_id.to_s).gsub('%2F', '/')).sub('{rule_id}', CGI.escape(rule_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :delete_user_notification_rule, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OnCallAPI#delete_user_notification_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get On-Call escalation policy. # # @see #get_on_call_escalation_policy_with_http_info @@ -840,6 +982,78 @@ def get_user_notification_channel_with_http_info(user_id, channel_id, opts = {}) return data, status_code, headers end + # Get an On-Call notification rule for a user. + # + # @see #get_user_notification_rule_with_http_info + def get_user_notification_rule(user_id, rule_id, opts = {}) + data, _status_code, _headers = get_user_notification_rule_with_http_info(user_id, rule_id, opts) + data + end + + # Get an On-Call notification rule for a user. + # + # Get a notification rule for a user. The authenticated user must be the target user or have the `on_call_admin` permission + # + # @param user_id [String] The user ID + # @param rule_id [String] The rule ID + # @param opts [Hash] the optional parameters + # @option opts [String] :include Comma-separated list of included relationships to be returned. Allowed values: `channel`. + # @return [Array<(OnCallNotificationRule, Integer, Hash)>] OnCallNotificationRule data, response status code and response headers + def get_user_notification_rule_with_http_info(user_id, rule_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.get_user_notification_rule ...' + end + # verify the required parameter 'user_id' is set + if @api_client.config.client_side_validation && user_id.nil? + fail ArgumentError, "Missing the required parameter 'user_id' when calling OnCallAPI.get_user_notification_rule" + end + # verify the required parameter 'rule_id' is set + if @api_client.config.client_side_validation && rule_id.nil? + fail ArgumentError, "Missing the required parameter 'rule_id' when calling OnCallAPI.get_user_notification_rule" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}'.sub('{user_id}', CGI.escape(user_id.to_s).gsub('%2F', '/')).sub('{rule_id}', CGI.escape(rule_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'OnCallNotificationRule' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_user_notification_rule, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OnCallAPI#get_user_notification_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List On-Call notification channels for a user. # # @see #list_user_notification_channels_with_http_info @@ -905,6 +1119,73 @@ def list_user_notification_channels_with_http_info(user_id, opts = {}) return data, status_code, headers end + # List On-Call notification rules for a user. + # + # @see #list_user_notification_rules_with_http_info + def list_user_notification_rules(user_id, opts = {}) + data, _status_code, _headers = list_user_notification_rules_with_http_info(user_id, opts) + data + end + + # List On-Call notification rules for a user. + # + # List the notification rules for a user. The authenticated user must be the target user or have the `on_call_admin` permission + # + # @param user_id [String] The user ID + # @param opts [Hash] the optional parameters + # @option opts [String] :include Comma-separated list of included relationships to be returned. Allowed values: `channel`. + # @return [Array<(ListOnCallNotificationRulesResponse, Integer, Hash)>] ListOnCallNotificationRulesResponse data, response status code and response headers + def list_user_notification_rules_with_http_info(user_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.list_user_notification_rules ...' + end + # verify the required parameter 'user_id' is set + if @api_client.config.client_side_validation && user_id.nil? + fail ArgumentError, "Missing the required parameter 'user_id' when calling OnCallAPI.list_user_notification_rules" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-rules'.sub('{user_id}', CGI.escape(user_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ListOnCallNotificationRulesResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_user_notification_rules, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OnCallAPI#list_user_notification_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Set On-Call team routing rules. # # @see #set_on_call_team_routing_rules_with_http_info @@ -1126,5 +1407,84 @@ def update_on_call_schedule_with_http_info(schedule_id, body, opts = {}) end return data, status_code, headers end + + # Update an On-Call notification rule for a user. + # + # @see #update_user_notification_rule_with_http_info + def update_user_notification_rule(user_id, rule_id, body, opts = {}) + data, _status_code, _headers = update_user_notification_rule_with_http_info(user_id, rule_id, body, opts) + data + end + + # Update an On-Call notification rule for a user. + # + # Update a notification rule for a user. The authenticated user must be the target user or have the `on_call_admin` permission + # + # @param user_id [String] The user ID + # @param rule_id [String] The rule ID + # @param body [UpdateOnCallNotificationRuleRequest] + # @param opts [Hash] the optional parameters + # @option opts [String] :include Comma-separated list of included relationships to be returned. Allowed values: `channel`. + # @return [Array<(OnCallNotificationRule, Integer, Hash)>] OnCallNotificationRule data, response status code and response headers + def update_user_notification_rule_with_http_info(user_id, rule_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.update_user_notification_rule ...' + end + # verify the required parameter 'user_id' is set + if @api_client.config.client_side_validation && user_id.nil? + fail ArgumentError, "Missing the required parameter 'user_id' when calling OnCallAPI.update_user_notification_rule" + end + # verify the required parameter 'rule_id' is set + if @api_client.config.client_side_validation && rule_id.nil? + fail ArgumentError, "Missing the required parameter 'rule_id' when calling OnCallAPI.update_user_notification_rule" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling OnCallAPI.update_user_notification_rule" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}'.sub('{user_id}', CGI.escape(user_id.to_s).gsub('%2F', '/')).sub('{rule_id}', CGI.escape(rule_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'OnCallNotificationRule' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :update_user_notification_rule, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OnCallAPI#update_user_notification_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/create_on_call_notification_rule_request.rb b/lib/datadog_api_client/v2/models/create_on_call_notification_rule_request.rb new file mode 100644 index 00000000000..52cd0621342 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_on_call_notification_rule_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A top-level wrapper for creating a notification rule for a user + class CreateOnCallNotificationRuleRequest + include BaseGenericModel + + # Data for creating an on-call notification rule + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'CreateOnCallNotificationRuleRequestData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CreateOnCallNotificationRuleRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/create_on_call_notification_rule_request_data.rb b/lib/datadog_api_client/v2/models/create_on_call_notification_rule_request_data.rb new file mode 100644 index 00000000000..923861ee4e9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_on_call_notification_rule_request_data.rb @@ -0,0 +1,143 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Data for creating an on-call notification rule + class CreateOnCallNotificationRuleRequestData + include BaseGenericModel + + # Attributes for creating or modifying an on-call notification rule. + attr_accessor :attributes + + # Relationship object for creating a notification rule + attr_accessor :relationships + + # Indicates that the resource is of type 'notification_rules'. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'relationships' => :'relationships', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'OnCallNotificationRuleRequestAttributes', + :'relationships' => :'OnCallNotificationRuleRelationships', + :'type' => :'OnCallNotificationRuleType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CreateOnCallNotificationRuleRequestData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'relationships') + self.relationships = attributes[:'relationships'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + relationships == o.relationships && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, relationships, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/list_on_call_notification_rules_response.rb b/lib/datadog_api_client/v2/models/list_on_call_notification_rules_response.rb new file mode 100644 index 00000000000..b429e8a53c4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/list_on_call_notification_rules_response.rb @@ -0,0 +1,119 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response type for listing notification rules for a user + class ListOnCallNotificationRulesResponse + include BaseGenericModel + + # + attr_accessor :data + + # + attr_accessor :included + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'included' => :'included' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'included' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ListOnCallNotificationRulesResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'included') + if (value = attributes[:'included']).is_a?(Array) + self.included = value + end + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + included == o.included && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, included, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule.rb new file mode 100644 index 00000000000..29e5a6512e2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule.rb @@ -0,0 +1,135 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A top-level wrapper for a notification rule + class OnCallNotificationRule + include BaseGenericModel + + # Data for an on-call notification rule + attr_reader :data + + # + attr_accessor :included + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'included' => :'included' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'OnCallNotificationRuleData', + :'included' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OnCallNotificationRule` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + + if attributes.key?(:'included') + if (value = attributes[:'included']).is_a?(Array) + self.included = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + included == o.included && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, included, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_attributes.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_attributes.rb new file mode 100644 index 00000000000..68de6f6e71d --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_attributes.rb @@ -0,0 +1,125 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes for an on-call notification rule. + class OnCallNotificationRuleAttributes + include BaseGenericModel + + # Specifies the category a notification rule will apply to + attr_accessor :category + + # Defines the configuration for a channel associated with a notification rule + attr_accessor :channel_settings + + # The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate evaluation + attr_accessor :delay_minutes + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'category' => :'category', + :'channel_settings' => :'channel_settings', + :'delay_minutes' => :'delay_minutes' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'category' => :'OnCallNotificationRuleCategory', + :'channel_settings' => :'OnCallNotificationRuleChannelSettings', + :'delay_minutes' => :'Integer' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OnCallNotificationRuleAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'channel_settings') + self.channel_settings = attributes[:'channel_settings'] + end + + if attributes.key?(:'delay_minutes') + self.delay_minutes = attributes[:'delay_minutes'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + category == o.category && + channel_settings == o.channel_settings && + delay_minutes == o.delay_minutes && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [category, channel_settings, delay_minutes, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_category.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_category.rb new file mode 100644 index 00000000000..79c0bf186f1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_category.rb @@ -0,0 +1,27 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Specifies the category a notification rule will apply to + class OnCallNotificationRuleCategory + include BaseEnumModel + + HIGH_URGENCY = "high_urgency".freeze + LOW_URGENCY = "low_urgency".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_relationship.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_relationship.rb new file mode 100644 index 00000000000..ec3a5b1aba9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_relationship.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Relationship object for creating a notification rule + class OnCallNotificationRuleChannelRelationship + include BaseGenericModel + + # Channel relationship data for creating a notification rule + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'OnCallNotificationRuleChannelRelationshipData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OnCallNotificationRuleChannelRelationship` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_relationship_data.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_relationship_data.rb new file mode 100644 index 00000000000..44e3f2dc35b --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_relationship_data.rb @@ -0,0 +1,115 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Channel relationship data for creating a notification rule + class OnCallNotificationRuleChannelRelationshipData + include BaseGenericModel + + # ID of the notification channel + attr_accessor :id + + # Indicates that the resource is of type 'notification_channels'. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'String', + :'type' => :'NotificationChannelType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OnCallNotificationRuleChannelRelationshipData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_settings.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_settings.rb new file mode 100644 index 00000000000..3c8a1662b51 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_channel_settings.rb @@ -0,0 +1,62 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Defines the configuration for a channel associated with a notification rule + module OnCallNotificationRuleChannelSettings + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'OnCallPhoneNotificationRuleSettings' + ] + end + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_data.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_data.rb new file mode 100644 index 00000000000..43f6a95c691 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_data.rb @@ -0,0 +1,153 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Data for an on-call notification rule + class OnCallNotificationRuleData + include BaseGenericModel + + # Attributes for an on-call notification rule. + attr_accessor :attributes + + # Unique identifier for the rule + attr_accessor :id + + # Relationship object for creating a notification rule + attr_accessor :relationships + + # Indicates that the resource is of type 'notification_rules'. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'relationships' => :'relationships', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'OnCallNotificationRuleAttributes', + :'id' => :'String', + :'relationships' => :'OnCallNotificationRuleRelationships', + :'type' => :'OnCallNotificationRuleType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OnCallNotificationRuleData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'relationships') + self.relationships = attributes[:'relationships'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + relationships == o.relationships && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, relationships, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_relationships.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_relationships.rb new file mode 100644 index 00000000000..36142c17a1c --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_relationships.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Relationship object for creating a notification rule + class OnCallNotificationRuleRelationships + include BaseGenericModel + + # Relationship object for creating a notification rule + attr_accessor :channel + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'channel' => :'channel' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'channel' => :'OnCallNotificationRuleChannelRelationship' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OnCallNotificationRuleRelationships` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + channel == o.channel && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [channel, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_request_attributes.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_request_attributes.rb new file mode 100644 index 00000000000..acd674a77d2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_request_attributes.rb @@ -0,0 +1,125 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes for creating or modifying an on-call notification rule. + class OnCallNotificationRuleRequestAttributes + include BaseGenericModel + + # Specifies the category a notification rule will apply to + attr_accessor :category + + # Defines the configuration for a channel associated with a notification rule + attr_accessor :channel_settings + + # The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate evaluation + attr_accessor :delay_minutes + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'category' => :'category', + :'channel_settings' => :'channel_settings', + :'delay_minutes' => :'delay_minutes' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'category' => :'OnCallNotificationRuleCategory', + :'channel_settings' => :'OnCallNotificationRuleChannelSettings', + :'delay_minutes' => :'Integer' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OnCallNotificationRuleRequestAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'channel_settings') + self.channel_settings = attributes[:'channel_settings'] + end + + if attributes.key?(:'delay_minutes') + self.delay_minutes = attributes[:'delay_minutes'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + category == o.category && + channel_settings == o.channel_settings && + delay_minutes == o.delay_minutes && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [category, channel_settings, delay_minutes, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rule_type.rb b/lib/datadog_api_client/v2/models/on_call_notification_rule_type.rb new file mode 100644 index 00000000000..46c3df31353 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rule_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Indicates that the resource is of type 'notification_rules'. + class OnCallNotificationRuleType + include BaseEnumModel + + NOTIFICATION_RULES = "notification_rules".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_notification_rules_included.rb b/lib/datadog_api_client/v2/models/on_call_notification_rules_included.rb new file mode 100644 index 00000000000..5ca67616233 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_notification_rules_included.rb @@ -0,0 +1,62 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Represents additional included resources for a on-call notification rules + module OnCallNotificationRulesIncluded + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'NotificationChannelData' + ] + end + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_phone_notification_rule_method.rb b/lib/datadog_api_client/v2/models/on_call_phone_notification_rule_method.rb new file mode 100644 index 00000000000..5e51ae7c30f --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_phone_notification_rule_method.rb @@ -0,0 +1,27 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Specifies the method in which a phone is used in a notification rule + class OnCallPhoneNotificationRuleMethod + include BaseEnumModel + + SMS = "sms".freeze + VOICE = "voice".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/on_call_phone_notification_rule_settings.rb b/lib/datadog_api_client/v2/models/on_call_phone_notification_rule_settings.rb new file mode 100644 index 00000000000..40132946828 --- /dev/null +++ b/lib/datadog_api_client/v2/models/on_call_phone_notification_rule_settings.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Configuration for using a phone notification channel in a notification rule + class OnCallPhoneNotificationRuleSettings + include BaseGenericModel + + # Specifies the method in which a phone is used in a notification rule + attr_reader :method + + # Indicates that the notification channel is a phone + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'method' => :'method', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'method' => :'OnCallPhoneNotificationRuleMethod', + :'type' => :'NotificationChannelPhoneConfigType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OnCallPhoneNotificationRuleSettings` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'method') + self.method = attributes[:'method'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @method.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param method [Object] Object to be assigned + # @!visibility private + def method=(method) + if method.nil? + fail ArgumentError, 'invalid value for "method", method cannot be nil.' + end + @method = method + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + method == o.method && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [method, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request.rb b/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request.rb new file mode 100644 index 00000000000..55e84bbf923 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A top-level wrapper for updating a notification rule for a user + class UpdateOnCallNotificationRuleRequest + include BaseGenericModel + + # Data for updating an on-call notification rule + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'UpdateOnCallNotificationRuleRequestData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request_attributes.rb b/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request_attributes.rb new file mode 100644 index 00000000000..04e00e09909 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request_attributes.rb @@ -0,0 +1,125 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes for creating or modifying an on-call notification rule. + class UpdateOnCallNotificationRuleRequestAttributes + include BaseGenericModel + + # Specifies the category a notification rule will apply to + attr_accessor :category + + # Defines the configuration for a channel associated with a notification rule + attr_accessor :channel_settings + + # The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate evaluation + attr_accessor :delay_minutes + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'category' => :'category', + :'channel_settings' => :'channel_settings', + :'delay_minutes' => :'delay_minutes' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'category' => :'OnCallNotificationRuleCategory', + :'channel_settings' => :'OnCallNotificationRuleChannelSettings', + :'delay_minutes' => :'Integer' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequestAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'channel_settings') + self.channel_settings = attributes[:'channel_settings'] + end + + if attributes.key?(:'delay_minutes') + self.delay_minutes = attributes[:'delay_minutes'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + category == o.category && + channel_settings == o.channel_settings && + delay_minutes == o.delay_minutes && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [category, channel_settings, delay_minutes, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request_data.rb b/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request_data.rb new file mode 100644 index 00000000000..6a9faa6c3ba --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_on_call_notification_rule_request_data.rb @@ -0,0 +1,153 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Data for updating an on-call notification rule + class UpdateOnCallNotificationRuleRequestData + include BaseGenericModel + + # Attributes for creating or modifying an on-call notification rule. + attr_accessor :attributes + + # Unique identifier for the rule + attr_accessor :id + + # Relationship object for creating a notification rule + attr_accessor :relationships + + # Indicates that the resource is of type 'notification_rules'. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'relationships' => :'relationships', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'UpdateOnCallNotificationRuleRequestAttributes', + :'id' => :'String', + :'relationships' => :'OnCallNotificationRuleRelationships', + :'type' => :'OnCallNotificationRuleType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateOnCallNotificationRuleRequestData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'relationships') + self.relationships = attributes[:'relationships'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + relationships == o.relationships && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, relationships, type, additional_properties].hash + end + end +end