diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 196165112da..f2a1dc5e082 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -13374,6 +13374,40 @@ components: - name - targets type: object + CreateOnCallNotificationRuleRequest: + description: A top-level wrapper for creating a notification rule for a user + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/CreateOnCallNotificationRuleRequestData' + required: + - data + type: object + CreateOnCallNotificationRuleRequestData: + description: Data for creating an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/OnCallNotificationRuleRequestAttributes' + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object CreateOpenAPIResponse: description: Response for `CreateOpenAPI` operation. properties: @@ -30599,6 +30633,18 @@ components: $ref: '#/components/schemas/NotificationChannelData' type: array type: object + ListOnCallNotificationRulesResponse: + description: Response type for listing notification rules for a user + properties: + data: + items: + $ref: '#/components/schemas/OnCallNotificationRuleData' + type: array + included: + items: + $ref: '#/components/schemas/OnCallNotificationRulesIncluded' + type: array + type: object ListPipelinesResponse: description: Represents the response payload containing a list of pipelines and associated metadata. @@ -39053,6 +39099,130 @@ components: required: - type type: object + OnCallNotificationRule: + description: A top-level wrapper for a notification rule + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + id: 27590dae-47be-4a7d-9abf-8f4e45124020 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/OnCallNotificationRuleData' + included: + items: + $ref: '#/components/schemas/OnCallNotificationRulesIncluded' + type: array + required: + - data + type: object + OnCallNotificationRuleAttributes: + description: Attributes for an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + OnCallNotificationRuleCategory: + default: high_urgency + description: Specifies the category a notification rule will apply to + enum: + - high_urgency + - low_urgency + type: string + x-enum-varnames: + - HIGH_URGENCY + - LOW_URGENCY + OnCallNotificationRuleChannelRelationship: + description: Relationship object for creating a notification rule + properties: + data: + $ref: '#/components/schemas/OnCallNotificationRuleChannelRelationshipData' + required: + - data + type: object + OnCallNotificationRuleChannelRelationshipData: + description: Channel relationship data for creating a notification rule + properties: + id: + description: ID of the notification channel + type: string + type: + $ref: '#/components/schemas/NotificationChannelType' + type: object + OnCallNotificationRuleChannelSettings: + description: Defines the configuration for a channel associated with a notification + rule + oneOf: + - $ref: '#/components/schemas/OnCallPhoneNotificationRuleSettings' + OnCallNotificationRuleData: + description: Data for an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/OnCallNotificationRuleAttributes' + id: + description: Unique identifier for the rule + type: string + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object + OnCallNotificationRuleRelationships: + description: Relationship object for creating a notification rule + properties: + channel: + $ref: '#/components/schemas/OnCallNotificationRuleChannelRelationship' + type: object + OnCallNotificationRuleRequestAttributes: + description: Attributes for creating or modifying an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + OnCallNotificationRuleType: + default: notification_rules + description: Indicates that the resource is of type 'notification_rules'. + enum: + - notification_rules + example: notification_rules + type: string + x-enum-varnames: + - NOTIFICATION_RULES + OnCallNotificationRulesIncluded: + description: Represents additional included resources for a on-call notification + rules + oneOf: + - $ref: '#/components/schemas/NotificationChannelData' OnCallPageTargetType: description: The kind of target, `team_id` | `team_handle` | `user_id`. enum: @@ -39065,6 +39235,29 @@ components: - TEAM_ID - TEAM_HANDLE - USER_ID + OnCallPhoneNotificationRuleMethod: + description: Specifies the method in which a phone is used in a notification + rule + enum: + - sms + - voice + example: sms + type: string + x-enum-varnames: + - SMS + - VOICE + OnCallPhoneNotificationRuleSettings: + description: Configuration for using a phone notification channel in a notification + rule + properties: + method: + $ref: '#/components/schemas/OnCallPhoneNotificationRuleMethod' + type: + $ref: '#/components/schemas/NotificationChannelPhoneConfigType' + required: + - type + - method + type: object OnDemandConcurrencyCap: description: On-demand concurrency cap. properties: @@ -56304,6 +56497,59 @@ components: - name - options type: object + UpdateOnCallNotificationRuleRequest: + description: A top-level wrapper for updating a notification rule for a user + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + id: 2462ace1-49e2-aab1-xc4f-29cc4ae1105n7 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequestData' + required: + - data + type: object + UpdateOnCallNotificationRuleRequestAttributes: + description: Attributes for creating or modifying an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + UpdateOnCallNotificationRuleRequestData: + description: Data for updating an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequestAttributes' + id: + description: Unique identifier for the rule + type: string + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object UpdateOpenAPIResponse: description: Response for `UpdateOpenAPI`. properties: @@ -76343,6 +76589,255 @@ paths: operator: AND permissions: - on_call_read + /api/v2/on-call/users/{user_id}/notification-rules: + get: + description: List the notification rules for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: ListUserNotificationRules + parameters: + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListOnCallNotificationRulesResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: List On-Call notification rules for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_read + post: + description: Create a new notification rule for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: CreateUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateOnCallNotificationRuleRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Create an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_respond + /api/v2/on-call/users/{user_id}/notification-rules/{rule_id}: + delete: + description: Delete a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: DeleteUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Delete an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: OR + permissions: + - on_call_respond + get: + description: Get a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: GetUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: OR + permissions: + - on_call_read + put: + description: Update a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: UpdateUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Update an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: OR + permissions: + - on_call_read /api/v2/org_configs: get: description: Returns all Org Configs (name, description, and value). diff --git a/examples/v2/on-call/CreateUserNotificationRule.java b/examples/v2/on-call/CreateUserNotificationRule.java new file mode 100644 index 00000000000..706f4bd693e --- /dev/null +++ b/examples/v2/on-call/CreateUserNotificationRule.java @@ -0,0 +1,58 @@ +// Create an On-Call notification rule 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.CreateOnCallNotificationRuleRequest; +import com.datadog.api.client.v2.model.CreateOnCallNotificationRuleRequestData; +import com.datadog.api.client.v2.model.NotificationChannelType; +import com.datadog.api.client.v2.model.OnCallNotificationRule; +import com.datadog.api.client.v2.model.OnCallNotificationRuleCategory; +import com.datadog.api.client.v2.model.OnCallNotificationRuleChannelRelationship; +import com.datadog.api.client.v2.model.OnCallNotificationRuleChannelRelationshipData; +import com.datadog.api.client.v2.model.OnCallNotificationRuleRelationships; +import com.datadog.api.client.v2.model.OnCallNotificationRuleRequestAttributes; +import com.datadog.api.client.v2.model.OnCallNotificationRuleType; + +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"); + + CreateOnCallNotificationRuleRequest body = + new CreateOnCallNotificationRuleRequest() + .data( + new CreateOnCallNotificationRuleRequestData() + .attributes( + new OnCallNotificationRuleRequestAttributes() + .category(OnCallNotificationRuleCategory.HIGH_URGENCY) + .delayMinutes(0L)) + .relationships( + new OnCallNotificationRuleRelationships() + .channel( + new OnCallNotificationRuleChannelRelationship() + .data( + new OnCallNotificationRuleChannelRelationshipData() + .id(ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID) + .type(NotificationChannelType.NOTIFICATION_CHANNELS)))) + .type(OnCallNotificationRuleType.NOTIFICATION_RULES)); + + try { + OnCallNotificationRule result = apiInstance.createUserNotificationRule(USER_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#createUserNotificationRule"); + 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/DeleteUserNotificationRule.java b/examples/v2/on-call/DeleteUserNotificationRule.java new file mode 100644 index 00000000000..66243d588dd --- /dev/null +++ b/examples/v2/on-call/DeleteUserNotificationRule.java @@ -0,0 +1,29 @@ +// Delete an On-Call notification rule 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_rule" in the system + String ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = + System.getenv("ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"); + + try { + apiInstance.deleteUserNotificationRule(USER_DATA_ID, ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#deleteUserNotificationRule"); + 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/GetUserNotificationRule.java b/examples/v2/on-call/GetUserNotificationRule.java new file mode 100644 index 00000000000..84852e6f2ba --- /dev/null +++ b/examples/v2/on-call/GetUserNotificationRule.java @@ -0,0 +1,36 @@ +// Get an On-Call notification rule 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.api.OnCallApi.GetUserNotificationRuleOptionalParameters; +import com.datadog.api.client.v2.model.OnCallNotificationRule; + +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_rule" in the system + String ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = + System.getenv("ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"); + + try { + OnCallNotificationRule result = + apiInstance.getUserNotificationRule( + USER_DATA_ID, + ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, + new GetUserNotificationRuleOptionalParameters().include("channel")); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#getUserNotificationRule"); + 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/ListUserNotificationRules.java b/examples/v2/on-call/ListUserNotificationRules.java new file mode 100644 index 00000000000..da2eba86262 --- /dev/null +++ b/examples/v2/on-call/ListUserNotificationRules.java @@ -0,0 +1,30 @@ +// List On-Call notification rules 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.api.OnCallApi.ListUserNotificationRulesOptionalParameters; +import com.datadog.api.client.v2.model.ListOnCallNotificationRulesResponse; + +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 { + ListOnCallNotificationRulesResponse result = + apiInstance.listUserNotificationRules( + USER_DATA_ID, new ListUserNotificationRulesOptionalParameters().include("channel")); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#listUserNotificationRules"); + 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/UpdateUserNotificationRule.java b/examples/v2/on-call/UpdateUserNotificationRule.java new file mode 100644 index 00000000000..b7a6b6eda1b --- /dev/null +++ b/examples/v2/on-call/UpdateUserNotificationRule.java @@ -0,0 +1,69 @@ +// Update an On-Call notification rule 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.api.OnCallApi.UpdateUserNotificationRuleOptionalParameters; +import com.datadog.api.client.v2.model.NotificationChannelType; +import com.datadog.api.client.v2.model.OnCallNotificationRule; +import com.datadog.api.client.v2.model.OnCallNotificationRuleCategory; +import com.datadog.api.client.v2.model.OnCallNotificationRuleChannelRelationship; +import com.datadog.api.client.v2.model.OnCallNotificationRuleChannelRelationshipData; +import com.datadog.api.client.v2.model.OnCallNotificationRuleRelationships; +import com.datadog.api.client.v2.model.OnCallNotificationRuleType; +import com.datadog.api.client.v2.model.UpdateOnCallNotificationRuleRequest; +import com.datadog.api.client.v2.model.UpdateOnCallNotificationRuleRequestAttributes; +import com.datadog.api.client.v2.model.UpdateOnCallNotificationRuleRequestData; + +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_rule" in the system + String ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = + System.getenv("ONCALL_EMAIL_NOTIFICATION_RULE_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"); + + UpdateOnCallNotificationRuleRequest body = + new UpdateOnCallNotificationRuleRequest() + .data( + new UpdateOnCallNotificationRuleRequestData() + .attributes( + new UpdateOnCallNotificationRuleRequestAttributes() + .category(OnCallNotificationRuleCategory.HIGH_URGENCY) + .delayMinutes(1L)) + .id(ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID) + .relationships( + new OnCallNotificationRuleRelationships() + .channel( + new OnCallNotificationRuleChannelRelationship() + .data( + new OnCallNotificationRuleChannelRelationshipData() + .id(ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID) + .type(NotificationChannelType.NOTIFICATION_CHANNELS)))) + .type(OnCallNotificationRuleType.NOTIFICATION_RULES)); + + try { + OnCallNotificationRule result = + apiInstance.updateUserNotificationRule( + USER_DATA_ID, + ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, + body, + new UpdateUserNotificationRuleOptionalParameters().include("channel")); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#updateUserNotificationRule"); + 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 2c705d7055f..c73f9e8304c 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,12 +4,15 @@ 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.CreateOnCallNotificationRuleRequest; 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.ListOnCallNotificationRulesResponse; import com.datadog.api.client.v2.model.NotificationChannel; +import com.datadog.api.client.v2.model.OnCallNotificationRule; import com.datadog.api.client.v2.model.Schedule; import com.datadog.api.client.v2.model.ScheduleCreateRequest; import com.datadog.api.client.v2.model.ScheduleUpdateRequest; @@ -17,6 +20,7 @@ import com.datadog.api.client.v2.model.TeamOnCallResponders; import com.datadog.api.client.v2.model.TeamRoutingRules; import com.datadog.api.client.v2.model.TeamRoutingRulesRequest; +import com.datadog.api.client.v2.model.UpdateOnCallNotificationRuleRequest; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.GenericType; import java.util.ArrayList; @@ -619,6 +623,168 @@ public ApiResponse createUserNotificationChannelWithHttpInf new GenericType() {}); } + /** + * Create an On-Call notification rule for a user. + * + *

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

See {@link #createUserNotificationRuleWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param body (required) + * @return CompletableFuture<OnCallNotificationRule> + */ + public CompletableFuture createUserNotificationRuleAsync( + String userId, CreateOnCallNotificationRuleRequest body) { + return createUserNotificationRuleWithHttpInfoAsync(userId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create a new notification rule 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<OnCallNotificationRule> + * @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 createUserNotificationRuleWithHttpInfo( + String userId, CreateOnCallNotificationRuleRequest 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 createUserNotificationRule"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createUserNotificationRule"); + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.createUserNotificationRule", + 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 rule for a user. + * + *

See {@link #createUserNotificationRuleWithHttpInfo}. + * + * @param userId The user ID (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<OnCallNotificationRule>> + */ + public CompletableFuture> + createUserNotificationRuleWithHttpInfoAsync( + String userId, CreateOnCallNotificationRuleRequest 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 createUserNotificationRule")); + 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 createUserNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.createUserNotificationRule", + 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. * @@ -1059,6 +1225,166 @@ public CompletableFuture> deleteUserNotificationChannelWithHtt null); } + /** + * Delete an On-Call notification rule for a user. + * + *

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

See {@link #deleteUserNotificationRuleWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @return CompletableFuture + */ + public CompletableFuture deleteUserNotificationRuleAsync(String userId, String ruleId) { + return deleteUserNotificationRuleWithHttpInfoAsync(userId, ruleId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Delete a notification rule 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 ruleId The rule 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 deleteUserNotificationRuleWithHttpInfo(String userId, String ruleId) + 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 deleteUserNotificationRule"); + } + + // verify the required parameter 'ruleId' is set + if (ruleId == null) { + throw new ApiException( + 400, "Missing the required parameter 'ruleId' when calling deleteUserNotificationRule"); + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "rule_id" + "\\}", apiClient.escapeString(ruleId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.deleteUserNotificationRule", + 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 rule for a user. + * + *

See {@link #deleteUserNotificationRuleWithHttpInfo}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteUserNotificationRuleWithHttpInfoAsync( + String userId, String ruleId) { + 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 deleteUserNotificationRule")); + return result; + } + + // verify the required parameter 'ruleId' is set + if (ruleId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'ruleId' when calling deleteUserNotificationRule")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "rule_id" + "\\}", apiClient.escapeString(ruleId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.deleteUserNotificationRule", + 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; @@ -2243,7 +2569,236 @@ public ApiResponse getUserNotificationChannelWithHttpInfo( new GenericType() {}); } - /** + /** Manage optional parameters to getUserNotificationRule. */ + public static class GetUserNotificationRuleOptionalParameters { + private String include; + + /** + * Set include. + * + * @param include Comma-separated list of included relationships to be returned. Allowed values: + * channel. (optional) + * @return GetUserNotificationRuleOptionalParameters + */ + public GetUserNotificationRuleOptionalParameters include(String include) { + this.include = include; + return this; + } + } + + /** + * Get an On-Call notification rule for a user. + * + *

See {@link #getUserNotificationRuleWithHttpInfo}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @return OnCallNotificationRule + * @throws ApiException if fails to make API call + */ + public OnCallNotificationRule getUserNotificationRule(String userId, String ruleId) + throws ApiException { + return getUserNotificationRuleWithHttpInfo( + userId, ruleId, new GetUserNotificationRuleOptionalParameters()) + .getData(); + } + + /** + * Get an On-Call notification rule for a user. + * + *

See {@link #getUserNotificationRuleWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @return CompletableFuture<OnCallNotificationRule> + */ + public CompletableFuture getUserNotificationRuleAsync( + String userId, String ruleId) { + return getUserNotificationRuleWithHttpInfoAsync( + userId, ruleId, new GetUserNotificationRuleOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get an On-Call notification rule for a user. + * + *

See {@link #getUserNotificationRuleWithHttpInfo}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @param parameters Optional parameters for the request. + * @return OnCallNotificationRule + * @throws ApiException if fails to make API call + */ + public OnCallNotificationRule getUserNotificationRule( + String userId, String ruleId, GetUserNotificationRuleOptionalParameters parameters) + throws ApiException { + return getUserNotificationRuleWithHttpInfo(userId, ruleId, parameters).getData(); + } + + /** + * Get an On-Call notification rule for a user. + * + *

See {@link #getUserNotificationRuleWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<OnCallNotificationRule> + */ + public CompletableFuture getUserNotificationRuleAsync( + String userId, String ruleId, GetUserNotificationRuleOptionalParameters parameters) { + return getUserNotificationRuleWithHttpInfoAsync(userId, ruleId, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get a notification rule 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 ruleId The rule ID (required) + * @param parameters Optional parameters for the request. + * @return ApiResponse<OnCallNotificationRule> + * @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 getUserNotificationRuleWithHttpInfo( + String userId, String ruleId, GetUserNotificationRuleOptionalParameters parameters) + 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 getUserNotificationRule"); + } + + // verify the required parameter 'ruleId' is set + if (ruleId == null) { + throw new ApiException( + 400, "Missing the required parameter 'ruleId' when calling getUserNotificationRule"); + } + String include = parameters.include; + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "rule_id" + "\\}", apiClient.escapeString(ruleId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.getUserNotificationRule", + localVarPath, + localVarQueryParams, + 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 rule for a user. + * + *

See {@link #getUserNotificationRuleWithHttpInfo}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<OnCallNotificationRule>> + */ + public CompletableFuture> + getUserNotificationRuleWithHttpInfoAsync( + String userId, String ruleId, GetUserNotificationRuleOptionalParameters parameters) { + 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 getUserNotificationRule")); + return result; + } + + // verify the required parameter 'ruleId' is set + if (ruleId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'ruleId' when calling getUserNotificationRule")); + return result; + } + String include = parameters.include; + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "rule_id" + "\\}", apiClient.escapeString(ruleId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.getUserNotificationRule", + localVarPath, + localVarQueryParams, + 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}. @@ -2386,6 +2941,213 @@ public ApiResponse listUserNotificationChannel new GenericType() {}); } + /** Manage optional parameters to listUserNotificationRules. */ + public static class ListUserNotificationRulesOptionalParameters { + private String include; + + /** + * Set include. + * + * @param include Comma-separated list of included relationships to be returned. Allowed values: + * channel. (optional) + * @return ListUserNotificationRulesOptionalParameters + */ + public ListUserNotificationRulesOptionalParameters include(String include) { + this.include = include; + return this; + } + } + + /** + * List On-Call notification rules for a user. + * + *

See {@link #listUserNotificationRulesWithHttpInfo}. + * + * @param userId The user ID (required) + * @return ListOnCallNotificationRulesResponse + * @throws ApiException if fails to make API call + */ + public ListOnCallNotificationRulesResponse listUserNotificationRules(String userId) + throws ApiException { + return listUserNotificationRulesWithHttpInfo( + userId, new ListUserNotificationRulesOptionalParameters()) + .getData(); + } + + /** + * List On-Call notification rules for a user. + * + *

See {@link #listUserNotificationRulesWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @return CompletableFuture<ListOnCallNotificationRulesResponse> + */ + public CompletableFuture listUserNotificationRulesAsync( + String userId) { + return listUserNotificationRulesWithHttpInfoAsync( + userId, new ListUserNotificationRulesOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List On-Call notification rules for a user. + * + *

See {@link #listUserNotificationRulesWithHttpInfo}. + * + * @param userId The user ID (required) + * @param parameters Optional parameters for the request. + * @return ListOnCallNotificationRulesResponse + * @throws ApiException if fails to make API call + */ + public ListOnCallNotificationRulesResponse listUserNotificationRules( + String userId, ListUserNotificationRulesOptionalParameters parameters) throws ApiException { + return listUserNotificationRulesWithHttpInfo(userId, parameters).getData(); + } + + /** + * List On-Call notification rules for a user. + * + *

See {@link #listUserNotificationRulesWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ListOnCallNotificationRulesResponse> + */ + public CompletableFuture listUserNotificationRulesAsync( + String userId, ListUserNotificationRulesOptionalParameters parameters) { + return listUserNotificationRulesWithHttpInfoAsync(userId, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List the notification rules 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 parameters Optional parameters for the request. + * @return ApiResponse<ListOnCallNotificationRulesResponse> + * @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 listUserNotificationRulesWithHttpInfo( + String userId, ListUserNotificationRulesOptionalParameters parameters) 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 listUserNotificationRules"); + } + String include = parameters.include; + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.listUserNotificationRules", + localVarPath, + localVarQueryParams, + 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 rules for a user. + * + *

See {@link #listUserNotificationRulesWithHttpInfo}. + * + * @param userId The user ID (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<ListOnCallNotificationRulesResponse>> + */ + public CompletableFuture> + listUserNotificationRulesWithHttpInfoAsync( + String userId, ListUserNotificationRulesOptionalParameters parameters) { + 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 listUserNotificationRules")); + return result; + } + String include = parameters.include; + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.listUserNotificationRules", + localVarPath, + localVarQueryParams, + 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; @@ -3091,4 +3853,269 @@ public CompletableFuture> updateOnCallScheduleWithHttpInfo false, new GenericType() {}); } + + /** Manage optional parameters to updateUserNotificationRule. */ + public static class UpdateUserNotificationRuleOptionalParameters { + private String include; + + /** + * Set include. + * + * @param include Comma-separated list of included relationships to be returned. Allowed values: + * channel. (optional) + * @return UpdateUserNotificationRuleOptionalParameters + */ + public UpdateUserNotificationRuleOptionalParameters include(String include) { + this.include = include; + return this; + } + } + + /** + * Update an On-Call notification rule for a user. + * + *

See {@link #updateUserNotificationRuleWithHttpInfo}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @param body (required) + * @return OnCallNotificationRule + * @throws ApiException if fails to make API call + */ + public OnCallNotificationRule updateUserNotificationRule( + String userId, String ruleId, UpdateOnCallNotificationRuleRequest body) throws ApiException { + return updateUserNotificationRuleWithHttpInfo( + userId, ruleId, body, new UpdateUserNotificationRuleOptionalParameters()) + .getData(); + } + + /** + * Update an On-Call notification rule for a user. + * + *

See {@link #updateUserNotificationRuleWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @param body (required) + * @return CompletableFuture<OnCallNotificationRule> + */ + public CompletableFuture updateUserNotificationRuleAsync( + String userId, String ruleId, UpdateOnCallNotificationRuleRequest body) { + return updateUserNotificationRuleWithHttpInfoAsync( + userId, ruleId, body, new UpdateUserNotificationRuleOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Update an On-Call notification rule for a user. + * + *

See {@link #updateUserNotificationRuleWithHttpInfo}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @param body (required) + * @param parameters Optional parameters for the request. + * @return OnCallNotificationRule + * @throws ApiException if fails to make API call + */ + public OnCallNotificationRule updateUserNotificationRule( + String userId, + String ruleId, + UpdateOnCallNotificationRuleRequest body, + UpdateUserNotificationRuleOptionalParameters parameters) + throws ApiException { + return updateUserNotificationRuleWithHttpInfo(userId, ruleId, body, parameters).getData(); + } + + /** + * Update an On-Call notification rule for a user. + * + *

See {@link #updateUserNotificationRuleWithHttpInfoAsync}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @param body (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<OnCallNotificationRule> + */ + public CompletableFuture updateUserNotificationRuleAsync( + String userId, + String ruleId, + UpdateOnCallNotificationRuleRequest body, + UpdateUserNotificationRuleOptionalParameters parameters) { + return updateUserNotificationRuleWithHttpInfoAsync(userId, ruleId, body, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Update a notification rule 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 ruleId The rule ID (required) + * @param body (required) + * @param parameters Optional parameters for the request. + * @return ApiResponse<OnCallNotificationRule> + * @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 updateUserNotificationRuleWithHttpInfo( + String userId, + String ruleId, + UpdateOnCallNotificationRuleRequest body, + UpdateUserNotificationRuleOptionalParameters parameters) + 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 updateUserNotificationRule"); + } + + // verify the required parameter 'ruleId' is set + if (ruleId == null) { + throw new ApiException( + 400, "Missing the required parameter 'ruleId' when calling updateUserNotificationRule"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling updateUserNotificationRule"); + } + String include = parameters.include; + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "rule_id" + "\\}", apiClient.escapeString(ruleId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.updateUserNotificationRule", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update an On-Call notification rule for a user. + * + *

See {@link #updateUserNotificationRuleWithHttpInfo}. + * + * @param userId The user ID (required) + * @param ruleId The rule ID (required) + * @param body (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<OnCallNotificationRule>> + */ + public CompletableFuture> + updateUserNotificationRuleWithHttpInfoAsync( + String userId, + String ruleId, + UpdateOnCallNotificationRuleRequest body, + UpdateUserNotificationRuleOptionalParameters parameters) { + 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 updateUserNotificationRule")); + return result; + } + + // verify the required parameter 'ruleId' is set + if (ruleId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'ruleId' when calling updateUserNotificationRule")); + 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 updateUserNotificationRule")); + return result; + } + String include = parameters.include; + // create path and map variables + String localVarPath = + "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}" + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())) + .replaceAll("\\{" + "rule_id" + "\\}", apiClient.escapeString(ruleId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.updateUserNotificationRule", + localVarPath, + localVarQueryParams, + 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( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/CreateOnCallNotificationRuleRequest.java b/src/main/java/com/datadog/api/client/v2/model/CreateOnCallNotificationRuleRequest.java new file mode 100644 index 00000000000..21ab82d587c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateOnCallNotificationRuleRequest.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 rule for a user */ +@JsonPropertyOrder({CreateOnCallNotificationRuleRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateOnCallNotificationRuleRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private CreateOnCallNotificationRuleRequestData data; + + public CreateOnCallNotificationRuleRequest() {} + + @JsonCreator + public CreateOnCallNotificationRuleRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + CreateOnCallNotificationRuleRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public CreateOnCallNotificationRuleRequest data(CreateOnCallNotificationRuleRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data for creating an on-call notification rule + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public CreateOnCallNotificationRuleRequestData getData() { + return data; + } + + public void setData(CreateOnCallNotificationRuleRequestData 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 CreateOnCallNotificationRuleRequest + */ + @JsonAnySetter + public CreateOnCallNotificationRuleRequest 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 CreateOnCallNotificationRuleRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateOnCallNotificationRuleRequest createOnCallNotificationRuleRequest = + (CreateOnCallNotificationRuleRequest) o; + return Objects.equals(this.data, createOnCallNotificationRuleRequest.data) + && Objects.equals( + this.additionalProperties, createOnCallNotificationRuleRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateOnCallNotificationRuleRequest {\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/CreateOnCallNotificationRuleRequestData.java b/src/main/java/com/datadog/api/client/v2/model/CreateOnCallNotificationRuleRequestData.java new file mode 100644 index 00000000000..6326c9026e1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CreateOnCallNotificationRuleRequestData.java @@ -0,0 +1,211 @@ +/* + * 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 rule */ +@JsonPropertyOrder({ + CreateOnCallNotificationRuleRequestData.JSON_PROPERTY_ATTRIBUTES, + CreateOnCallNotificationRuleRequestData.JSON_PROPERTY_RELATIONSHIPS, + CreateOnCallNotificationRuleRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CreateOnCallNotificationRuleRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private OnCallNotificationRuleRequestAttributes attributes; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private OnCallNotificationRuleRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private OnCallNotificationRuleType type = OnCallNotificationRuleType.NOTIFICATION_RULES; + + public CreateOnCallNotificationRuleRequestData() {} + + @JsonCreator + public CreateOnCallNotificationRuleRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) OnCallNotificationRuleType type) { + this.type = type; + this.unparsed |= !type.isValid(); + } + + public CreateOnCallNotificationRuleRequestData attributes( + OnCallNotificationRuleRequestAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for creating or modifying an on-call notification rule. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleRequestAttributes getAttributes() { + return attributes; + } + + public void setAttributes(OnCallNotificationRuleRequestAttributes attributes) { + this.attributes = attributes; + } + + public CreateOnCallNotificationRuleRequestData relationships( + OnCallNotificationRuleRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * Relationship object for creating a notification rule + * + * @return relationships + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleRelationships getRelationships() { + return relationships; + } + + public void setRelationships(OnCallNotificationRuleRelationships relationships) { + this.relationships = relationships; + } + + public CreateOnCallNotificationRuleRequestData type(OnCallNotificationRuleType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the resource is of type 'notification_rules'. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OnCallNotificationRuleType getType() { + return type; + } + + public void setType(OnCallNotificationRuleType 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 CreateOnCallNotificationRuleRequestData + */ + @JsonAnySetter + public CreateOnCallNotificationRuleRequestData 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 CreateOnCallNotificationRuleRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateOnCallNotificationRuleRequestData createOnCallNotificationRuleRequestData = + (CreateOnCallNotificationRuleRequestData) o; + return Objects.equals(this.attributes, createOnCallNotificationRuleRequestData.attributes) + && Objects.equals(this.relationships, createOnCallNotificationRuleRequestData.relationships) + && Objects.equals(this.type, createOnCallNotificationRuleRequestData.type) + && Objects.equals( + this.additionalProperties, + createOnCallNotificationRuleRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateOnCallNotificationRuleRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" relationships: ").append(toIndentedString(relationships)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ListOnCallNotificationRulesResponse.java b/src/main/java/com/datadog/api/client/v2/model/ListOnCallNotificationRulesResponse.java new file mode 100644 index 00000000000..8cd396464ee --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListOnCallNotificationRulesResponse.java @@ -0,0 +1,194 @@ +/* + * 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 rules for a user */ +@JsonPropertyOrder({ + ListOnCallNotificationRulesResponse.JSON_PROPERTY_DATA, + ListOnCallNotificationRulesResponse.JSON_PROPERTY_INCLUDED +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ListOnCallNotificationRulesResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = null; + + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + + public ListOnCallNotificationRulesResponse data(List data) { + this.data = data; + for (OnCallNotificationRuleData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ListOnCallNotificationRulesResponse addDataItem(OnCallNotificationRuleData 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; + } + + public ListOnCallNotificationRulesResponse included( + List included) { + this.included = included; + for (OnCallNotificationRulesIncluded item : included) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ListOnCallNotificationRulesResponse addIncludedItem( + OnCallNotificationRulesIncluded includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * Getincluded + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ListOnCallNotificationRulesResponse + */ + @JsonAnySetter + public ListOnCallNotificationRulesResponse 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 ListOnCallNotificationRulesResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListOnCallNotificationRulesResponse listOnCallNotificationRulesResponse = + (ListOnCallNotificationRulesResponse) o; + return Objects.equals(this.data, listOnCallNotificationRulesResponse.data) + && Objects.equals(this.included, listOnCallNotificationRulesResponse.included) + && Objects.equals( + this.additionalProperties, listOnCallNotificationRulesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, included, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListOnCallNotificationRulesResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRule.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRule.java new file mode 100644 index 00000000000..30afb592e9b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRule.java @@ -0,0 +1,188 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A top-level wrapper for a notification rule */ +@JsonPropertyOrder({ + OnCallNotificationRule.JSON_PROPERTY_DATA, + OnCallNotificationRule.JSON_PROPERTY_INCLUDED +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class OnCallNotificationRule { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private OnCallNotificationRuleData data; + + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + + public OnCallNotificationRule() {} + + @JsonCreator + public OnCallNotificationRule( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) OnCallNotificationRuleData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public OnCallNotificationRule data(OnCallNotificationRuleData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data for an on-call notification rule + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OnCallNotificationRuleData getData() { + return data; + } + + public void setData(OnCallNotificationRuleData data) { + this.data = data; + } + + public OnCallNotificationRule included(List included) { + this.included = included; + for (OnCallNotificationRulesIncluded item : included) { + this.unparsed |= item.unparsed; + } + return this; + } + + public OnCallNotificationRule addIncludedItem(OnCallNotificationRulesIncluded includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * Getincluded + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return OnCallNotificationRule + */ + @JsonAnySetter + public OnCallNotificationRule 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 OnCallNotificationRule object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OnCallNotificationRule onCallNotificationRule = (OnCallNotificationRule) o; + return Objects.equals(this.data, onCallNotificationRule.data) + && Objects.equals(this.included, onCallNotificationRule.included) + && Objects.equals(this.additionalProperties, onCallNotificationRule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, included, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OnCallNotificationRule {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleAttributes.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleAttributes.java new file mode 100644 index 00000000000..2cd3c405599 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleAttributes.java @@ -0,0 +1,200 @@ +/* + * 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 rule. */ +@JsonPropertyOrder({ + OnCallNotificationRuleAttributes.JSON_PROPERTY_CATEGORY, + OnCallNotificationRuleAttributes.JSON_PROPERTY_CHANNEL_SETTINGS, + OnCallNotificationRuleAttributes.JSON_PROPERTY_DELAY_MINUTES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class OnCallNotificationRuleAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CATEGORY = "category"; + private OnCallNotificationRuleCategory category = OnCallNotificationRuleCategory.HIGH_URGENCY; + + public static final String JSON_PROPERTY_CHANNEL_SETTINGS = "channel_settings"; + private OnCallNotificationRuleChannelSettings channelSettings; + + public static final String JSON_PROPERTY_DELAY_MINUTES = "delay_minutes"; + private Long delayMinutes; + + public OnCallNotificationRuleAttributes category(OnCallNotificationRuleCategory category) { + this.category = category; + this.unparsed |= !category.isValid(); + return this; + } + + /** + * Specifies the category a notification rule will apply to + * + * @return category + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleCategory getCategory() { + return category; + } + + public void setCategory(OnCallNotificationRuleCategory category) { + if (!category.isValid()) { + this.unparsed = true; + } + this.category = category; + } + + public OnCallNotificationRuleAttributes channelSettings( + OnCallNotificationRuleChannelSettings channelSettings) { + this.channelSettings = channelSettings; + this.unparsed |= channelSettings.unparsed; + return this; + } + + /** + * Defines the configuration for a channel associated with a notification rule + * + * @return channelSettings + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHANNEL_SETTINGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleChannelSettings getChannelSettings() { + return channelSettings; + } + + public void setChannelSettings(OnCallNotificationRuleChannelSettings channelSettings) { + this.channelSettings = channelSettings; + } + + public OnCallNotificationRuleAttributes delayMinutes(Long delayMinutes) { + this.delayMinutes = delayMinutes; + return this; + } + + /** + * The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate + * evaluation + * + * @return delayMinutes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DELAY_MINUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getDelayMinutes() { + return delayMinutes; + } + + public void setDelayMinutes(Long delayMinutes) { + this.delayMinutes = delayMinutes; + } + + /** + * 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 OnCallNotificationRuleAttributes + */ + @JsonAnySetter + public OnCallNotificationRuleAttributes 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 OnCallNotificationRuleAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OnCallNotificationRuleAttributes onCallNotificationRuleAttributes = + (OnCallNotificationRuleAttributes) o; + return Objects.equals(this.category, onCallNotificationRuleAttributes.category) + && Objects.equals(this.channelSettings, onCallNotificationRuleAttributes.channelSettings) + && Objects.equals(this.delayMinutes, onCallNotificationRuleAttributes.delayMinutes) + && Objects.equals( + this.additionalProperties, onCallNotificationRuleAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, channelSettings, delayMinutes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OnCallNotificationRuleAttributes {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" channelSettings: ").append(toIndentedString(channelSettings)).append("\n"); + sb.append(" delayMinutes: ").append(toIndentedString(delayMinutes)).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/OnCallNotificationRuleCategory.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleCategory.java new file mode 100644 index 00000000000..ea07e8dccfb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleCategory.java @@ -0,0 +1,60 @@ +/* + * 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 category a notification rule will apply to */ +@JsonSerialize( + using = OnCallNotificationRuleCategory.OnCallNotificationRuleCategorySerializer.class) +public class OnCallNotificationRuleCategory extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("high_urgency", "low_urgency")); + + public static final OnCallNotificationRuleCategory HIGH_URGENCY = + new OnCallNotificationRuleCategory("high_urgency"); + public static final OnCallNotificationRuleCategory LOW_URGENCY = + new OnCallNotificationRuleCategory("low_urgency"); + + OnCallNotificationRuleCategory(String value) { + super(value, allowedValues); + } + + public static class OnCallNotificationRuleCategorySerializer + extends StdSerializer { + public OnCallNotificationRuleCategorySerializer(Class t) { + super(t); + } + + public OnCallNotificationRuleCategorySerializer() { + this(null); + } + + @Override + public void serialize( + OnCallNotificationRuleCategory value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static OnCallNotificationRuleCategory fromValue(String value) { + return new OnCallNotificationRuleCategory(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleChannelRelationship.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleChannelRelationship.java new file mode 100644 index 00000000000..74ecb8d42da --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleChannelRelationship.java @@ -0,0 +1,150 @@ +/* + * 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; + +/** Relationship object for creating a notification rule */ +@JsonPropertyOrder({OnCallNotificationRuleChannelRelationship.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class OnCallNotificationRuleChannelRelationship { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private OnCallNotificationRuleChannelRelationshipData data; + + public OnCallNotificationRuleChannelRelationship() {} + + @JsonCreator + public OnCallNotificationRuleChannelRelationship( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + OnCallNotificationRuleChannelRelationshipData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public OnCallNotificationRuleChannelRelationship data( + OnCallNotificationRuleChannelRelationshipData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Channel relationship data for creating a notification rule + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OnCallNotificationRuleChannelRelationshipData getData() { + return data; + } + + public void setData(OnCallNotificationRuleChannelRelationshipData 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 OnCallNotificationRuleChannelRelationship + */ + @JsonAnySetter + public OnCallNotificationRuleChannelRelationship 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 OnCallNotificationRuleChannelRelationship object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OnCallNotificationRuleChannelRelationship onCallNotificationRuleChannelRelationship = + (OnCallNotificationRuleChannelRelationship) o; + return Objects.equals(this.data, onCallNotificationRuleChannelRelationship.data) + && Objects.equals( + this.additionalProperties, + onCallNotificationRuleChannelRelationship.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OnCallNotificationRuleChannelRelationship {\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/OnCallNotificationRuleChannelRelationshipData.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleChannelRelationshipData.java new file mode 100644 index 00000000000..d29b66e506e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleChannelRelationshipData.java @@ -0,0 +1,172 @@ +/* + * 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; + +/** Channel relationship data for creating a notification rule */ +@JsonPropertyOrder({ + OnCallNotificationRuleChannelRelationshipData.JSON_PROPERTY_ID, + OnCallNotificationRuleChannelRelationshipData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class OnCallNotificationRuleChannelRelationshipData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelType type = NotificationChannelType.NOTIFICATION_CHANNELS; + + public OnCallNotificationRuleChannelRelationshipData id(String id) { + this.id = id; + return this; + } + + /** + * ID of the notification 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 OnCallNotificationRuleChannelRelationshipData type(NotificationChannelType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the resource is of type 'notification_channels'. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + 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 OnCallNotificationRuleChannelRelationshipData + */ + @JsonAnySetter + public OnCallNotificationRuleChannelRelationshipData 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 OnCallNotificationRuleChannelRelationshipData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OnCallNotificationRuleChannelRelationshipData onCallNotificationRuleChannelRelationshipData = + (OnCallNotificationRuleChannelRelationshipData) o; + return Objects.equals(this.id, onCallNotificationRuleChannelRelationshipData.id) + && Objects.equals(this.type, onCallNotificationRuleChannelRelationshipData.type) + && Objects.equals( + this.additionalProperties, + onCallNotificationRuleChannelRelationshipData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OnCallNotificationRuleChannelRelationshipData {\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/OnCallNotificationRuleChannelSettings.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleChannelSettings.java new file mode 100644 index 00000000000..ff4130271dd --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleChannelSettings.java @@ -0,0 +1,232 @@ +/* + * 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 = + OnCallNotificationRuleChannelSettings.OnCallNotificationRuleChannelSettingsDeserializer + .class) +@JsonSerialize( + using = + OnCallNotificationRuleChannelSettings.OnCallNotificationRuleChannelSettingsSerializer.class) +public class OnCallNotificationRuleChannelSettings extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(OnCallNotificationRuleChannelSettings.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class OnCallNotificationRuleChannelSettingsSerializer + extends StdSerializer { + public OnCallNotificationRuleChannelSettingsSerializer( + Class t) { + super(t); + } + + public OnCallNotificationRuleChannelSettingsSerializer() { + this(null); + } + + @Override + public void serialize( + OnCallNotificationRuleChannelSettings value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class OnCallNotificationRuleChannelSettingsDeserializer + extends StdDeserializer { + public OnCallNotificationRuleChannelSettingsDeserializer() { + this(OnCallNotificationRuleChannelSettings.class); + } + + public OnCallNotificationRuleChannelSettingsDeserializer(Class vc) { + super(vc); + } + + @Override + public OnCallNotificationRuleChannelSettings 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 OnCallPhoneNotificationRuleSettings + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (OnCallPhoneNotificationRuleSettings.class.equals(Integer.class) + || OnCallPhoneNotificationRuleSettings.class.equals(Long.class) + || OnCallPhoneNotificationRuleSettings.class.equals(Float.class) + || OnCallPhoneNotificationRuleSettings.class.equals(Double.class) + || OnCallPhoneNotificationRuleSettings.class.equals(Boolean.class) + || OnCallPhoneNotificationRuleSettings.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((OnCallPhoneNotificationRuleSettings.class.equals(Integer.class) + || OnCallPhoneNotificationRuleSettings.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((OnCallPhoneNotificationRuleSettings.class.equals(Float.class) + || OnCallPhoneNotificationRuleSettings.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (OnCallPhoneNotificationRuleSettings.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (OnCallPhoneNotificationRuleSettings.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(OnCallPhoneNotificationRuleSettings.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 (!((OnCallPhoneNotificationRuleSettings) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'OnCallPhoneNotificationRuleSettings'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'OnCallPhoneNotificationRuleSettings'", + e); + } + + OnCallNotificationRuleChannelSettings ret = new OnCallNotificationRuleChannelSettings(); + 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 OnCallNotificationRuleChannelSettings getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "OnCallNotificationRuleChannelSettings cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public OnCallNotificationRuleChannelSettings() { + super("oneOf", Boolean.FALSE); + } + + public OnCallNotificationRuleChannelSettings(OnCallPhoneNotificationRuleSettings o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "OnCallPhoneNotificationRuleSettings", + new GenericType() {}); + JSON.registerDescendants( + OnCallNotificationRuleChannelSettings.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return OnCallNotificationRuleChannelSettings.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: OnCallPhoneNotificationRuleSettings + * + *

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( + OnCallPhoneNotificationRuleSettings.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 OnCallPhoneNotificationRuleSettings"); + } + + /** + * Get the actual instance, which can be the following: OnCallPhoneNotificationRuleSettings + * + * @return The actual instance (OnCallPhoneNotificationRuleSettings) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `OnCallPhoneNotificationRuleSettings`. If the actual instance is not + * `OnCallPhoneNotificationRuleSettings`, the ClassCastException will be thrown. + * + * @return The actual instance of `OnCallPhoneNotificationRuleSettings` + * @throws ClassCastException if the instance is not `OnCallPhoneNotificationRuleSettings` + */ + public OnCallPhoneNotificationRuleSettings getOnCallPhoneNotificationRuleSettings() + throws ClassCastException { + return (OnCallPhoneNotificationRuleSettings) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleData.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleData.java new file mode 100644 index 00000000000..922162b9d1d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleData.java @@ -0,0 +1,235 @@ +/* + * 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 rule */ +@JsonPropertyOrder({ + OnCallNotificationRuleData.JSON_PROPERTY_ATTRIBUTES, + OnCallNotificationRuleData.JSON_PROPERTY_ID, + OnCallNotificationRuleData.JSON_PROPERTY_RELATIONSHIPS, + OnCallNotificationRuleData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class OnCallNotificationRuleData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private OnCallNotificationRuleAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private OnCallNotificationRuleRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private OnCallNotificationRuleType type = OnCallNotificationRuleType.NOTIFICATION_RULES; + + public OnCallNotificationRuleData() {} + + @JsonCreator + public OnCallNotificationRuleData( + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) OnCallNotificationRuleType type) { + this.type = type; + this.unparsed |= !type.isValid(); + } + + public OnCallNotificationRuleData attributes(OnCallNotificationRuleAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for an on-call notification rule. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleAttributes getAttributes() { + return attributes; + } + + public void setAttributes(OnCallNotificationRuleAttributes attributes) { + this.attributes = attributes; + } + + public OnCallNotificationRuleData id(String id) { + this.id = id; + return this; + } + + /** + * Unique identifier for the rule + * + * @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 OnCallNotificationRuleData relationships( + OnCallNotificationRuleRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * Relationship object for creating a notification rule + * + * @return relationships + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleRelationships getRelationships() { + return relationships; + } + + public void setRelationships(OnCallNotificationRuleRelationships relationships) { + this.relationships = relationships; + } + + public OnCallNotificationRuleData type(OnCallNotificationRuleType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the resource is of type 'notification_rules'. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OnCallNotificationRuleType getType() { + return type; + } + + public void setType(OnCallNotificationRuleType 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 OnCallNotificationRuleData + */ + @JsonAnySetter + public OnCallNotificationRuleData 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 OnCallNotificationRuleData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OnCallNotificationRuleData onCallNotificationRuleData = (OnCallNotificationRuleData) o; + return Objects.equals(this.attributes, onCallNotificationRuleData.attributes) + && Objects.equals(this.id, onCallNotificationRuleData.id) + && Objects.equals(this.relationships, onCallNotificationRuleData.relationships) + && Objects.equals(this.type, onCallNotificationRuleData.type) + && Objects.equals( + this.additionalProperties, onCallNotificationRuleData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OnCallNotificationRuleData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" relationships: ").append(toIndentedString(relationships)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleRelationships.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleRelationships.java new file mode 100644 index 00000000000..852eb23a0f3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleRelationships.java @@ -0,0 +1,139 @@ +/* + * 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; + +/** Relationship object for creating a notification rule */ +@JsonPropertyOrder({OnCallNotificationRuleRelationships.JSON_PROPERTY_CHANNEL}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class OnCallNotificationRuleRelationships { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CHANNEL = "channel"; + private OnCallNotificationRuleChannelRelationship channel; + + public OnCallNotificationRuleRelationships channel( + OnCallNotificationRuleChannelRelationship channel) { + this.channel = channel; + this.unparsed |= channel.unparsed; + return this; + } + + /** + * Relationship object for creating a notification rule + * + * @return channel + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHANNEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleChannelRelationship getChannel() { + return channel; + } + + public void setChannel(OnCallNotificationRuleChannelRelationship channel) { + this.channel = channel; + } + + /** + * 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 OnCallNotificationRuleRelationships + */ + @JsonAnySetter + public OnCallNotificationRuleRelationships 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 OnCallNotificationRuleRelationships object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OnCallNotificationRuleRelationships onCallNotificationRuleRelationships = + (OnCallNotificationRuleRelationships) o; + return Objects.equals(this.channel, onCallNotificationRuleRelationships.channel) + && Objects.equals( + this.additionalProperties, onCallNotificationRuleRelationships.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(channel, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OnCallNotificationRuleRelationships {\n"); + sb.append(" channel: ").append(toIndentedString(channel)).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/OnCallNotificationRuleRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleRequestAttributes.java new file mode 100644 index 00000000000..a1c15b68397 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleRequestAttributes.java @@ -0,0 +1,202 @@ +/* + * 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 or modifying an on-call notification rule. */ +@JsonPropertyOrder({ + OnCallNotificationRuleRequestAttributes.JSON_PROPERTY_CATEGORY, + OnCallNotificationRuleRequestAttributes.JSON_PROPERTY_CHANNEL_SETTINGS, + OnCallNotificationRuleRequestAttributes.JSON_PROPERTY_DELAY_MINUTES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class OnCallNotificationRuleRequestAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CATEGORY = "category"; + private OnCallNotificationRuleCategory category = OnCallNotificationRuleCategory.HIGH_URGENCY; + + public static final String JSON_PROPERTY_CHANNEL_SETTINGS = "channel_settings"; + private OnCallNotificationRuleChannelSettings channelSettings; + + public static final String JSON_PROPERTY_DELAY_MINUTES = "delay_minutes"; + private Long delayMinutes; + + public OnCallNotificationRuleRequestAttributes category(OnCallNotificationRuleCategory category) { + this.category = category; + this.unparsed |= !category.isValid(); + return this; + } + + /** + * Specifies the category a notification rule will apply to + * + * @return category + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleCategory getCategory() { + return category; + } + + public void setCategory(OnCallNotificationRuleCategory category) { + if (!category.isValid()) { + this.unparsed = true; + } + this.category = category; + } + + public OnCallNotificationRuleRequestAttributes channelSettings( + OnCallNotificationRuleChannelSettings channelSettings) { + this.channelSettings = channelSettings; + this.unparsed |= channelSettings.unparsed; + return this; + } + + /** + * Defines the configuration for a channel associated with a notification rule + * + * @return channelSettings + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHANNEL_SETTINGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleChannelSettings getChannelSettings() { + return channelSettings; + } + + public void setChannelSettings(OnCallNotificationRuleChannelSettings channelSettings) { + this.channelSettings = channelSettings; + } + + public OnCallNotificationRuleRequestAttributes delayMinutes(Long delayMinutes) { + this.delayMinutes = delayMinutes; + return this; + } + + /** + * The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate + * evaluation + * + * @return delayMinutes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DELAY_MINUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getDelayMinutes() { + return delayMinutes; + } + + public void setDelayMinutes(Long delayMinutes) { + this.delayMinutes = delayMinutes; + } + + /** + * 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 OnCallNotificationRuleRequestAttributes + */ + @JsonAnySetter + public OnCallNotificationRuleRequestAttributes 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 OnCallNotificationRuleRequestAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OnCallNotificationRuleRequestAttributes onCallNotificationRuleRequestAttributes = + (OnCallNotificationRuleRequestAttributes) o; + return Objects.equals(this.category, onCallNotificationRuleRequestAttributes.category) + && Objects.equals( + this.channelSettings, onCallNotificationRuleRequestAttributes.channelSettings) + && Objects.equals(this.delayMinutes, onCallNotificationRuleRequestAttributes.delayMinutes) + && Objects.equals( + this.additionalProperties, + onCallNotificationRuleRequestAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, channelSettings, delayMinutes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OnCallNotificationRuleRequestAttributes {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" channelSettings: ").append(toIndentedString(channelSettings)).append("\n"); + sb.append(" delayMinutes: ").append(toIndentedString(delayMinutes)).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/OnCallNotificationRuleType.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleType.java new file mode 100644 index 00000000000..b765ae97df1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRuleType.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_rules'. */ +@JsonSerialize(using = OnCallNotificationRuleType.OnCallNotificationRuleTypeSerializer.class) +public class OnCallNotificationRuleType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("notification_rules")); + + public static final OnCallNotificationRuleType NOTIFICATION_RULES = + new OnCallNotificationRuleType("notification_rules"); + + OnCallNotificationRuleType(String value) { + super(value, allowedValues); + } + + public static class OnCallNotificationRuleTypeSerializer + extends StdSerializer { + public OnCallNotificationRuleTypeSerializer(Class t) { + super(t); + } + + public OnCallNotificationRuleTypeSerializer() { + this(null); + } + + @Override + public void serialize( + OnCallNotificationRuleType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static OnCallNotificationRuleType fromValue(String value) { + return new OnCallNotificationRuleType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRulesIncluded.java b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRulesIncluded.java new file mode 100644 index 00000000000..dece741a851 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallNotificationRulesIncluded.java @@ -0,0 +1,218 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = OnCallNotificationRulesIncluded.OnCallNotificationRulesIncludedDeserializer.class) +@JsonSerialize( + using = OnCallNotificationRulesIncluded.OnCallNotificationRulesIncludedSerializer.class) +public class OnCallNotificationRulesIncluded extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(OnCallNotificationRulesIncluded.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class OnCallNotificationRulesIncludedSerializer + extends StdSerializer { + public OnCallNotificationRulesIncludedSerializer(Class t) { + super(t); + } + + public OnCallNotificationRulesIncludedSerializer() { + this(null); + } + + @Override + public void serialize( + OnCallNotificationRulesIncluded value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class OnCallNotificationRulesIncludedDeserializer + extends StdDeserializer { + public OnCallNotificationRulesIncludedDeserializer() { + this(OnCallNotificationRulesIncluded.class); + } + + public OnCallNotificationRulesIncludedDeserializer(Class vc) { + super(vc); + } + + @Override + public OnCallNotificationRulesIncluded 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 NotificationChannelData + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (NotificationChannelData.class.equals(Integer.class) + || NotificationChannelData.class.equals(Long.class) + || NotificationChannelData.class.equals(Float.class) + || NotificationChannelData.class.equals(Double.class) + || NotificationChannelData.class.equals(Boolean.class) + || NotificationChannelData.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((NotificationChannelData.class.equals(Integer.class) + || NotificationChannelData.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((NotificationChannelData.class.equals(Float.class) + || NotificationChannelData.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (NotificationChannelData.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (NotificationChannelData.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(NotificationChannelData.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 (!((NotificationChannelData) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'NotificationChannelData'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'NotificationChannelData'", e); + } + + OnCallNotificationRulesIncluded ret = new OnCallNotificationRulesIncluded(); + 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 OnCallNotificationRulesIncluded getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "OnCallNotificationRulesIncluded cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public OnCallNotificationRulesIncluded() { + super("oneOf", Boolean.FALSE); + } + + public OnCallNotificationRulesIncluded(NotificationChannelData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("NotificationChannelData", new GenericType() {}); + JSON.registerDescendants( + OnCallNotificationRulesIncluded.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return OnCallNotificationRulesIncluded.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: NotificationChannelData + * + *

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(NotificationChannelData.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 NotificationChannelData"); + } + + /** + * Get the actual instance, which can be the following: NotificationChannelData + * + * @return The actual instance (NotificationChannelData) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `NotificationChannelData`. If the actual instance is not + * `NotificationChannelData`, the ClassCastException will be thrown. + * + * @return The actual instance of `NotificationChannelData` + * @throws ClassCastException if the instance is not `NotificationChannelData` + */ + public NotificationChannelData getNotificationChannelData() throws ClassCastException { + return (NotificationChannelData) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OnCallPhoneNotificationRuleMethod.java b/src/main/java/com/datadog/api/client/v2/model/OnCallPhoneNotificationRuleMethod.java new file mode 100644 index 00000000000..682f6e0f8cd --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallPhoneNotificationRuleMethod.java @@ -0,0 +1,60 @@ +/* + * 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 method in which a phone is used in a notification rule */ +@JsonSerialize( + using = OnCallPhoneNotificationRuleMethod.OnCallPhoneNotificationRuleMethodSerializer.class) +public class OnCallPhoneNotificationRuleMethod extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("sms", "voice")); + + public static final OnCallPhoneNotificationRuleMethod SMS = + new OnCallPhoneNotificationRuleMethod("sms"); + public static final OnCallPhoneNotificationRuleMethod VOICE = + new OnCallPhoneNotificationRuleMethod("voice"); + + OnCallPhoneNotificationRuleMethod(String value) { + super(value, allowedValues); + } + + public static class OnCallPhoneNotificationRuleMethodSerializer + extends StdSerializer { + public OnCallPhoneNotificationRuleMethodSerializer(Class t) { + super(t); + } + + public OnCallPhoneNotificationRuleMethodSerializer() { + this(null); + } + + @Override + public void serialize( + OnCallPhoneNotificationRuleMethod value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static OnCallPhoneNotificationRuleMethod fromValue(String value) { + return new OnCallPhoneNotificationRuleMethod(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OnCallPhoneNotificationRuleSettings.java b/src/main/java/com/datadog/api/client/v2/model/OnCallPhoneNotificationRuleSettings.java new file mode 100644 index 00000000000..da57a78803b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OnCallPhoneNotificationRuleSettings.java @@ -0,0 +1,187 @@ +/* + * 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 for using a phone notification channel in a notification rule */ +@JsonPropertyOrder({ + OnCallPhoneNotificationRuleSettings.JSON_PROPERTY_METHOD, + OnCallPhoneNotificationRuleSettings.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class OnCallPhoneNotificationRuleSettings { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_METHOD = "method"; + private OnCallPhoneNotificationRuleMethod method; + + public static final String JSON_PROPERTY_TYPE = "type"; + private NotificationChannelPhoneConfigType type = NotificationChannelPhoneConfigType.PHONE; + + public OnCallPhoneNotificationRuleSettings() {} + + @JsonCreator + public OnCallPhoneNotificationRuleSettings( + @JsonProperty(required = true, value = JSON_PROPERTY_METHOD) + OnCallPhoneNotificationRuleMethod method, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + NotificationChannelPhoneConfigType type) { + this.method = method; + this.unparsed |= !method.isValid(); + this.type = type; + this.unparsed |= !type.isValid(); + } + + public OnCallPhoneNotificationRuleSettings method(OnCallPhoneNotificationRuleMethod method) { + this.method = method; + this.unparsed |= !method.isValid(); + return this; + } + + /** + * Specifies the method in which a phone is used in a notification rule + * + * @return method + */ + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OnCallPhoneNotificationRuleMethod getMethod() { + return method; + } + + public void setMethod(OnCallPhoneNotificationRuleMethod method) { + if (!method.isValid()) { + this.unparsed = true; + } + this.method = method; + } + + public OnCallPhoneNotificationRuleSettings 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 OnCallPhoneNotificationRuleSettings + */ + @JsonAnySetter + public OnCallPhoneNotificationRuleSettings 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 OnCallPhoneNotificationRuleSettings object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OnCallPhoneNotificationRuleSettings onCallPhoneNotificationRuleSettings = + (OnCallPhoneNotificationRuleSettings) o; + return Objects.equals(this.method, onCallPhoneNotificationRuleSettings.method) + && Objects.equals(this.type, onCallPhoneNotificationRuleSettings.type) + && Objects.equals( + this.additionalProperties, onCallPhoneNotificationRuleSettings.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(method, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OnCallPhoneNotificationRuleSettings {\n"); + sb.append(" method: ").append(toIndentedString(method)).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/UpdateOnCallNotificationRuleRequest.java b/src/main/java/com/datadog/api/client/v2/model/UpdateOnCallNotificationRuleRequest.java new file mode 100644 index 00000000000..f0d218f8cdc --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdateOnCallNotificationRuleRequest.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 updating a notification rule for a user */ +@JsonPropertyOrder({UpdateOnCallNotificationRuleRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdateOnCallNotificationRuleRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private UpdateOnCallNotificationRuleRequestData data; + + public UpdateOnCallNotificationRuleRequest() {} + + @JsonCreator + public UpdateOnCallNotificationRuleRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + UpdateOnCallNotificationRuleRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public UpdateOnCallNotificationRuleRequest data(UpdateOnCallNotificationRuleRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data for updating an on-call notification rule + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UpdateOnCallNotificationRuleRequestData getData() { + return data; + } + + public void setData(UpdateOnCallNotificationRuleRequestData 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 UpdateOnCallNotificationRuleRequest + */ + @JsonAnySetter + public UpdateOnCallNotificationRuleRequest 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 UpdateOnCallNotificationRuleRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateOnCallNotificationRuleRequest updateOnCallNotificationRuleRequest = + (UpdateOnCallNotificationRuleRequest) o; + return Objects.equals(this.data, updateOnCallNotificationRuleRequest.data) + && Objects.equals( + this.additionalProperties, updateOnCallNotificationRuleRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateOnCallNotificationRuleRequest {\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/UpdateOnCallNotificationRuleRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/UpdateOnCallNotificationRuleRequestAttributes.java new file mode 100644 index 00000000000..75230c3e722 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdateOnCallNotificationRuleRequestAttributes.java @@ -0,0 +1,205 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes for creating or modifying an on-call notification rule. */ +@JsonPropertyOrder({ + UpdateOnCallNotificationRuleRequestAttributes.JSON_PROPERTY_CATEGORY, + UpdateOnCallNotificationRuleRequestAttributes.JSON_PROPERTY_CHANNEL_SETTINGS, + UpdateOnCallNotificationRuleRequestAttributes.JSON_PROPERTY_DELAY_MINUTES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdateOnCallNotificationRuleRequestAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CATEGORY = "category"; + private OnCallNotificationRuleCategory category = OnCallNotificationRuleCategory.HIGH_URGENCY; + + public static final String JSON_PROPERTY_CHANNEL_SETTINGS = "channel_settings"; + private OnCallNotificationRuleChannelSettings channelSettings; + + public static final String JSON_PROPERTY_DELAY_MINUTES = "delay_minutes"; + private Long delayMinutes; + + public UpdateOnCallNotificationRuleRequestAttributes category( + OnCallNotificationRuleCategory category) { + this.category = category; + this.unparsed |= !category.isValid(); + return this; + } + + /** + * Specifies the category a notification rule will apply to + * + * @return category + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleCategory getCategory() { + return category; + } + + public void setCategory(OnCallNotificationRuleCategory category) { + if (!category.isValid()) { + this.unparsed = true; + } + this.category = category; + } + + public UpdateOnCallNotificationRuleRequestAttributes channelSettings( + OnCallNotificationRuleChannelSettings channelSettings) { + this.channelSettings = channelSettings; + this.unparsed |= channelSettings.unparsed; + return this; + } + + /** + * Defines the configuration for a channel associated with a notification rule + * + * @return channelSettings + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHANNEL_SETTINGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleChannelSettings getChannelSettings() { + return channelSettings; + } + + public void setChannelSettings(OnCallNotificationRuleChannelSettings channelSettings) { + this.channelSettings = channelSettings; + } + + public UpdateOnCallNotificationRuleRequestAttributes delayMinutes(Long delayMinutes) { + this.delayMinutes = delayMinutes; + return this; + } + + /** + * The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate + * evaluation + * + * @return delayMinutes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DELAY_MINUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getDelayMinutes() { + return delayMinutes; + } + + public void setDelayMinutes(Long delayMinutes) { + this.delayMinutes = delayMinutes; + } + + /** + * 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 UpdateOnCallNotificationRuleRequestAttributes + */ + @JsonAnySetter + public UpdateOnCallNotificationRuleRequestAttributes 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 UpdateOnCallNotificationRuleRequestAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateOnCallNotificationRuleRequestAttributes updateOnCallNotificationRuleRequestAttributes = + (UpdateOnCallNotificationRuleRequestAttributes) o; + return Objects.equals(this.category, updateOnCallNotificationRuleRequestAttributes.category) + && Objects.equals( + this.channelSettings, updateOnCallNotificationRuleRequestAttributes.channelSettings) + && Objects.equals( + this.delayMinutes, updateOnCallNotificationRuleRequestAttributes.delayMinutes) + && Objects.equals( + this.additionalProperties, + updateOnCallNotificationRuleRequestAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, channelSettings, delayMinutes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateOnCallNotificationRuleRequestAttributes {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" channelSettings: ").append(toIndentedString(channelSettings)).append("\n"); + sb.append(" delayMinutes: ").append(toIndentedString(delayMinutes)).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/UpdateOnCallNotificationRuleRequestData.java b/src/main/java/com/datadog/api/client/v2/model/UpdateOnCallNotificationRuleRequestData.java new file mode 100644 index 00000000000..90dbb2996b7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdateOnCallNotificationRuleRequestData.java @@ -0,0 +1,238 @@ +/* + * 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 updating an on-call notification rule */ +@JsonPropertyOrder({ + UpdateOnCallNotificationRuleRequestData.JSON_PROPERTY_ATTRIBUTES, + UpdateOnCallNotificationRuleRequestData.JSON_PROPERTY_ID, + UpdateOnCallNotificationRuleRequestData.JSON_PROPERTY_RELATIONSHIPS, + UpdateOnCallNotificationRuleRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdateOnCallNotificationRuleRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private UpdateOnCallNotificationRuleRequestAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private OnCallNotificationRuleRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private OnCallNotificationRuleType type = OnCallNotificationRuleType.NOTIFICATION_RULES; + + public UpdateOnCallNotificationRuleRequestData() {} + + @JsonCreator + public UpdateOnCallNotificationRuleRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) OnCallNotificationRuleType type) { + this.type = type; + this.unparsed |= !type.isValid(); + } + + public UpdateOnCallNotificationRuleRequestData attributes( + UpdateOnCallNotificationRuleRequestAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for creating or modifying an on-call notification rule. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UpdateOnCallNotificationRuleRequestAttributes getAttributes() { + return attributes; + } + + public void setAttributes(UpdateOnCallNotificationRuleRequestAttributes attributes) { + this.attributes = attributes; + } + + public UpdateOnCallNotificationRuleRequestData id(String id) { + this.id = id; + return this; + } + + /** + * Unique identifier for the rule + * + * @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 UpdateOnCallNotificationRuleRequestData relationships( + OnCallNotificationRuleRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * Relationship object for creating a notification rule + * + * @return relationships + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OnCallNotificationRuleRelationships getRelationships() { + return relationships; + } + + public void setRelationships(OnCallNotificationRuleRelationships relationships) { + this.relationships = relationships; + } + + public UpdateOnCallNotificationRuleRequestData type(OnCallNotificationRuleType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the resource is of type 'notification_rules'. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OnCallNotificationRuleType getType() { + return type; + } + + public void setType(OnCallNotificationRuleType 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 UpdateOnCallNotificationRuleRequestData + */ + @JsonAnySetter + public UpdateOnCallNotificationRuleRequestData 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 UpdateOnCallNotificationRuleRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateOnCallNotificationRuleRequestData updateOnCallNotificationRuleRequestData = + (UpdateOnCallNotificationRuleRequestData) o; + return Objects.equals(this.attributes, updateOnCallNotificationRuleRequestData.attributes) + && Objects.equals(this.id, updateOnCallNotificationRuleRequestData.id) + && Objects.equals(this.relationships, updateOnCallNotificationRuleRequestData.relationships) + && Objects.equals(this.type, updateOnCallNotificationRuleRequestData.type) + && Objects.equals( + this.additionalProperties, + updateOnCallNotificationRuleRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateOnCallNotificationRuleRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" relationships: ").append(toIndentedString(relationships)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_rule_for_a_user_returns_Created_response.freeze b/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_rule_for_a_user_returns_Created_response.freeze new file mode 100644 index 00000000000..fd26d2eef23 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_rule_for_a_user_returns_Created_response.freeze @@ -0,0 +1 @@ +2025-12-16T19:30:04.834Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_rule_for_a_user_returns_Created_response.json b/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_rule_for_a_user_returns_Created_response.json new file mode 100644 index 00000000000..17c3a98d1ff --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_On_Call_notification_rule_for_a_user_returns_Created_response.json @@ -0,0 +1,113 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"email\":\"Test-Create_an_On_Call_notification_rule_for_a_user_returns_Created_response-1765913404@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"users\",\"id\":\"2ab53f07-289f-4060-b21a-3d704096aadf\",\"attributes\":{\"name\":null,\"handle\":\"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com\",\"created_at\":\"2025-12-16T19:30:05.014723+00:00\",\"modified_at\":\"2025-12-16T19:30:05.014723+00:00\",\"email\":\"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/c5ddb15c50d998db06711e0a31591216?s=48&d=retro\",\"title\":\"user title\",\"verified\":false,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Pending\",\"last_login_time\":null},\"relationships\":{\"roles\":{\"data\":[]},\"org\":{\"data\":{\"type\":\"orgs\",\"id\":\"4dee724d-00cc-11ea-a77b-570c9d03c6c5\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "603e6dc3-72cf-5745-6bdf-4520e65beb45" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"address\":\"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com\",\"formats\":[\"html\"],\"type\":\"email\"}},\"type\":\"notification_channels\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/2ab53f07-289f-4060-b21a-3d704096aadf/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"ca8520ce-27e0-4bba-997f-004047cda45d\",\"type\":\"notification_channels\",\"attributes\":{\"active\":true,\"config\":{\"type\":\"email\",\"address\":\"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com\",\"formats\":[\"html\"]}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "8f6e4e69-17a3-eef4-cc1a-432c5d2b54f0" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"ca8520ce-27e0-4bba-997f-004047cda45d\",\"type\":\"notification_channels\"}}},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/2ab53f07-289f-4060-b21a-3d704096aadf/notification-rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"4e551e4f-d1aa-4fce-8cc7-c6bf98925efe\",\"type\":\"notification_rules\",\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"ca8520ce-27e0-4bba-997f-004047cda45d\",\"type\":\"notification_channels\"}}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "28420a44-4c30-927d-0b4c-5932c10915a5" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/2ab53f07-289f-4060-b21a-3d704096aadf", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "99fd0d5d-ed68-1e05-6858-a46a02bec632" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response.freeze b/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response.freeze new file mode 100644 index 00000000000..3b1ee11b9e9 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response.freeze @@ -0,0 +1 @@ +2025-12-16T19:29:36.256Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response.json b/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response.json new file mode 100644 index 00000000000..fde26184a9a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response.json @@ -0,0 +1,134 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"email\":\"Test-Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response-1765913376@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"users\",\"id\":\"5ebbe76d-c072-4909-ba24-ffa71f4597a0\",\"attributes\":{\"name\":null,\"handle\":\"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com\",\"created_at\":\"2025-12-16T19:29:36.461504+00:00\",\"modified_at\":\"2025-12-16T19:29:36.461504+00:00\",\"email\":\"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/dad7a8a5508730e67ad8dea90bcc189c?s=48&d=retro\",\"title\":\"user title\",\"verified\":false,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Pending\",\"last_login_time\":null},\"relationships\":{\"roles\":{\"data\":[]},\"org\":{\"data\":{\"type\":\"orgs\",\"id\":\"4dee724d-00cc-11ea-a77b-570c9d03c6c5\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "577bc725-f06b-5764-6a8c-bb1c73518c33" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"address\":\"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com\",\"formats\":[\"html\"],\"type\":\"email\"}},\"type\":\"notification_channels\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"a557eb68-8b0a-48cf-ac65-73aede790994\",\"type\":\"notification_channels\",\"attributes\":{\"active\":true,\"config\":{\"type\":\"email\",\"address\":\"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com\",\"formats\":[\"html\"]}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "c26997eb-4491-6add-d02a-186b50160d47" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"a557eb68-8b0a-48cf-ac65-73aede790994\",\"type\":\"notification_channels\"}}},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"71e9f009-5a69-4946-992e-d76b05d1ae61\",\"type\":\"notification_rules\",\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"a557eb68-8b0a-48cf-ac65-73aede790994\",\"type\":\"notification_channels\"}}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6075f27c-379f-be76-5800-76b17974661e" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/on-call/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-rules/71e9f009-5a69-4946-992e-d76b05d1ae61", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "63e2e886-da69-36d6-ebea-b1e7e3b197ac" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "8072a58e-e13a-1646-be58-271789562c00" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_rule_for_a_user_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_rule_for_a_user_returns_OK_response.freeze new file mode 100644 index 00000000000..d938f1a43ed --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_rule_for_a_user_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-12-16T21:16:24.271Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_rule_for_a_user_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_rule_for_a_user_returns_OK_response.json new file mode 100644 index 00000000000..2668d2ddcae --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_an_On_Call_notification_rule_for_a_user_returns_OK_response.json @@ -0,0 +1,144 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"email\":\"Test-Get_an_On_Call_notification_rule_for_a_user_returns_OK_response-1765919784@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"users\",\"id\":\"b2a555c9-ac2d-430d-b321-10e4c0201ce3\",\"attributes\":{\"name\":null,\"handle\":\"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com\",\"created_at\":\"2025-12-16T21:16:24.480454+00:00\",\"modified_at\":\"2025-12-16T21:16:24.480454+00:00\",\"email\":\"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/8e38ab440c2cdd2808a61dfa83f734d7?s=48&d=retro\",\"title\":\"user title\",\"verified\":false,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Pending\",\"last_login_time\":null},\"relationships\":{\"roles\":{\"data\":[]},\"org\":{\"data\":{\"type\":\"orgs\",\"id\":\"4dee724d-00cc-11ea-a77b-570c9d03c6c5\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "4346a217-31da-c8fb-bc3a-d876d2fcc30d" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"address\":\"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com\",\"formats\":[\"html\"],\"type\":\"email\"}},\"type\":\"notification_channels\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"767234b0-0c79-4092-9b44-a8963021795b\",\"type\":\"notification_channels\",\"attributes\":{\"active\":true,\"config\":{\"type\":\"email\",\"address\":\"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com\",\"formats\":[\"html\"]}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e0800725-0191-c1c0-9b59-20496037a823" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"767234b0-0c79-4092-9b44-a8963021795b\",\"type\":\"notification_channels\"}}},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"d07cc90b-4fc5-455f-8f57-45d48a658bc6\",\"type\":\"notification_rules\",\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"767234b0-0c79-4092-9b44-a8963021795b\",\"type\":\"notification_channels\"}}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "046888e3-0b7b-e794-c343-e9844d2a970e" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/on-call/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-rules/d07cc90b-4fc5-455f-8f57-45d48a658bc6", + "queryStringParameters": { + "include": [ + "channel" + ] + }, + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"d07cc90b-4fc5-455f-8f57-45d48a658bc6\",\"type\":\"notification_rules\",\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"767234b0-0c79-4092-9b44-a8963021795b\",\"type\":\"notification_channels\"}}}},\"included\":[{\"id\":\"767234b0-0c79-4092-9b44-a8963021795b\",\"type\":\"notification_channels\",\"attributes\":{\"active\":true,\"config\":{\"type\":\"email\",\"address\":\"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com\",\"formats\":[\"html\"]}}}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d635a2ab-0aad-a438-ec09-d8d3e05f4cc7" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "c81374ce-2fef-2177-b5b1-9799878d2ce0" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_On_Call_notification_rules_for_a_user_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/List_On_Call_notification_rules_for_a_user_returns_OK_response.freeze new file mode 100644 index 00000000000..11e9c7c90b2 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_On_Call_notification_rules_for_a_user_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-12-16T21:16:48.356Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_On_Call_notification_rules_for_a_user_returns_OK_response.json b/src/test/resources/cassettes/features/v2/List_On_Call_notification_rules_for_a_user_returns_OK_response.json new file mode 100644 index 00000000000..91aa1c274ba --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_On_Call_notification_rules_for_a_user_returns_OK_response.json @@ -0,0 +1,144 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"email\":\"Test-List_On_Call_notification_rules_for_a_user_returns_OK_response-1765919808@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"users\",\"id\":\"0730802a-ee45-404b-a21d-5908d4c6b3c4\",\"attributes\":{\"name\":null,\"handle\":\"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com\",\"created_at\":\"2025-12-16T21:16:48.579239+00:00\",\"modified_at\":\"2025-12-16T21:16:48.579239+00:00\",\"email\":\"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/c2f584fb6a42fbc0f0aad204ea40c0fc?s=48&d=retro\",\"title\":\"user title\",\"verified\":false,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Pending\",\"last_login_time\":null},\"relationships\":{\"roles\":{\"data\":[]},\"org\":{\"data\":{\"type\":\"orgs\",\"id\":\"4dee724d-00cc-11ea-a77b-570c9d03c6c5\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "0c2ec0dd-d605-4d16-4fd6-c4cf9fa9e5cf" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"address\":\"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com\",\"formats\":[\"html\"],\"type\":\"email\"}},\"type\":\"notification_channels\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"3073e724-15e8-4aec-897a-478e31cca3a8\",\"type\":\"notification_channels\",\"attributes\":{\"active\":true,\"config\":{\"type\":\"email\",\"address\":\"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com\",\"formats\":[\"html\"]}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "ee7d2be6-ce94-aeb1-db86-c2e88e581bae" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"3073e724-15e8-4aec-897a-478e31cca3a8\",\"type\":\"notification_channels\"}}},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"d93215d1-85c1-4528-a92f-1b604c1f4b2a\",\"type\":\"notification_rules\",\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"3073e724-15e8-4aec-897a-478e31cca3a8\",\"type\":\"notification_channels\"}}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "a4499984-d63a-d38e-2aeb-cd19de807981" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/on-call/users/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-rules", + "queryStringParameters": { + "include": [ + "channel" + ] + }, + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[{\"id\":\"d93215d1-85c1-4528-a92f-1b604c1f4b2a\",\"type\":\"notification_rules\",\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"3073e724-15e8-4aec-897a-478e31cca3a8\",\"type\":\"notification_channels\"}}}}],\"included\":[{\"id\":\"3073e724-15e8-4aec-897a-478e31cca3a8\",\"type\":\"notification_channels\",\"attributes\":{\"active\":true,\"config\":{\"type\":\"email\",\"address\":\"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com\",\"formats\":[\"html\"]}}}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "cac80a28-daf7-5e1a-5ed6-5a3bff53d071" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/0730802a-ee45-404b-a21d-5908d4c6b3c4", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "244cbce8-9afc-5a6d-93b0-49d800516759" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_an_On_Call_notification_rule_for_a_user_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Update_an_On_Call_notification_rule_for_a_user_returns_OK_response.freeze new file mode 100644 index 00000000000..f55a35ff1b8 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_an_On_Call_notification_rule_for_a_user_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-12-17T01:04:35.713Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_an_On_Call_notification_rule_for_a_user_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Update_an_On_Call_notification_rule_for_a_user_returns_OK_response.json new file mode 100644 index 00000000000..b91b5a32f56 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_an_On_Call_notification_rule_for_a_user_returns_OK_response.json @@ -0,0 +1,148 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"email\":\"Test-Update_an_On_Call_notification_rule_for_a_user_returns_OK_response-1765933475@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/users", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"users\",\"id\":\"4ef9cf45-30a8-4117-9b56-adba96671dff\",\"attributes\":{\"name\":null,\"handle\":\"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com\",\"created_at\":\"2025-12-17T01:04:36.246950+00:00\",\"modified_at\":\"2025-12-17T01:04:36.246950+00:00\",\"email\":\"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/53cbcba1803f4569f759fcc6b3f90bb6?s=48&d=retro\",\"title\":\"user title\",\"verified\":false,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Pending\",\"last_login_time\":null},\"relationships\":{\"roles\":{\"data\":[]},\"org\":{\"data\":{\"type\":\"orgs\",\"id\":\"4dee724d-00cc-11ea-a77b-570c9d03c6c5\"}}}}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "f7376381-2383-3870-c641-2c05e5ac094b" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"config\":{\"address\":\"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com\",\"formats\":[\"html\"],\"type\":\"email\"}},\"type\":\"notification_channels\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-channels", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"7fc326c9-f3dc-4858-80c2-d88c24dcf54b\",\"type\":\"notification_channels\",\"attributes\":{\"active\":true,\"config\":{\"type\":\"email\",\"address\":\"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com\",\"formats\":[\"html\"]}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "afa68034-9fd4-f139-c1ff-88e12d7e0e5b" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"7fc326c9-f3dc-4858-80c2-d88c24dcf54b\",\"type\":\"notification_channels\"}}},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/users/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"c7b724f1-eb73-43d4-889f-d8f3e6fbe664\",\"type\":\"notification_rules\",\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":0},\"relationships\":{\"channel\":{\"data\":{\"id\":\"7fc326c9-f3dc-4858-80c2-d88c24dcf54b\",\"type\":\"notification_channels\"}}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "cd0c567b-9cb2-6bc2-256b-0a061c7bedc9" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":1},\"id\":\"c7b724f1-eb73-43d4-889f-d8f3e6fbe664\",\"relationships\":{\"channel\":{\"data\":{\"id\":\"7fc326c9-f3dc-4858-80c2-d88c24dcf54b\",\"type\":\"notification_channels\"}}},\"type\":\"notification_rules\"}}" + }, + "headers": {}, + "method": "PUT", + "path": "/api/v2/on-call/users/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-rules/c7b724f1-eb73-43d4-889f-d8f3e6fbe664", + "queryStringParameters": { + "include": [ + "channel" + ] + }, + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"c7b724f1-eb73-43d4-889f-d8f3e6fbe664\",\"type\":\"notification_rules\",\"attributes\":{\"category\":\"high_urgency\",\"delay_minutes\":1},\"relationships\":{\"channel\":{\"data\":{\"id\":\"7fc326c9-f3dc-4858-80c2-d88c24dcf54b\",\"type\":\"notification_channels\"}}}},\"included\":[{\"id\":\"7fc326c9-f3dc-4858-80c2-d88c24dcf54b\",\"type\":\"notification_channels\",\"attributes\":{\"active\":true,\"config\":{\"type\":\"email\",\"address\":\"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com\",\"formats\":[\"html\"]}}}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "ac937398-ca32-e37a-db66-38bb890841a5" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/users/4ef9cf45-30a8-4117-9b56-adba96671dff", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "1ce870f5-417b-e12f-9b41-751869eea48f" + } +] \ 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 8cf1925f45e..4651a346eb1 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 @@ -799,6 +799,22 @@ "tag": "On-Call", "operationId": "CreateUserNotificationChannel" }, + { + "parameters": [ + { + "name": "user_id", + "source": "user.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"notification_rules\",\n \"attributes\": {\n \"delay_minutes\": 0,\n \"category\": \"high_urgency\"\n },\n \"relationships\": {\n \"channel\": {\n \"data\": {\n \"id\": \"{{ oncall_email_notification_channel.data.id }}\",\n \"type\": \"notification_channels\"\n }\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"oncall_email_notification_rule\" in the system", + "key": "oncall_email_notification_rule", + "tag": "On-Call", + "operationId": "CreateUserNotificationRule" + }, { "parameters": [ { diff --git a/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 9f4750eef79..0f4b2a0e340 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 @@ -70,6 +70,32 @@ Feature: On-Call When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification rule for a user returns "Bad Request" response + Given new "CreateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/on-call + Scenario: Create an On-Call notification rule for a user returns "Created" response + Given new "CreateUserNotificationRule" request + And there is a valid "user" in the system + And request contains "user_id" parameter from "user.data.id" + And there is a valid "oncall_email_notification_channel" in the system + And body with value {"data": {"attributes": {"category": "high_urgency", "delay_minutes": 0}, "relationships": {"channel": {"data": {"id": "{{ oncall_email_notification_channel.data.id }}", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification rule for a user returns "Not Found" response + Given new "CreateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/on-call Scenario: Delete On-Call escalation policy returns "No Content" response Given new "DeleteOnCallEscalationPolicy" request @@ -130,6 +156,33 @@ Feature: On-Call When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call + Scenario: Delete an On-Call notification rule for a user returns "Bad Request" response + Given new "DeleteUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/on-call + Scenario: Delete an On-Call notification rule for a user returns "No Content" response + Given new "DeleteUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.data.id" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/on-call + Scenario: Delete an On-Call notification rule for a user returns "Not Found" response + Given new "DeleteUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call Scenario: Get On-Call escalation policy returns "Bad Request" response Given new "GetOnCallEscalationPolicy" request @@ -207,6 +260,36 @@ Feature: On-Call And the response "data.attributes.config.type" is equal to "email" And the response "data.attributes.config.address" is equal to "{{ user.data.attributes.email }}" + @generated @skip @team:DataDog/on-call + Scenario: Get an On-Call notification rule for a user returns "Bad Request" response + Given new "GetUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: Get an On-Call notification rule for a user returns "Not Found" response + Given new "GetUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: Get an On-Call notification rule for a user returns "OK" response + Given new "GetUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.data.id" + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.category" is equal to "high_urgency" + And the response "included" has length 1 + @generated @skip @team:DataDog/on-call Scenario: Get scheduled on-call user returns "Bad Request" response Given new "GetScheduleOnCallUser" request @@ -283,6 +366,33 @@ Feature: On-Call And the response "data[0].attributes.config.type" is equal to "email" And the response "data[0].attributes.config.address" is equal to "{{ user.data.attributes.email }}" + @generated @skip @team:DataDog/on-call + Scenario: List On-Call notification rules for a user returns "Bad Request" response + Given new "ListUserNotificationRules" request + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: List On-Call notification rules for a user returns "Not Found" response + Given new "ListUserNotificationRules" request + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: List On-Call notification rules for a user returns "OK" response + Given new "ListUserNotificationRules" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "included" has length 1 + @skip-python @team:DataDog/on-call Scenario: Set On-Call team routing rules returns "OK" response Given new "SetOnCallTeamRoutingRules" request @@ -350,3 +460,36 @@ Feature: On-Call And body with value {"data": { "id": "{{ schedule.data.id }}", "attributes": {"layers": [{"id": "{{ schedule.data.relationships.layers.data[0].id }}" , "effective_date": "{{ timeISO('now - 10d') }}", "end_date": "{{ timeISO('now + 10d') }}", "interval": {"seconds": 3600}, "members": [{"user": {"id": "{{user.data.id}}"}}], "name": "Layer 1", "restrictions": [{"end_day": "friday", "end_time": "17:00:00", "start_day": "monday", "start_time": "09:00:00"}], "rotation_start": "{{ timeISO('now - 5d') }}"}], "name": "{{ unique }}", "time_zone": "America/New_York"}, "relationships": {"teams": {"data": [{"id": "{{dd_team.data.id}}", "type": "teams"}]}}, "type": "schedules"}} When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "Bad Request" response + Given new "UpdateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "id": "2462ace1-49e2-aab1-xc4f-29cc4ae1105n7", "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "Not Found" response + Given new "UpdateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "id": "2462ace1-49e2-aab1-xc4f-29cc4ae1105n7", "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "OK" response + Given new "UpdateUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.data.id" + And body with value {"data": {"attributes": {"category": "high_urgency", "delay_minutes": 1}, "id": "{{ oncall_email_notification_rule.data.id }}", "relationships": {"channel": {"data": {"id": "{{ oncall_email_notification_channel.data.id }}", "type": "notification_channels"}}}, "type": "notification_rules"}} + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "included" has length 1 + And the response "data.attributes.delay_minutes" is equal to 1 diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index e0f0b98d0c9..d398c05fc13 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 @@ -2964,6 +2964,36 @@ "type": "safe" } }, + "ListUserNotificationRules": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "CreateUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "DeleteUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "idempotent" + } + }, + "GetUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "UpdateUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, "ListOrgConfigs": { "tag": "Organizations", "undo": {