diff --git a/.apigentools-info b/.apigentools-info index 3bb30a959..84cd6b06a 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-02 04:31:12.514459", - "spec_repo_commit": "272cce39" + "regenerated": "2025-05-02 09:33:50.575362", + "spec_repo_commit": "77cf469a" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-02 04:31:12.530271", - "spec_repo_commit": "272cce39" + "regenerated": "2025-05-02 09:33:50.591191", + "spec_repo_commit": "77cf469a" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 14c6d2062..37a8f69d1 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -13314,7 +13314,7 @@ components: request. Contains assignment strategy, escalation timeout, and a list of targets. properties: assignment: - $ref: '#/components/schemas/EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment' + $ref: '#/components/schemas/EscalationPolicyStepAttributesAssignment' escalate_after_seconds: description: Defines how many seconds to wait before escalating to the next step. @@ -13323,47 +13323,14 @@ components: type: integer targets: description: Specifies the collection of escalation targets for this step. + example: + - users items: - $ref: '#/components/schemas/EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems' + $ref: '#/components/schemas/EscalationPolicyStepTarget' type: array required: - targets type: object - EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment: - description: Specifies how this escalation step will assign targets (example - `default` or `round-robin`). - enum: - - default - - round-robin - example: default - type: string - x-enum-varnames: - - DEFAULT - - ROUND_ROBIN - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems: - description: Defines a single escalation target within a step for an escalation - policy creation request. Contains `id` and `type`. - properties: - id: - description: Specifies the unique identifier for this target. - example: 00000000-aba1-0000-0000-000000000000 - type: string - type: - $ref: '#/components/schemas/EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType' - type: object - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType: - description: Specifies the type of escalation target (example `users`, `schedules`, - or `teams`). - enum: - - users - - schedules - - teams - example: users - type: string - x-enum-varnames: - - USERS - - SCHEDULES - - TEAMS EscalationPolicyCreateRequestDataRelationships: description: Represents relationships in an escalation policy creation request, including references to teams. @@ -13594,6 +13561,30 @@ components: targets: $ref: '#/components/schemas/EscalationTarget' type: object + EscalationPolicyStepTarget: + description: Defines a single escalation target within a step for an escalation + policy creation request. Contains `id` and `type`. + properties: + id: + description: Specifies the unique identifier for this target. + example: 00000000-aba1-0000-0000-000000000000 + type: string + type: + $ref: '#/components/schemas/EscalationPolicyStepTargetType' + type: object + EscalationPolicyStepTargetType: + description: Specifies the type of escalation target (example `users`, `schedules`, + or `teams`). + enum: + - users + - schedules + - teams + example: users + type: string + x-enum-varnames: + - USERS + - SCHEDULES + - TEAMS EscalationPolicyStepType: default: steps description: Indicates that the resource is of type `steps`. @@ -13691,7 +13682,7 @@ components: ID, and a list of targets. properties: assignment: - $ref: '#/components/schemas/EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment' + $ref: '#/components/schemas/EscalationPolicyStepAttributesAssignment' escalate_after_seconds: description: Defines how many seconds to wait before escalating to the next step. @@ -13705,46 +13696,11 @@ components: targets: description: Specifies the collection of escalation targets for this step. items: - $ref: '#/components/schemas/EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems' + $ref: '#/components/schemas/EscalationPolicyStepTarget' type: array required: - targets type: object - EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment: - description: Specifies how this escalation step will assign targets (example - `default` or `round-robin`). - enum: - - default - - round-robin - example: default - type: string - x-enum-varnames: - - DEFAULT - - ROUND_ROBIN - EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems: - description: Defines a single escalation target within a step for an escalation - policy update request. Contains `id` and `type`. - properties: - id: - description: Specifies the unique identifier for this target. - example: 00000000-aba1-0000-0000-000000000000 - type: string - type: - $ref: '#/components/schemas/EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType' - type: object - EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType: - description: Specifies the type of escalation target (example `users`, `schedules`, - or `teams`). - enum: - - users - - schedules - - teams - example: users - type: string - x-enum-varnames: - - USERS - - SCHEDULES - - TEAMS EscalationPolicyUpdateRequestDataRelationships: description: Represents relationships in an escalation policy update request, including references to teams. @@ -29798,6 +29754,93 @@ components: type: string x-enum-varnames: - ROLES + RoutingRule: + description: Represents a routing rule, including its attributes, relationships, + and unique identifier. + properties: + attributes: + $ref: '#/components/schemas/RoutingRuleAttributes' + id: + description: Specifies the unique identifier of this routing rule. + type: string + relationships: + $ref: '#/components/schemas/RoutingRuleRelationships' + type: + $ref: '#/components/schemas/RoutingRuleType' + required: + - type + type: object + RoutingRuleAction: + description: Defines an action that is executed when a routing rule matches + certain criteria. + oneOf: + - $ref: '#/components/schemas/SlackAction' + - $ref: '#/components/schemas/TeamsAction' + RoutingRuleAttributes: + description: Defines the configurable attributes of a routing rule, such as + actions, query, time restriction, and urgency. + properties: + actions: + description: Specifies the list of actions to perform when the routing rule + matches. + items: + $ref: '#/components/schemas/RoutingRuleAction' + type: array + query: + description: Defines the query or condition that triggers this routing rule. + type: string + time_restriction: + $ref: '#/components/schemas/TimeRestrictions' + urgency: + $ref: '#/components/schemas/Urgency' + type: object + RoutingRuleRelationships: + description: Specifies relationships for a routing rule, linking to associated + policy resources. + properties: + policy: + $ref: '#/components/schemas/RoutingRuleRelationshipsPolicy' + type: object + RoutingRuleRelationshipsPolicy: + description: Defines the relationship that links a routing rule to a policy. + properties: + data: + $ref: '#/components/schemas/RoutingRuleRelationshipsPolicyData' + required: + - data + type: object + RoutingRuleRelationshipsPolicyData: + description: Represents the policy data reference, containing the policy's ID + and resource type. + properties: + id: + description: Specifies the unique identifier of the policy. + example: '' + type: string + type: + $ref: '#/components/schemas/RoutingRuleRelationshipsPolicyDataType' + required: + - type + - id + type: object + RoutingRuleRelationshipsPolicyDataType: + default: policies + description: Indicates that the resource is of type 'policies'. + enum: + - policies + example: policies + type: string + x-enum-varnames: + - POLICIES + RoutingRuleType: + default: team_routing_rules + description: Team routing rules resource type. + enum: + - team_routing_rules + example: team_routing_rules + type: string + x-enum-varnames: + - TEAM_ROUTING_RULES RuleAttributes: description: Details of a rule. properties: @@ -35922,6 +35965,26 @@ components: type: string x-enum-varnames: - AGGREGATED_CONNECTION + SlackAction: + description: Sends a message to a Slack channel. + properties: + channel: + description: The channel ID. + example: CHANNEL + type: string + type: + description: Must be set to "send_slack_message". + example: send_slack_message + type: string + workspace: + description: The workspace ID. + example: WORKSPACE + type: string + required: + - type + - channel + - workspace + type: object SlackIntegrationMetadata: description: Incident integration metadata for the Slack integration. properties: @@ -37570,6 +37633,212 @@ components: data: $ref: '#/components/schemas/Team' type: object + TeamRoutingRules: + description: Represents a complete set of team routing rules, including data + and optionally included related resources. + example: + data: + id: 27590dae-47be-4a7d-9abf-8f4e45124020 + relationships: + rules: + data: + - id: 03aff2d6-6cbf-496c-997f-a857bbe9a94a + type: team_routing_rules + - id: 03aff2d6-6cbf-496c-997f-a857bbe9a94a + type: team_routing_rules + type: team_routing_rules + included: + - attributes: + actions: null + query: tags.service:test + time_restriction: + restrictions: + - end_day: monday + end_time: '17:00:00' + start_day: monday + start_time: 09:00:00 + - end_day: tuesday + end_time: '17:00:00' + start_day: tuesday + start_time: 09:00:00 + time_zone: '' + urgency: high + id: 03aff2d6-6cbf-496c-997f-a857bbe9a94a + relationships: + policy: + data: null + type: team_routing_rules + properties: + data: + $ref: '#/components/schemas/TeamRoutingRulesData' + included: + description: Provides related routing rules or other included resources. + items: + $ref: '#/components/schemas/TeamRoutingRulesIncluded' + type: array + type: object + TeamRoutingRulesData: + description: Represents the top-level data object for team routing rules, containing + the ID, relationships, and resource type. + properties: + id: + description: Specifies the unique identifier of this team routing rules + record. + type: string + relationships: + $ref: '#/components/schemas/TeamRoutingRulesDataRelationships' + type: + $ref: '#/components/schemas/TeamRoutingRulesDataType' + required: + - type + type: object + TeamRoutingRulesDataRelationships: + description: Specifies relationships for team routing rules, including rule + references. + properties: + rules: + $ref: '#/components/schemas/TeamRoutingRulesDataRelationshipsRules' + type: object + TeamRoutingRulesDataRelationshipsRules: + description: Holds references to a set of routing rules in a relationship. + properties: + data: + description: An array of references to the routing rules associated with + this team. + items: + $ref: '#/components/schemas/TeamRoutingRulesDataRelationshipsRulesDataItems' + type: array + type: object + TeamRoutingRulesDataRelationshipsRulesDataItems: + description: Defines a relationship item to link a routing rule by its ID and + type. + properties: + id: + description: Specifies the unique identifier for the related routing rule. + example: '' + type: string + type: + $ref: '#/components/schemas/TeamRoutingRulesDataRelationshipsRulesDataItemsType' + required: + - type + - id + type: object + TeamRoutingRulesDataRelationshipsRulesDataItemsType: + default: team_routing_rules + description: Indicates that the resource is of type 'team_routing_rules'. + enum: + - team_routing_rules + example: team_routing_rules + type: string + x-enum-varnames: + - TEAM_ROUTING_RULES + TeamRoutingRulesDataType: + default: team_routing_rules + description: Team routing rules resource type. + enum: + - team_routing_rules + example: team_routing_rules + type: string + x-enum-varnames: + - TEAM_ROUTING_RULES + TeamRoutingRulesIncluded: + description: Represents additional included resources for team routing rules, + such as associated routing rules. + oneOf: + - $ref: '#/components/schemas/RoutingRule' + TeamRoutingRulesRequest: + description: Represents a request to create or update team routing rules, including + the data payload. + example: + data: + attributes: + rules: + - actions: null + policy_id: '' + query: tags.service:test + time_restriction: + restrictions: + - end_day: monday + end_time: '17:00:00' + start_day: monday + start_time: 09:00:00 + - end_day: tuesday + end_time: '17:00:00' + start_day: tuesday + start_time: 09:00:00 + time_zone: '' + urgency: high + - actions: + - channel: channel + type: send_slack_message + workspace: workspace + policy_id: fad4eee1-13f5-40d8-886b-4e56d8d5d1c6 + query: '' + time_restriction: null + urgency: low + id: 27590dae-47be-4a7d-9abf-8f4e45124020 + type: team_routing_rules + properties: + data: + $ref: '#/components/schemas/TeamRoutingRulesRequestData' + type: object + TeamRoutingRulesRequestData: + description: Holds the data necessary to create or update team routing rules, + including attributes, ID, and resource type. + properties: + attributes: + $ref: '#/components/schemas/TeamRoutingRulesRequestDataAttributes' + id: + description: Specifies the unique identifier for this set of team routing + rules. + type: string + type: + $ref: '#/components/schemas/TeamRoutingRulesRequestDataType' + required: + - type + type: object + TeamRoutingRulesRequestDataAttributes: + description: Represents the attributes of a request to update or create team + routing rules. + properties: + rules: + description: A list of routing rule items that define how incoming pages + should be handled. + items: + $ref: '#/components/schemas/TeamRoutingRulesRequestRule' + type: array + type: object + TeamRoutingRulesRequestDataType: + default: team_routing_rules + description: Team routing rules resource type. + enum: + - team_routing_rules + example: team_routing_rules + type: string + x-enum-varnames: + - TEAM_ROUTING_RULES + TeamRoutingRulesRequestRule: + description: Defines an individual routing rule item that contains the rule + data for the request. + properties: + actions: + description: Specifies the list of actions to perform when the routing rule + is matched. + items: + $ref: '#/components/schemas/RoutingRuleAction' + type: array + policy_id: + description: Identifies the policy to be applied when this routing rule + matches. + type: string + query: + description: Defines the query or condition that triggers this routing rule. + type: string + time_restriction: + $ref: '#/components/schemas/TimeRestrictions' + urgency: + $ref: '#/components/schemas/Urgency' + type: object TeamTarget: description: Represents a team target for an escalation policy step, including the team's ID and resource type. @@ -37672,6 +37941,31 @@ components: required: - data type: object + TeamsAction: + description: Sends a message to a Microsoft Teams channel. + properties: + channel: + description: The channel ID. + example: CHANNEL + type: string + team: + description: The team ID. + example: TEAM + type: string + tenant: + description: The tenant ID. + example: TENANT + type: string + type: + description: Must be set to "send_teams_message". + example: send_teams_message + type: string + required: + - type + - channel + - tenant + - team + type: object TeamsField: description: Supported teams field. enum: @@ -37803,6 +38097,38 @@ components: example: 86400 format: int64 type: integer + TimeRestriction: + description: Defines a single time restriction rule with start and end times + and the applicable weekdays. + properties: + end_day: + $ref: '#/components/schemas/Weekday' + end_time: + description: Specifies the ending time for this restriction. + type: string + start_day: + $ref: '#/components/schemas/Weekday' + start_time: + description: Specifies the starting time for this restriction. + type: string + type: object + TimeRestrictions: + description: Holds time zone information and a list of time restrictions for + a routing rule. + properties: + restrictions: + description: Defines the list of time-based restrictions. + items: + $ref: '#/components/schemas/TimeRestriction' + type: array + time_zone: + description: Specifies the time zone applicable to the restrictions. + example: '' + type: string + required: + - time_zone + - restrictions + type: object TimeseriesFormulaQueryRequest: description: A request wrapper around a single timeseries query to be executed. properties: @@ -38430,6 +38756,18 @@ components: description: Upsert entity response included item. oneOf: - $ref: '#/components/schemas/EntityResponseIncludedSchema' + Urgency: + description: Specifies the level of urgency for a routing rule (low, high, or + dynamic). + enum: + - low + - high + - dynamic + type: string + x-enum-varnames: + - LOW + - HIGH + - DYNAMIC UrlParam: description: The definition of `UrlParam` object. properties: @@ -39504,6 +39842,25 @@ components: - X_CONTENT_TYPE_HEADER_MISSING - X_PATH_INJECTION - XSS + Weekday: + description: A day of the week. + enum: + - monday + - tuesday + - wednesday + - thursday + - friday + - saturday + - sunday + type: string + x-enum-varnames: + - MONDAY + - TUESDAY + - WEDNESDAY + - THURSDAY + - FRIDAY + - SATURDAY + - SUNDAY WidgetLiveSpan: description: The available timeframes depend on the widget you are using. enum: @@ -51107,6 +51464,79 @@ paths: summary: Update on-call schedule tags: - On-Call + /api/v2/on-call/teams/{team_id}/routing-rules: + get: + description: Get a team's on-call routing rules + operationId: GetOnCallTeamRoutingRules + parameters: + - description: The team ID + in: path + name: team_id + required: true + schema: + example: 27590dae-47be-4a7d-9abf-8f4e45124020 + type: string + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `rules`, `rules.policy`.' + in: query + name: include + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamRoutingRules' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get on-call team routing rules + tags: + - On-Call + put: + description: Set a team's on-call routing rules + operationId: SetOnCallTeamRoutingRules + parameters: + - description: The team ID + in: path + name: team_id + required: true + schema: + example: 27590dae-47be-4a7d-9abf-8f4e45124020 + type: string + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `rules`, `rules.policy`.' + in: query + name: include + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TeamRoutingRulesRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamRoutingRules' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Set on-call team routing rules + tags: + - On-Call /api/v2/org_configs: get: description: Returns all Org Configs (name, description, and value). diff --git a/examples/v2_on-call_CreateOnCallEscalationPolicy.rs b/examples/v2_on-call_CreateOnCallEscalationPolicy.rs index eab7f6826..c82482aa7 100644 --- a/examples/v2_on-call_CreateOnCallEscalationPolicy.rs +++ b/examples/v2_on-call_CreateOnCallEscalationPolicy.rs @@ -6,14 +6,14 @@ use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequest; use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestData; use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataAttributes; use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItems; -use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment; -use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems; -use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType; use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataRelationships; use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataRelationshipsTeams; use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataRelationshipsTeamsDataItems; use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataRelationshipsTeamsDataItemsType; use datadog_api_client::datadogV2::model::EscalationPolicyCreateRequestDataType; +use datadog_api_client::datadogV2::model::EscalationPolicyStepAttributesAssignment; +use datadog_api_client::datadogV2::model::EscalationPolicyStepTarget; +use datadog_api_client::datadogV2::model::EscalationPolicyStepTargetType; #[tokio::main] async fn main() { @@ -25,66 +25,47 @@ async fn main() { // there is a valid "dd_team" in the system let dd_team_data_id = std::env::var("DD_TEAM_DATA_ID").unwrap(); - let body = - EscalationPolicyCreateRequest::new( - EscalationPolicyCreateRequestData::new( - EscalationPolicyCreateRequestDataAttributes::new( - "Example-On-Call".to_string(), - vec![ - EscalationPolicyCreateRequestDataAttributesStepsItems::new( - vec![ - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems::new() - .id(user_data_id.clone()) - .type_( - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType::USERS, - ), - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems::new() - .id(schedule_data_id.clone()) - .type_( - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType - ::SCHEDULES, - ), - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems::new() - .id(dd_team_data_id.clone()) - .type_( - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType::TEAMS, - ) - ], - ) - .assignment(EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment::DEFAULT) - .escalate_after_seconds(3600), - EscalationPolicyCreateRequestDataAttributesStepsItems::new( - vec![ - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems::new() - .id(dd_team_data_id.clone()) - .type_( - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType::TEAMS, - ) - ], - ) - .assignment(EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment::ROUND_ROBIN) - .escalate_after_seconds(3600) - ], - ) - .description("Escalation Policy 1 description".to_string()) - .resolve_page_on_policy_end(true) - .retries(2), - EscalationPolicyCreateRequestDataType::POLICIES, - ).relationships( - EscalationPolicyCreateRequestDataRelationships - ::new().teams( - EscalationPolicyCreateRequestDataRelationshipsTeams - ::new().data( - vec![ - EscalationPolicyCreateRequestDataRelationshipsTeamsDataItems::new( - dd_team_data_id.clone(), - EscalationPolicyCreateRequestDataRelationshipsTeamsDataItemsType::TEAMS, - ) - ], - ), + let body = EscalationPolicyCreateRequest::new( + EscalationPolicyCreateRequestData::new( + EscalationPolicyCreateRequestDataAttributes::new( + "Example-On-Call".to_string(), + vec![ + EscalationPolicyCreateRequestDataAttributesStepsItems::new(vec![ + EscalationPolicyStepTarget::new() + .id(user_data_id.clone()) + .type_(EscalationPolicyStepTargetType::USERS), + EscalationPolicyStepTarget::new() + .id(schedule_data_id.clone()) + .type_(EscalationPolicyStepTargetType::SCHEDULES), + EscalationPolicyStepTarget::new() + .id(dd_team_data_id.clone()) + .type_(EscalationPolicyStepTargetType::TEAMS), + ]) + .assignment(EscalationPolicyStepAttributesAssignment::DEFAULT) + .escalate_after_seconds(3600), + EscalationPolicyCreateRequestDataAttributesStepsItems::new(vec![ + EscalationPolicyStepTarget::new() + .id(dd_team_data_id.clone()) + .type_(EscalationPolicyStepTargetType::TEAMS), + ]) + .assignment(EscalationPolicyStepAttributesAssignment::ROUND_ROBIN) + .escalate_after_seconds(3600), + ], + ) + .description("Escalation Policy 1 description".to_string()) + .resolve_page_on_policy_end(true) + .retries(2), + EscalationPolicyCreateRequestDataType::POLICIES, + ) + .relationships(EscalationPolicyCreateRequestDataRelationships::new().teams( + EscalationPolicyCreateRequestDataRelationshipsTeams::new().data(vec![ + EscalationPolicyCreateRequestDataRelationshipsTeamsDataItems::new( + dd_team_data_id.clone(), + EscalationPolicyCreateRequestDataRelationshipsTeamsDataItemsType::TEAMS, ), - ), - ); + ]), + )), + ); let configuration = datadog::Configuration::new(); let api = OnCallAPI::with_config(configuration); let resp = api diff --git a/examples/v2_on-call_GetOnCallTeamRoutingRules.rs b/examples/v2_on-call_GetOnCallTeamRoutingRules.rs new file mode 100644 index 000000000..3ff72915a --- /dev/null +++ b/examples/v2_on-call_GetOnCallTeamRoutingRules.rs @@ -0,0 +1,21 @@ +// Get on-call team routing rules returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_on_call::GetOnCallTeamRoutingRulesOptionalParams; +use datadog_api_client::datadogV2::api_on_call::OnCallAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = OnCallAPI::with_config(configuration); + let resp = api + .get_on_call_team_routing_rules( + "27590dae-47be-4a7d-9abf-8f4e45124020".to_string(), + GetOnCallTeamRoutingRulesOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_on-call_SetOnCallTeamRoutingRules.rs b/examples/v2_on-call_SetOnCallTeamRoutingRules.rs new file mode 100644 index 000000000..a59178585 --- /dev/null +++ b/examples/v2_on-call_SetOnCallTeamRoutingRules.rs @@ -0,0 +1,81 @@ +// Set on-call team routing rules returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_on_call::OnCallAPI; +use datadog_api_client::datadogV2::api_on_call::SetOnCallTeamRoutingRulesOptionalParams; +use datadog_api_client::datadogV2::model::RoutingRuleAction; +use datadog_api_client::datadogV2::model::SlackAction; +use datadog_api_client::datadogV2::model::TeamRoutingRulesRequest; +use datadog_api_client::datadogV2::model::TeamRoutingRulesRequestData; +use datadog_api_client::datadogV2::model::TeamRoutingRulesRequestDataAttributes; +use datadog_api_client::datadogV2::model::TeamRoutingRulesRequestDataType; +use datadog_api_client::datadogV2::model::TeamRoutingRulesRequestRule; +use datadog_api_client::datadogV2::model::TimeRestriction; +use datadog_api_client::datadogV2::model::TimeRestrictions; +use datadog_api_client::datadogV2::model::Urgency; +use datadog_api_client::datadogV2::model::Weekday; + +#[tokio::main] +async fn main() { + // there is a valid "dd_team" in the system + let dd_team_data_id = std::env::var("DD_TEAM_DATA_ID").unwrap(); + + // there is a valid "escalation_policy" in the system + let escalation_policy_data_id = std::env::var("ESCALATION_POLICY_DATA_ID").unwrap(); + let body = TeamRoutingRulesRequest::new().data( + TeamRoutingRulesRequestData::new(TeamRoutingRulesRequestDataType::TEAM_ROUTING_RULES) + .attributes(TeamRoutingRulesRequestDataAttributes::new().rules(vec![ + TeamRoutingRulesRequestRule::new() + .actions( + vec![ + RoutingRuleAction::SlackAction( + Box::new( + SlackAction::new( + "channel".to_string(), + "send_slack_message".to_string(), + "workspace".to_string(), + ), + ), + ) + ], + ) + .query("tags.service:test".to_string()) + .time_restriction( + TimeRestrictions::new( + vec![ + TimeRestriction::new() + .end_day(Weekday::MONDAY) + .end_time("17:00:00".to_string()) + .start_day(Weekday::MONDAY) + .start_time("09:00:00".to_string()), + TimeRestriction::new() + .end_day(Weekday::TUESDAY) + .end_time("17:00:00".to_string()) + .start_day(Weekday::TUESDAY) + .start_time("09:00:00".to_string()) + ], + "Europe/Paris".to_string(), + ), + ) + .urgency(Urgency::HIGH), + TeamRoutingRulesRequestRule::new() + .policy_id(escalation_policy_data_id.clone()) + .query("".to_string()) + .urgency(Urgency::LOW) + ])) + .id(dd_team_data_id.clone()), + ); + let configuration = datadog::Configuration::new(); + let api = OnCallAPI::with_config(configuration); + let resp = api + .set_on_call_team_routing_rules( + dd_team_data_id.clone(), + body, + SetOnCallTeamRoutingRulesOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_on-call_UpdateOnCallEscalationPolicy.rs b/examples/v2_on-call_UpdateOnCallEscalationPolicy.rs index 0a0c9a7fe..c2b439d78 100644 --- a/examples/v2_on-call_UpdateOnCallEscalationPolicy.rs +++ b/examples/v2_on-call_UpdateOnCallEscalationPolicy.rs @@ -2,13 +2,13 @@ use datadog_api_client::datadog; use datadog_api_client::datadogV2::api_on_call::OnCallAPI; use datadog_api_client::datadogV2::api_on_call::UpdateOnCallEscalationPolicyOptionalParams; +use datadog_api_client::datadogV2::model::EscalationPolicyStepAttributesAssignment; +use datadog_api_client::datadogV2::model::EscalationPolicyStepTarget; +use datadog_api_client::datadogV2::model::EscalationPolicyStepTargetType; use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequest; use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestData; use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestDataAttributes; use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItems; -use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment; -use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems; -use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType; use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestDataRelationships; use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestDataRelationshipsTeams; use datadog_api_client::datadogV2::model::EscalationPolicyUpdateRequestDataRelationshipsTeamsDataItems; @@ -27,46 +27,36 @@ async fn main() { // there is a valid "dd_team" in the system let dd_team_data_id = std::env::var("DD_TEAM_DATA_ID").unwrap(); - let body = - EscalationPolicyUpdateRequest::new( - EscalationPolicyUpdateRequestData::new( - EscalationPolicyUpdateRequestDataAttributes::new( - "Example-On-Call-updated".to_string(), - vec![ - EscalationPolicyUpdateRequestDataAttributesStepsItems::new( - vec![ - EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems::new() - .id(user_data_id.clone()) - .type_( - EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType::USERS, - ) - ], - ) - .assignment(EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment::DEFAULT) - .escalate_after_seconds(3600) - .id(escalation_policy_data_relationships_steps_data_0_id.clone()) - ], - ) - .description("Example-On-Call".to_string()) - .resolve_page_on_policy_end(false) - .retries(0), - escalation_policy_data_id.clone(), - EscalationPolicyUpdateRequestDataType::POLICIES, - ).relationships( - EscalationPolicyUpdateRequestDataRelationships - ::new().teams( - EscalationPolicyUpdateRequestDataRelationshipsTeams - ::new().data( - vec![ - EscalationPolicyUpdateRequestDataRelationshipsTeamsDataItems::new( - dd_team_data_id.clone(), - EscalationPolicyUpdateRequestDataRelationshipsTeamsDataItemsType::TEAMS, - ) - ], - ), + let body = EscalationPolicyUpdateRequest::new( + EscalationPolicyUpdateRequestData::new( + EscalationPolicyUpdateRequestDataAttributes::new( + "Example-On-Call-updated".to_string(), + vec![ + EscalationPolicyUpdateRequestDataAttributesStepsItems::new(vec![ + EscalationPolicyStepTarget::new() + .id(user_data_id.clone()) + .type_(EscalationPolicyStepTargetType::USERS), + ]) + .assignment(EscalationPolicyStepAttributesAssignment::DEFAULT) + .escalate_after_seconds(3600) + .id(escalation_policy_data_relationships_steps_data_0_id.clone()), + ], + ) + .description("Example-On-Call".to_string()) + .resolve_page_on_policy_end(false) + .retries(0), + escalation_policy_data_id.clone(), + EscalationPolicyUpdateRequestDataType::POLICIES, + ) + .relationships(EscalationPolicyUpdateRequestDataRelationships::new().teams( + EscalationPolicyUpdateRequestDataRelationshipsTeams::new().data(vec![ + EscalationPolicyUpdateRequestDataRelationshipsTeamsDataItems::new( + dd_team_data_id.clone(), + EscalationPolicyUpdateRequestDataRelationshipsTeamsDataItemsType::TEAMS, ), - ), - ); + ]), + )), + ); let configuration = datadog::Configuration::new(); let api = OnCallAPI::with_config(configuration); let resp = api diff --git a/src/datadogV2/api/api_on_call.rs b/src/datadogV2/api/api_on_call.rs index ef5de0370..c84a1c8df 100644 --- a/src/datadogV2/api/api_on_call.rs +++ b/src/datadogV2/api/api_on_call.rs @@ -74,6 +74,38 @@ impl GetOnCallScheduleOptionalParams { } } +/// GetOnCallTeamRoutingRulesOptionalParams is a struct for passing parameters to the method [`OnCallAPI::get_on_call_team_routing_rules`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetOnCallTeamRoutingRulesOptionalParams { + /// Comma-separated list of included relationships to be returned. Allowed values: `rules`, `rules.policy`. + pub include: Option, +} + +impl GetOnCallTeamRoutingRulesOptionalParams { + /// Comma-separated list of included relationships to be returned. Allowed values: `rules`, `rules.policy`. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + +/// SetOnCallTeamRoutingRulesOptionalParams is a struct for passing parameters to the method [`OnCallAPI::set_on_call_team_routing_rules`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct SetOnCallTeamRoutingRulesOptionalParams { + /// Comma-separated list of included relationships to be returned. Allowed values: `rules`, `rules.policy`. + pub include: Option, +} + +impl SetOnCallTeamRoutingRulesOptionalParams { + /// Comma-separated list of included relationships to be returned. Allowed values: `rules`, `rules.policy`. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// UpdateOnCallEscalationPolicyOptionalParams is a struct for passing parameters to the method [`OnCallAPI::update_on_call_escalation_policy`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -154,6 +186,22 @@ pub enum GetOnCallScheduleError { UnknownValue(serde_json::Value), } +/// GetOnCallTeamRoutingRulesError is a struct for typed errors of method [`OnCallAPI::get_on_call_team_routing_rules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOnCallTeamRoutingRulesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// SetOnCallTeamRoutingRulesError is a struct for typed errors of method [`OnCallAPI::set_on_call_team_routing_rules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SetOnCallTeamRoutingRulesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateOnCallEscalationPolicyError is a struct for typed errors of method [`OnCallAPI::update_on_call_escalation_policy`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -985,6 +1033,296 @@ impl OnCallAPI { } } + /// Get a team's on-call routing rules + pub async fn get_on_call_team_routing_rules( + &self, + team_id: String, + params: GetOnCallTeamRoutingRulesOptionalParams, + ) -> Result< + crate::datadogV2::model::TeamRoutingRules, + datadog::Error, + > { + match self + .get_on_call_team_routing_rules_with_http_info(team_id, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get a team's on-call routing rules + pub async fn get_on_call_team_routing_rules_with_http_info( + &self, + team_id: String, + params: GetOnCallTeamRoutingRulesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_on_call_team_routing_rules"; + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/on-call/teams/{team_id}/routing-rules", + local_configuration.get_operation_host(operation_id), + team_id = datadog::urlencode(team_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Set a team's on-call routing rules + pub async fn set_on_call_team_routing_rules( + &self, + team_id: String, + body: crate::datadogV2::model::TeamRoutingRulesRequest, + params: SetOnCallTeamRoutingRulesOptionalParams, + ) -> Result< + crate::datadogV2::model::TeamRoutingRules, + datadog::Error, + > { + match self + .set_on_call_team_routing_rules_with_http_info(team_id, body, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Set a team's on-call routing rules + pub async fn set_on_call_team_routing_rules_with_http_info( + &self, + team_id: String, + body: crate::datadogV2::model::TeamRoutingRulesRequest, + params: SetOnCallTeamRoutingRulesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.set_on_call_team_routing_rules"; + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/on-call/teams/{team_id}/routing-rules", + local_configuration.get_operation_host(operation_id), + team_id = datadog::urlencode(team_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PUT, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Update an on-call escalation policy pub async fn update_on_call_escalation_policy( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 5604708d5..06253e084 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2552,12 +2552,12 @@ pub mod model_escalation_policy_create_request_data_attributes; pub use self::model_escalation_policy_create_request_data_attributes::EscalationPolicyCreateRequestDataAttributes; pub mod model_escalation_policy_create_request_data_attributes_steps_items; pub use self::model_escalation_policy_create_request_data_attributes_steps_items::EscalationPolicyCreateRequestDataAttributesStepsItems; -pub mod model_escalation_policy_create_request_data_attributes_steps_items_assignment; -pub use self::model_escalation_policy_create_request_data_attributes_steps_items_assignment::EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment; -pub mod model_escalation_policy_create_request_data_attributes_steps_items_targets_items; -pub use self::model_escalation_policy_create_request_data_attributes_steps_items_targets_items::EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems; -pub mod model_escalation_policy_create_request_data_attributes_steps_items_targets_items_type; -pub use self::model_escalation_policy_create_request_data_attributes_steps_items_targets_items_type::EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType; +pub mod model_escalation_policy_step_attributes_assignment; +pub use self::model_escalation_policy_step_attributes_assignment::EscalationPolicyStepAttributesAssignment; +pub mod model_escalation_policy_step_target; +pub use self::model_escalation_policy_step_target::EscalationPolicyStepTarget; +pub mod model_escalation_policy_step_target_type; +pub use self::model_escalation_policy_step_target_type::EscalationPolicyStepTargetType; pub mod model_escalation_policy_create_request_data_relationships; pub use self::model_escalation_policy_create_request_data_relationships::EscalationPolicyCreateRequestDataRelationships; pub mod model_escalation_policy_create_request_data_relationships_teams; @@ -2608,8 +2608,6 @@ pub mod model_escalation_policy_step; pub use self::model_escalation_policy_step::EscalationPolicyStep; pub mod model_escalation_policy_step_attributes; pub use self::model_escalation_policy_step_attributes::EscalationPolicyStepAttributes; -pub mod model_escalation_policy_step_attributes_assignment; -pub use self::model_escalation_policy_step_attributes_assignment::EscalationPolicyStepAttributesAssignment; pub mod model_escalation_policy_step_relationships; pub use self::model_escalation_policy_step_relationships::EscalationPolicyStepRelationships; pub mod model_team_target; @@ -2666,12 +2664,6 @@ pub mod model_escalation_policy_update_request_data_attributes; pub use self::model_escalation_policy_update_request_data_attributes::EscalationPolicyUpdateRequestDataAttributes; pub mod model_escalation_policy_update_request_data_attributes_steps_items; pub use self::model_escalation_policy_update_request_data_attributes_steps_items::EscalationPolicyUpdateRequestDataAttributesStepsItems; -pub mod model_escalation_policy_update_request_data_attributes_steps_items_assignment; -pub use self::model_escalation_policy_update_request_data_attributes_steps_items_assignment::EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment; -pub mod model_escalation_policy_update_request_data_attributes_steps_items_targets_items; -pub use self::model_escalation_policy_update_request_data_attributes_steps_items_targets_items::EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems; -pub mod model_escalation_policy_update_request_data_attributes_steps_items_targets_items_type; -pub use self::model_escalation_policy_update_request_data_attributes_steps_items_targets_items_type::EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType; pub mod model_escalation_policy_update_request_data_relationships; pub use self::model_escalation_policy_update_request_data_relationships::EscalationPolicyUpdateRequestDataRelationships; pub mod model_escalation_policy_update_request_data_relationships_teams; @@ -2786,6 +2778,60 @@ pub mod model_schedule_update_request_data_relationships_teams_data_items_type; pub use self::model_schedule_update_request_data_relationships_teams_data_items_type::ScheduleUpdateRequestDataRelationshipsTeamsDataItemsType; pub mod model_schedule_update_request_data_type; pub use self::model_schedule_update_request_data_type::ScheduleUpdateRequestDataType; +pub mod model_team_routing_rules; +pub use self::model_team_routing_rules::TeamRoutingRules; +pub mod model_team_routing_rules_data; +pub use self::model_team_routing_rules_data::TeamRoutingRulesData; +pub mod model_team_routing_rules_data_relationships; +pub use self::model_team_routing_rules_data_relationships::TeamRoutingRulesDataRelationships; +pub mod model_team_routing_rules_data_relationships_rules; +pub use self::model_team_routing_rules_data_relationships_rules::TeamRoutingRulesDataRelationshipsRules; +pub mod model_team_routing_rules_data_relationships_rules_data_items; +pub use self::model_team_routing_rules_data_relationships_rules_data_items::TeamRoutingRulesDataRelationshipsRulesDataItems; +pub mod model_team_routing_rules_data_relationships_rules_data_items_type; +pub use self::model_team_routing_rules_data_relationships_rules_data_items_type::TeamRoutingRulesDataRelationshipsRulesDataItemsType; +pub mod model_team_routing_rules_data_type; +pub use self::model_team_routing_rules_data_type::TeamRoutingRulesDataType; +pub mod model_routing_rule; +pub use self::model_routing_rule::RoutingRule; +pub mod model_routing_rule_attributes; +pub use self::model_routing_rule_attributes::RoutingRuleAttributes; +pub mod model_slack_action; +pub use self::model_slack_action::SlackAction; +pub mod model_teams_action; +pub use self::model_teams_action::TeamsAction; +pub mod model_routing_rule_action; +pub use self::model_routing_rule_action::RoutingRuleAction; +pub mod model_time_restrictions; +pub use self::model_time_restrictions::TimeRestrictions; +pub mod model_time_restriction; +pub use self::model_time_restriction::TimeRestriction; +pub mod model_weekday; +pub use self::model_weekday::Weekday; +pub mod model_urgency; +pub use self::model_urgency::Urgency; +pub mod model_routing_rule_relationships; +pub use self::model_routing_rule_relationships::RoutingRuleRelationships; +pub mod model_routing_rule_relationships_policy; +pub use self::model_routing_rule_relationships_policy::RoutingRuleRelationshipsPolicy; +pub mod model_routing_rule_relationships_policy_data; +pub use self::model_routing_rule_relationships_policy_data::RoutingRuleRelationshipsPolicyData; +pub mod model_routing_rule_relationships_policy_data_type; +pub use self::model_routing_rule_relationships_policy_data_type::RoutingRuleRelationshipsPolicyDataType; +pub mod model_routing_rule_type; +pub use self::model_routing_rule_type::RoutingRuleType; +pub mod model_team_routing_rules_included; +pub use self::model_team_routing_rules_included::TeamRoutingRulesIncluded; +pub mod model_team_routing_rules_request; +pub use self::model_team_routing_rules_request::TeamRoutingRulesRequest; +pub mod model_team_routing_rules_request_data; +pub use self::model_team_routing_rules_request_data::TeamRoutingRulesRequestData; +pub mod model_team_routing_rules_request_data_attributes; +pub use self::model_team_routing_rules_request_data_attributes::TeamRoutingRulesRequestDataAttributes; +pub mod model_team_routing_rules_request_rule; +pub use self::model_team_routing_rules_request_rule::TeamRoutingRulesRequestRule; +pub mod model_team_routing_rules_request_data_type; +pub use self::model_team_routing_rules_request_data_type::TeamRoutingRulesRequestDataType; pub mod model_org_config_list_response; pub use self::model_org_config_list_response::OrgConfigListResponse; pub mod model_org_config_read; diff --git a/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items.rs b/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items.rs index 8e2f17daa..e64e6b7a0 100644 --- a/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items.rs +++ b/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items.rs @@ -13,17 +13,13 @@ use std::fmt::{self, Formatter}; pub struct EscalationPolicyCreateRequestDataAttributesStepsItems { /// Specifies how this escalation step will assign targets (example `default` or `round-robin`). #[serde(rename = "assignment")] - pub assignment: Option< - crate::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment, - >, + pub assignment: Option, /// Defines how many seconds to wait before escalating to the next step. #[serde(rename = "escalate_after_seconds")] pub escalate_after_seconds: Option, /// Specifies the collection of escalation targets for this step. #[serde(rename = "targets")] - pub targets: Vec< - crate::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems, - >, + pub targets: Vec, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -33,7 +29,7 @@ pub struct EscalationPolicyCreateRequestDataAttributesStepsItems { impl EscalationPolicyCreateRequestDataAttributesStepsItems { pub fn new( - targets: Vec, + targets: Vec, ) -> EscalationPolicyCreateRequestDataAttributesStepsItems { EscalationPolicyCreateRequestDataAttributesStepsItems { assignment: None, @@ -46,7 +42,7 @@ impl EscalationPolicyCreateRequestDataAttributesStepsItems { pub fn assignment( mut self, - value: crate::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment, + value: crate::datadogV2::model::EscalationPolicyStepAttributesAssignment, ) -> Self { self.assignment = Some(value); self @@ -83,9 +79,12 @@ impl<'de> Deserialize<'de> for EscalationPolicyCreateRequestDataAttributesStepsI where M: MapAccess<'a>, { - let mut assignment: Option = None; + let mut assignment: Option< + crate::datadogV2::model::EscalationPolicyStepAttributesAssignment, + > = None; let mut escalate_after_seconds: Option = None; - let mut targets: Option> = None; + let mut targets: Option> = + None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -101,7 +100,7 @@ impl<'de> Deserialize<'de> for EscalationPolicyCreateRequestDataAttributesStepsI assignment = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _assignment) = assignment { match _assignment { - crate::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment::UnparsedObject(_assignment) => { + crate::datadogV2::model::EscalationPolicyStepAttributesAssignment::UnparsedObject(_assignment) => { _unparsed = true; }, _ => {} diff --git a/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_targets_items.rs b/src/datadogV2/model/model_escalation_policy_step_target.rs similarity index 71% rename from src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_targets_items.rs rename to src/datadogV2/model/model_escalation_policy_step_target.rs index 23727c19a..529222993 100644 --- a/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_targets_items.rs +++ b/src/datadogV2/model/model_escalation_policy_step_target.rs @@ -10,23 +10,23 @@ use std::fmt::{self, Formatter}; #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { +pub struct EscalationPolicyStepTarget { /// Specifies the unique identifier for this target. #[serde(rename = "id")] pub id: Option, /// Specifies the type of escalation target (example `users`, `schedules`, or `teams`). #[serde(rename = "type")] - pub type_: Option, + pub type_: Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] #[serde(default)] - pub(crate) _unparsed: bool + pub(crate) _unparsed: bool, } -impl EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { - pub fn new() -> EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { +impl EscalationPolicyStepTarget { + pub fn new() -> EscalationPolicyStepTarget { + EscalationPolicyStepTarget { id: None, type_: None, additional_properties: std::collections::BTreeMap::new(), @@ -39,10 +39,7 @@ impl EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { self } - pub fn type_( - mut self, - value: crate::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType, - ) -> Self { + pub fn type_(mut self, value: crate::datadogV2::model::EscalationPolicyStepTargetType) -> Self { self.type_ = Some(value); self } @@ -56,20 +53,20 @@ impl EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { } } -impl Default for EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { +impl Default for EscalationPolicyStepTarget { fn default() -> Self { Self::new() } } -impl<'de> Deserialize<'de> for EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { +impl<'de> Deserialize<'de> for EscalationPolicyStepTarget { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsVisitor; - impl<'a> Visitor<'a> for EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsVisitor { - type Value = EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems; + struct EscalationPolicyStepTargetVisitor; + impl<'a> Visitor<'a> for EscalationPolicyStepTargetVisitor { + type Value = EscalationPolicyStepTarget; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -80,7 +77,8 @@ impl<'de> Deserialize<'de> for EscalationPolicyCreateRequestDataAttributesStepsI M: MapAccess<'a>, { let mut id: Option = None; - let mut type_: Option = None; + let mut type_: Option = + None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -102,7 +100,7 @@ impl<'de> Deserialize<'de> for EscalationPolicyCreateRequestDataAttributesStepsI type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { match _type_ { - crate::datadogV2::model::EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType::UnparsedObject(_type_) => { + crate::datadogV2::model::EscalationPolicyStepTargetType::UnparsedObject(_type_) => { _unparsed = true; }, _ => {} @@ -117,7 +115,7 @@ impl<'de> Deserialize<'de> for EscalationPolicyCreateRequestDataAttributesStepsI } } - let content = EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItems { + let content = EscalationPolicyStepTarget { id, type_, additional_properties, @@ -128,8 +126,6 @@ impl<'de> Deserialize<'de> for EscalationPolicyCreateRequestDataAttributesStepsI } } - deserializer.deserialize_any( - EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsVisitor, - ) + deserializer.deserialize_any(EscalationPolicyStepTargetVisitor) } } diff --git a/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_targets_items_type.rs b/src/datadogV2/model/model_escalation_policy_step_target_type.rs similarity index 80% rename from src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_targets_items_type.rs rename to src/datadogV2/model/model_escalation_policy_step_target_type.rs index ad95170c8..33ad815eb 100644 --- a/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_targets_items_type.rs +++ b/src/datadogV2/model/model_escalation_policy_step_target_type.rs @@ -6,14 +6,14 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType { +pub enum EscalationPolicyStepTargetType { USERS, SCHEDULES, TEAMS, UnparsedObject(crate::datadog::UnparsedObject), } -impl ToString for EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType { +impl ToString for EscalationPolicyStepTargetType { fn to_string(&self) -> String { match self { Self::USERS => String::from("users"), @@ -24,7 +24,7 @@ impl ToString for EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsIt } } -impl Serialize for EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType { +impl Serialize for EscalationPolicyStepTargetType { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -36,9 +36,7 @@ impl Serialize for EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsI } } -impl<'de> Deserialize<'de> - for EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType -{ +impl<'de> Deserialize<'de> for EscalationPolicyStepTargetType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, diff --git a/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items.rs b/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items.rs index a9af8db25..58f3d5664 100644 --- a/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items.rs +++ b/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items.rs @@ -13,9 +13,7 @@ use std::fmt::{self, Formatter}; pub struct EscalationPolicyUpdateRequestDataAttributesStepsItems { /// Specifies how this escalation step will assign targets (example `default` or `round-robin`). #[serde(rename = "assignment")] - pub assignment: Option< - crate::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment, - >, + pub assignment: Option, /// Defines how many seconds to wait before escalating to the next step. #[serde(rename = "escalate_after_seconds")] pub escalate_after_seconds: Option, @@ -24,9 +22,7 @@ pub struct EscalationPolicyUpdateRequestDataAttributesStepsItems { pub id: Option, /// Specifies the collection of escalation targets for this step. #[serde(rename = "targets")] - pub targets: Vec< - crate::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems, - >, + pub targets: Vec, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -36,7 +32,7 @@ pub struct EscalationPolicyUpdateRequestDataAttributesStepsItems { impl EscalationPolicyUpdateRequestDataAttributesStepsItems { pub fn new( - targets: Vec, + targets: Vec, ) -> EscalationPolicyUpdateRequestDataAttributesStepsItems { EscalationPolicyUpdateRequestDataAttributesStepsItems { assignment: None, @@ -50,7 +46,7 @@ impl EscalationPolicyUpdateRequestDataAttributesStepsItems { pub fn assignment( mut self, - value: crate::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment, + value: crate::datadogV2::model::EscalationPolicyStepAttributesAssignment, ) -> Self { self.assignment = Some(value); self @@ -92,10 +88,13 @@ impl<'de> Deserialize<'de> for EscalationPolicyUpdateRequestDataAttributesStepsI where M: MapAccess<'a>, { - let mut assignment: Option = None; + let mut assignment: Option< + crate::datadogV2::model::EscalationPolicyStepAttributesAssignment, + > = None; let mut escalate_after_seconds: Option = None; let mut id: Option = None; - let mut targets: Option> = None; + let mut targets: Option> = + None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -111,7 +110,7 @@ impl<'de> Deserialize<'de> for EscalationPolicyUpdateRequestDataAttributesStepsI assignment = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _assignment) = assignment { match _assignment { - crate::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment::UnparsedObject(_assignment) => { + crate::datadogV2::model::EscalationPolicyStepAttributesAssignment::UnparsedObject(_assignment) => { _unparsed = true; }, _ => {} diff --git a/src/datadogV2/model/model_routing_rule.rs b/src/datadogV2/model/model_routing_rule.rs new file mode 100644 index 000000000..d75e3cf5d --- /dev/null +++ b/src/datadogV2/model/model_routing_rule.rs @@ -0,0 +1,158 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Represents a routing rule, including its attributes, relationships, and unique identifier. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RoutingRule { + /// Defines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Specifies the unique identifier of this routing rule. + #[serde(rename = "id")] + pub id: Option, + /// Specifies relationships for a routing rule, linking to associated policy resources. + #[serde(rename = "relationships")] + pub relationships: Option, + /// Team routing rules resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::RoutingRuleType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RoutingRule { + pub fn new(type_: crate::datadogV2::model::RoutingRuleType) -> RoutingRule { + RoutingRule { + attributes: None, + id: None, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::RoutingRuleAttributes) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::RoutingRuleRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for RoutingRule { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RoutingRuleVisitor; + impl<'a> Visitor<'a> for RoutingRuleVisitor { + type Value = RoutingRule; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut relationships: Option = + None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::RoutingRuleType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = RoutingRule { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RoutingRuleVisitor) + } +} diff --git a/src/datadogV2/model/model_routing_rule_action.rs b/src/datadogV2/model/model_routing_rule_action.rs new file mode 100644 index 000000000..ea0e4ff5c --- /dev/null +++ b/src/datadogV2/model/model_routing_rule_action.rs @@ -0,0 +1,41 @@ +// 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. +use serde::{Deserialize, Deserializer, Serialize}; + +/// Defines an action that is executed when a routing rule matches certain criteria. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum RoutingRuleAction { + SlackAction(Box), + TeamsAction(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for RoutingRuleAction { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(RoutingRuleAction::SlackAction(_v)); + } + } + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(RoutingRuleAction::TeamsAction(_v)); + } + } + + return Ok(RoutingRuleAction::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_routing_rule_attributes.rs b/src/datadogV2/model/model_routing_rule_attributes.rs new file mode 100644 index 000000000..1ce24e614 --- /dev/null +++ b/src/datadogV2/model/model_routing_rule_attributes.rs @@ -0,0 +1,165 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Defines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RoutingRuleAttributes { + /// Specifies the list of actions to perform when the routing rule matches. + #[serde(rename = "actions")] + pub actions: Option>, + /// Defines the query or condition that triggers this routing rule. + #[serde(rename = "query")] + pub query: Option, + /// Holds time zone information and a list of time restrictions for a routing rule. + #[serde(rename = "time_restriction")] + pub time_restriction: Option, + /// Specifies the level of urgency for a routing rule (low, high, or dynamic). + #[serde(rename = "urgency")] + pub urgency: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RoutingRuleAttributes { + pub fn new() -> RoutingRuleAttributes { + RoutingRuleAttributes { + actions: None, + query: None, + time_restriction: None, + urgency: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn actions(mut self, value: Vec) -> Self { + self.actions = Some(value); + self + } + + pub fn query(mut self, value: String) -> Self { + self.query = Some(value); + self + } + + pub fn time_restriction(mut self, value: crate::datadogV2::model::TimeRestrictions) -> Self { + self.time_restriction = Some(value); + self + } + + pub fn urgency(mut self, value: crate::datadogV2::model::Urgency) -> Self { + self.urgency = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RoutingRuleAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RoutingRuleAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RoutingRuleAttributesVisitor; + impl<'a> Visitor<'a> for RoutingRuleAttributesVisitor { + type Value = RoutingRuleAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut actions: Option> = None; + let mut query: Option = None; + let mut time_restriction: Option = None; + let mut urgency: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "actions" => { + if v.is_null() { + continue; + } + actions = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "query" => { + if v.is_null() { + continue; + } + query = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "time_restriction" => { + if v.is_null() { + continue; + } + time_restriction = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "urgency" => { + if v.is_null() { + continue; + } + urgency = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _urgency) = urgency { + match _urgency { + crate::datadogV2::model::Urgency::UnparsedObject(_urgency) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RoutingRuleAttributes { + actions, + query, + time_restriction, + urgency, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RoutingRuleAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_routing_rule_relationships.rs b/src/datadogV2/model/model_routing_rule_relationships.rs new file mode 100644 index 000000000..616ccb585 --- /dev/null +++ b/src/datadogV2/model/model_routing_rule_relationships.rs @@ -0,0 +1,109 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Specifies relationships for a routing rule, linking to associated policy resources. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RoutingRuleRelationships { + /// Defines the relationship that links a routing rule to a policy. + #[serde(rename = "policy")] + pub policy: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RoutingRuleRelationships { + pub fn new() -> RoutingRuleRelationships { + RoutingRuleRelationships { + policy: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn policy( + mut self, + value: crate::datadogV2::model::RoutingRuleRelationshipsPolicy, + ) -> Self { + self.policy = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RoutingRuleRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RoutingRuleRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RoutingRuleRelationshipsVisitor; + impl<'a> Visitor<'a> for RoutingRuleRelationshipsVisitor { + type Value = RoutingRuleRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut policy: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "policy" => { + if v.is_null() { + continue; + } + policy = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RoutingRuleRelationships { + policy, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RoutingRuleRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_routing_rule_relationships_policy.rs b/src/datadogV2/model/model_routing_rule_relationships_policy.rs new file mode 100644 index 000000000..f60a54426 --- /dev/null +++ b/src/datadogV2/model/model_routing_rule_relationships_policy.rs @@ -0,0 +1,95 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Defines the relationship that links a routing rule to a policy. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RoutingRuleRelationshipsPolicy { + /// Represents the policy data reference, containing the policy's ID and resource type. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::RoutingRuleRelationshipsPolicyData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RoutingRuleRelationshipsPolicy { + pub fn new( + data: crate::datadogV2::model::RoutingRuleRelationshipsPolicyData, + ) -> RoutingRuleRelationshipsPolicy { + RoutingRuleRelationshipsPolicy { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for RoutingRuleRelationshipsPolicy { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RoutingRuleRelationshipsPolicyVisitor; + impl<'a> Visitor<'a> for RoutingRuleRelationshipsPolicyVisitor { + type Value = RoutingRuleRelationshipsPolicy; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = RoutingRuleRelationshipsPolicy { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RoutingRuleRelationshipsPolicyVisitor) + } +} diff --git a/src/datadogV2/model/model_routing_rule_relationships_policy_data.rs b/src/datadogV2/model/model_routing_rule_relationships_policy_data.rs new file mode 100644 index 000000000..27157d180 --- /dev/null +++ b/src/datadogV2/model/model_routing_rule_relationships_policy_data.rs @@ -0,0 +1,115 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Represents the policy data reference, containing the policy's ID and resource type. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RoutingRuleRelationshipsPolicyData { + /// Specifies the unique identifier of the policy. + #[serde(rename = "id")] + pub id: String, + /// Indicates that the resource is of type 'policies'. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::RoutingRuleRelationshipsPolicyDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RoutingRuleRelationshipsPolicyData { + pub fn new( + id: String, + type_: crate::datadogV2::model::RoutingRuleRelationshipsPolicyDataType, + ) -> RoutingRuleRelationshipsPolicyData { + RoutingRuleRelationshipsPolicyData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for RoutingRuleRelationshipsPolicyData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RoutingRuleRelationshipsPolicyDataVisitor; + impl<'a> Visitor<'a> for RoutingRuleRelationshipsPolicyDataVisitor { + type Value = RoutingRuleRelationshipsPolicyData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::RoutingRuleRelationshipsPolicyDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::RoutingRuleRelationshipsPolicyDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = RoutingRuleRelationshipsPolicyData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RoutingRuleRelationshipsPolicyDataVisitor) + } +} diff --git a/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_assignment.rs b/src/datadogV2/model/model_routing_rule_relationships_policy_data_type.rs similarity index 67% rename from src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_assignment.rs rename to src/datadogV2/model/model_routing_rule_relationships_policy_data_type.rs index 694772948..7aaf1f0d3 100644 --- a/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_assignment.rs +++ b/src/datadogV2/model/model_routing_rule_relationships_policy_data_type.rs @@ -6,23 +6,21 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment { - DEFAULT, - ROUND_ROBIN, +pub enum RoutingRuleRelationshipsPolicyDataType { + POLICIES, UnparsedObject(crate::datadog::UnparsedObject), } -impl ToString for EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment { +impl ToString for RoutingRuleRelationshipsPolicyDataType { fn to_string(&self) -> String { match self { - Self::DEFAULT => String::from("default"), - Self::ROUND_ROBIN => String::from("round-robin"), + Self::POLICIES => String::from("policies"), Self::UnparsedObject(v) => v.value.to_string(), } } } -impl Serialize for EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment { +impl Serialize for RoutingRuleRelationshipsPolicyDataType { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -34,15 +32,14 @@ impl Serialize for EscalationPolicyCreateRequestDataAttributesStepsItemsAssignme } } -impl<'de> Deserialize<'de> for EscalationPolicyCreateRequestDataAttributesStepsItemsAssignment { +impl<'de> Deserialize<'de> for RoutingRuleRelationshipsPolicyDataType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let s: String = String::deserialize(deserializer)?; Ok(match s.as_str() { - "default" => Self::DEFAULT, - "round-robin" => Self::ROUND_ROBIN, + "policies" => Self::POLICIES, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), }), diff --git a/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_assignment.rs b/src/datadogV2/model/model_routing_rule_type.rs similarity index 67% rename from src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_assignment.rs rename to src/datadogV2/model/model_routing_rule_type.rs index 8c6ce281a..c6b263672 100644 --- a/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_assignment.rs +++ b/src/datadogV2/model/model_routing_rule_type.rs @@ -6,23 +6,21 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment { - DEFAULT, - ROUND_ROBIN, +pub enum RoutingRuleType { + TEAM_ROUTING_RULES, UnparsedObject(crate::datadog::UnparsedObject), } -impl ToString for EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment { +impl ToString for RoutingRuleType { fn to_string(&self) -> String { match self { - Self::DEFAULT => String::from("default"), - Self::ROUND_ROBIN => String::from("round-robin"), + Self::TEAM_ROUTING_RULES => String::from("team_routing_rules"), Self::UnparsedObject(v) => v.value.to_string(), } } } -impl Serialize for EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment { +impl Serialize for RoutingRuleType { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -34,15 +32,14 @@ impl Serialize for EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignme } } -impl<'de> Deserialize<'de> for EscalationPolicyUpdateRequestDataAttributesStepsItemsAssignment { +impl<'de> Deserialize<'de> for RoutingRuleType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let s: String = String::deserialize(deserializer)?; Ok(match s.as_str() { - "default" => Self::DEFAULT, - "round-robin" => Self::ROUND_ROBIN, + "team_routing_rules" => Self::TEAM_ROUTING_RULES, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), }), diff --git a/src/datadogV2/model/model_slack_action.rs b/src/datadogV2/model/model_slack_action.rs new file mode 100644 index 000000000..3067a7e0e --- /dev/null +++ b/src/datadogV2/model/model_slack_action.rs @@ -0,0 +1,112 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Sends a message to a Slack channel. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SlackAction { + /// The channel ID. + #[serde(rename = "channel")] + pub channel: String, + /// Must be set to "send_slack_message". + #[serde(rename = "type")] + pub type_: String, + /// The workspace ID. + #[serde(rename = "workspace")] + pub workspace: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SlackAction { + pub fn new(channel: String, type_: String, workspace: String) -> SlackAction { + SlackAction { + channel, + type_, + workspace, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SlackAction { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SlackActionVisitor; + impl<'a> Visitor<'a> for SlackActionVisitor { + type Value = SlackAction; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut channel: Option = None; + let mut type_: Option = None; + let mut workspace: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "channel" => { + channel = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "workspace" => { + workspace = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let channel = channel.ok_or_else(|| M::Error::missing_field("channel"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + let workspace = workspace.ok_or_else(|| M::Error::missing_field("workspace"))?; + + let content = SlackAction { + channel, + type_, + workspace, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SlackActionVisitor) + } +} diff --git a/src/datadogV2/model/model_team_routing_rules.rs b/src/datadogV2/model/model_team_routing_rules.rs new file mode 100644 index 000000000..c2aaa4ada --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules.rs @@ -0,0 +1,126 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Represents a complete set of team routing rules, including data and optionally included related resources. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRoutingRules { + /// Represents the top-level data object for team routing rules, containing the ID, relationships, and resource type. + #[serde(rename = "data")] + pub data: Option, + /// Provides related routing rules or other included resources. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRoutingRules { + pub fn new() -> TeamRoutingRules { + TeamRoutingRules { + data: None, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::TeamRoutingRulesData) -> Self { + self.data = Some(value); + self + } + + pub fn included( + mut self, + value: Vec, + ) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamRoutingRules { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRules { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRoutingRulesVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesVisitor { + type Value = TeamRoutingRules; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut included: Option> = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamRoutingRules { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRoutingRulesVisitor) + } +} diff --git a/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_targets_items.rs b/src/datadogV2/model/model_team_routing_rules_data.rs similarity index 63% rename from src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_targets_items.rs rename to src/datadogV2/model/model_team_routing_rules_data.rs index db0e41390..c2a11373c 100644 --- a/src/datadogV2/model/model_escalation_policy_update_request_data_attributes_steps_items_targets_items.rs +++ b/src/datadogV2/model/model_team_routing_rules_data.rs @@ -6,29 +6,33 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// Defines a single escalation target within a step for an escalation policy update request. Contains `id` and `type`. +/// Represents the top-level data object for team routing rules, containing the ID, relationships, and resource type. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { - /// Specifies the unique identifier for this target. +pub struct TeamRoutingRulesData { + /// Specifies the unique identifier of this team routing rules record. #[serde(rename = "id")] pub id: Option, - /// Specifies the type of escalation target (example `users`, `schedules`, or `teams`). + /// Specifies relationships for team routing rules, including rule references. + #[serde(rename = "relationships")] + pub relationships: Option, + /// Team routing rules resource type. #[serde(rename = "type")] - pub type_: Option, + pub type_: crate::datadogV2::model::TeamRoutingRulesDataType, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] #[serde(default)] - pub(crate) _unparsed: bool + pub(crate) _unparsed: bool, } -impl EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { - pub fn new() -> EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { - EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { +impl TeamRoutingRulesData { + pub fn new(type_: crate::datadogV2::model::TeamRoutingRulesDataType) -> TeamRoutingRulesData { + TeamRoutingRulesData { id: None, - type_: None, + relationships: None, + type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } @@ -39,11 +43,11 @@ impl EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { self } - pub fn type_( + pub fn relationships( mut self, - value: crate::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType, + value: crate::datadogV2::model::TeamRoutingRulesDataRelationships, ) -> Self { - self.type_ = Some(value); + self.relationships = Some(value); self } @@ -56,20 +60,14 @@ impl EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { } } -impl Default for EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { - fn default() -> Self { - Self::new() - } -} - -impl<'de> Deserialize<'de> for EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { +impl<'de> Deserialize<'de> for TeamRoutingRulesData { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsVisitor; - impl<'a> Visitor<'a> for EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsVisitor { - type Value = EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems; + struct TeamRoutingRulesDataVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesDataVisitor { + type Value = TeamRoutingRulesData; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -80,7 +78,10 @@ impl<'de> Deserialize<'de> for EscalationPolicyUpdateRequestDataAttributesStepsI M: MapAccess<'a>, { let mut id: Option = None; - let mut type_: Option = None; + let mut relationships: Option< + crate::datadogV2::model::TeamRoutingRulesDataRelationships, + > = None; + let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -95,14 +96,18 @@ impl<'de> Deserialize<'de> for EscalationPolicyUpdateRequestDataAttributesStepsI } id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } - "type" => { + "relationships" => { if v.is_null() { continue; } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { match _type_ { - crate::datadogV2::model::EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsType::UnparsedObject(_type_) => { + crate::datadogV2::model::TeamRoutingRulesDataType::UnparsedObject(_type_) => { _unparsed = true; }, _ => {} @@ -116,9 +121,11 @@ impl<'de> Deserialize<'de> for EscalationPolicyUpdateRequestDataAttributesStepsI } } } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; - let content = EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItems { + let content = TeamRoutingRulesData { id, + relationships, type_, additional_properties, _unparsed, @@ -128,8 +135,6 @@ impl<'de> Deserialize<'de> for EscalationPolicyUpdateRequestDataAttributesStepsI } } - deserializer.deserialize_any( - EscalationPolicyUpdateRequestDataAttributesStepsItemsTargetsItemsVisitor, - ) + deserializer.deserialize_any(TeamRoutingRulesDataVisitor) } } diff --git a/src/datadogV2/model/model_team_routing_rules_data_relationships.rs b/src/datadogV2/model/model_team_routing_rules_data_relationships.rs new file mode 100644 index 000000000..a3c0292d2 --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_data_relationships.rs @@ -0,0 +1,110 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Specifies relationships for team routing rules, including rule references. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRoutingRulesDataRelationships { + /// Holds references to a set of routing rules in a relationship. + #[serde(rename = "rules")] + pub rules: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRoutingRulesDataRelationships { + pub fn new() -> TeamRoutingRulesDataRelationships { + TeamRoutingRulesDataRelationships { + rules: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn rules( + mut self, + value: crate::datadogV2::model::TeamRoutingRulesDataRelationshipsRules, + ) -> Self { + self.rules = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamRoutingRulesDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRoutingRulesDataRelationshipsVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesDataRelationshipsVisitor { + type Value = TeamRoutingRulesDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut rules: Option< + crate::datadogV2::model::TeamRoutingRulesDataRelationshipsRules, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "rules" => { + if v.is_null() { + continue; + } + rules = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamRoutingRulesDataRelationships { + rules, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRoutingRulesDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_team_routing_rules_data_relationships_rules.rs b/src/datadogV2/model/model_team_routing_rules_data_relationships_rules.rs new file mode 100644 index 000000000..e7c7c473a --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_data_relationships_rules.rs @@ -0,0 +1,110 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Holds references to a set of routing rules in a relationship. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRoutingRulesDataRelationshipsRules { + /// An array of references to the routing rules associated with this team. + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRoutingRulesDataRelationshipsRules { + pub fn new() -> TeamRoutingRulesDataRelationshipsRules { + TeamRoutingRulesDataRelationshipsRules { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamRoutingRulesDataRelationshipsRules { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesDataRelationshipsRules { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRoutingRulesDataRelationshipsRulesVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesDataRelationshipsRulesVisitor { + type Value = TeamRoutingRulesDataRelationshipsRules; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamRoutingRulesDataRelationshipsRules { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRoutingRulesDataRelationshipsRulesVisitor) + } +} diff --git a/src/datadogV2/model/model_team_routing_rules_data_relationships_rules_data_items.rs b/src/datadogV2/model/model_team_routing_rules_data_relationships_rules_data_items.rs new file mode 100644 index 000000000..8fd55e62d --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_data_relationships_rules_data_items.rs @@ -0,0 +1,115 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Defines a relationship item to link a routing rule by its ID and type. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRoutingRulesDataRelationshipsRulesDataItems { + /// Specifies the unique identifier for the related routing rule. + #[serde(rename = "id")] + pub id: String, + /// Indicates that the resource is of type 'team_routing_rules'. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamRoutingRulesDataRelationshipsRulesDataItemsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRoutingRulesDataRelationshipsRulesDataItems { + pub fn new( + id: String, + type_: crate::datadogV2::model::TeamRoutingRulesDataRelationshipsRulesDataItemsType, + ) -> TeamRoutingRulesDataRelationshipsRulesDataItems { + TeamRoutingRulesDataRelationshipsRulesDataItems { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesDataRelationshipsRulesDataItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRoutingRulesDataRelationshipsRulesDataItemsVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesDataRelationshipsRulesDataItemsVisitor { + type Value = TeamRoutingRulesDataRelationshipsRulesDataItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::TeamRoutingRulesDataRelationshipsRulesDataItemsType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamRoutingRulesDataRelationshipsRulesDataItemsType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamRoutingRulesDataRelationshipsRulesDataItems { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRoutingRulesDataRelationshipsRulesDataItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_targets_items_type.rs b/src/datadogV2/model/model_team_routing_rules_data_relationships_rules_data_items_type.rs similarity index 63% rename from src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_targets_items_type.rs rename to src/datadogV2/model/model_team_routing_rules_data_relationships_rules_data_items_type.rs index 761cdacd1..6abe8afc1 100644 --- a/src/datadogV2/model/model_escalation_policy_create_request_data_attributes_steps_items_targets_items_type.rs +++ b/src/datadogV2/model/model_team_routing_rules_data_relationships_rules_data_items_type.rs @@ -6,25 +6,21 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType { - USERS, - SCHEDULES, - TEAMS, +pub enum TeamRoutingRulesDataRelationshipsRulesDataItemsType { + TEAM_ROUTING_RULES, UnparsedObject(crate::datadog::UnparsedObject), } -impl ToString for EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType { +impl ToString for TeamRoutingRulesDataRelationshipsRulesDataItemsType { fn to_string(&self) -> String { match self { - Self::USERS => String::from("users"), - Self::SCHEDULES => String::from("schedules"), - Self::TEAMS => String::from("teams"), + Self::TEAM_ROUTING_RULES => String::from("team_routing_rules"), Self::UnparsedObject(v) => v.value.to_string(), } } } -impl Serialize for EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType { +impl Serialize for TeamRoutingRulesDataRelationshipsRulesDataItemsType { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -36,18 +32,14 @@ impl Serialize for EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsI } } -impl<'de> Deserialize<'de> - for EscalationPolicyCreateRequestDataAttributesStepsItemsTargetsItemsType -{ +impl<'de> Deserialize<'de> for TeamRoutingRulesDataRelationshipsRulesDataItemsType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let s: String = String::deserialize(deserializer)?; Ok(match s.as_str() { - "users" => Self::USERS, - "schedules" => Self::SCHEDULES, - "teams" => Self::TEAMS, + "team_routing_rules" => Self::TEAM_ROUTING_RULES, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), }), diff --git a/src/datadogV2/model/model_team_routing_rules_data_type.rs b/src/datadogV2/model/model_team_routing_rules_data_type.rs new file mode 100644 index 000000000..da2739329 --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_data_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TeamRoutingRulesDataType { + TEAM_ROUTING_RULES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TeamRoutingRulesDataType { + fn to_string(&self) -> String { + match self { + Self::TEAM_ROUTING_RULES => String::from("team_routing_rules"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TeamRoutingRulesDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "team_routing_rules" => Self::TEAM_ROUTING_RULES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_team_routing_rules_included.rs b/src/datadogV2/model/model_team_routing_rules_included.rs new file mode 100644 index 000000000..85acc7339 --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_included.rs @@ -0,0 +1,33 @@ +// 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. +use serde::{Deserialize, Deserializer, Serialize}; + +/// Represents additional included resources for team routing rules, such as associated routing rules. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum TeamRoutingRulesIncluded { + RoutingRule(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesIncluded { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(TeamRoutingRulesIncluded::RoutingRule(_v)); + } + } + + return Ok(TeamRoutingRulesIncluded::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_team_routing_rules_request.rs b/src/datadogV2/model/model_team_routing_rules_request.rs new file mode 100644 index 000000000..7bc12d522 --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_request.rs @@ -0,0 +1,105 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Represents a request to create or update team routing rules, including the data payload. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRoutingRulesRequest { + /// Holds the data necessary to create or update team routing rules, including attributes, ID, and resource type. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRoutingRulesRequest { + pub fn new() -> TeamRoutingRulesRequest { + TeamRoutingRulesRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::TeamRoutingRulesRequestData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamRoutingRulesRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRoutingRulesRequestVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesRequestVisitor { + type Value = TeamRoutingRulesRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamRoutingRulesRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRoutingRulesRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_team_routing_rules_request_data.rs b/src/datadogV2/model/model_team_routing_rules_request_data.rs new file mode 100644 index 000000000..f028d381e --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_request_data.rs @@ -0,0 +1,142 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Holds the data necessary to create or update team routing rules, including attributes, ID, and resource type. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRoutingRulesRequestData { + /// Represents the attributes of a request to update or create team routing rules. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Specifies the unique identifier for this set of team routing rules. + #[serde(rename = "id")] + pub id: Option, + /// Team routing rules resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamRoutingRulesRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRoutingRulesRequestData { + pub fn new( + type_: crate::datadogV2::model::TeamRoutingRulesRequestDataType, + ) -> TeamRoutingRulesRequestData { + TeamRoutingRulesRequestData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::TeamRoutingRulesRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRoutingRulesRequestDataVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesRequestDataVisitor { + type Value = TeamRoutingRulesRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::TeamRoutingRulesRequestDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamRoutingRulesRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamRoutingRulesRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRoutingRulesRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_team_routing_rules_request_data_attributes.rs b/src/datadogV2/model/model_team_routing_rules_request_data_attributes.rs new file mode 100644 index 000000000..04e49cca9 --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_request_data_attributes.rs @@ -0,0 +1,109 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Represents the attributes of a request to update or create team routing rules. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRoutingRulesRequestDataAttributes { + /// A list of routing rule items that define how incoming pages should be handled. + #[serde(rename = "rules")] + pub rules: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRoutingRulesRequestDataAttributes { + pub fn new() -> TeamRoutingRulesRequestDataAttributes { + TeamRoutingRulesRequestDataAttributes { + rules: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn rules( + mut self, + value: Vec, + ) -> Self { + self.rules = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamRoutingRulesRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRoutingRulesRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesRequestDataAttributesVisitor { + type Value = TeamRoutingRulesRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut rules: Option> = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "rules" => { + if v.is_null() { + continue; + } + rules = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamRoutingRulesRequestDataAttributes { + rules, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRoutingRulesRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_team_routing_rules_request_data_type.rs b/src/datadogV2/model/model_team_routing_rules_request_data_type.rs new file mode 100644 index 000000000..64e1241db --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_request_data_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TeamRoutingRulesRequestDataType { + TEAM_ROUTING_RULES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TeamRoutingRulesRequestDataType { + fn to_string(&self) -> String { + match self { + Self::TEAM_ROUTING_RULES => String::from("team_routing_rules"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TeamRoutingRulesRequestDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "team_routing_rules" => Self::TEAM_ROUTING_RULES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_team_routing_rules_request_rule.rs b/src/datadogV2/model/model_team_routing_rules_request_rule.rs new file mode 100644 index 000000000..1382e5d22 --- /dev/null +++ b/src/datadogV2/model/model_team_routing_rules_request_rule.rs @@ -0,0 +1,182 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Defines an individual routing rule item that contains the rule data for the request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamRoutingRulesRequestRule { + /// Specifies the list of actions to perform when the routing rule is matched. + #[serde(rename = "actions")] + pub actions: Option>, + /// Identifies the policy to be applied when this routing rule matches. + #[serde(rename = "policy_id")] + pub policy_id: Option, + /// Defines the query or condition that triggers this routing rule. + #[serde(rename = "query")] + pub query: Option, + /// Holds time zone information and a list of time restrictions for a routing rule. + #[serde(rename = "time_restriction")] + pub time_restriction: Option, + /// Specifies the level of urgency for a routing rule (low, high, or dynamic). + #[serde(rename = "urgency")] + pub urgency: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamRoutingRulesRequestRule { + pub fn new() -> TeamRoutingRulesRequestRule { + TeamRoutingRulesRequestRule { + actions: None, + policy_id: None, + query: None, + time_restriction: None, + urgency: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn actions(mut self, value: Vec) -> Self { + self.actions = Some(value); + self + } + + pub fn policy_id(mut self, value: String) -> Self { + self.policy_id = Some(value); + self + } + + pub fn query(mut self, value: String) -> Self { + self.query = Some(value); + self + } + + pub fn time_restriction(mut self, value: crate::datadogV2::model::TimeRestrictions) -> Self { + self.time_restriction = Some(value); + self + } + + pub fn urgency(mut self, value: crate::datadogV2::model::Urgency) -> Self { + self.urgency = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamRoutingRulesRequestRule { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamRoutingRulesRequestRule { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamRoutingRulesRequestRuleVisitor; + impl<'a> Visitor<'a> for TeamRoutingRulesRequestRuleVisitor { + type Value = TeamRoutingRulesRequestRule; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut actions: Option> = None; + let mut policy_id: Option = None; + let mut query: Option = None; + let mut time_restriction: Option = None; + let mut urgency: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "actions" => { + if v.is_null() { + continue; + } + actions = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "policy_id" => { + if v.is_null() { + continue; + } + policy_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "query" => { + if v.is_null() { + continue; + } + query = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "time_restriction" => { + if v.is_null() { + continue; + } + time_restriction = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "urgency" => { + if v.is_null() { + continue; + } + urgency = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _urgency) = urgency { + match _urgency { + crate::datadogV2::model::Urgency::UnparsedObject(_urgency) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamRoutingRulesRequestRule { + actions, + policy_id, + query, + time_restriction, + urgency, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamRoutingRulesRequestRuleVisitor) + } +} diff --git a/src/datadogV2/model/model_teams_action.rs b/src/datadogV2/model/model_teams_action.rs new file mode 100644 index 000000000..e0d17b9b6 --- /dev/null +++ b/src/datadogV2/model/model_teams_action.rs @@ -0,0 +1,122 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Sends a message to a Microsoft Teams channel. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamsAction { + /// The channel ID. + #[serde(rename = "channel")] + pub channel: String, + /// The team ID. + #[serde(rename = "team")] + pub team: String, + /// The tenant ID. + #[serde(rename = "tenant")] + pub tenant: String, + /// Must be set to "send_teams_message". + #[serde(rename = "type")] + pub type_: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamsAction { + pub fn new(channel: String, team: String, tenant: String, type_: String) -> TeamsAction { + TeamsAction { + channel, + team, + tenant, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamsAction { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamsActionVisitor; + impl<'a> Visitor<'a> for TeamsActionVisitor { + type Value = TeamsAction; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut channel: Option = None; + let mut team: Option = None; + let mut tenant: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "channel" => { + channel = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "team" => { + team = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tenant" => { + tenant = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let channel = channel.ok_or_else(|| M::Error::missing_field("channel"))?; + let team = team.ok_or_else(|| M::Error::missing_field("team"))?; + let tenant = tenant.ok_or_else(|| M::Error::missing_field("tenant"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamsAction { + channel, + team, + tenant, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamsActionVisitor) + } +} diff --git a/src/datadogV2/model/model_time_restriction.rs b/src/datadogV2/model/model_time_restriction.rs new file mode 100644 index 000000000..35805c144 --- /dev/null +++ b/src/datadogV2/model/model_time_restriction.rs @@ -0,0 +1,174 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Defines a single time restriction rule with start and end times and the applicable weekdays. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TimeRestriction { + /// A day of the week. + #[serde(rename = "end_day")] + pub end_day: Option, + /// Specifies the ending time for this restriction. + #[serde(rename = "end_time")] + pub end_time: Option, + /// A day of the week. + #[serde(rename = "start_day")] + pub start_day: Option, + /// Specifies the starting time for this restriction. + #[serde(rename = "start_time")] + pub start_time: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TimeRestriction { + pub fn new() -> TimeRestriction { + TimeRestriction { + end_day: None, + end_time: None, + start_day: None, + start_time: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn end_day(mut self, value: crate::datadogV2::model::Weekday) -> Self { + self.end_day = Some(value); + self + } + + pub fn end_time(mut self, value: String) -> Self { + self.end_time = Some(value); + self + } + + pub fn start_day(mut self, value: crate::datadogV2::model::Weekday) -> Self { + self.start_day = Some(value); + self + } + + pub fn start_time(mut self, value: String) -> Self { + self.start_time = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TimeRestriction { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TimeRestriction { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TimeRestrictionVisitor; + impl<'a> Visitor<'a> for TimeRestrictionVisitor { + type Value = TimeRestriction; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut end_day: Option = None; + let mut end_time: Option = None; + let mut start_day: Option = None; + let mut start_time: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "end_day" => { + if v.is_null() { + continue; + } + end_day = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _end_day) = end_day { + match _end_day { + crate::datadogV2::model::Weekday::UnparsedObject(_end_day) => { + _unparsed = true; + } + _ => {} + } + } + } + "end_time" => { + if v.is_null() { + continue; + } + end_time = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "start_day" => { + if v.is_null() { + continue; + } + start_day = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _start_day) = start_day { + match _start_day { + crate::datadogV2::model::Weekday::UnparsedObject( + _start_day, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "start_time" => { + if v.is_null() { + continue; + } + start_time = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TimeRestriction { + end_day, + end_time, + start_day, + start_time, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TimeRestrictionVisitor) + } +} diff --git a/src/datadogV2/model/model_time_restrictions.rs b/src/datadogV2/model/model_time_restrictions.rs new file mode 100644 index 000000000..c2f8f1513 --- /dev/null +++ b/src/datadogV2/model/model_time_restrictions.rs @@ -0,0 +1,107 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Holds time zone information and a list of time restrictions for a routing rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TimeRestrictions { + /// Defines the list of time-based restrictions. + #[serde(rename = "restrictions")] + pub restrictions: Vec, + /// Specifies the time zone applicable to the restrictions. + #[serde(rename = "time_zone")] + pub time_zone: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TimeRestrictions { + pub fn new( + restrictions: Vec, + time_zone: String, + ) -> TimeRestrictions { + TimeRestrictions { + restrictions, + time_zone, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TimeRestrictions { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TimeRestrictionsVisitor; + impl<'a> Visitor<'a> for TimeRestrictionsVisitor { + type Value = TimeRestrictions; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut restrictions: Option> = None; + let mut time_zone: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "restrictions" => { + restrictions = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "time_zone" => { + time_zone = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let restrictions = + restrictions.ok_or_else(|| M::Error::missing_field("restrictions"))?; + let time_zone = time_zone.ok_or_else(|| M::Error::missing_field("time_zone"))?; + + let content = TimeRestrictions { + restrictions, + time_zone, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TimeRestrictionsVisitor) + } +} diff --git a/src/datadogV2/model/model_urgency.rs b/src/datadogV2/model/model_urgency.rs new file mode 100644 index 000000000..a00e6a7f4 --- /dev/null +++ b/src/datadogV2/model/model_urgency.rs @@ -0,0 +1,54 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Urgency { + LOW, + HIGH, + DYNAMIC, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for Urgency { + fn to_string(&self) -> String { + match self { + Self::LOW => String::from("low"), + Self::HIGH => String::from("high"), + Self::DYNAMIC => String::from("dynamic"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for Urgency { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for Urgency { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "low" => Self::LOW, + "high" => Self::HIGH, + "dynamic" => Self::DYNAMIC, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_weekday.rs b/src/datadogV2/model/model_weekday.rs new file mode 100644 index 000000000..93e6125a0 --- /dev/null +++ b/src/datadogV2/model/model_weekday.rs @@ -0,0 +1,66 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Weekday { + MONDAY, + TUESDAY, + WEDNESDAY, + THURSDAY, + FRIDAY, + SATURDAY, + SUNDAY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for Weekday { + fn to_string(&self) -> String { + match self { + Self::MONDAY => String::from("monday"), + Self::TUESDAY => String::from("tuesday"), + Self::WEDNESDAY => String::from("wednesday"), + Self::THURSDAY => String::from("thursday"), + Self::FRIDAY => String::from("friday"), + Self::SATURDAY => String::from("saturday"), + Self::SUNDAY => String::from("sunday"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for Weekday { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for Weekday { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "monday" => Self::MONDAY, + "tuesday" => Self::TUESDAY, + "wednesday" => Self::WEDNESDAY, + "thursday" => Self::THURSDAY, + "friday" => Self::FRIDAY, + "saturday" => Self::SATURDAY, + "sunday" => Self::SUNDAY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/cassettes/v2/on-call/Set-on-call-team-routing-rules-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/on-call/Set-on-call-team-routing-rules-returns-OK-response.frozen new file mode 100644 index 000000000..aa8d3dd92 --- /dev/null +++ b/tests/scenarios/cassettes/v2/on-call/Set-on-call-team-routing-rules-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-05-02T07:28:35.869Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/on-call/Set-on-call-team-routing-rules-returns-OK-response.json b/tests/scenarios/cassettes/v2/on-call/Set-on-call-team-routing-rules-returns-OK-response.json new file mode 100644 index 000000000..137cab333 --- /dev/null +++ b/tests/scenarios/cassettes/v2/on-call/Set-on-call-team-routing-rules-returns-OK-response.json @@ -0,0 +1,279 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"email\":\"Test-Set_on_call_team_routing_rules_returns_OK_response-1746170915@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/users" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"users\",\"id\":\"0f6790f5-2727-11f0-a9cb-b6ff84ad8646\",\"attributes\":{\"name\":null,\"handle\":\"test-set_on_call_team_routing_rules_returns_ok_response-1746170915@datadoghq.com\",\"created_at\":\"2025-05-02T07:28:36.413905+00:00\",\"modified_at\":\"2025-05-02T07:28:36.413905+00:00\",\"email\":\"test-set_on_call_team_routing_rules_returns_ok_response-1746170915@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b9e2f38a22d0273582e08252ffbae94a?s=48&d=retro\",\"title\":\"user title\",\"verified\":false,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Pending\"},\"relationships\":{\"roles\":{\"data\":[]},\"org\":{\"data\":{\"type\":\"orgs\",\"id\":\"4dee724d-00cc-11ea-a77b-570c9d03c6c5\"}}}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-f6cbca2a9dc51017\",\"name\":\"test-name-f6cbca2a9dc51017\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"team\",\"id\":\"0db9884c-62de-4b52-ae74-1d256d8ecb75\",\"attributes\":{\"name\":\"test-name-f6cbca2a9dc51017\",\"handle\":\"test-handle-f6cbca2a9dc51017\",\"summary\":null,\"description\":null,\"avatar\":null,\"banner\":9,\"visible_modules\":[],\"hidden_modules\":[],\"created_at\":\"2025-05-02T07:28:36.528008+00:00\",\"modified_at\":\"2025-05-02T07:28:36.528018+00:00\",\"user_count\":0,\"link_count\":0},\"relationships\":{\"team_links\":{\"links\":{\"related\":\"/api/v2/team/0db9884c-62de-4b52-ae74-1d256d8ecb75/links\"}},\"user_team_permissions\":{\"links\":{\"related\":\"/api/v2/team/0db9884c-62de-4b52-ae74-1d256d8ecb75/permission-settings\"}}}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"layers\":[{\"effective_date\":\"2025-04-22T07:28:35.869Z\",\"end_date\":\"2025-05-12T07:28:35.869Z\",\"interval\":{\"days\":1},\"members\":[{\"user\":{\"id\":\"890f29d4-0b7a-11f0-aeb2-760fcae4f596\"}}],\"name\":\"Layer 1\",\"restrictions\":[{\"end_day\":\"friday\",\"end_time\":\"17:00:00\",\"start_day\":\"monday\",\"start_time\":\"09:00:00\"}],\"rotation_start\":\"2025-04-27T07:28:35.869Z\"}],\"name\":\"Test-Set_on_call_team_routing_rules_returns_OK_response-1746170915\",\"tags\":[\"tag1\",\"tag2\"],\"time_zone\":\"America/New_York\"},\"relationships\":{\"teams\":{\"data\":[{\"id\":\"65aea9d0-941c-4607-bf8a-14fc0dac2820\",\"type\":\"teams\"}]}},\"type\":\"schedules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/on-call/schedules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"f4ae5b94-3985-490a-bdc0-e7f64890968c\",\"type\":\"schedules\",\"attributes\":{\"name\":\"Test-Set_on_call_team_routing_rules_returns_OK_response-1746170915\",\"tags\":[\"tag1\",\"tag2\"],\"time_zone\":\"America/New_York\"},\"relationships\":{\"layers\":{\"data\":[{\"id\":\"498723e5-43d7-407c-b7cb-171e9c08f402\",\"type\":\"layers\"}]},\"teams\":{\"data\":[{\"id\":\"65aea9d0-941c-4607-bf8a-14fc0dac2820\",\"type\":\"teams\"}]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"description\":\"Test-Set_on_call_team_routing_rules_returns_OK_response-1746170915\",\"name\":\"Test-Set_on_call_team_routing_rules_returns_OK_response-1746170915\",\"resolve_page_on_policy_end\":true,\"retries\":2,\"steps\":[{\"assignment\":\"default\",\"escalate_after_seconds\":3600,\"targets\":[{\"id\":\"0db9884c-62de-4b52-ae74-1d256d8ecb75\",\"type\":\"teams\"},{\"id\":\"f4ae5b94-3985-490a-bdc0-e7f64890968c\",\"type\":\"schedules\"},{\"id\":\"0f6790f5-2727-11f0-a9cb-b6ff84ad8646\",\"type\":\"users\"}]},{\"assignment\":\"round-robin\",\"escalate_after_seconds\":3600,\"targets\":[{\"id\":\"0db9884c-62de-4b52-ae74-1d256d8ecb75\",\"type\":\"teams\"}]}]},\"relationships\":{\"teams\":{\"data\":[{\"id\":\"0db9884c-62de-4b52-ae74-1d256d8ecb75\",\"type\":\"teams\"}]}},\"type\":\"policies\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/on-call/escalation-policies" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"b79d430d-1e03-4840-a933-a1ee9baae339\",\"type\":\"policies\",\"attributes\":{\"description\":\"Test-Set_on_call_team_routing_rules_returns_OK_response-1746170915\",\"name\":\"Test-Set_on_call_team_routing_rules_returns_OK_response-1746170915\",\"resolve_page_on_policy_end\":true,\"retries\":2},\"relationships\":{\"steps\":{\"data\":[{\"id\":\"46b170a7-ad4a-4cc3-b933-386af8fbee11\",\"type\":\"steps\"},{\"id\":\"11c45a97-a232-4f34-a086-77005522ea7a\",\"type\":\"steps\"}]},\"teams\":{\"data\":[{\"id\":\"0db9884c-62de-4b52-ae74-1d256d8ecb75\",\"type\":\"teams\"}]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"rules\":[{\"actions\":[{\"channel\":\"channel\",\"type\":\"send_slack_message\",\"workspace\":\"workspace\"}],\"query\":\"tags.service:test\",\"time_restriction\":{\"restrictions\":[{\"end_day\":\"monday\",\"end_time\":\"17:00:00\",\"start_day\":\"monday\",\"start_time\":\"09:00:00\"},{\"end_day\":\"tuesday\",\"end_time\":\"17:00:00\",\"start_day\":\"tuesday\",\"start_time\":\"09:00:00\"}],\"time_zone\":\"Europe/Paris\"},\"urgency\":\"high\"},{\"policy_id\":\"b79d430d-1e03-4840-a933-a1ee9baae339\",\"query\":\"\",\"urgency\":\"low\"}]},\"id\":\"0db9884c-62de-4b52-ae74-1d256d8ecb75\",\"type\":\"team_routing_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/on-call/teams/0db9884c-62de-4b52-ae74-1d256d8ecb75/routing-rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"0db9884c-62de-4b52-ae74-1d256d8ecb75\",\"type\":\"team_routing_rules\",\"relationships\":{\"rules\":{\"data\":[{\"id\":\"virtual-0db9884c-62de-4b52-ae74-1d256d8ecb75-rule-0\",\"type\":\"team_routing_rules\"},{\"id\":\"virtual-0db9884c-62de-4b52-ae74-1d256d8ecb75-rule-1\",\"type\":\"team_routing_rules\"}]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/on-call/escalation-policies/b79d430d-1e03-4840-a933-a1ee9baae339" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"policy[b79d430d-1e03-4840-a933-a1ee9baae339] is in use\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 409, + "message": "Conflict" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/on-call/schedules/f4ae5b94-3985-490a-bdc0-e7f64890968c" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"schedule[f4ae5b94-3985-490a-bdc0-e7f64890968c] is in use\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 409, + "message": "Conflict" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/0db9884c-62de-4b52-ae74-1d256d8ecb75" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/users/0f6790f5-2727-11f0-a9cb-b6ff84ad8646" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Fri, 02 May 2025 07:28:35 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 950b601c7..7b12664d3 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -496,6 +496,18 @@ "tag": "On-Call", "operationId": "CreateOnCallSchedule" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"rules\": [\n {\n \"query\": \"\",\n \"policy_id\": \"{{ escalation_policy.data.id }}\",\n \"urgency\": \"low\",\n \"time_restriction\": null,\n \"actions\": []\n }\n ]\n }\n }\n}" + } + ], + "step": "there are valid \"routing_rules\" in the system", + "key": "routing_rules", + "tag": "On-Call", + "operationId": "SetOnCallTeamRoutingRules" + }, { "source": "data[4]", "step": "there is a valid \"permission\" in the system", diff --git a/tests/scenarios/features/v2/on-call.feature b/tests/scenarios/features/v2/on-call.feature index bacb4828a..0597e0b99 100644 --- a/tests/scenarios/features/v2/on-call.feature +++ b/tests/scenarios/features/v2/on-call.feature @@ -115,6 +115,25 @@ Feature: On-Call When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/bugle + Scenario: Get on-call team routing rules returns "OK" response + Given new "GetOnCallTeamRoutingRules" request + And request contains "team_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @skip-python @team:DataDog/bugle + Scenario: Set on-call team routing rules returns "OK" response + Given new "SetOnCallTeamRoutingRules" request + And there is a valid "user" in the system + And there is a valid "dd_team" in the system + And there is a valid "schedule" in the system + And there is a valid "escalation_policy" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And body with value {"data": {"attributes": {"rules": [{"actions": [{"channel": "channel", "type": "send_slack_message", "workspace": "workspace"}], "query": "tags.service:test", "time_restriction": {"time_zone": "Europe/Paris", "restrictions": [{"end_day": "monday", "end_time": "17:00:00", "start_day": "monday", "start_time": "09:00:00"}, {"end_day": "tuesday", "end_time": "17:00:00", "start_day": "tuesday", "start_time": "09:00:00"}]}, "urgency": "high"}, {"policy_id": "{{ escalation_policy.data.id }}", "query": "", "urgency": "low"}]}, "id": "{{ dd_team.data.id }}", "type": "team_routing_rules"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/bugle Scenario: Update on-call escalation policy returns "Bad Request" response Given new "UpdateOnCallEscalationPolicy" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index c1daab385..6e56bb443 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1915,6 +1915,18 @@ "type": "idempotent" } }, + "GetOnCallTeamRoutingRules": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "SetOnCallTeamRoutingRules": { + "tag": "On-Call", + "undo": { + "type": "idempotent" + } + }, "ListOrgConfigs": { "tag": "Organizations", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 944f5e390..a97554f95 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -2990,6 +2990,14 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.UpdateOnCallSchedule".into(), test_v2_update_on_call_schedule, ); + world.function_mappings.insert( + "v2.GetOnCallTeamRoutingRules".into(), + test_v2_get_on_call_team_routing_rules, + ); + world.function_mappings.insert( + "v2.SetOnCallTeamRoutingRules".into(), + test_v2_set_on_call_team_routing_rules, + ); world .function_mappings .insert("v2.ListOrgConfigs".into(), test_v2_list_org_configs); @@ -22337,6 +22345,75 @@ fn test_v2_update_on_call_schedule(world: &mut DatadogWorld, _parameters: &HashM world.response.code = response.status.as_u16(); } +fn test_v2_get_on_call_team_routing_rules( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_on_call + .as_ref() + .expect("api instance not found"); + let team_id = serde_json::from_value(_parameters.get("team_id").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_on_call::GetOnCallTeamRoutingRulesOptionalParams::default(); + params.include = include; + let response = + match block_on(api.get_on_call_team_routing_rules_with_http_info(team_id, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_set_on_call_team_routing_rules( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_on_call + .as_ref() + .expect("api instance not found"); + let team_id = serde_json::from_value(_parameters.get("team_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_on_call::SetOnCallTeamRoutingRulesOptionalParams::default(); + params.include = include; + let response = + match block_on(api.set_on_call_team_routing_rules_with_http_info(team_id, body, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_org_configs(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances