diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5d738d0d1f0..42168cb0f30 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -13195,6 +13195,27 @@ components: - options - type type: object + CreateEmailNotificationChannelConfig: + description: Configuration to create an e-mail notification channel + properties: + address: + description: The e-mail address to be notified + example: '' + type: string + formats: + description: Preferred content formats for notifications. + example: + - html + items: + $ref: '#/components/schemas/NotificationChannelEmailFormatType' + type: array + type: + $ref: '#/components/schemas/NotificationChannelEmailConfigType' + required: + - type + - address + - formats + type: object CreateIncidentNotificationRuleRequest: description: Create request for a notification rule. properties: @@ -13282,6 +13303,29 @@ components: - findings - project type: object + CreateNotificationChannelAttributes: + description: Attributes for creating an on-call notification channel. + properties: + config: + $ref: '#/components/schemas/CreateNotificationChannelConfig' + description: Notification channel configuration + type: object + CreateNotificationChannelConfig: + description: Defines the configuration for creating an On-Call notification + channel + oneOf: + - $ref: '#/components/schemas/CreatePhoneNotificationChannelConfig' + - $ref: '#/components/schemas/CreateEmailNotificationChannelConfig' + CreateNotificationChannelData: + description: Data for creating an on-call notification channel + properties: + attributes: + $ref: '#/components/schemas/CreateNotificationChannelAttributes' + type: + $ref: '#/components/schemas/NotificationChannelType' + required: + - type + type: object CreateNotificationRuleParameters: description: Body of the notification rule create request. properties: @@ -13442,6 +13486,19 @@ components: type: string x-enum-varnames: - PAGES + CreatePhoneNotificationChannelConfig: + description: Configuration to create a phone notification channel + properties: + number: + description: The E-164 formatted phone number (e.g. +3371234567) + example: '' + type: string + type: + $ref: '#/components/schemas/NotificationChannelPhoneConfigType' + required: + - type + - number + type: object CreateRuleRequest: description: Scorecard create rule request. properties: @@ -14008,6 +14065,23 @@ components: type: string x-enum-varnames: - UPLOAD + CreateUserNotificationChannelRequest: + description: A top-level wrapper for creating a notification channel for a user + example: + data: + attributes: + config: + address: foo@bar.com + formats: + - html + type: email + type: notification_channels + properties: + data: + $ref: '#/components/schemas/CreateNotificationChannelData' + required: + - data + type: object CreateWorkflowRequest: description: A request object for creating a new workflow. example: @@ -30505,6 +30579,14 @@ components: meta: $ref: '#/components/schemas/KindResponseMeta' type: object + ListNotificationChannelsResponse: + description: Response type for listing notification channels for a user + properties: + data: + items: + $ref: '#/components/schemas/NotificationChannelData' + type: array + type: object ListPipelinesResponse: description: Represents the response payload containing a list of pipelines and associated metadata. @@ -34679,6 +34761,174 @@ components: required: - notebookTrigger type: object + NotificationChannel: + description: A top-level wrapper for a user notification channel + example: + data: + attributes: + config: + address: foo@bar.com + formats: + - html + type: email + id: 27590dae-47be-4a7d-9abf-8f4e45124020 + type: notification_channels + properties: + data: + $ref: '#/components/schemas/NotificationChannelData' + type: object + NotificationChannelAttributes: + description: Attributes for an on-call notification channel. + properties: + active: + description: Whether the notification channel is currently active. + type: boolean + config: + $ref: '#/components/schemas/NotificationChannelConfig' + description: Notification channel configuration + type: object + NotificationChannelConfig: + description: Defines the configuration for an On-Call notification channel + oneOf: + - $ref: '#/components/schemas/NotificationChannelPhoneConfig' + - $ref: '#/components/schemas/NotificationChannelEmailConfig' + - $ref: '#/components/schemas/NotificationChannelPushConfig' + NotificationChannelData: + description: Data for an on-call notification channel + properties: + attributes: + $ref: '#/components/schemas/NotificationChannelAttributes' + id: + description: Unique identifier for the channel + type: string + type: + $ref: '#/components/schemas/NotificationChannelType' + required: + - type + type: object + NotificationChannelEmailConfig: + description: Email notification channel configuration + properties: + address: + description: The e-mail address to be notified + example: '' + type: string + formats: + description: Preferred content formats for notifications. + example: + - html + items: + $ref: '#/components/schemas/NotificationChannelEmailFormatType' + type: array + type: + $ref: '#/components/schemas/NotificationChannelEmailConfigType' + required: + - type + - address + - formats + type: object + NotificationChannelEmailConfigType: + default: email + description: Indicates that the notification channel is an e-mail address + enum: + - email + example: email + type: string + x-enum-varnames: + - EMAIL + NotificationChannelEmailFormatType: + default: html + description: Specifies the format of the e-mail that is sent for On-Call notifications + enum: + - html + - text + example: html + type: string + x-enum-varnames: + - HTML + - TEXT + NotificationChannelPhoneConfig: + description: Phone notification channel configuration + properties: + formatted_number: + description: The formatted international version of Number (e.g. +33 7 1 + 23 45 67). + example: '' + type: string + number: + description: The E-164 formatted phone number (e.g. +3371234567) + example: '' + type: string + region: + description: The ISO 3166-1 alpha-2 two-letter country code. + example: '' + type: string + sms_subscribed_at: + description: If present, the date the user subscribed this number to SMS + messages + format: date-time + nullable: true + type: string + type: + $ref: '#/components/schemas/NotificationChannelPhoneConfigType' + verified: + description: Indicates whether this phone has been verified by the user + in Datadog On-Call + example: false + type: boolean + required: + - type + - number + - formatted_number + - region + - verified + type: object + NotificationChannelPhoneConfigType: + default: phone + description: Indicates that the notification channel is a phone + enum: + - phone + example: phone + type: string + x-enum-varnames: + - PHONE + NotificationChannelPushConfig: + description: Push notification channel configuration + properties: + application_name: + description: The name of the application used to receive push notifications + example: '' + type: string + device_name: + description: The name of the mobile device being used + example: '' + type: string + type: + $ref: '#/components/schemas/NotificationChannelPushConfigType' + required: + - type + - device_name + - application_name + type: object + NotificationChannelPushConfigType: + default: push + description: Indicates that the notification channel is a mobile device for + push notifications + enum: + - push + example: push + type: string + x-enum-varnames: + - PUSH + NotificationChannelType: + default: notification_channels + description: Indicates that the resource is of type 'notification_channels'. + enum: + - notification_channels + example: notification_channels + type: string + x-enum-varnames: + - NOTIFICATION_CHANNELS NotificationRule: description: 'Notification rules allow full control over notifications generated by the various Datadog security products. @@ -75741,6 +75991,184 @@ paths: operator: AND permissions: - on_call_write + /api/v2/on-call/users/{user_id}/notification-channels: + get: + description: List the notification channels for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: ListUserNotificationChannels + parameters: + - 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/ListNotificationChannelsResponse' + 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 channels for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_read + post: + description: Create a new notification channel for a user. The authenticated + user must be the target user or have the `on_call_admin` permission + operationId: CreateUserNotificationChannel + 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/CreateUserNotificationChannelRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationChannel' + 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 channel for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_respond + /api/v2/on-call/users/{user_id}/notification-channels/{channel_id}: + delete: + description: Delete a notification channel for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: DeleteUserNotificationChannel + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The channel ID + in: path + name: channel_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 channel for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_respond + get: + description: Get a notification channel for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: GetUserNotificationChannel + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The channel ID + in: path + name: channel_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationChannel' + 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 channel for a user + tags: + - On-Call + x-permission: + operator: AND + 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-channel-for-a-user-returns-Created-response.frozen b/cassettes/features/v2/on-call/Create-an-On-Call-notification-channel-for-a-user-returns-Created-response.frozen new file mode 100644 index 00000000000..d364f431dfd --- /dev/null +++ b/cassettes/features/v2/on-call/Create-an-On-Call-notification-channel-for-a-user-returns-Created-response.frozen @@ -0,0 +1 @@ +2025-12-12T14:05:32.425Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/Create-an-On-Call-notification-channel-for-a-user-returns-Created-response.yml b/cassettes/features/v2/on-call/Create-an-On-Call-notification-channel-for-a-user-returns-Created-response.yml new file mode 100644 index 00000000000..2c98c094337 --- /dev/null +++ b/cassettes/features/v2/on-call/Create-an-On-Call-notification-channel-for-a-user-returns-Created-response.yml @@ -0,0 +1,66 @@ +http_interactions: +- recorded_at: Fri, 12 Dec 2025 14:05:32 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Create_an_On_Call_notification_channel_for_a_user_returns_Created_response-1765548332@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":"5ba8ee87-4d71-458c-883d-a6016738f7ce","attributes":{"name":null,"handle":"test-create_an_on_call_notification_channel_for_a_user_returns_created_response-1765548332@datadoghq.com","created_at":"2025-12-12T14:05:32.704821+00:00","modified_at":"2025-12-12T14:05:32.704821+00:00","email":"test-create_an_on_call_notification_channel_for_a_user_returns_created_response-1765548332@datadoghq.com","icon":"https://secure.gravatar.com/avatar/01791216e0fc8e5e005271e285ad9760?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: Fri, 12 Dec 2025 14:05:32 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"foo@bar.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/5ba8ee87-4d71-458c-883d-a6016738f7ce/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"f944f63a-2606-43c0-9c0b-10a34b9b214a","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"foo@bar.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Fri, 12 Dec 2025 14:05:32 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/5ba8ee87-4d71-458c-883d-a6016738f7ce + 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-channel-for-a-user-returns-No-Content-response.frozen b/cassettes/features/v2/on-call/Delete-an-On-Call-notification-channel-for-a-user-returns-No-Content-response.frozen new file mode 100644 index 00000000000..065691eedf0 --- /dev/null +++ b/cassettes/features/v2/on-call/Delete-an-On-Call-notification-channel-for-a-user-returns-No-Content-response.frozen @@ -0,0 +1 @@ +2025-12-11T18:27:50.679Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/Delete-an-On-Call-notification-channel-for-a-user-returns-No-Content-response.yml b/cassettes/features/v2/on-call/Delete-an-On-Call-notification-channel-for-a-user-returns-No-Content-response.yml new file mode 100644 index 00000000000..ec6d2bf20f4 --- /dev/null +++ b/cassettes/features/v2/on-call/Delete-an-On-Call-notification-channel-for-a-user-returns-No-Content-response.yml @@ -0,0 +1,82 @@ +http_interactions: +- recorded_at: Thu, 11 Dec 2025 18:27:50 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Delete_an_On_Call_notification_channel_for_a_user_returns_No_Content_response-1765477670@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":"1df33be3-5397-4aaf-95c0-00dd63819c80","attributes":{"name":null,"handle":"test-delete_an_on_call_notification_channel_for_a_user_returns_no_content_response-1765477670@datadoghq.com","created_at":"2025-12-11T18:27:50.837055+00:00","modified_at":"2025-12-11T18:27:50.837055+00:00","email":"test-delete_an_on_call_notification_channel_for_a_user_returns_no_content_response-1765477670@datadoghq.com","icon":"https://secure.gravatar.com/avatar/f0ef01f65aae0d49a442ade4a44a5a53?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: Thu, 11 Dec 2025 18:27:50 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"test-delete_an_on_call_notification_channel_for_a_user_returns_no_content_response-1765477670@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/1df33be3-5397-4aaf-95c0-00dd63819c80/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"dd22cf57-a576-4c7e-92f8-36c2171f5f99","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-delete_an_on_call_notification_channel_for_a_user_returns_no_content_response-1765477670@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Thu, 11 Dec 2025 18:27:50 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/on-call/users/1df33be3-5397-4aaf-95c0-00dd63819c80/notification-channels/dd22cf57-a576-4c7e-92f8-36c2171f5f99 + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +- recorded_at: Thu, 11 Dec 2025 18:27:50 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/1df33be3-5397-4aaf-95c0-00dd63819c80 + 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-channel-for-a-user-returns-OK-response.frozen b/cassettes/features/v2/on-call/Get-an-On-Call-notification-channel-for-a-user-returns-OK-response.frozen new file mode 100644 index 00000000000..e6a81ebe054 --- /dev/null +++ b/cassettes/features/v2/on-call/Get-an-On-Call-notification-channel-for-a-user-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-12-12T14:04:17.257Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/Get-an-On-Call-notification-channel-for-a-user-returns-OK-response.yml b/cassettes/features/v2/on-call/Get-an-On-Call-notification-channel-for-a-user-returns-OK-response.yml new file mode 100644 index 00000000000..3352dec40f6 --- /dev/null +++ b/cassettes/features/v2/on-call/Get-an-On-Call-notification-channel-for-a-user-returns-OK-response.yml @@ -0,0 +1,84 @@ +http_interactions: +- recorded_at: Fri, 12 Dec 2025 14:04:17 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Get_an_On_Call_notification_channel_for_a_user_returns_OK_response-1765548257@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":"0131b53c-5aec-4c8a-a14f-9ef487448833","attributes":{"name":null,"handle":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","created_at":"2025-12-12T14:04:17.531988+00:00","modified_at":"2025-12-12T14:04:17.531988+00:00","email":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","icon":"https://secure.gravatar.com/avatar/cedb283c90667a7da02c585159b4eda3?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: Fri, 12 Dec 2025 14:04:17 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@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/0131b53c-5aec-4c8a-a14f-9ef487448833/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"d5fc3f5a-a4b9-4972-80bb-cb4db7ec958b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Fri, 12 Dec 2025 14:04:17 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/on-call/users/0131b53c-5aec-4c8a-a14f-9ef487448833/notification-channels/d5fc3f5a-a4b9-4972-80bb-cb4db7ec958b + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"d5fc3f5a-a4b9-4972-80bb-cb4db7ec958b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Fri, 12 Dec 2025 14:04:17 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/0131b53c-5aec-4c8a-a14f-9ef487448833 + 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-channels-for-a-user-returns-OK-response.frozen b/cassettes/features/v2/on-call/List-On-Call-notification-channels-for-a-user-returns-OK-response.frozen new file mode 100644 index 00000000000..d77fcd86e2a --- /dev/null +++ b/cassettes/features/v2/on-call/List-On-Call-notification-channels-for-a-user-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-12-12T14:40:40.219Z \ No newline at end of file diff --git a/cassettes/features/v2/on-call/List-On-Call-notification-channels-for-a-user-returns-OK-response.yml b/cassettes/features/v2/on-call/List-On-Call-notification-channels-for-a-user-returns-OK-response.yml new file mode 100644 index 00000000000..5ad48ae482c --- /dev/null +++ b/cassettes/features/v2/on-call/List-On-Call-notification-channels-for-a-user-returns-OK-response.yml @@ -0,0 +1,84 @@ +http_interactions: +- recorded_at: Fri, 12 Dec 2025 14:40:40 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-List_On_Call_notification_channels_for_a_user_returns_OK_response-1765550440@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":"c7fe3658-67dd-4a91-bf86-3709728fd8a5","attributes":{"name":null,"handle":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","created_at":"2025-12-12T14:40:40.467657+00:00","modified_at":"2025-12-12T14:40:40.467657+00:00","email":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","icon":"https://secure.gravatar.com/avatar/c74061cf101e1fea18813bda82103b47?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: Fri, 12 Dec 2025 14:40:40 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"address":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@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/c7fe3658-67dd-4a91-bf86-3709728fd8a5/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"8e9a9ded-ff10-4661-8d56-b4b789f54bf1","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","formats":["html"]}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Fri, 12 Dec 2025 14:40:40 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/on-call/users/c7fe3658-67dd-4a91-bf86-3709728fd8a5/notification-channels + response: + body: + encoding: UTF-8 + string: '{"data":[{"id":"8e9a9ded-ff10-4661-8d56-b4b789f54bf1","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","formats":["html"]}}}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Fri, 12 Dec 2025 14:40:40 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/c7fe3658-67dd-4a91-bf86-3709728fd8a5 + 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/CreateUserNotificationChannel.rb b/examples/v2/on-call/CreateUserNotificationChannel.rb new file mode 100644 index 00000000000..3549f8ce261 --- /dev/null +++ b/examples/v2/on-call/CreateUserNotificationChannel.rb @@ -0,0 +1,23 @@ +# Create an On-Call notification channel 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"] + +body = DatadogAPIClient::V2::CreateUserNotificationChannelRequest.new({ + data: DatadogAPIClient::V2::CreateNotificationChannelData.new({ + attributes: DatadogAPIClient::V2::CreateNotificationChannelAttributes.new({ + config: DatadogAPIClient::V2::CreateEmailNotificationChannelConfig.new({ + address: "foo@bar.com", + formats: [ + DatadogAPIClient::V2::NotificationChannelEmailFormatType::HTML, + ], + type: DatadogAPIClient::V2::NotificationChannelEmailConfigType::EMAIL, + }), + }), + type: DatadogAPIClient::V2::NotificationChannelType::NOTIFICATION_CHANNELS, + }), +}) +p api_instance.create_user_notification_channel(USER_DATA_ID, body) diff --git a/examples/v2/on-call/DeleteUserNotificationChannel.rb b/examples/v2/on-call/DeleteUserNotificationChannel.rb new file mode 100644 index 00000000000..102dda274e8 --- /dev/null +++ b/examples/v2/on-call/DeleteUserNotificationChannel.rb @@ -0,0 +1,11 @@ +# Delete an On-Call notification channel 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_channel" in the system +ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID = ENV["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"] +api_instance.delete_user_notification_channel(USER_DATA_ID, ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID) diff --git a/examples/v2/on-call/GetUserNotificationChannel.rb b/examples/v2/on-call/GetUserNotificationChannel.rb new file mode 100644 index 00000000000..b48c7af4fa0 --- /dev/null +++ b/examples/v2/on-call/GetUserNotificationChannel.rb @@ -0,0 +1,11 @@ +# Get an On-Call notification channel 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_channel" in the system +ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID = ENV["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"] +p api_instance.get_user_notification_channel(USER_DATA_ID, ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID) diff --git a/examples/v2/on-call/ListUserNotificationChannels.rb b/examples/v2/on-call/ListUserNotificationChannels.rb new file mode 100644 index 00000000000..46af9551608 --- /dev/null +++ b/examples/v2/on-call/ListUserNotificationChannels.rb @@ -0,0 +1,8 @@ +# List On-Call notification channels 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"] +p api_instance.list_user_notification_channels(USER_DATA_ID) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 881252db3d6..52ba0405690 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2662,6 +2662,21 @@ "include" => "String", "body" => "TeamRoutingRulesRequest", }, + "v2.ListUserNotificationChannels" => { + "user_id" => "String", + }, + "v2.CreateUserNotificationChannel" => { + "user_id" => "String", + "body" => "CreateUserNotificationChannelRequest", + }, + "v2.DeleteUserNotificationChannel" => { + "user_id" => "String", + "channel_id" => "String", + }, + "v2.GetUserNotificationChannel" => { + "user_id" => "String", + "channel_id" => "String", + }, "v2.CreateOnCallPage" => { "body" => "CreatePageRequest", }, diff --git a/features/v2/given.json b/features/v2/given.json index 7725798de44..8cf1925f45e 100644 --- a/features/v2/given.json +++ b/features/v2/given.json @@ -783,6 +783,22 @@ "tag": "On-Call", "operationId": "SetOnCallTeamRoutingRules" }, + { + "parameters": [ + { + "name": "user_id", + "source": "user.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"config\": {\n \"type\": \"email\",\n \"address\": \"{{ user.data.attributes.email }}\",\n \"formats\": [\n \"html\"\n ]\n }\n },\n \"type\": \"notification_channels\"\n }\n}" + } + ], + "step": "there is a valid \"oncall_email_notification_channel\" in the system", + "key": "oncall_email_notification_channel", + "tag": "On-Call", + "operationId": "CreateUserNotificationChannel" + }, { "parameters": [ { diff --git a/features/v2/on-call.feature b/features/v2/on-call.feature index c52e4291fc6..9f4750eef79 100644 --- a/features/v2/on-call.feature +++ b/features/v2/on-call.feature @@ -43,6 +43,33 @@ Feature: On-Call When the request is sent Then the response status is 201 Created + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification channel for a user returns "Bad Request" response + Given new "CreateUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"config": {"address": "foo@bar.com", "formats": ["html"], "type": "email"}}, "type": "notification_channels"}} + 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 channel for a user returns "Created" response + Given new "CreateUserNotificationChannel" request + And there is a valid "user" in the system + And request contains "user_id" parameter from "user.data.id" + And body with value {"data": {"attributes": {"config": {"address": "foo@bar.com", "formats": ["html"], "type": "email"}}, "type": "notification_channels"}} + When the request is sent + Then the response status is 201 Created + And the response "data.attributes.config.type" is equal to "email" + And the response "data.attributes.config.address" is equal to "foo@bar.com" + + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification channel for a user returns "Not Found" response + Given new "CreateUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"config": {"address": "foo@bar.com", "formats": ["html"], "type": "email"}}, "type": "notification_channels"}} + 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 @@ -77,6 +104,32 @@ 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 channel for a user returns "Bad Request" response + Given new "DeleteUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "channel_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 channel for a user returns "No Content" response + Given new "DeleteUserNotificationChannel" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "channel_id" parameter from "oncall_email_notification_channel.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 channel for a user returns "Not Found" response + Given new "DeleteUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "channel_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 @@ -126,6 +179,34 @@ Feature: On-Call When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/on-call + Scenario: Get an On-Call notification channel for a user returns "Bad Request" response + Given new "GetUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "channel_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 channel for a user returns "Not Found" response + Given new "GetUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "channel_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 channel for a user returns "OK" response + Given new "GetUserNotificationChannel" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "channel_id" parameter from "oncall_email_notification_channel.data.id" + When the request is sent + Then the response status is 200 OK + 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 scheduled on-call user returns "Bad Request" response Given new "GetScheduleOnCallUser" request @@ -176,6 +257,32 @@ Feature: On-Call When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/on-call + Scenario: List On-Call notification channels for a user returns "Bad Request" response + Given new "ListUserNotificationChannels" 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 channels for a user returns "Not Found" response + Given new "ListUserNotificationChannels" 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 channels for a user returns "OK" response + Given new "ListUserNotificationChannels" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And request contains "user_id" parameter from "user.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + 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 }}" + @skip-python @team:DataDog/on-call Scenario: Set On-Call team routing rules returns "OK" response Given new "SetOnCallTeamRoutingRules" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 56977a4c301..8aec373cdd9 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2934,6 +2934,30 @@ "type": "unsafe" } }, + "ListUserNotificationChannels": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "CreateUserNotificationChannel": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "DeleteUserNotificationChannel": { + "tag": "On-Call", + "undo": { + "type": "idempotent" + } + }, + "GetUserNotificationChannel": { + "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 26a9fcd42e8..0a3bb74f57f 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1706,12 +1706,16 @@ def overrides "v2.create_deployment_rule_params" => "CreateDeploymentRuleParams", "v2.create_deployment_rule_params_data" => "CreateDeploymentRuleParamsData", "v2.create_deployment_rule_params_data_attributes" => "CreateDeploymentRuleParamsDataAttributes", + "v2.create_email_notification_channel_config" => "CreateEmailNotificationChannelConfig", "v2.create_incident_notification_rule_request" => "CreateIncidentNotificationRuleRequest", "v2.create_incident_notification_template_request" => "CreateIncidentNotificationTemplateRequest", "v2.create_jira_issue_request_array" => "CreateJiraIssueRequestArray", "v2.create_jira_issue_request_data" => "CreateJiraIssueRequestData", "v2.create_jira_issue_request_data_attributes" => "CreateJiraIssueRequestDataAttributes", "v2.create_jira_issue_request_data_relationships" => "CreateJiraIssueRequestDataRelationships", + "v2.create_notification_channel_attributes" => "CreateNotificationChannelAttributes", + "v2.create_notification_channel_config" => "CreateNotificationChannelConfig", + "v2.create_notification_channel_data" => "CreateNotificationChannelData", "v2.create_notification_rule_parameters" => "CreateNotificationRuleParameters", "v2.create_notification_rule_parameters_data" => "CreateNotificationRuleParametersData", "v2.create_notification_rule_parameters_data_attributes" => "CreateNotificationRuleParametersDataAttributes", @@ -1726,6 +1730,7 @@ def overrides "v2.create_page_response" => "CreatePageResponse", "v2.create_page_response_data" => "CreatePageResponseData", "v2.create_page_response_data_type" => "CreatePageResponseDataType", + "v2.create_phone_notification_channel_config" => "CreatePhoneNotificationChannelConfig", "v2.create_rule_request" => "CreateRuleRequest", "v2.create_rule_request_data" => "CreateRuleRequestData", "v2.create_rule_response" => "CreateRuleResponse", @@ -1761,6 +1766,7 @@ def overrides "v2.create_upload_response_data" => "CreateUploadResponseData", "v2.create_upload_response_data_attributes" => "CreateUploadResponseDataAttributes", "v2.create_upload_response_data_type" => "CreateUploadResponseDataType", + "v2.create_user_notification_channel_request" => "CreateUserNotificationChannelRequest", "v2.create_workflow_request" => "CreateWorkflowRequest", "v2.create_workflow_response" => "CreateWorkflowResponse", "v2.creator" => "Creator", @@ -2811,6 +2817,7 @@ def overrides "v2.list_findings_page" => "ListFindingsPage", "v2.list_findings_response" => "ListFindingsResponse", "v2.list_kind_catalog_response" => "ListKindCatalogResponse", + "v2.list_notification_channels_response" => "ListNotificationChannelsResponse", "v2.list_pipelines_response" => "ListPipelinesResponse", "v2.list_pipelines_response_meta" => "ListPipelinesResponseMeta", "v2.list_powerpacks_response" => "ListPowerpacksResponse", @@ -3096,6 +3103,18 @@ def overrides "v2.ms_teams_integration_metadata" => "MSTeamsIntegrationMetadata", "v2.ms_teams_integration_metadata_teams_item" => "MSTeamsIntegrationMetadataTeamsItem", "v2.notebook_trigger_wrapper" => "NotebookTriggerWrapper", + "v2.notification_channel" => "NotificationChannel", + "v2.notification_channel_attributes" => "NotificationChannelAttributes", + "v2.notification_channel_config" => "NotificationChannelConfig", + "v2.notification_channel_data" => "NotificationChannelData", + "v2.notification_channel_email_config" => "NotificationChannelEmailConfig", + "v2.notification_channel_email_config_type" => "NotificationChannelEmailConfigType", + "v2.notification_channel_email_format_type" => "NotificationChannelEmailFormatType", + "v2.notification_channel_phone_config" => "NotificationChannelPhoneConfig", + "v2.notification_channel_phone_config_type" => "NotificationChannelPhoneConfigType", + "v2.notification_channel_push_config" => "NotificationChannelPushConfig", + "v2.notification_channel_push_config_type" => "NotificationChannelPushConfigType", + "v2.notification_channel_type" => "NotificationChannelType", "v2.notification_rule" => "NotificationRule", "v2.notification_rule_attributes" => "NotificationRuleAttributes", "v2.notification_rule_response" => "NotificationRuleResponse", 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 f9abcde0e33..f3be233f273 100644 --- a/lib/datadog_api_client/v2/api/on_call_api.rb +++ b/lib/datadog_api_client/v2/api/on_call_api.rb @@ -161,6 +161,78 @@ def create_on_call_schedule_with_http_info(body, opts = {}) return data, status_code, headers end + # Create an On-Call notification channel for a user. + # + # @see #create_user_notification_channel_with_http_info + def create_user_notification_channel(user_id, body, opts = {}) + data, _status_code, _headers = create_user_notification_channel_with_http_info(user_id, body, opts) + data + end + + # Create an On-Call notification channel for a user. + # + # Create a new notification channel 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 [CreateUserNotificationChannelRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(NotificationChannel, Integer, Hash)>] NotificationChannel data, response status code and response headers + def create_user_notification_channel_with_http_info(user_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.create_user_notification_channel ...' + 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_channel" + 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_channel" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-channels'.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] || 'NotificationChannel' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :create_user_notification_channel, + :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_channel\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 @@ -291,6 +363,76 @@ def delete_on_call_schedule_with_http_info(schedule_id, opts = {}) return data, status_code, headers end + # Delete an On-Call notification channel for a user. + # + # @see #delete_user_notification_channel_with_http_info + def delete_user_notification_channel(user_id, channel_id, opts = {}) + delete_user_notification_channel_with_http_info(user_id, channel_id, opts) + nil + end + + # Delete an On-Call notification channel for a user. + # + # Delete a notification channel 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 channel_id [String] The channel ID + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_user_notification_channel_with_http_info(user_id, channel_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.delete_user_notification_channel ...' + 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_channel" + end + # verify the required parameter 'channel_id' is set + if @api_client.config.client_side_validation && channel_id.nil? + fail ArgumentError, "Missing the required parameter 'channel_id' when calling OnCallAPI.delete_user_notification_channel" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-channels/{channel_id}'.sub('{user_id}', CGI.escape(user_id.to_s).gsub('%2F', '/')).sub('{channel_id}', CGI.escape(channel_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_channel, + :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_channel\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 @@ -628,6 +770,141 @@ def get_team_on_call_users_with_http_info(team_id, opts = {}) return data, status_code, headers end + # Get an On-Call notification channel for a user. + # + # @see #get_user_notification_channel_with_http_info + def get_user_notification_channel(user_id, channel_id, opts = {}) + data, _status_code, _headers = get_user_notification_channel_with_http_info(user_id, channel_id, opts) + data + end + + # Get an On-Call notification channel for a user. + # + # Get a notification channel 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 channel_id [String] The channel ID + # @param opts [Hash] the optional parameters + # @return [Array<(NotificationChannel, Integer, Hash)>] NotificationChannel data, response status code and response headers + def get_user_notification_channel_with_http_info(user_id, channel_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.get_user_notification_channel ...' + 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_channel" + end + # verify the required parameter 'channel_id' is set + if @api_client.config.client_side_validation && channel_id.nil? + fail ArgumentError, "Missing the required parameter 'channel_id' when calling OnCallAPI.get_user_notification_channel" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-channels/{channel_id}'.sub('{user_id}', CGI.escape(user_id.to_s).gsub('%2F', '/')).sub('{channel_id}', CGI.escape(channel_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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'NotificationChannel' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_user_notification_channel, + :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_channel\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 + def list_user_notification_channels(user_id, opts = {}) + data, _status_code, _headers = list_user_notification_channels_with_http_info(user_id, opts) + data + end + + # List On-Call notification channels for a user. + # + # List the notification channels 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 + # @return [Array<(ListNotificationChannelsResponse, Integer, Hash)>] ListNotificationChannelsResponse data, response status code and response headers + def list_user_notification_channels_with_http_info(user_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OnCallAPI.list_user_notification_channels ...' + 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_channels" + end + # resource path + local_var_path = '/api/v2/on-call/users/{user_id}/notification-channels'.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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ListNotificationChannelsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_user_notification_channels, + :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_channels\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 diff --git a/lib/datadog_api_client/v2/models/create_email_notification_channel_config.rb b/lib/datadog_api_client/v2/models/create_email_notification_channel_config.rb new file mode 100644 index 00000000000..a994ca17f63 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_email_notification_channel_config.rb @@ -0,0 +1,167 @@ +=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 to create an e-mail notification channel + class CreateEmailNotificationChannelConfig + include BaseGenericModel + + # The e-mail address to be notified + attr_reader :address + + # Preferred content formats for notifications. + attr_reader :formats + + # Indicates that the notification channel is an e-mail address + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'address' => :'address', + :'formats' => :'formats', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'address' => :'String', + :'formats' => :'Array', + :'type' => :'NotificationChannelEmailConfigType' + } + 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::CreateEmailNotificationChannelConfig` 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?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'formats') + if (value = attributes[:'formats']).is_a?(Array) + self.formats = value + end + 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 @address.nil? + return false if @formats.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param address [Object] Object to be assigned + # @!visibility private + def address=(address) + if address.nil? + fail ArgumentError, 'invalid value for "address", address cannot be nil.' + end + @address = address + end + + # Custom attribute writer method with validation + # @param formats [Object] Object to be assigned + # @!visibility private + def formats=(formats) + if formats.nil? + fail ArgumentError, 'invalid value for "formats", formats cannot be nil.' + end + @formats = formats + 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 && + address == o.address && + formats == o.formats && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [address, formats, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/create_notification_channel_attributes.rb b/lib/datadog_api_client/v2/models/create_notification_channel_attributes.rb new file mode 100644 index 00000000000..7f073f698f6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_notification_channel_attributes.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 + # Attributes for creating an on-call notification channel. + class CreateNotificationChannelAttributes + include BaseGenericModel + + # Defines the configuration for creating an On-Call notification channel + attr_accessor :config + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'config' => :'config' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'config' => :'CreateNotificationChannelConfig' + } + 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::CreateNotificationChannelAttributes` 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?(:'config') + self.config = attributes[:'config'] + 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 && + config == o.config && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [config, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/create_notification_channel_config.rb b/lib/datadog_api_client/v2/models/create_notification_channel_config.rb new file mode 100644 index 00000000000..dfdd15459f2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_notification_channel_config.rb @@ -0,0 +1,63 @@ +=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 creating an On-Call notification channel + module CreateNotificationChannelConfig + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'CreatePhoneNotificationChannelConfig', + :'CreateEmailNotificationChannelConfig' + ] + 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/create_notification_channel_data.rb b/lib/datadog_api_client/v2/models/create_notification_channel_data.rb new file mode 100644 index 00000000000..bd4e46c4aa7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_notification_channel_data.rb @@ -0,0 +1,133 @@ +=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 channel + class CreateNotificationChannelData + include BaseGenericModel + + # Attributes for creating an on-call notification channel. + attr_accessor :attributes + + # Indicates that the resource is of type 'notification_channels'. + 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', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'CreateNotificationChannelAttributes', + :'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::CreateNotificationChannelData` 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?(:'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 && + 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, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/create_phone_notification_channel_config.rb b/lib/datadog_api_client/v2/models/create_phone_notification_channel_config.rb new file mode 100644 index 00000000000..e2d47ea6ea5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_phone_notification_channel_config.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 to create a phone notification channel + class CreatePhoneNotificationChannelConfig + include BaseGenericModel + + # The E-164 formatted phone number (e.g. +3371234567) + attr_reader :number + + # 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 + { + :'number' => :'number', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'number' => :'String', + :'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::CreatePhoneNotificationChannelConfig` 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?(:'number') + self.number = attributes[:'number'] + 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 @number.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param number [Object] Object to be assigned + # @!visibility private + def number=(number) + if number.nil? + fail ArgumentError, 'invalid value for "number", number cannot be nil.' + end + @number = number + 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 && + number == o.number && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [number, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/create_user_notification_channel_request.rb b/lib/datadog_api_client/v2/models/create_user_notification_channel_request.rb new file mode 100644 index 00000000000..9dfe65d5328 --- /dev/null +++ b/lib/datadog_api_client/v2/models/create_user_notification_channel_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 channel for a user + class CreateUserNotificationChannelRequest + include BaseGenericModel + + # Data for creating an on-call notification channel + 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' => :'CreateNotificationChannelData' + } + 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::CreateUserNotificationChannelRequest` 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/list_notification_channels_response.rb b/lib/datadog_api_client/v2/models/list_notification_channels_response.rb new file mode 100644 index 00000000000..7bf99da4e79 --- /dev/null +++ b/lib/datadog_api_client/v2/models/list_notification_channels_response.rb @@ -0,0 +1,107 @@ +=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 channels for a user + class ListNotificationChannelsResponse + include BaseGenericModel + + # + attr_accessor :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' => :'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::ListNotificationChannelsResponse` 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 + 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/notification_channel.rb b/lib/datadog_api_client/v2/models/notification_channel.rb new file mode 100644 index 00000000000..17e3ad182a3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel.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 + # A top-level wrapper for a user notification channel + class NotificationChannel + include BaseGenericModel + + # Data for an on-call notification channel + attr_accessor :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' => :'NotificationChannelData' + } + 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::NotificationChannel` 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 + + # 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/notification_channel_attributes.rb b/lib/datadog_api_client/v2/models/notification_channel_attributes.rb new file mode 100644 index 00000000000..dc0a18c4c06 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_attributes.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 + # Attributes for an on-call notification channel. + class NotificationChannelAttributes + include BaseGenericModel + + # Whether the notification channel is currently active. + attr_accessor :active + + # Defines the configuration for an On-Call notification channel + attr_accessor :config + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'active' => :'active', + :'config' => :'config' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'active' => :'Boolean', + :'config' => :'NotificationChannelConfig' + } + 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::NotificationChannelAttributes` 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?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'config') + self.config = attributes[:'config'] + 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 && + active == o.active && + config == o.config && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [active, config, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_config.rb b/lib/datadog_api_client/v2/models/notification_channel_config.rb new file mode 100644 index 00000000000..35b909476c0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_config.rb @@ -0,0 +1,64 @@ +=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 an On-Call notification channel + module NotificationChannelConfig + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'NotificationChannelPhoneConfig', + :'NotificationChannelEmailConfig', + :'NotificationChannelPushConfig' + ] + 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/notification_channel_data.rb b/lib/datadog_api_client/v2/models/notification_channel_data.rb new file mode 100644 index 00000000000..f6029c12172 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_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 an on-call notification channel + class NotificationChannelData + include BaseGenericModel + + # Attributes for an on-call notification channel. + attr_accessor :attributes + + # Unique identifier for the channel + attr_accessor :id + + # Indicates that the resource is of type 'notification_channels'. + 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', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'NotificationChannelAttributes', + :'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::NotificationChannelData` 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?(:'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 && + 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, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_email_config.rb b/lib/datadog_api_client/v2/models/notification_channel_email_config.rb new file mode 100644 index 00000000000..0477a476d7d --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_email_config.rb @@ -0,0 +1,167 @@ +=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 + # Email notification channel configuration + class NotificationChannelEmailConfig + include BaseGenericModel + + # The e-mail address to be notified + attr_reader :address + + # Preferred content formats for notifications. + attr_reader :formats + + # Indicates that the notification channel is an e-mail address + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'address' => :'address', + :'formats' => :'formats', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'address' => :'String', + :'formats' => :'Array', + :'type' => :'NotificationChannelEmailConfigType' + } + 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::NotificationChannelEmailConfig` 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?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'formats') + if (value = attributes[:'formats']).is_a?(Array) + self.formats = value + end + 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 @address.nil? + return false if @formats.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param address [Object] Object to be assigned + # @!visibility private + def address=(address) + if address.nil? + fail ArgumentError, 'invalid value for "address", address cannot be nil.' + end + @address = address + end + + # Custom attribute writer method with validation + # @param formats [Object] Object to be assigned + # @!visibility private + def formats=(formats) + if formats.nil? + fail ArgumentError, 'invalid value for "formats", formats cannot be nil.' + end + @formats = formats + 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 && + address == o.address && + formats == o.formats && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [address, formats, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_email_config_type.rb b/lib/datadog_api_client/v2/models/notification_channel_email_config_type.rb new file mode 100644 index 00000000000..3925bd5be36 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_email_config_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 notification channel is an e-mail address + class NotificationChannelEmailConfigType + include BaseEnumModel + + EMAIL = "email".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_email_format_type.rb b/lib/datadog_api_client/v2/models/notification_channel_email_format_type.rb new file mode 100644 index 00000000000..a29aca88952 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_email_format_type.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 format of the e-mail that is sent for On-Call notifications + class NotificationChannelEmailFormatType + include BaseEnumModel + + HTML = "html".freeze + TEXT = "text".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_phone_config.rb b/lib/datadog_api_client/v2/models/notification_channel_phone_config.rb new file mode 100644 index 00000000000..48adb8a555e --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_phone_config.rb @@ -0,0 +1,225 @@ +=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 + # Phone notification channel configuration + class NotificationChannelPhoneConfig + include BaseGenericModel + + # The formatted international version of Number (e.g. +33 7 1 23 45 67). + attr_reader :formatted_number + + # The E-164 formatted phone number (e.g. +3371234567) + attr_reader :number + + # The ISO 3166-1 alpha-2 two-letter country code. + attr_reader :region + + # If present, the date the user subscribed this number to SMS messages + attr_accessor :sms_subscribed_at + + # Indicates that the notification channel is a phone + attr_reader :type + + # Indicates whether this phone has been verified by the user in Datadog On-Call + attr_reader :verified + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'formatted_number' => :'formatted_number', + :'number' => :'number', + :'region' => :'region', + :'sms_subscribed_at' => :'sms_subscribed_at', + :'type' => :'type', + :'verified' => :'verified' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'formatted_number' => :'String', + :'number' => :'String', + :'region' => :'String', + :'sms_subscribed_at' => :'Time', + :'type' => :'NotificationChannelPhoneConfigType', + :'verified' => :'Boolean' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'sms_subscribed_at', + ]) + 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::NotificationChannelPhoneConfig` 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?(:'formatted_number') + self.formatted_number = attributes[:'formatted_number'] + end + + if attributes.key?(:'number') + self.number = attributes[:'number'] + end + + if attributes.key?(:'region') + self.region = attributes[:'region'] + end + + if attributes.key?(:'sms_subscribed_at') + self.sms_subscribed_at = attributes[:'sms_subscribed_at'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'verified') + self.verified = attributes[:'verified'] + 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 @formatted_number.nil? + return false if @number.nil? + return false if @region.nil? + return false if @type.nil? + return false if @verified.nil? + true + end + + # Custom attribute writer method with validation + # @param formatted_number [Object] Object to be assigned + # @!visibility private + def formatted_number=(formatted_number) + if formatted_number.nil? + fail ArgumentError, 'invalid value for "formatted_number", formatted_number cannot be nil.' + end + @formatted_number = formatted_number + end + + # Custom attribute writer method with validation + # @param number [Object] Object to be assigned + # @!visibility private + def number=(number) + if number.nil? + fail ArgumentError, 'invalid value for "number", number cannot be nil.' + end + @number = number + end + + # Custom attribute writer method with validation + # @param region [Object] Object to be assigned + # @!visibility private + def region=(region) + if region.nil? + fail ArgumentError, 'invalid value for "region", region cannot be nil.' + end + @region = region + 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 + + # Custom attribute writer method with validation + # @param verified [Object] Object to be assigned + # @!visibility private + def verified=(verified) + if verified.nil? + fail ArgumentError, 'invalid value for "verified", verified cannot be nil.' + end + @verified = verified + 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 && + formatted_number == o.formatted_number && + number == o.number && + region == o.region && + sms_subscribed_at == o.sms_subscribed_at && + type == o.type && + verified == o.verified && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [formatted_number, number, region, sms_subscribed_at, type, verified, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_phone_config_type.rb b/lib/datadog_api_client/v2/models/notification_channel_phone_config_type.rb new file mode 100644 index 00000000000..1bee07919b6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_phone_config_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 notification channel is a phone + class NotificationChannelPhoneConfigType + include BaseEnumModel + + PHONE = "phone".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_push_config.rb b/lib/datadog_api_client/v2/models/notification_channel_push_config.rb new file mode 100644 index 00000000000..c5450174eb0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_push_config.rb @@ -0,0 +1,165 @@ +=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 + # Push notification channel configuration + class NotificationChannelPushConfig + include BaseGenericModel + + # The name of the application used to receive push notifications + attr_reader :application_name + + # The name of the mobile device being used + attr_reader :device_name + + # Indicates that the notification channel is a mobile device for push notifications + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'application_name' => :'application_name', + :'device_name' => :'device_name', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'application_name' => :'String', + :'device_name' => :'String', + :'type' => :'NotificationChannelPushConfigType' + } + 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::NotificationChannelPushConfig` 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?(:'application_name') + self.application_name = attributes[:'application_name'] + end + + if attributes.key?(:'device_name') + self.device_name = attributes[:'device_name'] + 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 @application_name.nil? + return false if @device_name.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param application_name [Object] Object to be assigned + # @!visibility private + def application_name=(application_name) + if application_name.nil? + fail ArgumentError, 'invalid value for "application_name", application_name cannot be nil.' + end + @application_name = application_name + end + + # Custom attribute writer method with validation + # @param device_name [Object] Object to be assigned + # @!visibility private + def device_name=(device_name) + if device_name.nil? + fail ArgumentError, 'invalid value for "device_name", device_name cannot be nil.' + end + @device_name = device_name + 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 && + application_name == o.application_name && + device_name == o.device_name && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [application_name, device_name, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_push_config_type.rb b/lib/datadog_api_client/v2/models/notification_channel_push_config_type.rb new file mode 100644 index 00000000000..ecdaf44a270 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_push_config_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 notification channel is a mobile device for push notifications + class NotificationChannelPushConfigType + include BaseEnumModel + + PUSH = "push".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/notification_channel_type.rb b/lib/datadog_api_client/v2/models/notification_channel_type.rb new file mode 100644 index 00000000000..e40c0223f42 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_channel_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_channels'. + class NotificationChannelType + include BaseEnumModel + + NOTIFICATION_CHANNELS = "notification_channels".freeze + end +end