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/examples/v2/on-call/CreateUserNotificationChannel.java b/examples/v2/on-call/CreateUserNotificationChannel.java new file mode 100644 index 00000000000..3d0743ee5c8 --- /dev/null +++ b/examples/v2/on-call/CreateUserNotificationChannel.java @@ -0,0 +1,52 @@ +// Create an On-Call notification channel for a user returns "Created" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.OnCallApi; +import com.datadog.api.client.v2.model.CreateEmailNotificationChannelConfig; +import com.datadog.api.client.v2.model.CreateNotificationChannelAttributes; +import com.datadog.api.client.v2.model.CreateNotificationChannelConfig; +import com.datadog.api.client.v2.model.CreateNotificationChannelData; +import com.datadog.api.client.v2.model.CreateUserNotificationChannelRequest; +import com.datadog.api.client.v2.model.NotificationChannel; +import com.datadog.api.client.v2.model.NotificationChannelEmailConfigType; +import com.datadog.api.client.v2.model.NotificationChannelEmailFormatType; +import com.datadog.api.client.v2.model.NotificationChannelType; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + OnCallApi apiInstance = new OnCallApi(defaultClient); + + // there is a valid "user" in the system + String USER_DATA_ID = System.getenv("USER_DATA_ID"); + + CreateUserNotificationChannelRequest body = + new CreateUserNotificationChannelRequest() + .data( + new CreateNotificationChannelData() + .attributes( + new CreateNotificationChannelAttributes() + .config( + new CreateNotificationChannelConfig( + new CreateEmailNotificationChannelConfig() + .address("foo@bar.com") + .formats( + Collections.singletonList( + NotificationChannelEmailFormatType.HTML)) + .type(NotificationChannelEmailConfigType.EMAIL)))) + .type(NotificationChannelType.NOTIFICATION_CHANNELS)); + + try { + NotificationChannel result = apiInstance.createUserNotificationChannel(USER_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#createUserNotificationChannel"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/on-call/DeleteUserNotificationChannel.java b/examples/v2/on-call/DeleteUserNotificationChannel.java new file mode 100644 index 00000000000..39b19472ee3 --- /dev/null +++ b/examples/v2/on-call/DeleteUserNotificationChannel.java @@ -0,0 +1,30 @@ +// Delete an On-Call notification channel for a user returns "No Content" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.OnCallApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + OnCallApi apiInstance = new OnCallApi(defaultClient); + + // there is a valid "user" in the system + String USER_DATA_ID = System.getenv("USER_DATA_ID"); + + // there is a valid "oncall_email_notification_channel" in the system + String ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID = + System.getenv("ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"); + + try { + apiInstance.deleteUserNotificationChannel( + USER_DATA_ID, ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#deleteUserNotificationChannel"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/on-call/GetUserNotificationChannel.java b/examples/v2/on-call/GetUserNotificationChannel.java new file mode 100644 index 00000000000..cf129084148 --- /dev/null +++ b/examples/v2/on-call/GetUserNotificationChannel.java @@ -0,0 +1,33 @@ +// Get an On-Call notification channel for a user returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.OnCallApi; +import com.datadog.api.client.v2.model.NotificationChannel; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + OnCallApi apiInstance = new OnCallApi(defaultClient); + + // there is a valid "user" in the system + String USER_DATA_ID = System.getenv("USER_DATA_ID"); + + // there is a valid "oncall_email_notification_channel" in the system + String ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID = + System.getenv("ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"); + + try { + NotificationChannel result = + apiInstance.getUserNotificationChannel( + USER_DATA_ID, ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#getUserNotificationChannel"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/on-call/ListUserNotificationChannels.java b/examples/v2/on-call/ListUserNotificationChannels.java new file mode 100644 index 00000000000..d5930b756e0 --- /dev/null +++ b/examples/v2/on-call/ListUserNotificationChannels.java @@ -0,0 +1,28 @@ +// List On-Call notification channels for a user returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.OnCallApi; +import com.datadog.api.client.v2.model.ListNotificationChannelsResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + OnCallApi apiInstance = new OnCallApi(defaultClient); + + // there is a valid "user" in the system + String USER_DATA_ID = System.getenv("USER_DATA_ID"); + + try { + ListNotificationChannelsResponse result = + apiInstance.listUserNotificationChannels(USER_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#listUserNotificationChannels"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v2/api/OnCallApi.java b/src/main/java/com/datadog/api/client/v2/api/OnCallApi.java index b68bcc5a6d1..2c705d7055f 100644 --- a/src/main/java/com/datadog/api/client/v2/api/OnCallApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/OnCallApi.java @@ -4,9 +4,12 @@ import com.datadog.api.client.ApiException; import com.datadog.api.client.ApiResponse; import com.datadog.api.client.Pair; +import com.datadog.api.client.v2.model.CreateUserNotificationChannelRequest; import com.datadog.api.client.v2.model.EscalationPolicy; import com.datadog.api.client.v2.model.EscalationPolicyCreateRequest; import com.datadog.api.client.v2.model.EscalationPolicyUpdateRequest; +import com.datadog.api.client.v2.model.ListNotificationChannelsResponse; +import com.datadog.api.client.v2.model.NotificationChannel; import com.datadog.api.client.v2.model.Schedule; import com.datadog.api.client.v2.model.ScheduleCreateRequest; import com.datadog.api.client.v2.model.ScheduleUpdateRequest; @@ -452,6 +455,170 @@ public CompletableFuture> createOnCallScheduleWithHttpInfo new GenericType() {}); } + /** + * Create an On-Call notification channel for a user. + * + *

See {@link #createUserNotificationChannelWithHttpInfo}. + * + * @param userId The user ID (required) + * @param body (required) + * @return NotificationChannel + * @throws ApiException if fails to make API call + */ + public NotificationChannel createUserNotificationChannel( + String userId, CreateUserNotificationChannelRequest body) throws ApiException { + return createUserNotificationChannelWithHttpInfo(userId, body).getData(); + } + + /** + * Create an On-Call notification channel for a user. + * + *

See {@link #createUserNotificationChannelWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param body (required) + * @return CompletableFuture<NotificationChannel> + */ + public CompletableFuture createUserNotificationChannelAsync( + String userId, CreateUserNotificationChannelRequest body) { + return createUserNotificationChannelWithHttpInfoAsync(userId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create a new notification channel for a user. The authenticated user must be the target user or + * have the on_call_admin permission + * + * @param userId The user ID (required) + * @param body (required) + * @return ApiResponse<NotificationChannel> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
201 Created -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse createUserNotificationChannelWithHttpInfo( + String userId, CreateUserNotificationChannelRequest body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'userId' is set + if (userId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'userId' when calling createUserNotificationChannel"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createUserNotificationChannel"); + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-channels" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.createUserNotificationChannel", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Create an On-Call notification channel for a user. + * + *

See {@link #createUserNotificationChannelWithHttpInfo}. + * + * @param userId The user ID (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<NotificationChannel>> + */ + public CompletableFuture> + createUserNotificationChannelWithHttpInfoAsync( + String userId, CreateUserNotificationChannelRequest body) { + Object localVarPostBody = body; + + // verify the required parameter 'userId' is set + if (userId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'userId' when calling" + + " createUserNotificationChannel")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling createUserNotificationChannel")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-channels" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.createUserNotificationChannel", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Delete On-Call escalation policy. * @@ -727,6 +894,171 @@ public CompletableFuture> deleteOnCallScheduleWithHttpInfoAsyn null); } + /** + * Delete an On-Call notification channel for a user. + * + *

See {@link #deleteUserNotificationChannelWithHttpInfo}. + * + * @param userId The user ID (required) + * @param channelId The channel ID (required) + * @throws ApiException if fails to make API call + */ + public void deleteUserNotificationChannel(String userId, String channelId) throws ApiException { + deleteUserNotificationChannelWithHttpInfo(userId, channelId); + } + + /** + * Delete an On-Call notification channel for a user. + * + *

See {@link #deleteUserNotificationChannelWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param channelId The channel ID (required) + * @return CompletableFuture + */ + public CompletableFuture deleteUserNotificationChannelAsync( + String userId, String channelId) { + return deleteUserNotificationChannelWithHttpInfoAsync(userId, channelId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Delete a notification channel for a user. The authenticated user must be the target user or + * have the on_call_admin permission + * + * @param userId The user ID (required) + * @param channelId The channel ID (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse deleteUserNotificationChannelWithHttpInfo( + String userId, String channelId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'userId' is set + if (userId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'userId' when calling deleteUserNotificationChannel"); + } + + // verify the required parameter 'channelId' is set + if (channelId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'channelId' when calling deleteUserNotificationChannel"); + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-channels/{channel_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "channel_id" + "\\}", apiClient.escapeString(channelId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.deleteUserNotificationChannel", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete an On-Call notification channel for a user. + * + *

See {@link #deleteUserNotificationChannelWithHttpInfo}. + * + * @param userId The user ID (required) + * @param channelId The channel ID (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteUserNotificationChannelWithHttpInfoAsync( + String userId, String channelId) { + Object localVarPostBody = null; + + // verify the required parameter 'userId' is set + if (userId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'userId' when calling" + + " deleteUserNotificationChannel")); + return result; + } + + // verify the required parameter 'channelId' is set + if (channelId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'channelId' when calling" + + " deleteUserNotificationChannel")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-channels/{channel_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "channel_id" + "\\}", apiClient.escapeString(channelId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.deleteUserNotificationChannel", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + /** Manage optional parameters to getOnCallEscalationPolicy. */ public static class GetOnCallEscalationPolicyOptionalParameters { private String include; @@ -1746,6 +2078,314 @@ public CompletableFuture> getTeamOnCallUsersWi new GenericType() {}); } + /** + * Get an On-Call notification channel for a user. + * + *

See {@link #getUserNotificationChannelWithHttpInfo}. + * + * @param userId The user ID (required) + * @param channelId The channel ID (required) + * @return NotificationChannel + * @throws ApiException if fails to make API call + */ + public NotificationChannel getUserNotificationChannel(String userId, String channelId) + throws ApiException { + return getUserNotificationChannelWithHttpInfo(userId, channelId).getData(); + } + + /** + * Get an On-Call notification channel for a user. + * + *

See {@link #getUserNotificationChannelWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param channelId The channel ID (required) + * @return CompletableFuture<NotificationChannel> + */ + public CompletableFuture getUserNotificationChannelAsync( + String userId, String channelId) { + return getUserNotificationChannelWithHttpInfoAsync(userId, channelId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get a notification channel for a user. The authenticated user must be the target user or have + * the on_call_admin permission + * + * @param userId The user ID (required) + * @param channelId The channel ID (required) + * @return ApiResponse<NotificationChannel> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getUserNotificationChannelWithHttpInfo( + String userId, String channelId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'userId' is set + if (userId == null) { + throw new ApiException( + 400, "Missing the required parameter 'userId' when calling getUserNotificationChannel"); + } + + // verify the required parameter 'channelId' is set + if (channelId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'channelId' when calling getUserNotificationChannel"); + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-channels/{channel_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "channel_id" + "\\}", apiClient.escapeString(channelId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.getUserNotificationChannel", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get an On-Call notification channel for a user. + * + *

See {@link #getUserNotificationChannelWithHttpInfo}. + * + * @param userId The user ID (required) + * @param channelId The channel ID (required) + * @return CompletableFuture<ApiResponse<NotificationChannel>> + */ + public CompletableFuture> + getUserNotificationChannelWithHttpInfoAsync(String userId, String channelId) { + Object localVarPostBody = null; + + // verify the required parameter 'userId' is set + if (userId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'userId' when calling getUserNotificationChannel")); + return result; + } + + // verify the required parameter 'channelId' is set + if (channelId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'channelId' when calling" + + " getUserNotificationChannel")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-channels/{channel_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "channel_id" + "\\}", apiClient.escapeString(channelId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.getUserNotificationChannel", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * List On-Call notification channels for a user. + * + *

See {@link #listUserNotificationChannelsWithHttpInfo}. + * + * @param userId The user ID (required) + * @return ListNotificationChannelsResponse + * @throws ApiException if fails to make API call + */ + public ListNotificationChannelsResponse listUserNotificationChannels(String userId) + throws ApiException { + return listUserNotificationChannelsWithHttpInfo(userId).getData(); + } + + /** + * List On-Call notification channels for a user. + * + *

See {@link #listUserNotificationChannelsWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @return CompletableFuture<ListNotificationChannelsResponse> + */ + public CompletableFuture listUserNotificationChannelsAsync( + String userId) { + return listUserNotificationChannelsWithHttpInfoAsync(userId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List the notification channels for a user. The authenticated user must be the target user or + * have the on_call_admin permission + * + * @param userId The user ID (required) + * @return ApiResponse<ListNotificationChannelsResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse listUserNotificationChannelsWithHttpInfo( + String userId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'userId' is set + if (userId == null) { + throw new ApiException( + 400, "Missing the required parameter 'userId' when calling listUserNotificationChannels"); + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-channels" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.listUserNotificationChannels", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * List On-Call notification channels for a user. + * + *

See {@link #listUserNotificationChannelsWithHttpInfo}. + * + * @param userId The user ID (required) + * @return CompletableFuture<ApiResponse<ListNotificationChannelsResponse>> + */ + public CompletableFuture> + listUserNotificationChannelsWithHttpInfoAsync(String userId) { + Object localVarPostBody = null; + + // verify the required parameter 'userId' is set + if (userId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'userId' when calling listUserNotificationChannels")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-channels" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.listUserNotificationChannels", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** Manage optional parameters to setOnCallTeamRoutingRules. */ public static class SetOnCallTeamRoutingRulesOptionalParameters { private String include; diff --git a/src/main/java/com/datadog/api/client/v2/model/CreateEmailNotificationChannelConfig.java b/src/main/java/com/datadog/api/client/v2/model/CreateEmailNotificationChannelConfig.java new file mode 100644 index 00000000000..7141b0f1104 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateEmailNotificationChannelConfig.java @@ -0,0 +1,220 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Configuration to create an e-mail notification channel */ +@JsonPropertyOrder({ + CreateEmailNotificationChannelConfig.JSON_PROPERTY_ADDRESS, + CreateEmailNotificationChannelConfig.JSON_PROPERTY_FORMATS, + CreateEmailNotificationChannelConfig.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateEmailNotificationChannelConfig { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ADDRESS = "address"; + private String address; + + public static final String JSON_PROPERTY_FORMATS = "formats"; + private List formats = new ArrayList<>(); + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelEmailConfigType type = NotificationChannelEmailConfigType.EMAIL; + + public CreateEmailNotificationChannelConfig() {} + + @JsonCreator + public CreateEmailNotificationChannelConfig( + @JsonProperty(required = true, value = JSON_PROPERTY_ADDRESS) String address, + @JsonProperty(required = true, value = JSON_PROPERTY_FORMATS) + List formats, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + NotificationChannelEmailConfigType type) { + this.address = address; + this.formats = formats; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public CreateEmailNotificationChannelConfig address(String address) { + this.address = address; + return this; + } + + /** + * The e-mail address to be notified + * + * @return address + */ + @JsonProperty(JSON_PROPERTY_ADDRESS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public CreateEmailNotificationChannelConfig formats( + List formats) { + this.formats = formats; + return this; + } + + public CreateEmailNotificationChannelConfig addFormatsItem( + NotificationChannelEmailFormatType formatsItem) { + this.formats.add(formatsItem); + this.unparsed |= !formatsItem.isValid(); + return this; + } + + /** + * Preferred content formats for notifications. + * + * @return formats + */ + @JsonProperty(JSON_PROPERTY_FORMATS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getFormats() { + return formats; + } + + public void setFormats(List formats) { + this.formats = formats; + } + + public CreateEmailNotificationChannelConfig type(NotificationChannelEmailConfigType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the notification channel is an e-mail address + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationChannelEmailConfigType getType() { + return type; + } + + public void setType(NotificationChannelEmailConfigType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return CreateEmailNotificationChannelConfig + */ + @JsonAnySetter + public CreateEmailNotificationChannelConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this CreateEmailNotificationChannelConfig object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateEmailNotificationChannelConfig createEmailNotificationChannelConfig = + (CreateEmailNotificationChannelConfig) o; + return Objects.equals(this.address, createEmailNotificationChannelConfig.address) + && Objects.equals(this.formats, createEmailNotificationChannelConfig.formats) + && Objects.equals(this.type, createEmailNotificationChannelConfig.type) + && Objects.equals( + this.additionalProperties, createEmailNotificationChannelConfig.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(address, formats, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateEmailNotificationChannelConfig {\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" formats: ").append(toIndentedString(formats)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelAttributes.java b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelAttributes.java new file mode 100644 index 00000000000..4f3fe66f158 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelAttributes.java @@ -0,0 +1,138 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes for creating an on-call notification channel. */ +@JsonPropertyOrder({CreateNotificationChannelAttributes.JSON_PROPERTY_CONFIG}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateNotificationChannelAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CONFIG = "config"; + private CreateNotificationChannelConfig config; + + public CreateNotificationChannelAttributes config(CreateNotificationChannelConfig config) { + this.config = config; + this.unparsed |= config.unparsed; + return this; + } + + /** + * Defines the configuration for creating an On-Call notification channel + * + * @return config + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONFIG) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public CreateNotificationChannelConfig getConfig() { + return config; + } + + public void setConfig(CreateNotificationChannelConfig config) { + this.config = config; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return CreateNotificationChannelAttributes + */ + @JsonAnySetter + public CreateNotificationChannelAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this CreateNotificationChannelAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateNotificationChannelAttributes createNotificationChannelAttributes = + (CreateNotificationChannelAttributes) o; + return Objects.equals(this.config, createNotificationChannelAttributes.config) + && Objects.equals( + this.additionalProperties, createNotificationChannelAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(config, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationChannelAttributes {\n"); + sb.append(" config: ").append(toIndentedString(config)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelConfig.java b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelConfig.java new file mode 100644 index 00000000000..9672d1c9040 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelConfig.java @@ -0,0 +1,305 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize( + using = CreateNotificationChannelConfig.CreateNotificationChannelConfigDeserializer.class) +@JsonSerialize( + using = CreateNotificationChannelConfig.CreateNotificationChannelConfigSerializer.class) +public class CreateNotificationChannelConfig extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(CreateNotificationChannelConfig.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CreateNotificationChannelConfigSerializer + extends StdSerializer { + public CreateNotificationChannelConfigSerializer(Class t) { + super(t); + } + + public CreateNotificationChannelConfigSerializer() { + this(null); + } + + @Override + public void serialize( + CreateNotificationChannelConfig value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CreateNotificationChannelConfigDeserializer + extends StdDeserializer { + public CreateNotificationChannelConfigDeserializer() { + this(CreateNotificationChannelConfig.class); + } + + public CreateNotificationChannelConfigDeserializer(Class vc) { + super(vc); + } + + @Override + public CreateNotificationChannelConfig deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize CreatePhoneNotificationChannelConfig + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (CreatePhoneNotificationChannelConfig.class.equals(Integer.class) + || CreatePhoneNotificationChannelConfig.class.equals(Long.class) + || CreatePhoneNotificationChannelConfig.class.equals(Float.class) + || CreatePhoneNotificationChannelConfig.class.equals(Double.class) + || CreatePhoneNotificationChannelConfig.class.equals(Boolean.class) + || CreatePhoneNotificationChannelConfig.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((CreatePhoneNotificationChannelConfig.class.equals(Integer.class) + || CreatePhoneNotificationChannelConfig.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((CreatePhoneNotificationChannelConfig.class.equals(Float.class) + || CreatePhoneNotificationChannelConfig.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (CreatePhoneNotificationChannelConfig.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (CreatePhoneNotificationChannelConfig.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()).readValueAs(CreatePhoneNotificationChannelConfig.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((CreatePhoneNotificationChannelConfig) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'CreatePhoneNotificationChannelConfig'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'CreatePhoneNotificationChannelConfig'", + e); + } + + // deserialize CreateEmailNotificationChannelConfig + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (CreateEmailNotificationChannelConfig.class.equals(Integer.class) + || CreateEmailNotificationChannelConfig.class.equals(Long.class) + || CreateEmailNotificationChannelConfig.class.equals(Float.class) + || CreateEmailNotificationChannelConfig.class.equals(Double.class) + || CreateEmailNotificationChannelConfig.class.equals(Boolean.class) + || CreateEmailNotificationChannelConfig.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((CreateEmailNotificationChannelConfig.class.equals(Integer.class) + || CreateEmailNotificationChannelConfig.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((CreateEmailNotificationChannelConfig.class.equals(Float.class) + || CreateEmailNotificationChannelConfig.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (CreateEmailNotificationChannelConfig.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (CreateEmailNotificationChannelConfig.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()).readValueAs(CreateEmailNotificationChannelConfig.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((CreateEmailNotificationChannelConfig) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'CreateEmailNotificationChannelConfig'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'CreateEmailNotificationChannelConfig'", + e); + } + + CreateNotificationChannelConfig ret = new CreateNotificationChannelConfig(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public CreateNotificationChannelConfig getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "CreateNotificationChannelConfig cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CreateNotificationChannelConfig() { + super("oneOf", Boolean.FALSE); + } + + public CreateNotificationChannelConfig(CreatePhoneNotificationChannelConfig o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CreateNotificationChannelConfig(CreateEmailNotificationChannelConfig o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "CreatePhoneNotificationChannelConfig", + new GenericType() {}); + schemas.put( + "CreateEmailNotificationChannelConfig", + new GenericType() {}); + JSON.registerDescendants( + CreateNotificationChannelConfig.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CreateNotificationChannelConfig.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: CreatePhoneNotificationChannelConfig, + * CreateEmailNotificationChannelConfig + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf( + CreatePhoneNotificationChannelConfig.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + CreateEmailNotificationChannelConfig.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException( + "Invalid instance type. Must be CreatePhoneNotificationChannelConfig," + + " CreateEmailNotificationChannelConfig"); + } + + /** + * Get the actual instance, which can be the following: CreatePhoneNotificationChannelConfig, + * CreateEmailNotificationChannelConfig + * + * @return The actual instance (CreatePhoneNotificationChannelConfig, + * CreateEmailNotificationChannelConfig) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CreatePhoneNotificationChannelConfig`. If the actual instance is + * not `CreatePhoneNotificationChannelConfig`, the ClassCastException will be thrown. + * + * @return The actual instance of `CreatePhoneNotificationChannelConfig` + * @throws ClassCastException if the instance is not `CreatePhoneNotificationChannelConfig` + */ + public CreatePhoneNotificationChannelConfig getCreatePhoneNotificationChannelConfig() + throws ClassCastException { + return (CreatePhoneNotificationChannelConfig) super.getActualInstance(); + } + + /** + * Get the actual instance of `CreateEmailNotificationChannelConfig`. If the actual instance is + * not `CreateEmailNotificationChannelConfig`, the ClassCastException will be thrown. + * + * @return The actual instance of `CreateEmailNotificationChannelConfig` + * @throws ClassCastException if the instance is not `CreateEmailNotificationChannelConfig` + */ + public CreateEmailNotificationChannelConfig getCreateEmailNotificationChannelConfig() + throws ClassCastException { + return (CreateEmailNotificationChannelConfig) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelData.java b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelData.java new file mode 100644 index 00000000000..b47ced70f59 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateNotificationChannelData.java @@ -0,0 +1,179 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Data for creating an on-call notification channel */ +@JsonPropertyOrder({ + CreateNotificationChannelData.JSON_PROPERTY_ATTRIBUTES, + CreateNotificationChannelData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateNotificationChannelData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private CreateNotificationChannelAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelType type = NotificationChannelType.NOTIFICATION_CHANNELS; + + public CreateNotificationChannelData() {} + + @JsonCreator + public CreateNotificationChannelData( + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) NotificationChannelType type) { + this.type = type; + this.unparsed |= !type.isValid(); + } + + public CreateNotificationChannelData attributes(CreateNotificationChannelAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for creating an on-call notification channel. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public CreateNotificationChannelAttributes getAttributes() { + return attributes; + } + + public void setAttributes(CreateNotificationChannelAttributes attributes) { + this.attributes = attributes; + } + + public CreateNotificationChannelData type(NotificationChannelType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the resource is of type 'notification_channels'. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationChannelType getType() { + return type; + } + + public void setType(NotificationChannelType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return CreateNotificationChannelData + */ + @JsonAnySetter + public CreateNotificationChannelData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this CreateNotificationChannelData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateNotificationChannelData createNotificationChannelData = (CreateNotificationChannelData) o; + return Objects.equals(this.attributes, createNotificationChannelData.attributes) + && Objects.equals(this.type, createNotificationChannelData.type) + && Objects.equals( + this.additionalProperties, createNotificationChannelData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationChannelData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CreatePhoneNotificationChannelConfig.java b/src/main/java/com/datadog/api/client/v2/model/CreatePhoneNotificationChannelConfig.java new file mode 100644 index 00000000000..5ee1a7613c9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreatePhoneNotificationChannelConfig.java @@ -0,0 +1,181 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Configuration to create a phone notification channel */ +@JsonPropertyOrder({ + CreatePhoneNotificationChannelConfig.JSON_PROPERTY_NUMBER, + CreatePhoneNotificationChannelConfig.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreatePhoneNotificationChannelConfig { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NUMBER = "number"; + private String number; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelPhoneConfigType type = NotificationChannelPhoneConfigType.PHONE; + + public CreatePhoneNotificationChannelConfig() {} + + @JsonCreator + public CreatePhoneNotificationChannelConfig( + @JsonProperty(required = true, value = JSON_PROPERTY_NUMBER) String number, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + NotificationChannelPhoneConfigType type) { + this.number = number; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public CreatePhoneNotificationChannelConfig number(String number) { + this.number = number; + return this; + } + + /** + * The E-164 formatted phone number (e.g. +3371234567) + * + * @return number + */ + @JsonProperty(JSON_PROPERTY_NUMBER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public CreatePhoneNotificationChannelConfig type(NotificationChannelPhoneConfigType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the notification channel is a phone + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationChannelPhoneConfigType getType() { + return type; + } + + public void setType(NotificationChannelPhoneConfigType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return CreatePhoneNotificationChannelConfig + */ + @JsonAnySetter + public CreatePhoneNotificationChannelConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this CreatePhoneNotificationChannelConfig object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreatePhoneNotificationChannelConfig createPhoneNotificationChannelConfig = + (CreatePhoneNotificationChannelConfig) o; + return Objects.equals(this.number, createPhoneNotificationChannelConfig.number) + && Objects.equals(this.type, createPhoneNotificationChannelConfig.type) + && Objects.equals( + this.additionalProperties, createPhoneNotificationChannelConfig.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(number, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreatePhoneNotificationChannelConfig {\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CreateUserNotificationChannelRequest.java b/src/main/java/com/datadog/api/client/v2/model/CreateUserNotificationChannelRequest.java new file mode 100644 index 00000000000..d5b11f1e2af --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateUserNotificationChannelRequest.java @@ -0,0 +1,148 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A top-level wrapper for creating a notification channel for a user */ +@JsonPropertyOrder({CreateUserNotificationChannelRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateUserNotificationChannelRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private CreateNotificationChannelData data; + + public CreateUserNotificationChannelRequest() {} + + @JsonCreator + public CreateUserNotificationChannelRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + CreateNotificationChannelData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public CreateUserNotificationChannelRequest data(CreateNotificationChannelData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data for creating an on-call notification channel + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public CreateNotificationChannelData getData() { + return data; + } + + public void setData(CreateNotificationChannelData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return CreateUserNotificationChannelRequest + */ + @JsonAnySetter + public CreateUserNotificationChannelRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this CreateUserNotificationChannelRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateUserNotificationChannelRequest createUserNotificationChannelRequest = + (CreateUserNotificationChannelRequest) o; + return Objects.equals(this.data, createUserNotificationChannelRequest.data) + && Objects.equals( + this.additionalProperties, createUserNotificationChannelRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateUserNotificationChannelRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ListNotificationChannelsResponse.java b/src/main/java/com/datadog/api/client/v2/model/ListNotificationChannelsResponse.java new file mode 100644 index 00000000000..06ca2040757 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListNotificationChannelsResponse.java @@ -0,0 +1,151 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Response type for listing notification channels for a user */ +@JsonPropertyOrder({ListNotificationChannelsResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ListNotificationChannelsResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = null; + + public ListNotificationChannelsResponse data(List data) { + this.data = data; + for (NotificationChannelData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ListNotificationChannelsResponse addDataItem(NotificationChannelData dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * Getdata + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ListNotificationChannelsResponse + */ + @JsonAnySetter + public ListNotificationChannelsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ListNotificationChannelsResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListNotificationChannelsResponse listNotificationChannelsResponse = + (ListNotificationChannelsResponse) o; + return Objects.equals(this.data, listNotificationChannelsResponse.data) + && Objects.equals( + this.additionalProperties, listNotificationChannelsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListNotificationChannelsResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannel.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannel.java new file mode 100644 index 00000000000..556a5bab6b0 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannel.java @@ -0,0 +1,136 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A top-level wrapper for a user notification channel */ +@JsonPropertyOrder({NotificationChannel.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationChannel { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private NotificationChannelData data; + + public NotificationChannel data(NotificationChannelData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data for an on-call notification channel + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NotificationChannelData getData() { + return data; + } + + public void setData(NotificationChannelData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return NotificationChannel + */ + @JsonAnySetter + public NotificationChannel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this NotificationChannel object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationChannel notificationChannel = (NotificationChannel) o; + return Objects.equals(this.data, notificationChannel.data) + && Objects.equals(this.additionalProperties, notificationChannel.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationChannel {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelAttributes.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelAttributes.java new file mode 100644 index 00000000000..227725e4f2d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelAttributes.java @@ -0,0 +1,166 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes for an on-call notification channel. */ +@JsonPropertyOrder({ + NotificationChannelAttributes.JSON_PROPERTY_ACTIVE, + NotificationChannelAttributes.JSON_PROPERTY_CONFIG +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationChannelAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ACTIVE = "active"; + private Boolean active; + + public static final String JSON_PROPERTY_CONFIG = "config"; + private NotificationChannelConfig config; + + public NotificationChannelAttributes active(Boolean active) { + this.active = active; + return this; + } + + /** + * Whether the notification channel is currently active. + * + * @return active + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ACTIVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public NotificationChannelAttributes config(NotificationChannelConfig config) { + this.config = config; + this.unparsed |= config.unparsed; + return this; + } + + /** + * Defines the configuration for an On-Call notification channel + * + * @return config + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONFIG) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NotificationChannelConfig getConfig() { + return config; + } + + public void setConfig(NotificationChannelConfig config) { + this.config = config; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return NotificationChannelAttributes + */ + @JsonAnySetter + public NotificationChannelAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this NotificationChannelAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationChannelAttributes notificationChannelAttributes = (NotificationChannelAttributes) o; + return Objects.equals(this.active, notificationChannelAttributes.active) + && Objects.equals(this.config, notificationChannelAttributes.config) + && Objects.equals( + this.additionalProperties, notificationChannelAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(active, config, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationChannelAttributes {\n"); + sb.append(" active: ").append(toIndentedString(active)).append("\n"); + sb.append(" config: ").append(toIndentedString(config)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelConfig.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelConfig.java new file mode 100644 index 00000000000..5ec84a8f00c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelConfig.java @@ -0,0 +1,360 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize(using = NotificationChannelConfig.NotificationChannelConfigDeserializer.class) +@JsonSerialize(using = NotificationChannelConfig.NotificationChannelConfigSerializer.class) +public class NotificationChannelConfig extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(NotificationChannelConfig.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class NotificationChannelConfigSerializer + extends StdSerializer { + public NotificationChannelConfigSerializer(Class t) { + super(t); + } + + public NotificationChannelConfigSerializer() { + this(null); + } + + @Override + public void serialize( + NotificationChannelConfig value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class NotificationChannelConfigDeserializer + extends StdDeserializer { + public NotificationChannelConfigDeserializer() { + this(NotificationChannelConfig.class); + } + + public NotificationChannelConfigDeserializer(Class vc) { + super(vc); + } + + @Override + public NotificationChannelConfig deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize NotificationChannelPhoneConfig + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (NotificationChannelPhoneConfig.class.equals(Integer.class) + || NotificationChannelPhoneConfig.class.equals(Long.class) + || NotificationChannelPhoneConfig.class.equals(Float.class) + || NotificationChannelPhoneConfig.class.equals(Double.class) + || NotificationChannelPhoneConfig.class.equals(Boolean.class) + || NotificationChannelPhoneConfig.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((NotificationChannelPhoneConfig.class.equals(Integer.class) + || NotificationChannelPhoneConfig.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((NotificationChannelPhoneConfig.class.equals(Float.class) + || NotificationChannelPhoneConfig.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (NotificationChannelPhoneConfig.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (NotificationChannelPhoneConfig.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(NotificationChannelPhoneConfig.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((NotificationChannelPhoneConfig) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'NotificationChannelPhoneConfig'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'NotificationChannelPhoneConfig'", e); + } + + // deserialize NotificationChannelEmailConfig + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (NotificationChannelEmailConfig.class.equals(Integer.class) + || NotificationChannelEmailConfig.class.equals(Long.class) + || NotificationChannelEmailConfig.class.equals(Float.class) + || NotificationChannelEmailConfig.class.equals(Double.class) + || NotificationChannelEmailConfig.class.equals(Boolean.class) + || NotificationChannelEmailConfig.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((NotificationChannelEmailConfig.class.equals(Integer.class) + || NotificationChannelEmailConfig.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((NotificationChannelEmailConfig.class.equals(Float.class) + || NotificationChannelEmailConfig.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (NotificationChannelEmailConfig.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (NotificationChannelEmailConfig.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(NotificationChannelEmailConfig.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((NotificationChannelEmailConfig) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'NotificationChannelEmailConfig'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'NotificationChannelEmailConfig'", e); + } + + // deserialize NotificationChannelPushConfig + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (NotificationChannelPushConfig.class.equals(Integer.class) + || NotificationChannelPushConfig.class.equals(Long.class) + || NotificationChannelPushConfig.class.equals(Float.class) + || NotificationChannelPushConfig.class.equals(Double.class) + || NotificationChannelPushConfig.class.equals(Boolean.class) + || NotificationChannelPushConfig.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((NotificationChannelPushConfig.class.equals(Integer.class) + || NotificationChannelPushConfig.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((NotificationChannelPushConfig.class.equals(Float.class) + || NotificationChannelPushConfig.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (NotificationChannelPushConfig.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (NotificationChannelPushConfig.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(NotificationChannelPushConfig.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((NotificationChannelPushConfig) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'NotificationChannelPushConfig'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'NotificationChannelPushConfig'", e); + } + + NotificationChannelConfig ret = new NotificationChannelConfig(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public NotificationChannelConfig getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "NotificationChannelConfig cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public NotificationChannelConfig() { + super("oneOf", Boolean.FALSE); + } + + public NotificationChannelConfig(NotificationChannelPhoneConfig o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public NotificationChannelConfig(NotificationChannelEmailConfig o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public NotificationChannelConfig(NotificationChannelPushConfig o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "NotificationChannelPhoneConfig", new GenericType() {}); + schemas.put( + "NotificationChannelEmailConfig", new GenericType() {}); + schemas.put( + "NotificationChannelPushConfig", new GenericType() {}); + JSON.registerDescendants(NotificationChannelConfig.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return NotificationChannelConfig.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: NotificationChannelPhoneConfig, + * NotificationChannelEmailConfig, NotificationChannelPushConfig + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf( + NotificationChannelPhoneConfig.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + NotificationChannelEmailConfig.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(NotificationChannelPushConfig.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException( + "Invalid instance type. Must be NotificationChannelPhoneConfig," + + " NotificationChannelEmailConfig, NotificationChannelPushConfig"); + } + + /** + * Get the actual instance, which can be the following: NotificationChannelPhoneConfig, + * NotificationChannelEmailConfig, NotificationChannelPushConfig + * + * @return The actual instance (NotificationChannelPhoneConfig, NotificationChannelEmailConfig, + * NotificationChannelPushConfig) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `NotificationChannelPhoneConfig`. If the actual instance is not + * `NotificationChannelPhoneConfig`, the ClassCastException will be thrown. + * + * @return The actual instance of `NotificationChannelPhoneConfig` + * @throws ClassCastException if the instance is not `NotificationChannelPhoneConfig` + */ + public NotificationChannelPhoneConfig getNotificationChannelPhoneConfig() + throws ClassCastException { + return (NotificationChannelPhoneConfig) super.getActualInstance(); + } + + /** + * Get the actual instance of `NotificationChannelEmailConfig`. If the actual instance is not + * `NotificationChannelEmailConfig`, the ClassCastException will be thrown. + * + * @return The actual instance of `NotificationChannelEmailConfig` + * @throws ClassCastException if the instance is not `NotificationChannelEmailConfig` + */ + public NotificationChannelEmailConfig getNotificationChannelEmailConfig() + throws ClassCastException { + return (NotificationChannelEmailConfig) super.getActualInstance(); + } + + /** + * Get the actual instance of `NotificationChannelPushConfig`. If the actual instance is not + * `NotificationChannelPushConfig`, the ClassCastException will be thrown. + * + * @return The actual instance of `NotificationChannelPushConfig` + * @throws ClassCastException if the instance is not `NotificationChannelPushConfig` + */ + public NotificationChannelPushConfig getNotificationChannelPushConfig() + throws ClassCastException { + return (NotificationChannelPushConfig) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelData.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelData.java new file mode 100644 index 00000000000..ae3934a66ae --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelData.java @@ -0,0 +1,205 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Data for an on-call notification channel */ +@JsonPropertyOrder({ + NotificationChannelData.JSON_PROPERTY_ATTRIBUTES, + NotificationChannelData.JSON_PROPERTY_ID, + NotificationChannelData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationChannelData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private NotificationChannelAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelType type = NotificationChannelType.NOTIFICATION_CHANNELS; + + public NotificationChannelData() {} + + @JsonCreator + public NotificationChannelData( + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) NotificationChannelType type) { + this.type = type; + this.unparsed |= !type.isValid(); + } + + public NotificationChannelData attributes(NotificationChannelAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for an on-call notification channel. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NotificationChannelAttributes getAttributes() { + return attributes; + } + + public void setAttributes(NotificationChannelAttributes attributes) { + this.attributes = attributes; + } + + public NotificationChannelData id(String id) { + this.id = id; + return this; + } + + /** + * Unique identifier for the channel + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public NotificationChannelData type(NotificationChannelType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the resource is of type 'notification_channels'. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationChannelType getType() { + return type; + } + + public void setType(NotificationChannelType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return NotificationChannelData + */ + @JsonAnySetter + public NotificationChannelData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this NotificationChannelData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationChannelData notificationChannelData = (NotificationChannelData) o; + return Objects.equals(this.attributes, notificationChannelData.attributes) + && Objects.equals(this.id, notificationChannelData.id) + && Objects.equals(this.type, notificationChannelData.type) + && Objects.equals(this.additionalProperties, notificationChannelData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationChannelData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailConfig.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailConfig.java new file mode 100644 index 00000000000..2ec39d55fc0 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailConfig.java @@ -0,0 +1,219 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Email notification channel configuration */ +@JsonPropertyOrder({ + NotificationChannelEmailConfig.JSON_PROPERTY_ADDRESS, + NotificationChannelEmailConfig.JSON_PROPERTY_FORMATS, + NotificationChannelEmailConfig.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationChannelEmailConfig { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ADDRESS = "address"; + private String address; + + public static final String JSON_PROPERTY_FORMATS = "formats"; + private List formats = new ArrayList<>(); + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelEmailConfigType type = NotificationChannelEmailConfigType.EMAIL; + + public NotificationChannelEmailConfig() {} + + @JsonCreator + public NotificationChannelEmailConfig( + @JsonProperty(required = true, value = JSON_PROPERTY_ADDRESS) String address, + @JsonProperty(required = true, value = JSON_PROPERTY_FORMATS) + List formats, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + NotificationChannelEmailConfigType type) { + this.address = address; + this.formats = formats; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public NotificationChannelEmailConfig address(String address) { + this.address = address; + return this; + } + + /** + * The e-mail address to be notified + * + * @return address + */ + @JsonProperty(JSON_PROPERTY_ADDRESS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public NotificationChannelEmailConfig formats(List formats) { + this.formats = formats; + return this; + } + + public NotificationChannelEmailConfig addFormatsItem( + NotificationChannelEmailFormatType formatsItem) { + this.formats.add(formatsItem); + this.unparsed |= !formatsItem.isValid(); + return this; + } + + /** + * Preferred content formats for notifications. + * + * @return formats + */ + @JsonProperty(JSON_PROPERTY_FORMATS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getFormats() { + return formats; + } + + public void setFormats(List formats) { + this.formats = formats; + } + + public NotificationChannelEmailConfig type(NotificationChannelEmailConfigType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the notification channel is an e-mail address + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationChannelEmailConfigType getType() { + return type; + } + + public void setType(NotificationChannelEmailConfigType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return NotificationChannelEmailConfig + */ + @JsonAnySetter + public NotificationChannelEmailConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this NotificationChannelEmailConfig object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationChannelEmailConfig notificationChannelEmailConfig = + (NotificationChannelEmailConfig) o; + return Objects.equals(this.address, notificationChannelEmailConfig.address) + && Objects.equals(this.formats, notificationChannelEmailConfig.formats) + && Objects.equals(this.type, notificationChannelEmailConfig.type) + && Objects.equals( + this.additionalProperties, notificationChannelEmailConfig.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(address, formats, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationChannelEmailConfig {\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" formats: ").append(toIndentedString(formats)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailConfigType.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailConfigType.java new file mode 100644 index 00000000000..3bdc984f953 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailConfigType.java @@ -0,0 +1,58 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Indicates that the notification channel is an e-mail address */ +@JsonSerialize( + using = NotificationChannelEmailConfigType.NotificationChannelEmailConfigTypeSerializer.class) +public class NotificationChannelEmailConfigType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("email")); + + public static final NotificationChannelEmailConfigType EMAIL = + new NotificationChannelEmailConfigType("email"); + + NotificationChannelEmailConfigType(String value) { + super(value, allowedValues); + } + + public static class NotificationChannelEmailConfigTypeSerializer + extends StdSerializer { + public NotificationChannelEmailConfigTypeSerializer( + Class t) { + super(t); + } + + public NotificationChannelEmailConfigTypeSerializer() { + this(null); + } + + @Override + public void serialize( + NotificationChannelEmailConfigType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static NotificationChannelEmailConfigType fromValue(String value) { + return new NotificationChannelEmailConfigType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailFormatType.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailFormatType.java new file mode 100644 index 00000000000..13d93bea9a4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelEmailFormatType.java @@ -0,0 +1,61 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Specifies the format of the e-mail that is sent for On-Call notifications */ +@JsonSerialize( + using = NotificationChannelEmailFormatType.NotificationChannelEmailFormatTypeSerializer.class) +public class NotificationChannelEmailFormatType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("html", "text")); + + public static final NotificationChannelEmailFormatType HTML = + new NotificationChannelEmailFormatType("html"); + public static final NotificationChannelEmailFormatType TEXT = + new NotificationChannelEmailFormatType("text"); + + NotificationChannelEmailFormatType(String value) { + super(value, allowedValues); + } + + public static class NotificationChannelEmailFormatTypeSerializer + extends StdSerializer { + public NotificationChannelEmailFormatTypeSerializer( + Class t) { + super(t); + } + + public NotificationChannelEmailFormatTypeSerializer() { + this(null); + } + + @Override + public void serialize( + NotificationChannelEmailFormatType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static NotificationChannelEmailFormatType fromValue(String value) { + return new NotificationChannelEmailFormatType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPhoneConfig.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPhoneConfig.java new file mode 100644 index 00000000000..f74fa106351 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPhoneConfig.java @@ -0,0 +1,305 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Phone notification channel configuration */ +@JsonPropertyOrder({ + NotificationChannelPhoneConfig.JSON_PROPERTY_FORMATTED_NUMBER, + NotificationChannelPhoneConfig.JSON_PROPERTY_NUMBER, + NotificationChannelPhoneConfig.JSON_PROPERTY_REGION, + NotificationChannelPhoneConfig.JSON_PROPERTY_SMS_SUBSCRIBED_AT, + NotificationChannelPhoneConfig.JSON_PROPERTY_TYPE, + NotificationChannelPhoneConfig.JSON_PROPERTY_VERIFIED +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationChannelPhoneConfig { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FORMATTED_NUMBER = "formatted_number"; + private String formattedNumber; + + public static final String JSON_PROPERTY_NUMBER = "number"; + private String number; + + public static final String JSON_PROPERTY_REGION = "region"; + private String region; + + public static final String JSON_PROPERTY_SMS_SUBSCRIBED_AT = "sms_subscribed_at"; + private JsonNullable smsSubscribedAt = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelPhoneConfigType type = NotificationChannelPhoneConfigType.PHONE; + + public static final String JSON_PROPERTY_VERIFIED = "verified"; + private Boolean verified; + + public NotificationChannelPhoneConfig() {} + + @JsonCreator + public NotificationChannelPhoneConfig( + @JsonProperty(required = true, value = JSON_PROPERTY_FORMATTED_NUMBER) String formattedNumber, + @JsonProperty(required = true, value = JSON_PROPERTY_NUMBER) String number, + @JsonProperty(required = true, value = JSON_PROPERTY_REGION) String region, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + NotificationChannelPhoneConfigType type, + @JsonProperty(required = true, value = JSON_PROPERTY_VERIFIED) Boolean verified) { + this.formattedNumber = formattedNumber; + this.number = number; + this.region = region; + this.type = type; + this.unparsed |= !type.isValid(); + this.verified = verified; + } + + public NotificationChannelPhoneConfig formattedNumber(String formattedNumber) { + this.formattedNumber = formattedNumber; + return this; + } + + /** + * The formatted international version of Number (e.g. +33 7 1 23 45 67). + * + * @return formattedNumber + */ + @JsonProperty(JSON_PROPERTY_FORMATTED_NUMBER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getFormattedNumber() { + return formattedNumber; + } + + public void setFormattedNumber(String formattedNumber) { + this.formattedNumber = formattedNumber; + } + + public NotificationChannelPhoneConfig number(String number) { + this.number = number; + return this; + } + + /** + * The E-164 formatted phone number (e.g. +3371234567) + * + * @return number + */ + @JsonProperty(JSON_PROPERTY_NUMBER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public NotificationChannelPhoneConfig region(String region) { + this.region = region; + return this; + } + + /** + * The ISO 3166-1 alpha-2 two-letter country code. + * + * @return region + */ + @JsonProperty(JSON_PROPERTY_REGION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public NotificationChannelPhoneConfig smsSubscribedAt(OffsetDateTime smsSubscribedAt) { + this.smsSubscribedAt = JsonNullable.of(smsSubscribedAt); + return this; + } + + /** + * If present, the date the user subscribed this number to SMS messages + * + * @return smsSubscribedAt + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getSmsSubscribedAt() { + return smsSubscribedAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SMS_SUBSCRIBED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getSmsSubscribedAt_JsonNullable() { + return smsSubscribedAt; + } + + @JsonProperty(JSON_PROPERTY_SMS_SUBSCRIBED_AT) + public void setSmsSubscribedAt_JsonNullable(JsonNullable smsSubscribedAt) { + this.smsSubscribedAt = smsSubscribedAt; + } + + public void setSmsSubscribedAt(OffsetDateTime smsSubscribedAt) { + this.smsSubscribedAt = JsonNullable.of(smsSubscribedAt); + } + + public NotificationChannelPhoneConfig type(NotificationChannelPhoneConfigType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the notification channel is a phone + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationChannelPhoneConfigType getType() { + return type; + } + + public void setType(NotificationChannelPhoneConfigType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + public NotificationChannelPhoneConfig verified(Boolean verified) { + this.verified = verified; + return this; + } + + /** + * Indicates whether this phone has been verified by the user in Datadog On-Call + * + * @return verified + */ + @JsonProperty(JSON_PROPERTY_VERIFIED) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Boolean getVerified() { + return verified; + } + + public void setVerified(Boolean verified) { + this.verified = verified; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return NotificationChannelPhoneConfig + */ + @JsonAnySetter + public NotificationChannelPhoneConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this NotificationChannelPhoneConfig object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationChannelPhoneConfig notificationChannelPhoneConfig = + (NotificationChannelPhoneConfig) o; + return Objects.equals(this.formattedNumber, notificationChannelPhoneConfig.formattedNumber) + && Objects.equals(this.number, notificationChannelPhoneConfig.number) + && Objects.equals(this.region, notificationChannelPhoneConfig.region) + && Objects.equals(this.smsSubscribedAt, notificationChannelPhoneConfig.smsSubscribedAt) + && Objects.equals(this.type, notificationChannelPhoneConfig.type) + && Objects.equals(this.verified, notificationChannelPhoneConfig.verified) + && Objects.equals( + this.additionalProperties, notificationChannelPhoneConfig.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + formattedNumber, number, region, smsSubscribedAt, type, verified, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationChannelPhoneConfig {\n"); + sb.append(" formattedNumber: ").append(toIndentedString(formattedNumber)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" smsSubscribedAt: ").append(toIndentedString(smsSubscribedAt)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" verified: ").append(toIndentedString(verified)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPhoneConfigType.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPhoneConfigType.java new file mode 100644 index 00000000000..25babe0afde --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPhoneConfigType.java @@ -0,0 +1,58 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Indicates that the notification channel is a phone */ +@JsonSerialize( + using = NotificationChannelPhoneConfigType.NotificationChannelPhoneConfigTypeSerializer.class) +public class NotificationChannelPhoneConfigType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("phone")); + + public static final NotificationChannelPhoneConfigType PHONE = + new NotificationChannelPhoneConfigType("phone"); + + NotificationChannelPhoneConfigType(String value) { + super(value, allowedValues); + } + + public static class NotificationChannelPhoneConfigTypeSerializer + extends StdSerializer { + public NotificationChannelPhoneConfigTypeSerializer( + Class t) { + super(t); + } + + public NotificationChannelPhoneConfigTypeSerializer() { + this(null); + } + + @Override + public void serialize( + NotificationChannelPhoneConfigType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static NotificationChannelPhoneConfigType fromValue(String value) { + return new NotificationChannelPhoneConfigType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPushConfig.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPushConfig.java new file mode 100644 index 00000000000..7b5af48d17b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPushConfig.java @@ -0,0 +1,208 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Push notification channel configuration */ +@JsonPropertyOrder({ + NotificationChannelPushConfig.JSON_PROPERTY_APPLICATION_NAME, + NotificationChannelPushConfig.JSON_PROPERTY_DEVICE_NAME, + NotificationChannelPushConfig.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class NotificationChannelPushConfig { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_APPLICATION_NAME = "application_name"; + private String applicationName; + + public static final String JSON_PROPERTY_DEVICE_NAME = "device_name"; + private String deviceName; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelPushConfigType type = NotificationChannelPushConfigType.PUSH; + + public NotificationChannelPushConfig() {} + + @JsonCreator + public NotificationChannelPushConfig( + @JsonProperty(required = true, value = JSON_PROPERTY_APPLICATION_NAME) String applicationName, + @JsonProperty(required = true, value = JSON_PROPERTY_DEVICE_NAME) String deviceName, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + NotificationChannelPushConfigType type) { + this.applicationName = applicationName; + this.deviceName = deviceName; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public NotificationChannelPushConfig applicationName(String applicationName) { + this.applicationName = applicationName; + return this; + } + + /** + * The name of the application used to receive push notifications + * + * @return applicationName + */ + @JsonProperty(JSON_PROPERTY_APPLICATION_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public NotificationChannelPushConfig deviceName(String deviceName) { + this.deviceName = deviceName; + return this; + } + + /** + * The name of the mobile device being used + * + * @return deviceName + */ + @JsonProperty(JSON_PROPERTY_DEVICE_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public NotificationChannelPushConfig type(NotificationChannelPushConfigType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the notification channel is a mobile device for push notifications + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public NotificationChannelPushConfigType getType() { + return type; + } + + public void setType(NotificationChannelPushConfigType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return NotificationChannelPushConfig + */ + @JsonAnySetter + public NotificationChannelPushConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this NotificationChannelPushConfig object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationChannelPushConfig notificationChannelPushConfig = (NotificationChannelPushConfig) o; + return Objects.equals(this.applicationName, notificationChannelPushConfig.applicationName) + && Objects.equals(this.deviceName, notificationChannelPushConfig.deviceName) + && Objects.equals(this.type, notificationChannelPushConfig.type) + && Objects.equals( + this.additionalProperties, notificationChannelPushConfig.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(applicationName, deviceName, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationChannelPushConfig {\n"); + sb.append(" applicationName: ").append(toIndentedString(applicationName)).append("\n"); + sb.append(" deviceName: ").append(toIndentedString(deviceName)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPushConfigType.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPushConfigType.java new file mode 100644 index 00000000000..8b025bb0aca --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelPushConfigType.java @@ -0,0 +1,57 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Indicates that the notification channel is a mobile device for push notifications */ +@JsonSerialize( + using = NotificationChannelPushConfigType.NotificationChannelPushConfigTypeSerializer.class) +public class NotificationChannelPushConfigType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("push")); + + public static final NotificationChannelPushConfigType PUSH = + new NotificationChannelPushConfigType("push"); + + NotificationChannelPushConfigType(String value) { + super(value, allowedValues); + } + + public static class NotificationChannelPushConfigTypeSerializer + extends StdSerializer { + public NotificationChannelPushConfigTypeSerializer(Class t) { + super(t); + } + + public NotificationChannelPushConfigTypeSerializer() { + this(null); + } + + @Override + public void serialize( + NotificationChannelPushConfigType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static NotificationChannelPushConfigType fromValue(String value) { + return new NotificationChannelPushConfigType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotificationChannelType.java b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelType.java new file mode 100644 index 00000000000..05e2ad0ed5f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotificationChannelType.java @@ -0,0 +1,57 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Indicates that the resource is of type 'notification_channels'. */ +@JsonSerialize(using = NotificationChannelType.NotificationChannelTypeSerializer.class) +public class NotificationChannelType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("notification_channels")); + + public static final NotificationChannelType NOTIFICATION_CHANNELS = + new NotificationChannelType("notification_channels"); + + NotificationChannelType(String value) { + super(value, allowedValues); + } + + public static class NotificationChannelTypeSerializer + extends StdSerializer { + public NotificationChannelTypeSerializer(Class t) { + super(t); + } + + public NotificationChannelTypeSerializer() { + this(null); + } + + @Override + public void serialize( + NotificationChannelType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static NotificationChannelType fromValue(String value) { + return new NotificationChannelType(value); + } +} diff --git a/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_channel_for_a_user_returns_Created_response.freeze b/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_channel_for_a_user_returns_Created_response.freeze new file mode 100644 index 00000000000..d364f431dfd --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_channel_for_a_user_returns_Created_response.freeze @@ -0,0 +1 @@ +2025-12-12T14:05:32.425Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_channel_for_a_user_returns_Created_response.json b/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_channel_for_a_user_returns_Created_response.json new file mode 100644 index 00000000000..8cf953eff4a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_channel_for_a_user_returns_Created_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e646869a-131a-5dae-20e5-3caa10c414ba" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"address\":\"foo@bar.com\",\"formats\":[\"html\"],\"type\":\"email\"}},\"type\":\"notification_channels\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/5ba8ee87-4d71-458c-883d-a6016738f7ce/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "cb19fc28-181a-edaf-9a5f-1d997dc58d95" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/5ba8ee87-4d71-458c-883d-a6016738f7ce", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "908a4a17-23da-a3ca-996e-6930ca7912bf" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_channel_for_a_user_returns_No_Content_response.freeze b/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_channel_for_a_user_returns_No_Content_response.freeze new file mode 100644 index 00000000000..065691eedf0 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_channel_for_a_user_returns_No_Content_response.freeze @@ -0,0 +1 @@ +2025-12-11T18:27:50.679Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_channel_for_a_user_returns_No_Content_response.json b/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_channel_for_a_user_returns_No_Content_response.json new file mode 100644 index 00000000000..3d67debd01b --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_channel_for_a_user_returns_No_Content_response.json @@ -0,0 +1,104 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "80da1347-5cb7-fcb8-d246-ecb3a2e83eeb" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "POST", + "path": "/api/v2/on-call/users/1df33be3-5397-4aaf-95c0-00dd63819c80/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "b54ba694-e3ee-3096-441d-eff4941b2a2e" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/on-call/users/1df33be3-5397-4aaf-95c0-00dd63819c80/notification-channels/dd22cf57-a576-4c7e-92f8-36c2171f5f99", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "16cde92b-365f-2969-442f-556b74d3b28e" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/1df33be3-5397-4aaf-95c0-00dd63819c80", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "5dcdb2de-9d9b-03ee-65dd-240047575a00" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_channel_for_a_user_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_channel_for_a_user_returns_OK_response.freeze new file mode 100644 index 00000000000..e6a81ebe054 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_channel_for_a_user_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-12-12T14:04:17.257Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_channel_for_a_user_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_channel_for_a_user_returns_OK_response.json new file mode 100644 index 00000000000..8a3e84e6cd1 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_channel_for_a_user_returns_OK_response.json @@ -0,0 +1,109 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "bb0f1f2b-f51d-389e-2006-79d0cb16e6a3" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "POST", + "path": "/api/v2/on-call/users/0131b53c-5aec-4c8a-a14f-9ef487448833/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "0f4b23e9-dbff-162f-eeb4-7cb9c12aa159" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/on-call/users/0131b53c-5aec-4c8a-a14f-9ef487448833/notification-channels/d5fc3f5a-a4b9-4972-80bb-cb4db7ec958b", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "92271064-0656-d498-5548-6b6bb0cff94a" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/0131b53c-5aec-4c8a-a14f-9ef487448833", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "4c95055b-3123-4813-a2ea-6a9bd8d0292d" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_On_Call_notification_channels_for_a_user_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/List_On_Call_notification_channels_for_a_user_returns_OK_response.freeze new file mode 100644 index 00000000000..d77fcd86e2a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_On_Call_notification_channels_for_a_user_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-12-12T14:40:40.219Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_On_Call_notification_channels_for_a_user_returns_OK_response.json b/src/test/resources/cassettes/features/v2/List_On_Call_notification_channels_for_a_user_returns_OK_response.json new file mode 100644 index 00000000000..901f033182c --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_On_Call_notification_channels_for_a_user_returns_OK_response.json @@ -0,0 +1,109 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"email\":\"Test-List_On_Call_notification_channels_for_a_user_returns_OK_response-1765550440@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6ddfc267-b7b8-7643-eb7d-58b6864ec71c" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "POST", + "path": "/api/v2/on-call/users/c7fe3658-67dd-4a91-bf86-3709728fd8a5/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "8b6257b6-661c-2f65-0b81-b85b3f6c45d4" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/on-call/users/c7fe3658-67dd-4a91-bf86-3709728fd8a5/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d72734fa-d87a-8355-0ecc-b3dbd27dae01" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/c7fe3658-67dd-4a91-bf86-3709728fd8a5", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "cb4a1520-7e11-8ea2-3c7c-ba8ace639482" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/given.json b/src/test/resources/com/datadog/api/client/v2/api/given.json index 7725798de44..8cf1925f45e 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/given.json +++ b/src/test/resources/com/datadog/api/client/v2/api/given.json @@ -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/src/test/resources/com/datadog/api/client/v2/api/on-call.feature b/src/test/resources/com/datadog/api/client/v2/api/on-call.feature index c52e4291fc6..9f4750eef79 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/on-call.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/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/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index 56977a4c301..8aec373cdd9 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -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": {