diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 590c8e62b..72c53b807 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -9354,6 +9354,110 @@ components: - name - expression type: object + CampaignResponse: + description: Response containing campaign data. + properties: + data: + $ref: '#/components/schemas/CampaignResponseData' + required: + - data + type: object + CampaignResponseAttributes: + description: Campaign attributes. + properties: + created_at: + description: Creation time of the campaign. + example: '2023-12-15T10:30:00Z' + format: date-time + type: string + description: + description: The description of the campaign. + example: Campaign to improve security posture for Q1 2024. + type: string + due_date: + description: The due date of the campaign. + example: '2024-03-31T23:59:59Z' + format: date-time + type: string + entity_scope: + description: Entity scope query to filter entities for this campaign. + example: kind:service AND team:platform + type: string + guidance: + description: Guidance for the campaign. + example: Please ensure all services pass the security requirements. + type: string + key: + description: The unique key for the campaign. + example: q1-security-2024 + type: string + modified_at: + description: Time of last campaign modification. + example: '2024-01-05T14:20:00Z' + format: date-time + type: string + name: + description: The name of the campaign. + example: Q1 Security Campaign + type: string + owner: + description: The UUID of the campaign owner. + example: 550e8400-e29b-41d4-a716-446655440000 + type: string + start_date: + description: The start date of the campaign. + example: '2024-01-01T00:00:00Z' + format: date-time + type: string + status: + description: The status of the campaign. + example: in_progress + type: string + required: + - key + - name + - owner + - status + - start_date + - created_at + - modified_at + type: object + CampaignResponseData: + description: Campaign data. + properties: + attributes: + $ref: '#/components/schemas/CampaignResponseAttributes' + id: + description: The unique ID of the campaign. + example: c10ODp0VCrrIpXmz + type: string + type: + $ref: '#/components/schemas/CampaignType' + required: + - id + - type + - attributes + type: object + CampaignStatus: + description: The status of the campaign. + enum: + - in_progress + - not_started + - completed + example: in_progress + type: string + x-enum-varnames: + - IN_PROGRESS + - NOT_STARTED + - COMPLETED + CampaignType: + description: The JSON:API type for campaigns. + enum: + - campaign + example: campaign + type: string + x-enum-varnames: + - CAMPAIGN CancelDataDeletionResponseBody: description: The response from the cancel data deletion request endpoint. properties: @@ -13801,6 +13905,79 @@ components: example: Postmortem-IR-123 type: string type: object + CreateCampaignRequest: + description: Request to create a new campaign. + properties: + data: + $ref: '#/components/schemas/CreateCampaignRequestData' + required: + - data + type: object + CreateCampaignRequestAttributes: + description: Attributes for creating a new campaign. + properties: + description: + description: The description of the campaign. + example: Campaign to improve security posture for Q1 2024. + type: string + due_date: + description: The due date of the campaign. + example: '2024-03-31T23:59:59Z' + format: date-time + type: string + entity_scope: + description: Entity scope query to filter entities for this campaign. + example: kind:service AND team:platform + type: string + guidance: + description: Guidance for the campaign. + example: Please ensure all services pass the security requirements. + type: string + key: + description: The unique key for the campaign. + example: q1-security-2024 + type: string + name: + description: The name of the campaign. + example: Q1 Security Campaign + type: string + owner_id: + description: The UUID of the campaign owner. + example: 550e8400-e29b-41d4-a716-446655440000 + type: string + rule_ids: + description: Array of rule IDs associated with this campaign. + example: + - q8MQxk8TCqrHnWkx + - r9NRyl9UDrsIoXly + items: + type: string + type: array + start_date: + description: The start date of the campaign. + example: '2024-01-01T00:00:00Z' + format: date-time + type: string + status: + $ref: '#/components/schemas/CampaignStatus' + required: + - name + - key + - owner_id + - start_date + - rule_ids + type: object + CreateCampaignRequestData: + description: Data for creating a new campaign. + properties: + attributes: + $ref: '#/components/schemas/CreateCampaignRequestAttributes' + type: + $ref: '#/components/schemas/CampaignType' + required: + - type + - attributes + type: object CreateCaseRequestArray: description: List of requests to create cases for security findings. properties: @@ -19191,6 +19368,62 @@ components: example: 1722439510282 format: int64 type: integer + DefaultRuleResponseAttributes: + description: Default rule attributes. + properties: + description: + description: The description of the default rule. + example: Service has at least one SLO defined. + type: string + level: + description: The maturity level of the rule. + example: 2 + format: int64 + type: integer + name: + description: The name of the default rule. + example: SLOs Defined + type: string + scope_required: + description: Required scope for the rule. + example: kind:service + type: string + scorecard_description: + description: The description of the scorecard. + example: Best practices for observability. + type: string + scorecard_name: + description: The scorecard this rule belongs to. + example: Observability Best Practices + type: string + required: + - name + - scorecard_name + type: object + DefaultRuleResponseData: + description: Default rule data. + properties: + attributes: + $ref: '#/components/schemas/DefaultRuleResponseAttributes' + id: + description: The unique ID of the default rule. + example: q8MQxk8TCqrHnWkx + type: string + type: + $ref: '#/components/schemas/DefaultRuleType' + required: + - id + - type + - attributes + type: object + DefaultRuleType: + description: The JSON:API type for default rules. + enum: + - default-rule + example: default-rule + type: string + x-enum-varnames: + - DEFAULT_RULE Degradation: properties: data: @@ -20956,6 +21189,19 @@ components: description: The origin. type: string type: object + EntityOwnerDestination: + description: Entity owner and Slack destination for team reports. + properties: + slack: + $ref: '#/components/schemas/SlackRoutingOptions' + team_id: + description: Team UUID. + example: 550e8400-e29b-41d4-a716-446655440000 + type: string + required: + - team_id + - slack + type: object EntityRaw: description: Entity definition in raw JSON or YAML representation. example: "apiVersion: v3\nkind: service\nmetadata:\n name: myservice" @@ -23573,6 +23819,66 @@ components: type: string x-enum-varnames: - USERS_FACET_INFO + FacetItem: + description: Facet item with count. + properties: + name: + description: The name of the facet value. + example: platform + type: string + value: + description: The count for this facet value. + example: 42 + format: int64 + type: integer + required: + - name + - value + type: object + FacetResponseAttributes: + description: Facet attributes. + properties: + items: + description: Array of facet values. + items: + $ref: '#/components/schemas/FacetItem' + type: array + key: + description: The key of the facet. + example: team + type: string + name: + description: The display name of the facet. + example: Team + type: string + required: + - key + - items + type: object + FacetResponseData: + description: Facet data. + properties: + attributes: + $ref: '#/components/schemas/FacetResponseAttributes' + id: + description: The unique ID of the facet. + example: team + type: string + type: + $ref: '#/components/schemas/FacetType' + required: + - id + - type + - attributes + type: object + FacetType: + description: The JSON:API type for facets. + enum: + - facet + example: facet + type: string + x-enum-varnames: + - FACET FastlyAPIKey: description: The definition of the `FastlyAPIKey` object. properties: @@ -26866,6 +27172,82 @@ components: required: - type type: object + GenerateCampaignReportRequest: + description: Request to generate a campaign report. + properties: + data: + $ref: '#/components/schemas/GenerateCampaignReportRequestData' + required: + - data + type: object + GenerateCampaignReportRequestAttributes: + description: Attributes for generating a campaign report. + properties: + slack: + $ref: '#/components/schemas/SlackRoutingOptions' + required: + - slack + type: object + GenerateCampaignReportRequestData: + description: Data for generating a campaign report. + properties: + attributes: + $ref: '#/components/schemas/GenerateCampaignReportRequestAttributes' + type: + $ref: '#/components/schemas/GenerateCampaignReportRequestDataType' + required: + - type + - attributes + type: object + GenerateCampaignReportRequestDataType: + enum: + - campaign-report + example: campaign-report + type: string + x-enum-varnames: + - CAMPAIGN_REPORT + GenerateCampaignTeamReportsRequest: + description: Request to generate team-specific campaign reports. + properties: + data: + $ref: '#/components/schemas/GenerateCampaignTeamReportsRequestData' + required: + - data + type: object + GenerateCampaignTeamReportsRequestAttributes: + description: Attributes for generating team campaign reports. + properties: + entity_owners: + description: List of entity owners and their Slack destinations. + example: + - slack: + channel_id: C024BDQ4N + workspace_id: T024BDQ4N + team_id: 550e8400-e29b-41d4-a716-446655440000 + items: + $ref: '#/components/schemas/EntityOwnerDestination' + type: array + required: + - entity_owners + type: object + GenerateCampaignTeamReportsRequestData: + description: Data for generating team campaign reports. + properties: + attributes: + $ref: '#/components/schemas/GenerateCampaignTeamReportsRequestAttributes' + type: + $ref: '#/components/schemas/GenerateCampaignTeamReportsRequestDataType' + required: + - type + - attributes + type: object + GenerateCampaignTeamReportsRequestDataType: + enum: + - campaign-team-report + example: campaign-team-report + type: string + x-enum-varnames: + - CAMPAIGN_TEAM_REPORT GetActionConnectionResponse: description: The response for found connection properties: @@ -33757,6 +34139,22 @@ components: required: - data type: object + ListCampaignsResponse: + description: Response containing a list of campaigns. + properties: + data: + $ref: '#/components/schemas/ListCampaignsResponseData' + meta: + $ref: '#/components/schemas/PaginatedResponseMeta' + required: + - data + - meta + type: object + ListCampaignsResponseData: + description: Array of campaigns. + items: + $ref: '#/components/schemas/CampaignResponseData' + type: array ListConnectionsResponse: example: data: @@ -33855,6 +34253,19 @@ components: type: string x-enum-varnames: - LIST_CONNECTIONS_RESPONSE + ListDefaultRulesResponse: + description: Response containing a list of default rules. + properties: + data: + $ref: '#/components/schemas/ListDefaultRulesResponseData' + required: + - data + type: object + ListDefaultRulesResponseData: + description: Array of default rules. + items: + $ref: '#/components/schemas/DefaultRuleResponseData' + type: array ListDeploymentRuleResponseData: description: Data for a list of deployment rules. properties: @@ -33966,6 +34377,33 @@ components: description: Current link. type: string type: object + ListFacetsResponse: + description: Response containing a list of facets. + properties: + data: + $ref: '#/components/schemas/ListFacetsResponseData' + meta: + $ref: '#/components/schemas/ListFacetsResponseMeta' + required: + - data + - meta + type: object + ListFacetsResponseData: + description: Array of facets. + items: + $ref: '#/components/schemas/FacetResponseData' + type: array + ListFacetsResponseMeta: + description: Metadata for facets response. + properties: + total_entities: + description: Total number of entities. + example: 150 + format: int64 + type: integer + required: + - total_entities + type: object ListFindingsData: description: Array of findings. items: @@ -34162,6 +34600,35 @@ components: example: /api/v2/scorecard/rules?page%5Blimit%5D=2&page%5Boffset%5D=2&page%5Bsize%5D=2 type: string type: object + ListScorecardsResponse: + description: Response containing a list of scorecards. + properties: + data: + $ref: '#/components/schemas/ListScorecardsResponseData' + required: + - data + type: object + ListScorecardsResponseData: + description: Array of scorecards. + items: + $ref: '#/components/schemas/ScorecardListResponseData' + type: array + ListScoresResponse: + description: Response containing a list of scores. + properties: + data: + $ref: '#/components/schemas/ListScoresResponseData' + meta: + $ref: '#/components/schemas/PaginatedResponseMeta' + required: + - data + - meta + type: object + ListScoresResponseData: + description: Array of scores. + items: + $ref: '#/components/schemas/ScoreResponseData' + type: array ListSecurityFindingsResponse: description: The expected response schema when listing security findings. properties: @@ -45002,6 +45469,35 @@ components: x-enum-varnames: - LOW - HIGH + PaginatedResponseMeta: + description: Metadata for scores response. + properties: + count: + description: Number of entities in this response. + example: 10 + format: int64 + type: integer + limit: + description: Pagination limit. + example: 10 + format: int64 + type: integer + offset: + description: Pagination offset. + example: 0 + format: int64 + type: integer + total: + description: Total number of entities available. + example: 150 + format: int64 + type: integer + required: + - count + - total + - limit + - offset + type: object Pagination: description: Pagination object. properties: @@ -52686,6 +53182,132 @@ components: type: string x-enum-varnames: - USERS + ScoreResponseAttributes: + description: Score attributes. + properties: + aggregation: + description: The aggregation type. + example: by-entity + type: string + denominator: + description: Score denominator. + example: 18 + format: int64 + type: integer + numerator: + description: Score numerator. + example: 15 + format: int64 + type: integer + score: + description: Calculated score value. + example: 0.833 + format: double + type: number + total_fail: + description: Total number of failing rules. + example: 3 + format: int64 + type: integer + total_no_data: + description: Total number of rules with no data. + example: 1 + format: int64 + type: integer + total_pass: + description: Total number of passing rules. + example: 15 + format: int64 + type: integer + total_skip: + description: Total number of skipped rules. + example: 2 + format: int64 + type: integer + required: + - aggregation + - total_pass + - total_fail + - total_skip + - total_no_data + - numerator + - denominator + - score + type: object + ScoreResponseData: + description: Score data. + properties: + attributes: + $ref: '#/components/schemas/ScoreResponseAttributes' + id: + description: The unique ID of the score entity. + example: service:my-service + type: string + type: + $ref: '#/components/schemas/ScoreType' + required: + - id + - type + - attributes + type: object + ScoreType: + description: The JSON:API type for scores. + enum: + - score + example: score + type: string + x-enum-varnames: + - SCORE + ScorecardListResponseAttributes: + description: Scorecard attributes. + properties: + created_at: + description: Creation time of the scorecard. + example: '2023-01-15T10:30:00Z' + format: date-time + type: string + description: + description: The description of the scorecard. + example: Best practices for observability. + type: string + modified_at: + description: Time of last scorecard modification. + example: '2024-01-05T14:20:00Z' + format: date-time + type: string + name: + description: The name of the scorecard. + example: Observability Best Practices + type: string + required: + - name + - created_at + - modified_at + type: object + ScorecardListResponseData: + description: Scorecard data. + properties: + attributes: + $ref: '#/components/schemas/ScorecardListResponseAttributes' + id: + description: The unique ID of the scorecard. + example: q8MQxk8TCqrHnWkx + type: string + type: + $ref: '#/components/schemas/ScorecardListType' + required: + - id + - type + - attributes + type: object + ScorecardListType: + description: The JSON:API type for scorecard list. + enum: + - scorecard + example: scorecard + type: string + x-enum-varnames: + - SCORECARD ScorecardType: default: scorecard description: The JSON:API type for scorecard. @@ -58922,6 +59544,44 @@ components: required: - type type: object + SetupRulesRequest: + description: Request to set up rules for an organization. + properties: + data: + $ref: '#/components/schemas/SetupRulesRequestData' + required: + - data + type: object + SetupRulesRequestAttributes: + description: Attributes for setting up rules. + properties: + disabled_default_rules: + description: Array of default rule IDs to disable. + example: + - q8MQxk8TCqrHnWkx + - r9NRyl9UDrsIoXly + items: + type: string + type: array + type: object + SetupRulesRequestData: + description: Data for setting up rules. + properties: + attributes: + $ref: '#/components/schemas/SetupRulesRequestAttributes' + type: + $ref: '#/components/schemas/SetupRulesRequestDataType' + required: + - type + - attributes + type: object + SetupRulesRequestDataType: + enum: + - setup + example: setup + type: string + x-enum-varnames: + - SETUP Shift: description: An on-call shift with its associated data and relationships. example: @@ -59310,6 +59970,26 @@ components: - channel_name - redirect_url type: object + SlackRoutingOptions: + description: Slack routing options for report delivery. + properties: + channel_id: + description: Slack channel ID. + example: C024BDQ4N + type: string + channel_name: + description: Slack channel name. + example: service-scorecards + type: string + workspace_id: + description: Slack workspace ID. + example: T024BDQ4N + type: string + workspace_name: + description: Slack workspace name. + example: datadog-workspace + type: string + type: object SlackTriggerWrapper: description: Schema for a Slack-based trigger. properties: @@ -65310,6 +65990,81 @@ components: description: The display name of the datastore. type: string type: object + UpdateCampaignRequest: + description: Request to update a campaign. + properties: + data: + $ref: '#/components/schemas/UpdateCampaignRequestData' + required: + - data + type: object + UpdateCampaignRequestAttributes: + description: Attributes for updating a campaign. + properties: + description: + description: The description of the campaign. + example: Campaign to improve security posture for Q1 2024. + type: string + due_date: + description: The due date of the campaign. + example: '2024-03-31T23:59:59Z' + format: date-time + type: string + entity_scope: + description: Entity scope query to filter entities for this campaign. + example: kind:service AND team:platform + type: string + guidance: + description: Guidance for the campaign. + example: Please ensure all services pass the security requirements. + type: string + key: + description: The unique key for the campaign. + example: q1-security-2024 + type: string + name: + description: The name of the campaign. + example: Q1 Security Campaign + type: string + owner_id: + description: The UUID of the campaign owner. + example: 550e8400-e29b-41d4-a716-446655440000 + type: string + rule_ids: + description: Array of rule IDs associated with this campaign. + example: + - q8MQxk8TCqrHnWkx + - r9NRyl9UDrsIoXly + items: + type: string + type: array + start_date: + description: The start date of the campaign. + example: '2024-01-01T00:00:00Z' + format: date-time + type: string + status: + description: The status of the campaign. + example: in_progress + type: string + required: + - name + - owner_id + - status + - start_date + - rule_ids + type: object + UpdateCampaignRequestData: + description: Data for updating a campaign. + properties: + attributes: + $ref: '#/components/schemas/UpdateCampaignRequestAttributes' + type: + $ref: '#/components/schemas/CampaignType' + required: + - type + - attributes + type: object UpdateConnectionRequest: example: data: @@ -93131,6 +93886,476 @@ paths: operator: OR permissions: - org_management + /api/v2/scorecard/campaigns: + get: + description: Fetches all scorecard campaigns. + operationId: ListScorecardCampaigns + parameters: + - description: Maximum number of campaigns to return. + in: query + name: page[limit] + required: false + schema: + default: 10 + example: 10 + format: int64 + type: integer + - description: Offset for pagination. + in: query + name: page[offset] + required: false + schema: + default: 0 + example: 0 + format: int64 + type: integer + - description: Filter campaigns by name (full-text search). + in: query + name: filter[campaign][name] + required: false + schema: + example: security + type: string + - description: Filter campaigns by status. + in: query + name: filter[campaign][status] + required: false + schema: + example: in_progress + type: string + - description: Filter campaigns by owner UUID. + in: query + name: filter[campaign][owner] + required: false + schema: + example: 550e8400-e29b-41d4-a716-446655440000 + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListCampaignsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + - cases_read + summary: List all campaigns + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Creates a new scorecard campaign. + operationId: CreateScorecardCampaign + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateCampaignRequest' + description: Campaign data. + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/CampaignResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_write + - cases_write + summary: Create a new campaign + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/campaigns/{campaign_id}: + delete: + description: Deletes a single campaign by ID or key. + operationId: DeleteScorecardCampaign + parameters: + - description: Campaign ID or key. + in: path + name: campaign_id + required: true + schema: + example: c10ODp0VCrrIpXmz + type: string + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_write + - cases_write + summary: Delete a campaign + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Fetches a single campaign by ID or key. + operationId: GetScorecardCampaign + parameters: + - description: Campaign ID or key. + in: path + name: campaign_id + required: true + schema: + example: c10ODp0VCrrIpXmz + type: string + - description: Include related data (for example, scores). + in: query + name: include + required: false + schema: + example: scores + type: string + - description: Include metadata (entity and rule counts). + in: query + name: include_meta + required: false + schema: + example: true + type: boolean + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CampaignResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + - cases_read + summary: Get a campaign + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + put: + description: Updates an existing campaign. + operationId: UpdateScorecardCampaign + parameters: + - description: Campaign ID or key. + in: path + name: campaign_id + required: true + schema: + example: c10ODp0VCrrIpXmz + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateCampaignRequest' + description: Campaign data. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CampaignResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_write + - cases_write + summary: Update a campaign + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/campaigns/{campaign_id}/entity-owner-report: + post: + description: Generates and sends team-specific campaign reports to Slack. + operationId: GenerateScorecardCampaignTeamReports + parameters: + - description: Campaign ID. + in: path + name: campaign_id + required: true + schema: + example: c10ODp0VCrrIpXmz + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GenerateCampaignTeamReportsRequest' + description: Team report generation request. + required: true + responses: + '202': + description: Accepted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + - cases_read + summary: Generate team-specific campaign reports + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/campaigns/{campaign_id}/report: + post: + description: Generates and sends a campaign report to Slack. + operationId: GenerateScorecardCampaignReport + parameters: + - description: Campaign ID. + in: path + name: campaign_id + required: true + schema: + example: c10ODp0VCrrIpXmz + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GenerateCampaignReportRequest' + description: Report generation request. + required: true + responses: + '202': + description: Accepted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + - cases_read + summary: Generate campaign report + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/default-rules: + get: + description: Fetches all default scorecard rules available for the organization. + operationId: ListScorecardDefaultRules + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListDefaultRulesResponse' + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + summary: List default rules + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/facets: + get: + description: Fetches facets for scorecard entities with counts. + operationId: ListScorecardFacets + parameters: + - description: Entity query filter. + in: query + name: filter[entity][query] + required: false + schema: + example: kind:service AND team:platform + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListFacetsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + summary: List entity facets + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/scorecard/outcomes: get: description: Fetches all rule outcomes. @@ -93159,21 +94384,21 @@ paths: schema: example: name type: string - - description: Filter the outcomes on a specific service name. + - description: Filter outcomes on a specific service name. in: query name: filter[outcome][service_name] required: false schema: example: web-store type: string - - description: Filter the outcomes by a specific state. + - description: Filter outcomes by a specific state. in: query name: filter[outcome][state] required: false schema: example: fail type: string - - description: Filter outcomes on whether a rule is enabled/disabled. + - description: Filter outcomes based on whether a rule is enabled or disabled. in: query name: filter[rule][enabled] required: false @@ -93219,7 +94444,7 @@ paths: limitParam: page[size] pageOffsetParam: page[offset] resultsPath: data - x-unstable: '**Note**: This endpoint is in public beta. + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: @@ -93252,7 +94477,7 @@ paths: tags: - Service Scorecards x-codegen-request-body-name: body - x-unstable: '**Note**: This endpoint is in public beta. + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/scorecard/outcomes/batch: @@ -93288,7 +94513,7 @@ paths: tags: - Service Scorecards x-codegen-request-body-name: body - x-unstable: '**Note**: This endpoint is in public beta. + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/scorecard/rules: @@ -93380,7 +94605,7 @@ paths: limitParam: page[size] pageOffsetParam: page[offset] resultsPath: data - x-unstable: '**Note**: This endpoint is in public beta. + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: @@ -93415,7 +94640,7 @@ paths: tags: - Service Scorecards x-codegen-request-body-name: body - x-unstable: '**Note**: This endpoint is in public beta. + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/scorecard/rules/{rule_id}: @@ -93443,7 +94668,7 @@ paths: summary: Delete a rule tags: - Service Scorecards - x-unstable: '**Note**: This endpoint is in public beta. + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' put: @@ -93480,7 +94705,309 @@ paths: tags: - Service Scorecards x-codegen-request-body-name: body - x-unstable: '**Note**: This endpoint is in public beta. + x-unstable: '**Note**: This endpoint is in Preview. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/rules/{rule_id}/workflow: + delete: + description: Removes workflow association from a scorecard rule. + operationId: DeleteScorecardRuleWorkflow + parameters: + - $ref: '#/components/parameters/RuleId' + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_write + summary: Delete rule workflow + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/rules/{rule_id}/workflow/{workflow_id}: + put: + description: Associates a workflow with a scorecard rule. + operationId: UpdateScorecardRuleWorkflow + parameters: + - $ref: '#/components/parameters/RuleId' + - description: Workflow ID. + in: path + name: workflow_id + required: true + schema: + example: 550e8400-e29b-41d4-a716-446655440000 + type: string + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_write + summary: Associate workflow with rule + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/scorecards: + get: + description: Fetches all scorecards. + operationId: ListScorecards + parameters: + - description: Offset for pagination. + in: query + name: page[offset] + required: false + schema: + default: 0 + example: 0 + format: int64 + type: integer + - description: Maximum number of scorecards to return. + in: query + name: page[size] + required: false + schema: + default: 100 + example: 10 + format: int64 + type: integer + - description: Filter by scorecard ID. + in: query + name: filter[scorecard][id] + required: false + schema: + example: q8MQxk8TCqrHnWkx + type: string + - description: Filter by scorecard name (partial match). + in: query + name: filter[scorecard][name] + required: false + schema: + example: Observability + type: string + - description: Filter by scorecard description (partial match). + in: query + name: filter[scorecard][description] + required: false + schema: + example: Best Practices + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListScorecardsResponse' + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + summary: List all scorecards + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/scores/{aggregation}: + get: + description: Fetches scorecard scores aggregated by entity, rule, scorecard, + service, or team. + operationId: ListScorecardScores + parameters: + - description: Aggregation type (by-entity, by-rule, by-scorecard, by-service, + by-team). + in: path + name: aggregation + required: true + schema: + example: by-entity + type: string + - description: Maximum number of scores to return. + in: query + name: page[limit] + required: false + schema: + default: 100 + example: 10 + format: int64 + type: integer + - description: Offset for pagination. + in: query + name: page[offset] + required: false + schema: + default: 0 + example: 0 + format: int64 + type: integer + - description: Entity query filter. + in: query + name: filter[entity][query] + required: false + schema: + example: kind:service AND team:platform + type: string + - description: Filter by rule IDs (comma-separated). + in: query + name: filter[rule][id] + required: false + schema: + example: q8MQxk8TCqrHnWkx + type: string + - description: Filter by rule enabled status. + in: query + name: filter[rule][enabled] + required: false + schema: + example: true + type: boolean + - description: Filter by custom rules. + in: query + name: filter[rule][custom] + required: false + schema: + example: false + type: boolean + - description: Sort order (comma-separated list of fields; prefix a field with + - for descending order). + in: query + name: sort + required: false + schema: + example: score,-total_fail + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListScoresResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + summary: List scores by aggregation + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/scorecard/setup: + post: + description: Sets up default scorecard rules for the organization. + operationId: SetupScorecardRules + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SetupRulesRequest' + description: Setup rules request. + required: true + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_write + summary: Set up rules for organization + tags: + - Service Scorecards + x-unstable: '**Note**: This endpoint is in Preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/seats/users: diff --git a/examples/v2_service-scorecards_CreateScorecardCampaign.rs b/examples/v2_service-scorecards_CreateScorecardCampaign.rs new file mode 100644 index 000000000..9af9105cf --- /dev/null +++ b/examples/v2_service-scorecards_CreateScorecardCampaign.rs @@ -0,0 +1,46 @@ +// Create a new campaign returns "Created" response +use chrono::{DateTime, Utc}; +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; +use datadog_api_client::datadogV2::model::CampaignStatus; +use datadog_api_client::datadogV2::model::CampaignType; +use datadog_api_client::datadogV2::model::CreateCampaignRequest; +use datadog_api_client::datadogV2::model::CreateCampaignRequestAttributes; +use datadog_api_client::datadogV2::model::CreateCampaignRequestData; + +#[tokio::main] +async fn main() { + let body = CreateCampaignRequest::new(CreateCampaignRequestData::new( + CreateCampaignRequestAttributes::new( + "q1-security-2024".to_string(), + "Q1 Security Campaign".to_string(), + "550e8400-e29b-41d4-a716-446655440000".to_string(), + vec![ + "q8MQxk8TCqrHnWkx".to_string(), + "r9NRyl9UDrsIoXly".to_string(), + ], + DateTime::parse_from_rfc3339("2024-01-01T00:00:00+00:00") + .expect("Failed to parse datetime") + .with_timezone(&Utc), + ) + .description("Campaign to improve security posture for Q1 2024.".to_string()) + .due_date( + DateTime::parse_from_rfc3339("2024-03-31T23:59:59+00:00") + .expect("Failed to parse datetime") + .with_timezone(&Utc), + ) + .entity_scope("kind:service AND team:platform".to_string()) + .guidance("Please ensure all services pass the security requirements.".to_string()) + .status(CampaignStatus::IN_PROGRESS), + CampaignType::CAMPAIGN, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateScorecardCampaign", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api.create_scorecard_campaign(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_DeleteScorecardCampaign.rs b/examples/v2_service-scorecards_DeleteScorecardCampaign.rs new file mode 100644 index 000000000..0d218ce07 --- /dev/null +++ b/examples/v2_service-scorecards_DeleteScorecardCampaign.rs @@ -0,0 +1,18 @@ +// Delete a campaign returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteScorecardCampaign", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .delete_scorecard_campaign("c10ODp0VCrrIpXmz".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_DeleteScorecardRuleWorkflow.rs b/examples/v2_service-scorecards_DeleteScorecardRuleWorkflow.rs new file mode 100644 index 000000000..288729c93 --- /dev/null +++ b/examples/v2_service-scorecards_DeleteScorecardRuleWorkflow.rs @@ -0,0 +1,18 @@ +// Delete rule workflow returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteScorecardRuleWorkflow", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .delete_scorecard_rule_workflow("rule_id".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_GenerateScorecardCampaignReport.rs b/examples/v2_service-scorecards_GenerateScorecardCampaignReport.rs new file mode 100644 index 000000000..b4147cf38 --- /dev/null +++ b/examples/v2_service-scorecards_GenerateScorecardCampaignReport.rs @@ -0,0 +1,33 @@ +// Generate campaign report returns "Accepted" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; +use datadog_api_client::datadogV2::model::GenerateCampaignReportRequest; +use datadog_api_client::datadogV2::model::GenerateCampaignReportRequestAttributes; +use datadog_api_client::datadogV2::model::GenerateCampaignReportRequestData; +use datadog_api_client::datadogV2::model::GenerateCampaignReportRequestDataType; +use datadog_api_client::datadogV2::model::SlackRoutingOptions; + +#[tokio::main] +async fn main() { + let body = GenerateCampaignReportRequest::new(GenerateCampaignReportRequestData::new( + GenerateCampaignReportRequestAttributes::new( + SlackRoutingOptions::new() + .channel_id("C024BDQ4N".to_string()) + .channel_name("service-scorecards".to_string()) + .workspace_id("T024BDQ4N".to_string()) + .workspace_name("datadog-workspace".to_string()), + ), + GenerateCampaignReportRequestDataType::CAMPAIGN_REPORT, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GenerateScorecardCampaignReport", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .generate_scorecard_campaign_report("c10ODp0VCrrIpXmz".to_string(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_GenerateScorecardCampaignTeamReports.rs b/examples/v2_service-scorecards_GenerateScorecardCampaignTeamReports.rs new file mode 100644 index 000000000..63dd1b7ae --- /dev/null +++ b/examples/v2_service-scorecards_GenerateScorecardCampaignTeamReports.rs @@ -0,0 +1,34 @@ +// Generate team-specific campaign reports returns "Accepted" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; +use datadog_api_client::datadogV2::model::EntityOwnerDestination; +use datadog_api_client::datadogV2::model::GenerateCampaignTeamReportsRequest; +use datadog_api_client::datadogV2::model::GenerateCampaignTeamReportsRequestAttributes; +use datadog_api_client::datadogV2::model::GenerateCampaignTeamReportsRequestData; +use datadog_api_client::datadogV2::model::GenerateCampaignTeamReportsRequestDataType; +use datadog_api_client::datadogV2::model::SlackRoutingOptions; + +#[tokio::main] +async fn main() { + let body = + GenerateCampaignTeamReportsRequest::new(GenerateCampaignTeamReportsRequestData::new( + GenerateCampaignTeamReportsRequestAttributes::new(vec![EntityOwnerDestination::new( + SlackRoutingOptions::new() + .channel_id("C024BDQ4N".to_string()) + .workspace_id("T024BDQ4N".to_string()), + "550e8400-e29b-41d4-a716-446655440000".to_string(), + )]), + GenerateCampaignTeamReportsRequestDataType::CAMPAIGN_TEAM_REPORT, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GenerateScorecardCampaignTeamReports", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .generate_scorecard_campaign_team_reports("c10ODp0VCrrIpXmz".to_string(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_GetScorecardCampaign.rs b/examples/v2_service-scorecards_GetScorecardCampaign.rs new file mode 100644 index 000000000..ff0d2d472 --- /dev/null +++ b/examples/v2_service-scorecards_GetScorecardCampaign.rs @@ -0,0 +1,22 @@ +// Get a campaign returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::GetScorecardCampaignOptionalParams; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetScorecardCampaign", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .get_scorecard_campaign( + "c10ODp0VCrrIpXmz".to_string(), + GetScorecardCampaignOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_ListScorecardCampaigns.rs b/examples/v2_service-scorecards_ListScorecardCampaigns.rs new file mode 100644 index 000000000..c3c776166 --- /dev/null +++ b/examples/v2_service-scorecards_ListScorecardCampaigns.rs @@ -0,0 +1,19 @@ +// List all campaigns returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ListScorecardCampaignsOptionalParams; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListScorecardCampaigns", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .list_scorecard_campaigns(ListScorecardCampaignsOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_ListScorecardDefaultRules.rs b/examples/v2_service-scorecards_ListScorecardDefaultRules.rs new file mode 100644 index 000000000..d0da45134 --- /dev/null +++ b/examples/v2_service-scorecards_ListScorecardDefaultRules.rs @@ -0,0 +1,16 @@ +// List default rules returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListScorecardDefaultRules", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api.list_scorecard_default_rules().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_ListScorecardFacets.rs b/examples/v2_service-scorecards_ListScorecardFacets.rs new file mode 100644 index 000000000..e20406d38 --- /dev/null +++ b/examples/v2_service-scorecards_ListScorecardFacets.rs @@ -0,0 +1,19 @@ +// List entity facets returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ListScorecardFacetsOptionalParams; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListScorecardFacets", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .list_scorecard_facets(ListScorecardFacetsOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_ListScorecardScores.rs b/examples/v2_service-scorecards_ListScorecardScores.rs new file mode 100644 index 000000000..209dc4e05 --- /dev/null +++ b/examples/v2_service-scorecards_ListScorecardScores.rs @@ -0,0 +1,22 @@ +// List scores by aggregation returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ListScorecardScoresOptionalParams; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListScorecardScores", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .list_scorecard_scores( + "by-entity".to_string(), + ListScorecardScoresOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_ListScorecards.rs b/examples/v2_service-scorecards_ListScorecards.rs new file mode 100644 index 000000000..6caa03d44 --- /dev/null +++ b/examples/v2_service-scorecards_ListScorecards.rs @@ -0,0 +1,19 @@ +// List all scorecards returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ListScorecardsOptionalParams; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListScorecards", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .list_scorecards(ListScorecardsOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_SetupScorecardRules.rs b/examples/v2_service-scorecards_SetupScorecardRules.rs new file mode 100644 index 000000000..4061b3287 --- /dev/null +++ b/examples/v2_service-scorecards_SetupScorecardRules.rs @@ -0,0 +1,27 @@ +// Set up rules for organization returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; +use datadog_api_client::datadogV2::model::SetupRulesRequest; +use datadog_api_client::datadogV2::model::SetupRulesRequestAttributes; +use datadog_api_client::datadogV2::model::SetupRulesRequestData; +use datadog_api_client::datadogV2::model::SetupRulesRequestDataType; + +#[tokio::main] +async fn main() { + let body = SetupRulesRequest::new(SetupRulesRequestData::new( + SetupRulesRequestAttributes::new().disabled_default_rules(vec![ + "q8MQxk8TCqrHnWkx".to_string(), + "r9NRyl9UDrsIoXly".to_string(), + ]), + SetupRulesRequestDataType::SETUP, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.SetupScorecardRules", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api.setup_scorecard_rules(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_UpdateScorecardCampaign.rs b/examples/v2_service-scorecards_UpdateScorecardCampaign.rs new file mode 100644 index 000000000..c2077efe5 --- /dev/null +++ b/examples/v2_service-scorecards_UpdateScorecardCampaign.rs @@ -0,0 +1,47 @@ +// Update a campaign returns "OK" response +use chrono::{DateTime, Utc}; +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; +use datadog_api_client::datadogV2::model::CampaignType; +use datadog_api_client::datadogV2::model::UpdateCampaignRequest; +use datadog_api_client::datadogV2::model::UpdateCampaignRequestAttributes; +use datadog_api_client::datadogV2::model::UpdateCampaignRequestData; + +#[tokio::main] +async fn main() { + let body = UpdateCampaignRequest::new(UpdateCampaignRequestData::new( + UpdateCampaignRequestAttributes::new( + "Q1 Security Campaign".to_string(), + "550e8400-e29b-41d4-a716-446655440000".to_string(), + vec![ + "q8MQxk8TCqrHnWkx".to_string(), + "r9NRyl9UDrsIoXly".to_string(), + ], + DateTime::parse_from_rfc3339("2024-01-01T00:00:00+00:00") + .expect("Failed to parse datetime") + .with_timezone(&Utc), + "in_progress".to_string(), + ) + .description("Campaign to improve security posture for Q1 2024.".to_string()) + .due_date( + DateTime::parse_from_rfc3339("2024-03-31T23:59:59+00:00") + .expect("Failed to parse datetime") + .with_timezone(&Utc), + ) + .entity_scope("kind:service AND team:platform".to_string()) + .guidance("Please ensure all services pass the security requirements.".to_string()) + .key("q1-security-2024".to_string()), + CampaignType::CAMPAIGN, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateScorecardCampaign", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .update_scorecard_campaign("c10ODp0VCrrIpXmz".to_string(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_service-scorecards_UpdateScorecardRuleWorkflow.rs b/examples/v2_service-scorecards_UpdateScorecardRuleWorkflow.rs new file mode 100644 index 000000000..1ad4368f2 --- /dev/null +++ b/examples/v2_service-scorecards_UpdateScorecardRuleWorkflow.rs @@ -0,0 +1,21 @@ +// Associate workflow with rule returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_service_scorecards::ServiceScorecardsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateScorecardRuleWorkflow", true); + let api = ServiceScorecardsAPI::with_config(configuration); + let resp = api + .update_scorecard_rule_workflow( + "rule_id".to_string(), + "550e8400-e29b-41d4-a716-446655440000".to_string(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index d00ab9a63..a284d0299 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -294,13 +294,30 @@ impl Default for Configuration { ("v2.query_event_filtered_users".to_owned(), false), ("v2.query_users".to_owned(), false), ("v2.update_connection".to_owned(), false), + ("v2.create_scorecard_campaign".to_owned(), false), ("v2.create_scorecard_outcomes_batch".to_owned(), false), ("v2.create_scorecard_rule".to_owned(), false), + ("v2.delete_scorecard_campaign".to_owned(), false), ("v2.delete_scorecard_rule".to_owned(), false), + ("v2.delete_scorecard_rule_workflow".to_owned(), false), + ("v2.generate_scorecard_campaign_report".to_owned(), false), + ( + "v2.generate_scorecard_campaign_team_reports".to_owned(), + false, + ), + ("v2.get_scorecard_campaign".to_owned(), false), + ("v2.list_scorecard_campaigns".to_owned(), false), + ("v2.list_scorecard_default_rules".to_owned(), false), + ("v2.list_scorecard_facets".to_owned(), false), ("v2.list_scorecard_outcomes".to_owned(), false), ("v2.list_scorecard_rules".to_owned(), false), + ("v2.list_scorecards".to_owned(), false), + ("v2.list_scorecard_scores".to_owned(), false), + ("v2.setup_scorecard_rules".to_owned(), false), + ("v2.update_scorecard_campaign".to_owned(), false), ("v2.update_scorecard_outcomes_async".to_owned(), false), ("v2.update_scorecard_rule".to_owned(), false), + ("v2.update_scorecard_rule_workflow".to_owned(), false), ("v2.list_entity_risk_scores".to_owned(), false), ("v2.create_incident_service".to_owned(), false), ("v2.delete_incident_service".to_owned(), false), diff --git a/src/datadogV2/api/api_service_scorecards.rs b/src/datadogV2/api/api_service_scorecards.rs index aeeb1d6cb..6a08b3c5a 100644 --- a/src/datadogV2/api/api_service_scorecards.rs +++ b/src/datadogV2/api/api_service_scorecards.rs @@ -13,6 +13,89 @@ use reqwest::header::{HeaderMap, HeaderValue}; use serde::{Deserialize, Serialize}; use std::io::Write; +/// GetScorecardCampaignOptionalParams is a struct for passing parameters to the method [`ServiceScorecardsAPI::get_scorecard_campaign`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetScorecardCampaignOptionalParams { + /// Include related data (for example, scores). + pub include: Option, + /// Include metadata (entity and rule counts). + pub include_meta: Option, +} + +impl GetScorecardCampaignOptionalParams { + /// Include related data (for example, scores). + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } + /// Include metadata (entity and rule counts). + pub fn include_meta(mut self, value: bool) -> Self { + self.include_meta = Some(value); + self + } +} + +/// ListScorecardCampaignsOptionalParams is a struct for passing parameters to the method [`ServiceScorecardsAPI::list_scorecard_campaigns`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListScorecardCampaignsOptionalParams { + /// Maximum number of campaigns to return. + pub page_limit: Option, + /// Offset for pagination. + pub page_offset: Option, + /// Filter campaigns by name (full-text search). + pub filter_campaign_name: Option, + /// Filter campaigns by status. + pub filter_campaign_status: Option, + /// Filter campaigns by owner UUID. + pub filter_campaign_owner: Option, +} + +impl ListScorecardCampaignsOptionalParams { + /// Maximum number of campaigns to return. + pub fn page_limit(mut self, value: i64) -> Self { + self.page_limit = Some(value); + self + } + /// Offset for pagination. + pub fn page_offset(mut self, value: i64) -> Self { + self.page_offset = Some(value); + self + } + /// Filter campaigns by name (full-text search). + pub fn filter_campaign_name(mut self, value: String) -> Self { + self.filter_campaign_name = Some(value); + self + } + /// Filter campaigns by status. + pub fn filter_campaign_status(mut self, value: String) -> Self { + self.filter_campaign_status = Some(value); + self + } + /// Filter campaigns by owner UUID. + pub fn filter_campaign_owner(mut self, value: String) -> Self { + self.filter_campaign_owner = Some(value); + self + } +} + +/// ListScorecardFacetsOptionalParams is a struct for passing parameters to the method [`ServiceScorecardsAPI::list_scorecard_facets`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListScorecardFacetsOptionalParams { + /// Entity query filter. + pub filter_entity_query: Option, +} + +impl ListScorecardFacetsOptionalParams { + /// Entity query filter. + pub fn filter_entity_query(mut self, value: String) -> Self { + self.filter_entity_query = Some(value); + self + } +} + /// ListScorecardOutcomesOptionalParams is a struct for passing parameters to the method [`ServiceScorecardsAPI::list_scorecard_outcomes`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -27,11 +110,11 @@ pub struct ListScorecardOutcomesOptionalParams { pub fields_outcome: Option, /// Return only specified values in the included rule details. pub fields_rule: Option, - /// Filter the outcomes on a specific service name. + /// Filter outcomes on a specific service name. pub filter_outcome_service_name: Option, - /// Filter the outcomes by a specific state. + /// Filter outcomes by a specific state. pub filter_outcome_state: Option, - /// Filter outcomes on whether a rule is enabled/disabled. + /// Filter outcomes based on whether a rule is enabled or disabled. pub filter_rule_enabled: Option, /// Filter outcomes based on rule ID. pub filter_rule_id: Option, @@ -65,17 +148,17 @@ impl ListScorecardOutcomesOptionalParams { self.fields_rule = Some(value); self } - /// Filter the outcomes on a specific service name. + /// Filter outcomes on a specific service name. pub fn filter_outcome_service_name(mut self, value: String) -> Self { self.filter_outcome_service_name = Some(value); self } - /// Filter the outcomes by a specific state. + /// Filter outcomes by a specific state. pub fn filter_outcome_state(mut self, value: String) -> Self { self.filter_outcome_state = Some(value); self } - /// Filter outcomes on whether a rule is enabled/disabled. + /// Filter outcomes based on whether a rule is enabled or disabled. pub fn filter_rule_enabled(mut self, value: bool) -> Self { self.filter_rule_enabled = Some(value); self @@ -171,6 +254,117 @@ impl ListScorecardRulesOptionalParams { } } +/// ListScorecardScoresOptionalParams is a struct for passing parameters to the method [`ServiceScorecardsAPI::list_scorecard_scores`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListScorecardScoresOptionalParams { + /// Maximum number of scores to return. + pub page_limit: Option, + /// Offset for pagination. + pub page_offset: Option, + /// Entity query filter. + pub filter_entity_query: Option, + /// Filter by rule IDs (comma-separated). + pub filter_rule_id: Option, + /// Filter by rule enabled status. + pub filter_rule_enabled: Option, + /// Filter by custom rules. + pub filter_rule_custom: Option, + /// Sort order (comma-separated list of fields; prefix a field with - for descending order). + pub sort: Option, +} + +impl ListScorecardScoresOptionalParams { + /// Maximum number of scores to return. + pub fn page_limit(mut self, value: i64) -> Self { + self.page_limit = Some(value); + self + } + /// Offset for pagination. + pub fn page_offset(mut self, value: i64) -> Self { + self.page_offset = Some(value); + self + } + /// Entity query filter. + pub fn filter_entity_query(mut self, value: String) -> Self { + self.filter_entity_query = Some(value); + self + } + /// Filter by rule IDs (comma-separated). + pub fn filter_rule_id(mut self, value: String) -> Self { + self.filter_rule_id = Some(value); + self + } + /// Filter by rule enabled status. + pub fn filter_rule_enabled(mut self, value: bool) -> Self { + self.filter_rule_enabled = Some(value); + self + } + /// Filter by custom rules. + pub fn filter_rule_custom(mut self, value: bool) -> Self { + self.filter_rule_custom = Some(value); + self + } + /// Sort order (comma-separated list of fields; prefix a field with - for descending order). + pub fn sort(mut self, value: String) -> Self { + self.sort = Some(value); + self + } +} + +/// ListScorecardsOptionalParams is a struct for passing parameters to the method [`ServiceScorecardsAPI::list_scorecards`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListScorecardsOptionalParams { + /// Offset for pagination. + pub page_offset: Option, + /// Maximum number of scorecards to return. + pub page_size: Option, + /// Filter by scorecard ID. + pub filter_scorecard_id: Option, + /// Filter by scorecard name (partial match). + pub filter_scorecard_name: Option, + /// Filter by scorecard description (partial match). + pub filter_scorecard_description: Option, +} + +impl ListScorecardsOptionalParams { + /// Offset for pagination. + pub fn page_offset(mut self, value: i64) -> Self { + self.page_offset = Some(value); + self + } + /// Maximum number of scorecards to return. + pub fn page_size(mut self, value: i64) -> Self { + self.page_size = Some(value); + self + } + /// Filter by scorecard ID. + pub fn filter_scorecard_id(mut self, value: String) -> Self { + self.filter_scorecard_id = Some(value); + self + } + /// Filter by scorecard name (partial match). + pub fn filter_scorecard_name(mut self, value: String) -> Self { + self.filter_scorecard_name = Some(value); + self + } + /// Filter by scorecard description (partial match). + pub fn filter_scorecard_description(mut self, value: String) -> Self { + self.filter_scorecard_description = Some(value); + self + } +} + +/// CreateScorecardCampaignError is a struct for typed errors of method [`ServiceScorecardsAPI::create_scorecard_campaign`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateScorecardCampaignError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateScorecardOutcomesBatchError is a struct for typed errors of method [`ServiceScorecardsAPI::create_scorecard_outcomes_batch`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -187,6 +381,15 @@ pub enum CreateScorecardRuleError { UnknownValue(serde_json::Value), } +/// DeleteScorecardCampaignError is a struct for typed errors of method [`ServiceScorecardsAPI::delete_scorecard_campaign`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteScorecardCampaignError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// DeleteScorecardRuleError is a struct for typed errors of method [`ServiceScorecardsAPI::delete_scorecard_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -195,6 +398,69 @@ pub enum DeleteScorecardRuleError { UnknownValue(serde_json::Value), } +/// DeleteScorecardRuleWorkflowError is a struct for typed errors of method [`ServiceScorecardsAPI::delete_scorecard_rule_workflow`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteScorecardRuleWorkflowError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GenerateScorecardCampaignReportError is a struct for typed errors of method [`ServiceScorecardsAPI::generate_scorecard_campaign_report`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GenerateScorecardCampaignReportError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GenerateScorecardCampaignTeamReportsError is a struct for typed errors of method [`ServiceScorecardsAPI::generate_scorecard_campaign_team_reports`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GenerateScorecardCampaignTeamReportsError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetScorecardCampaignError is a struct for typed errors of method [`ServiceScorecardsAPI::get_scorecard_campaign`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetScorecardCampaignError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListScorecardCampaignsError is a struct for typed errors of method [`ServiceScorecardsAPI::list_scorecard_campaigns`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListScorecardCampaignsError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListScorecardDefaultRulesError is a struct for typed errors of method [`ServiceScorecardsAPI::list_scorecard_default_rules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListScorecardDefaultRulesError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListScorecardFacetsError is a struct for typed errors of method [`ServiceScorecardsAPI::list_scorecard_facets`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListScorecardFacetsError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListScorecardOutcomesError is a struct for typed errors of method [`ServiceScorecardsAPI::list_scorecard_outcomes`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -211,6 +477,42 @@ pub enum ListScorecardRulesError { UnknownValue(serde_json::Value), } +/// ListScorecardScoresError is a struct for typed errors of method [`ServiceScorecardsAPI::list_scorecard_scores`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListScorecardScoresError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListScorecardsError is a struct for typed errors of method [`ServiceScorecardsAPI::list_scorecards`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListScorecardsError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// SetupScorecardRulesError is a struct for typed errors of method [`ServiceScorecardsAPI::setup_scorecard_rules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SetupScorecardRulesError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpdateScorecardCampaignError is a struct for typed errors of method [`ServiceScorecardsAPI::update_scorecard_campaign`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateScorecardCampaignError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateScorecardOutcomesAsyncError is a struct for typed errors of method [`ServiceScorecardsAPI::update_scorecard_outcomes_async`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -227,6 +529,15 @@ pub enum UpdateScorecardRuleError { UnknownValue(serde_json::Value), } +/// UpdateScorecardRuleWorkflowError is a struct for typed errors of method [`ServiceScorecardsAPI::update_scorecard_rule_workflow`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateScorecardRuleWorkflowError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// API to create and update scorecard rules and outcomes. See [Service Scorecards]() for more information. /// /// This feature is currently in BETA. If you have any feedback, contact [Datadog support](). @@ -294,18 +605,15 @@ impl ServiceScorecardsAPI { Self { config, client } } - /// Sets multiple service-rule outcomes in a single batched request. - pub async fn create_scorecard_outcomes_batch( + /// Creates a new scorecard campaign. + pub async fn create_scorecard_campaign( &self, - body: crate::datadogV2::model::OutcomesBatchRequest, + body: crate::datadogV2::model::CreateCampaignRequest, ) -> Result< - crate::datadogV2::model::OutcomesBatchResponse, - datadog::Error, + crate::datadogV2::model::CampaignResponse, + datadog::Error, > { - match self - .create_scorecard_outcomes_batch_with_http_info(body) - .await - { + match self.create_scorecard_campaign_with_http_info(body).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -319,21 +627,21 @@ impl ServiceScorecardsAPI { } } - /// Sets multiple service-rule outcomes in a single batched request. - pub async fn create_scorecard_outcomes_batch_with_http_info( + /// Creates a new scorecard campaign. + pub async fn create_scorecard_campaign_with_http_info( &self, - body: crate::datadogV2::model::OutcomesBatchRequest, + body: crate::datadogV2::model::CreateCampaignRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_scorecard_outcomes_batch"; + let operation_id = "v2.create_scorecard_campaign"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.create_scorecard_outcomes_batch' is not enabled".to_string(), + msg: "Operation 'v2.create_scorecard_campaign' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } @@ -341,7 +649,7 @@ impl ServiceScorecardsAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/scorecard/outcomes/batch", + "{}/api/v2/scorecard/campaigns", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -435,9 +743,8 @@ impl ServiceScorecardsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -448,7 +755,7 @@ impl ServiceScorecardsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -459,13 +766,18 @@ impl ServiceScorecardsAPI { } } - /// Creates a new rule. - pub async fn create_scorecard_rule( + /// Sets multiple service-rule outcomes in a single batched request. + pub async fn create_scorecard_outcomes_batch( &self, - body: crate::datadogV2::model::CreateRuleRequest, - ) -> Result> - { - match self.create_scorecard_rule_with_http_info(body).await { + body: crate::datadogV2::model::OutcomesBatchRequest, + ) -> Result< + crate::datadogV2::model::OutcomesBatchResponse, + datadog::Error, + > { + match self + .create_scorecard_outcomes_batch_with_http_info(body) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -479,21 +791,21 @@ impl ServiceScorecardsAPI { } } - /// Creates a new rule. - pub async fn create_scorecard_rule_with_http_info( + /// Sets multiple service-rule outcomes in a single batched request. + pub async fn create_scorecard_outcomes_batch_with_http_info( &self, - body: crate::datadogV2::model::CreateRuleRequest, + body: crate::datadogV2::model::OutcomesBatchRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_scorecard_rule"; + let operation_id = "v2.create_scorecard_outcomes_batch"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.create_scorecard_rule' is not enabled".to_string(), + msg: "Operation 'v2.create_scorecard_outcomes_batch' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } @@ -501,7 +813,7 @@ impl ServiceScorecardsAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/scorecard/rules", + "{}/api/v2/scorecard/outcomes/batch", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -595,7 +907,7 @@ impl ServiceScorecardsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -608,7 +920,7 @@ impl ServiceScorecardsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -619,29 +931,41 @@ impl ServiceScorecardsAPI { } } - /// Deletes a single rule. - pub async fn delete_scorecard_rule( - &self, - rule_id: String, - ) -> Result<(), datadog::Error> { - match self.delete_scorecard_rule_with_http_info(rule_id).await { - Ok(_) => Ok(()), - Err(err) => Err(err), - } - } - - /// Deletes a single rule. - pub async fn delete_scorecard_rule_with_http_info( + /// Creates a new rule. + pub async fn create_scorecard_rule( &self, - rule_id: String, - ) -> Result, datadog::Error> { - let local_configuration = &self.config; - let operation_id = "v2.delete_scorecard_rule"; + body: crate::datadogV2::model::CreateRuleRequest, + ) -> Result> + { + match self.create_scorecard_rule_with_http_info(body).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), + } + } + + /// Creates a new rule. + pub async fn create_scorecard_rule_with_http_info( + &self, + body: crate::datadogV2::model::CreateRuleRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_scorecard_rule"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.delete_scorecard_rule' is not enabled".to_string(), + msg: "Operation 'v2.create_scorecard_rule' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } @@ -649,16 +973,1735 @@ impl ServiceScorecardsAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/scorecard/rules/{rule_id}", + "{}/api/v2/scorecard/rules", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // 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)) + } + } + + /// Deletes a single campaign by ID or key. + pub async fn delete_scorecard_campaign( + &self, + campaign_id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_scorecard_campaign_with_http_info(campaign_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Deletes a single campaign by ID or key. + pub async fn delete_scorecard_campaign_with_http_info( + &self, + campaign_id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_scorecard_campaign"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_scorecard_campaign' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/campaigns/{campaign_id}", local_configuration.get_operation_host(operation_id), - rule_id = datadog::urlencode(rule_id) + campaign_id = datadog::urlencode(campaign_id) ); let mut local_req_builder = local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("*/*")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // 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() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } 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)) + } + } + + /// Deletes a single rule. + pub async fn delete_scorecard_rule( + &self, + rule_id: String, + ) -> Result<(), datadog::Error> { + match self.delete_scorecard_rule_with_http_info(rule_id).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Deletes a single rule. + pub async fn delete_scorecard_rule_with_http_info( + &self, + rule_id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_scorecard_rule"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_scorecard_rule' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/rules/{rule_id}", + local_configuration.get_operation_host(operation_id), + rule_id = datadog::urlencode(rule_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // 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() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } 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)) + } + } + + /// Removes workflow association from a scorecard rule. + pub async fn delete_scorecard_rule_workflow( + &self, + rule_id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_scorecard_rule_workflow_with_http_info(rule_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Removes workflow association from a scorecard rule. + pub async fn delete_scorecard_rule_workflow_with_http_info( + &self, + rule_id: String, + ) -> Result, datadog::Error> + { + let local_configuration = &self.config; + let operation_id = "v2.delete_scorecard_rule_workflow"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_scorecard_rule_workflow' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/rules/{rule_id}/workflow", + local_configuration.get_operation_host(operation_id), + rule_id = datadog::urlencode(rule_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // 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() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } 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)) + } + } + + /// Generates and sends a campaign report to Slack. + pub async fn generate_scorecard_campaign_report( + &self, + campaign_id: String, + body: crate::datadogV2::model::GenerateCampaignReportRequest, + ) -> Result<(), datadog::Error> { + match self + .generate_scorecard_campaign_report_with_http_info(campaign_id, body) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Generates and sends a campaign report to Slack. + pub async fn generate_scorecard_campaign_report_with_http_info( + &self, + campaign_id: String, + body: crate::datadogV2::model::GenerateCampaignReportRequest, + ) -> Result, datadog::Error> + { + let local_configuration = &self.config; + let operation_id = "v2.generate_scorecard_campaign_report"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.generate_scorecard_campaign_report' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/campaigns/{campaign_id}/report", + local_configuration.get_operation_host(operation_id), + campaign_id = datadog::urlencode(campaign_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // 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() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } 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)) + } + } + + /// Generates and sends team-specific campaign reports to Slack. + pub async fn generate_scorecard_campaign_team_reports( + &self, + campaign_id: String, + body: crate::datadogV2::model::GenerateCampaignTeamReportsRequest, + ) -> Result<(), datadog::Error> { + match self + .generate_scorecard_campaign_team_reports_with_http_info(campaign_id, body) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Generates and sends team-specific campaign reports to Slack. + pub async fn generate_scorecard_campaign_team_reports_with_http_info( + &self, + campaign_id: String, + body: crate::datadogV2::model::GenerateCampaignTeamReportsRequest, + ) -> Result< + datadog::ResponseContent<()>, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.generate_scorecard_campaign_team_reports"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.generate_scorecard_campaign_team_reports' is not enabled" + .to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/campaigns/{campaign_id}/entity-owner-report", + local_configuration.get_operation_host(operation_id), + campaign_id = datadog::urlencode(campaign_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // 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() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } 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)) + } + } + + /// Fetches a single campaign by ID or key. + pub async fn get_scorecard_campaign( + &self, + campaign_id: String, + params: GetScorecardCampaignOptionalParams, + ) -> Result> + { + match self + .get_scorecard_campaign_with_http_info(campaign_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), + } + } + + /// Fetches a single campaign by ID or key. + pub async fn get_scorecard_campaign_with_http_info( + &self, + campaign_id: String, + params: GetScorecardCampaignOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_scorecard_campaign"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_scorecard_campaign' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let include = params.include; + let include_meta = params.include_meta; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/campaigns/{campaign_id}", + local_configuration.get_operation_host(operation_id), + campaign_id = datadog::urlencode(campaign_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())]); + }; + if let Some(ref local_query_param) = include_meta { + local_req_builder = + local_req_builder.query(&[("include_meta", &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)) + } + } + + /// Fetches all scorecard campaigns. + pub async fn list_scorecard_campaigns( + &self, + params: ListScorecardCampaignsOptionalParams, + ) -> Result< + crate::datadogV2::model::ListCampaignsResponse, + datadog::Error, + > { + match self.list_scorecard_campaigns_with_http_info(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), + } + } + + /// Fetches all scorecard campaigns. + pub async fn list_scorecard_campaigns_with_http_info( + &self, + params: ListScorecardCampaignsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_scorecard_campaigns"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_scorecard_campaigns' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_limit = params.page_limit; + let page_offset = params.page_offset; + let filter_campaign_name = params.filter_campaign_name; + let filter_campaign_status = params.filter_campaign_status; + let filter_campaign_owner = params.filter_campaign_owner; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/campaigns", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_limit { + local_req_builder = + local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_offset { + local_req_builder = + local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_campaign_name { + local_req_builder = local_req_builder + .query(&[("filter[campaign][name]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_campaign_status { + local_req_builder = local_req_builder + .query(&[("filter[campaign][status]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_campaign_owner { + local_req_builder = local_req_builder + .query(&[("filter[campaign][owner]", &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)) + } + } + + /// Fetches all default scorecard rules available for the organization. + pub async fn list_scorecard_default_rules( + &self, + ) -> Result< + crate::datadogV2::model::ListDefaultRulesResponse, + datadog::Error, + > { + match self.list_scorecard_default_rules_with_http_info().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), + } + } + + /// Fetches all default scorecard rules available for the organization. + pub async fn list_scorecard_default_rules_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_scorecard_default_rules"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_scorecard_default_rules' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/default-rules", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // 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)) + } + } + + /// Fetches facets for scorecard entities with counts. + pub async fn list_scorecard_facets( + &self, + params: ListScorecardFacetsOptionalParams, + ) -> Result> + { + match self.list_scorecard_facets_with_http_info(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), + } + } + + /// Fetches facets for scorecard entities with counts. + pub async fn list_scorecard_facets_with_http_info( + &self, + params: ListScorecardFacetsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_scorecard_facets"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_scorecard_facets' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let filter_entity_query = params.filter_entity_query; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/facets", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = filter_entity_query { + local_req_builder = local_req_builder + .query(&[("filter[entity][query]", &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)) + } + } + + /// Fetches all rule outcomes. + pub async fn list_scorecard_outcomes( + &self, + params: ListScorecardOutcomesOptionalParams, + ) -> Result> + { + match self.list_scorecard_outcomes_with_http_info(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), + } + } + + pub fn list_scorecard_outcomes_with_pagination( + &self, + mut params: ListScorecardOutcomesOptionalParams, + ) -> impl Stream< + Item = Result< + crate::datadogV2::model::OutcomesResponseDataItem, + datadog::Error, + >, + > + '_ { + try_stream! { + let mut page_size: i64 = 10; + if params.page_size.is_none() { + params.page_size = Some(page_size); + } else { + page_size = params.page_size.unwrap().clone(); + } + loop { + let resp = self.list_scorecard_outcomes(params.clone()).await?; + let Some(data) = resp.data else { break }; + + let r = data; + let count = r.len(); + for team in r { + yield team; + } + + if count < page_size as usize { + break; + } + if params.page_offset.is_none() { + params.page_offset = Some(page_size.clone()); + } else { + params.page_offset = Some(params.page_offset.unwrap() + page_size.clone()); + } + } + } + } + + /// Fetches all rule outcomes. + pub async fn list_scorecard_outcomes_with_http_info( + &self, + params: ListScorecardOutcomesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_scorecard_outcomes"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_scorecard_outcomes' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_size = params.page_size; + let page_offset = params.page_offset; + let include = params.include; + let fields_outcome = params.fields_outcome; + let fields_rule = params.fields_rule; + let filter_outcome_service_name = params.filter_outcome_service_name; + let filter_outcome_state = params.filter_outcome_state; + let filter_rule_enabled = params.filter_rule_enabled; + let filter_rule_id = params.filter_rule_id; + let filter_rule_name = params.filter_rule_name; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/outcomes", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_offset { + local_req_builder = + local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = fields_outcome { + local_req_builder = + local_req_builder.query(&[("fields[outcome]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = fields_rule { + local_req_builder = + local_req_builder.query(&[("fields[rule]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_outcome_service_name { + local_req_builder = local_req_builder.query(&[( + "filter[outcome][service_name]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_outcome_state { + local_req_builder = local_req_builder + .query(&[("filter[outcome][state]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_enabled { + local_req_builder = local_req_builder + .query(&[("filter[rule][enabled]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_id { + local_req_builder = + local_req_builder.query(&[("filter[rule][id]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_name { + local_req_builder = + local_req_builder.query(&[("filter[rule][name]", &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)) + } + } + + /// Fetch all rules. + pub async fn list_scorecard_rules( + &self, + params: ListScorecardRulesOptionalParams, + ) -> Result> + { + match self.list_scorecard_rules_with_http_info(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), + } + } + + pub fn list_scorecard_rules_with_pagination( + &self, + mut params: ListScorecardRulesOptionalParams, + ) -> impl Stream< + Item = Result< + crate::datadogV2::model::ListRulesResponseDataItem, + datadog::Error, + >, + > + '_ { + try_stream! { + let mut page_size: i64 = 10; + if params.page_size.is_none() { + params.page_size = Some(page_size); + } else { + page_size = params.page_size.unwrap().clone(); + } + loop { + let resp = self.list_scorecard_rules(params.clone()).await?; + let Some(data) = resp.data else { break }; + + let r = data; + let count = r.len(); + for team in r { + yield team; + } + + if count < page_size as usize { + break; + } + if params.page_offset.is_none() { + params.page_offset = Some(page_size.clone()); + } else { + params.page_offset = Some(params.page_offset.unwrap() + page_size.clone()); + } + } + } + } + + /// Fetch all rules. + pub async fn list_scorecard_rules_with_http_info( + &self, + params: ListScorecardRulesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_scorecard_rules"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_scorecard_rules' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_size = params.page_size; + let page_offset = params.page_offset; + let include = params.include; + let filter_rule_id = params.filter_rule_id; + let filter_rule_enabled = params.filter_rule_enabled; + let filter_rule_custom = params.filter_rule_custom; + let filter_rule_name = params.filter_rule_name; + let filter_rule_description = params.filter_rule_description; + let fields_rule = params.fields_rule; + let fields_scorecard = params.fields_scorecard; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/rules", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_offset { + local_req_builder = + local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_id { + local_req_builder = + local_req_builder.query(&[("filter[rule][id]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_enabled { + local_req_builder = local_req_builder + .query(&[("filter[rule][enabled]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_custom { + local_req_builder = local_req_builder + .query(&[("filter[rule][custom]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_name { + local_req_builder = + local_req_builder.query(&[("filter[rule][name]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_description { + local_req_builder = local_req_builder + .query(&[("filter[rule][description]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = fields_rule { + local_req_builder = + local_req_builder.query(&[("fields[rule]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = fields_scorecard { + local_req_builder = + local_req_builder.query(&[("fields[scorecard]", &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)) + } + } + + /// Fetches scorecard scores aggregated by entity, rule, scorecard, service, or team. + pub async fn list_scorecard_scores( + &self, + aggregation: String, + params: ListScorecardScoresOptionalParams, + ) -> Result> + { + match self + .list_scorecard_scores_with_http_info(aggregation, 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), + } + } + + /// Fetches scorecard scores aggregated by entity, rule, scorecard, service, or team. + pub async fn list_scorecard_scores_with_http_info( + &self, + aggregation: String, + params: ListScorecardScoresOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_scorecard_scores"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_scorecard_scores' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_limit = params.page_limit; + let page_offset = params.page_offset; + let filter_entity_query = params.filter_entity_query; + let filter_rule_id = params.filter_rule_id; + let filter_rule_enabled = params.filter_rule_enabled; + let filter_rule_custom = params.filter_rule_custom; + let sort = params.sort; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/scores/{aggregation}", + local_configuration.get_operation_host(operation_id), + aggregation = datadog::urlencode(aggregation) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_limit { + local_req_builder = + local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_offset { + local_req_builder = + local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_entity_query { + local_req_builder = local_req_builder + .query(&[("filter[entity][query]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_id { + local_req_builder = + local_req_builder.query(&[("filter[rule][id]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_enabled { + local_req_builder = local_req_builder + .query(&[("filter[rule][enabled]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_rule_custom { + local_req_builder = local_req_builder + .query(&[("filter[rule][custom]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = sort { + local_req_builder = + local_req_builder.query(&[("sort", &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()) { @@ -698,13 +2741,20 @@ impl ServiceScorecardsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: None, - }) + 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 = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -715,13 +2765,13 @@ impl ServiceScorecardsAPI { } } - /// Fetches all rule outcomes. - pub async fn list_scorecard_outcomes( + /// Fetches all scorecards. + pub async fn list_scorecards( &self, - params: ListScorecardOutcomesOptionalParams, - ) -> Result> + params: ListScorecardsOptionalParams, + ) -> Result> { - match self.list_scorecard_outcomes_with_http_info(params).await { + match self.list_scorecards_with_http_info(params).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -735,126 +2785,63 @@ impl ServiceScorecardsAPI { } } - pub fn list_scorecard_outcomes_with_pagination( - &self, - mut params: ListScorecardOutcomesOptionalParams, - ) -> impl Stream< - Item = Result< - crate::datadogV2::model::OutcomesResponseDataItem, - datadog::Error, - >, - > + '_ { - try_stream! { - let mut page_size: i64 = 10; - if params.page_size.is_none() { - params.page_size = Some(page_size); - } else { - page_size = params.page_size.unwrap().clone(); - } - loop { - let resp = self.list_scorecard_outcomes(params.clone()).await?; - let Some(data) = resp.data else { break }; - - let r = data; - let count = r.len(); - for team in r { - yield team; - } - - if count < page_size as usize { - break; - } - if params.page_offset.is_none() { - params.page_offset = Some(page_size.clone()); - } else { - params.page_offset = Some(params.page_offset.unwrap() + page_size.clone()); - } - } - } - } - - /// Fetches all rule outcomes. - pub async fn list_scorecard_outcomes_with_http_info( + /// Fetches all scorecards. + pub async fn list_scorecards_with_http_info( &self, - params: ListScorecardOutcomesOptionalParams, + params: ListScorecardsOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_scorecard_outcomes"; + let operation_id = "v2.list_scorecards"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.list_scorecard_outcomes' is not enabled".to_string(), + msg: "Operation 'v2.list_scorecards' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } // unbox and build optional parameters - let page_size = params.page_size; let page_offset = params.page_offset; - let include = params.include; - let fields_outcome = params.fields_outcome; - let fields_rule = params.fields_rule; - let filter_outcome_service_name = params.filter_outcome_service_name; - let filter_outcome_state = params.filter_outcome_state; - let filter_rule_enabled = params.filter_rule_enabled; - let filter_rule_id = params.filter_rule_id; - let filter_rule_name = params.filter_rule_name; + let page_size = params.page_size; + let filter_scorecard_id = params.filter_scorecard_id; + let filter_scorecard_name = params.filter_scorecard_name; + let filter_scorecard_description = params.filter_scorecard_description; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/scorecard/outcomes", + "{}/api/v2/scorecard/scorecards", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - if let Some(ref local_query_param) = page_size { - local_req_builder = - local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); - }; if let Some(ref local_query_param) = page_offset { local_req_builder = local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = include { + if let Some(ref local_query_param) = page_size { local_req_builder = - local_req_builder.query(&[("include", &local_query_param.to_string())]); + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = fields_outcome { - local_req_builder = - local_req_builder.query(&[("fields[outcome]", &local_query_param.to_string())]); + if let Some(ref local_query_param) = filter_scorecard_id { + local_req_builder = local_req_builder + .query(&[("filter[scorecard][id]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = fields_rule { - local_req_builder = - local_req_builder.query(&[("fields[rule]", &local_query_param.to_string())]); + if let Some(ref local_query_param) = filter_scorecard_name { + local_req_builder = local_req_builder + .query(&[("filter[scorecard][name]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_outcome_service_name { + if let Some(ref local_query_param) = filter_scorecard_description { local_req_builder = local_req_builder.query(&[( - "filter[outcome][service_name]", + "filter[scorecard][description]", &local_query_param.to_string(), )]); }; - if let Some(ref local_query_param) = filter_outcome_state { - local_req_builder = local_req_builder - .query(&[("filter[outcome][state]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_enabled { - local_req_builder = local_req_builder - .query(&[("filter[rule][enabled]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_id { - local_req_builder = - local_req_builder.query(&[("filter[rule][id]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_name { - local_req_builder = - local_req_builder.query(&[("filter[rule][name]", &local_query_param.to_string())]); - }; // build headers let mut headers = HeaderMap::new(); @@ -898,8 +2885,9 @@ impl ServiceScorecardsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) - { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -910,7 +2898,148 @@ impl ServiceScorecardsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + 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)) + } + } + + /// Sets up default scorecard rules for the organization. + pub async fn setup_scorecard_rules( + &self, + body: crate::datadogV2::model::SetupRulesRequest, + ) -> Result<(), datadog::Error> { + match self.setup_scorecard_rules_with_http_info(body).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Sets up default scorecard rules for the organization. + pub async fn setup_scorecard_rules_with_http_info( + &self, + body: crate::datadogV2::model::SetupRulesRequest, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.setup_scorecard_rules"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.setup_scorecard_rules' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/setup", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // 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() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -921,13 +3050,19 @@ impl ServiceScorecardsAPI { } } - /// Fetch all rules. - pub async fn list_scorecard_rules( + /// Updates an existing campaign. + pub async fn update_scorecard_campaign( &self, - params: ListScorecardRulesOptionalParams, - ) -> Result> - { - match self.list_scorecard_rules_with_http_info(params).await { + campaign_id: String, + body: crate::datadogV2::model::UpdateCampaignRequest, + ) -> Result< + crate::datadogV2::model::CampaignResponse, + datadog::Error, + > { + match self + .update_scorecard_campaign_with_http_info(campaign_id, body) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -941,127 +3076,39 @@ impl ServiceScorecardsAPI { } } - pub fn list_scorecard_rules_with_pagination( - &self, - mut params: ListScorecardRulesOptionalParams, - ) -> impl Stream< - Item = Result< - crate::datadogV2::model::ListRulesResponseDataItem, - datadog::Error, - >, - > + '_ { - try_stream! { - let mut page_size: i64 = 10; - if params.page_size.is_none() { - params.page_size = Some(page_size); - } else { - page_size = params.page_size.unwrap().clone(); - } - loop { - let resp = self.list_scorecard_rules(params.clone()).await?; - let Some(data) = resp.data else { break }; - - let r = data; - let count = r.len(); - for team in r { - yield team; - } - - if count < page_size as usize { - break; - } - if params.page_offset.is_none() { - params.page_offset = Some(page_size.clone()); - } else { - params.page_offset = Some(params.page_offset.unwrap() + page_size.clone()); - } - } - } - } - - /// Fetch all rules. - pub async fn list_scorecard_rules_with_http_info( + /// Updates an existing campaign. + pub async fn update_scorecard_campaign_with_http_info( &self, - params: ListScorecardRulesOptionalParams, + campaign_id: String, + body: crate::datadogV2::model::UpdateCampaignRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_scorecard_rules"; + let operation_id = "v2.update_scorecard_campaign"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.list_scorecard_rules' is not enabled".to_string(), + msg: "Operation 'v2.update_scorecard_campaign' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } - // unbox and build optional parameters - let page_size = params.page_size; - let page_offset = params.page_offset; - let include = params.include; - let filter_rule_id = params.filter_rule_id; - let filter_rule_enabled = params.filter_rule_enabled; - let filter_rule_custom = params.filter_rule_custom; - let filter_rule_name = params.filter_rule_name; - let filter_rule_description = params.filter_rule_description; - let fields_rule = params.fields_rule; - let fields_scorecard = params.fields_scorecard; - let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/scorecard/rules", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/scorecard/campaigns/{campaign_id}", + local_configuration.get_operation_host(operation_id), + campaign_id = datadog::urlencode(campaign_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - - if let Some(ref local_query_param) = page_size { - local_req_builder = - local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_offset { - local_req_builder = - local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = include { - local_req_builder = - local_req_builder.query(&[("include", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_id { - local_req_builder = - local_req_builder.query(&[("filter[rule][id]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_enabled { - local_req_builder = local_req_builder - .query(&[("filter[rule][enabled]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_custom { - local_req_builder = local_req_builder - .query(&[("filter[rule][custom]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_name { - local_req_builder = - local_req_builder.query(&[("filter[rule][name]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_description { - local_req_builder = local_req_builder - .query(&[("filter[rule][description]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = fields_rule { - local_req_builder = - local_req_builder.query(&[("fields[rule]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = fields_scorecard { - local_req_builder = - local_req_builder.query(&[("fields[scorecard]", &local_query_param.to_string())]); - }; + local_client.request(reqwest::Method::PUT, local_uri_str.as_str()); // 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 @@ -1092,6 +3139,51 @@ impl ServiceScorecardsAPI { ); }; + // 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()); @@ -1102,7 +3194,7 @@ impl ServiceScorecardsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { @@ -1114,7 +3206,7 @@ impl ServiceScorecardsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -1435,4 +3527,107 @@ impl ServiceScorecardsAPI { Err(datadog::Error::ResponseError(local_error)) } } + + /// Associates a workflow with a scorecard rule. + pub async fn update_scorecard_rule_workflow( + &self, + rule_id: String, + workflow_id: String, + ) -> Result<(), datadog::Error> { + match self + .update_scorecard_rule_workflow_with_http_info(rule_id, workflow_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Associates a workflow with a scorecard rule. + pub async fn update_scorecard_rule_workflow_with_http_info( + &self, + rule_id: String, + workflow_id: String, + ) -> Result, datadog::Error> + { + let local_configuration = &self.config; + let operation_id = "v2.update_scorecard_rule_workflow"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.update_scorecard_rule_workflow' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/scorecard/rules/{rule_id}/workflow/{workflow_id}", + local_configuration.get_operation_host(operation_id), + rule_id = datadog::urlencode(rule_id), + workflow_id = datadog::urlencode(workflow_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PUT, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // 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() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } 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)) + } + } } diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 81aa14e7d..f95f1a685 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -6310,6 +6310,72 @@ pub mod model_viewership_history_session_data_attributes; pub use self::model_viewership_history_session_data_attributes::ViewershipHistorySessionDataAttributes; pub mod model_idp_metadata_form_data; pub use self::model_idp_metadata_form_data::IdPMetadataFormData; +pub mod model_list_campaigns_response; +pub use self::model_list_campaigns_response::ListCampaignsResponse; +pub mod model_campaign_response_data; +pub use self::model_campaign_response_data::CampaignResponseData; +pub mod model_campaign_response_attributes; +pub use self::model_campaign_response_attributes::CampaignResponseAttributes; +pub mod model_campaign_type; +pub use self::model_campaign_type::CampaignType; +pub mod model_paginated_response_meta; +pub use self::model_paginated_response_meta::PaginatedResponseMeta; +pub mod model_create_campaign_request; +pub use self::model_create_campaign_request::CreateCampaignRequest; +pub mod model_create_campaign_request_data; +pub use self::model_create_campaign_request_data::CreateCampaignRequestData; +pub mod model_create_campaign_request_attributes; +pub use self::model_create_campaign_request_attributes::CreateCampaignRequestAttributes; +pub mod model_campaign_status; +pub use self::model_campaign_status::CampaignStatus; +pub mod model_campaign_response; +pub use self::model_campaign_response::CampaignResponse; +pub mod model_update_campaign_request; +pub use self::model_update_campaign_request::UpdateCampaignRequest; +pub mod model_update_campaign_request_data; +pub use self::model_update_campaign_request_data::UpdateCampaignRequestData; +pub mod model_update_campaign_request_attributes; +pub use self::model_update_campaign_request_attributes::UpdateCampaignRequestAttributes; +pub mod model_generate_campaign_team_reports_request; +pub use self::model_generate_campaign_team_reports_request::GenerateCampaignTeamReportsRequest; +pub mod model_generate_campaign_team_reports_request_data; +pub use self::model_generate_campaign_team_reports_request_data::GenerateCampaignTeamReportsRequestData; +pub mod model_generate_campaign_team_reports_request_attributes; +pub use self::model_generate_campaign_team_reports_request_attributes::GenerateCampaignTeamReportsRequestAttributes; +pub mod model_entity_owner_destination; +pub use self::model_entity_owner_destination::EntityOwnerDestination; +pub mod model_slack_routing_options; +pub use self::model_slack_routing_options::SlackRoutingOptions; +pub mod model_generate_campaign_team_reports_request_data_type; +pub use self::model_generate_campaign_team_reports_request_data_type::GenerateCampaignTeamReportsRequestDataType; +pub mod model_generate_campaign_report_request; +pub use self::model_generate_campaign_report_request::GenerateCampaignReportRequest; +pub mod model_generate_campaign_report_request_data; +pub use self::model_generate_campaign_report_request_data::GenerateCampaignReportRequestData; +pub mod model_generate_campaign_report_request_attributes; +pub use self::model_generate_campaign_report_request_attributes::GenerateCampaignReportRequestAttributes; +pub mod model_generate_campaign_report_request_data_type; +pub use self::model_generate_campaign_report_request_data_type::GenerateCampaignReportRequestDataType; +pub mod model_list_default_rules_response; +pub use self::model_list_default_rules_response::ListDefaultRulesResponse; +pub mod model_default_rule_response_data; +pub use self::model_default_rule_response_data::DefaultRuleResponseData; +pub mod model_default_rule_response_attributes; +pub use self::model_default_rule_response_attributes::DefaultRuleResponseAttributes; +pub mod model_default_rule_type; +pub use self::model_default_rule_type::DefaultRuleType; +pub mod model_list_facets_response; +pub use self::model_list_facets_response::ListFacetsResponse; +pub mod model_facet_response_data; +pub use self::model_facet_response_data::FacetResponseData; +pub mod model_facet_response_attributes; +pub use self::model_facet_response_attributes::FacetResponseAttributes; +pub mod model_facet_item; +pub use self::model_facet_item::FacetItem; +pub mod model_facet_type; +pub use self::model_facet_type::FacetType; +pub mod model_list_facets_response_meta; +pub use self::model_list_facets_response_meta::ListFacetsResponseMeta; pub mod model_outcomes_response; pub use self::model_outcomes_response::OutcomesResponse; pub mod model_outcomes_response_data_item; @@ -6390,6 +6456,30 @@ pub mod model_update_rule_response; pub use self::model_update_rule_response::UpdateRuleResponse; pub mod model_update_rule_response_data; pub use self::model_update_rule_response_data::UpdateRuleResponseData; +pub mod model_list_scorecards_response; +pub use self::model_list_scorecards_response::ListScorecardsResponse; +pub mod model_scorecard_list_response_data; +pub use self::model_scorecard_list_response_data::ScorecardListResponseData; +pub mod model_scorecard_list_response_attributes; +pub use self::model_scorecard_list_response_attributes::ScorecardListResponseAttributes; +pub mod model_scorecard_list_type; +pub use self::model_scorecard_list_type::ScorecardListType; +pub mod model_list_scores_response; +pub use self::model_list_scores_response::ListScoresResponse; +pub mod model_score_response_data; +pub use self::model_score_response_data::ScoreResponseData; +pub mod model_score_response_attributes; +pub use self::model_score_response_attributes::ScoreResponseAttributes; +pub mod model_score_type; +pub use self::model_score_type::ScoreType; +pub mod model_setup_rules_request; +pub use self::model_setup_rules_request::SetupRulesRequest; +pub mod model_setup_rules_request_data; +pub use self::model_setup_rules_request_data::SetupRulesRequestData; +pub mod model_setup_rules_request_attributes; +pub use self::model_setup_rules_request_attributes::SetupRulesRequestAttributes; +pub mod model_setup_rules_request_data_type; +pub use self::model_setup_rules_request_data_type::SetupRulesRequestDataType; pub mod model_unassign_seats_user_request; pub use self::model_unassign_seats_user_request::UnassignSeatsUserRequest; pub mod model_unassign_seats_user_request_data; diff --git a/src/datadogV2/model/model_campaign_response.rs b/src/datadogV2/model/model_campaign_response.rs new file mode 100644 index 000000000..209d687bc --- /dev/null +++ b/src/datadogV2/model/model_campaign_response.rs @@ -0,0 +1,92 @@ +// 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}; + +/// Response containing campaign data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CampaignResponse { + /// Campaign data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::CampaignResponseData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CampaignResponse { + pub fn new(data: crate::datadogV2::model::CampaignResponseData) -> CampaignResponse { + CampaignResponse { + 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 CampaignResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CampaignResponseVisitor; + impl<'a> Visitor<'a> for CampaignResponseVisitor { + type Value = CampaignResponse; + + 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 = CampaignResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CampaignResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_campaign_response_attributes.rs b/src/datadogV2/model/model_campaign_response_attributes.rs new file mode 100644 index 000000000..a6e9cd545 --- /dev/null +++ b/src/datadogV2/model/model_campaign_response_attributes.rs @@ -0,0 +1,232 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Campaign attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CampaignResponseAttributes { + /// Creation time of the campaign. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The description of the campaign. + #[serde(rename = "description")] + pub description: Option, + /// The due date of the campaign. + #[serde(rename = "due_date")] + pub due_date: Option>, + /// Entity scope query to filter entities for this campaign. + #[serde(rename = "entity_scope")] + pub entity_scope: Option, + /// Guidance for the campaign. + #[serde(rename = "guidance")] + pub guidance: Option, + /// The unique key for the campaign. + #[serde(rename = "key")] + pub key: String, + /// Time of last campaign modification. + #[serde(rename = "modified_at")] + pub modified_at: chrono::DateTime, + /// The name of the campaign. + #[serde(rename = "name")] + pub name: String, + /// The UUID of the campaign owner. + #[serde(rename = "owner")] + pub owner: String, + /// The start date of the campaign. + #[serde(rename = "start_date")] + pub start_date: chrono::DateTime, + /// The status of the campaign. + #[serde(rename = "status")] + pub status: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CampaignResponseAttributes { + pub fn new( + created_at: chrono::DateTime, + key: String, + modified_at: chrono::DateTime, + name: String, + owner: String, + start_date: chrono::DateTime, + status: String, + ) -> CampaignResponseAttributes { + CampaignResponseAttributes { + created_at, + description: None, + due_date: None, + entity_scope: None, + guidance: None, + key, + modified_at, + name, + owner, + start_date, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn due_date(mut self, value: chrono::DateTime) -> Self { + self.due_date = Some(value); + self + } + + pub fn entity_scope(mut self, value: String) -> Self { + self.entity_scope = Some(value); + self + } + + pub fn guidance(mut self, value: String) -> Self { + self.guidance = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CampaignResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CampaignResponseAttributesVisitor; + impl<'a> Visitor<'a> for CampaignResponseAttributesVisitor { + type Value = CampaignResponseAttributes; + + 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 created_at: Option> = None; + let mut description: Option = None; + let mut due_date: Option> = None; + let mut entity_scope: Option = None; + let mut guidance: Option = None; + let mut key: Option = None; + let mut modified_at: Option> = None; + let mut name: Option = None; + let mut owner: Option = None; + let mut start_date: Option> = None; + let mut status: 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() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "due_date" => { + if v.is_null() { + continue; + } + due_date = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "entity_scope" => { + if v.is_null() { + continue; + } + entity_scope = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "guidance" => { + if v.is_null() { + continue; + } + guidance = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "key" => { + key = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "owner" => { + owner = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "start_date" => { + start_date = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = 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 created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let key = key.ok_or_else(|| M::Error::missing_field("key"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let owner = owner.ok_or_else(|| M::Error::missing_field("owner"))?; + let start_date = start_date.ok_or_else(|| M::Error::missing_field("start_date"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = CampaignResponseAttributes { + created_at, + description, + due_date, + entity_scope, + guidance, + key, + modified_at, + name, + owner, + start_date, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CampaignResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_campaign_response_data.rs b/src/datadogV2/model/model_campaign_response_data.rs new file mode 100644 index 000000000..4c8a7ac56 --- /dev/null +++ b/src/datadogV2/model/model_campaign_response_data.rs @@ -0,0 +1,127 @@ +// 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}; + +/// Campaign data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CampaignResponseData { + /// Campaign attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::CampaignResponseAttributes, + /// The unique ID of the campaign. + #[serde(rename = "id")] + pub id: String, + /// The JSON:API type for campaigns. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::CampaignType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CampaignResponseData { + pub fn new( + attributes: crate::datadogV2::model::CampaignResponseAttributes, + id: String, + type_: crate::datadogV2::model::CampaignType, + ) -> CampaignResponseData { + CampaignResponseData { + attributes, + 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 CampaignResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CampaignResponseDataVisitor; + impl<'a> Visitor<'a> for CampaignResponseDataVisitor { + type Value = CampaignResponseData; + + 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 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" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "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::CampaignType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CampaignResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CampaignResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_campaign_status.rs b/src/datadogV2/model/model_campaign_status.rs new file mode 100644 index 000000000..04f249160 --- /dev/null +++ b/src/datadogV2/model/model_campaign_status.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 CampaignStatus { + IN_PROGRESS, + NOT_STARTED, + COMPLETED, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for CampaignStatus { + fn to_string(&self) -> String { + match self { + Self::IN_PROGRESS => String::from("in_progress"), + Self::NOT_STARTED => String::from("not_started"), + Self::COMPLETED => String::from("completed"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for CampaignStatus { + 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 CampaignStatus { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "in_progress" => Self::IN_PROGRESS, + "not_started" => Self::NOT_STARTED, + "completed" => Self::COMPLETED, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_campaign_type.rs b/src/datadogV2/model/model_campaign_type.rs new file mode 100644 index 000000000..1e515b4b7 --- /dev/null +++ b/src/datadogV2/model/model_campaign_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 CampaignType { + CAMPAIGN, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for CampaignType { + fn to_string(&self) -> String { + match self { + Self::CAMPAIGN => String::from("campaign"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for CampaignType { + 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 CampaignType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "campaign" => Self::CAMPAIGN, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_create_campaign_request.rs b/src/datadogV2/model/model_create_campaign_request.rs new file mode 100644 index 000000000..913170cf2 --- /dev/null +++ b/src/datadogV2/model/model_create_campaign_request.rs @@ -0,0 +1,92 @@ +// 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}; + +/// Request to create a new campaign. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateCampaignRequest { + /// Data for creating a new campaign. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::CreateCampaignRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateCampaignRequest { + pub fn new(data: crate::datadogV2::model::CreateCampaignRequestData) -> CreateCampaignRequest { + CreateCampaignRequest { + 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 CreateCampaignRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateCampaignRequestVisitor; + impl<'a> Visitor<'a> for CreateCampaignRequestVisitor { + type Value = CreateCampaignRequest; + + 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 = CreateCampaignRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateCampaignRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_create_campaign_request_attributes.rs b/src/datadogV2/model/model_create_campaign_request_attributes.rs new file mode 100644 index 000000000..3b8926d25 --- /dev/null +++ b/src/datadogV2/model/model_create_campaign_request_attributes.rs @@ -0,0 +1,235 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for creating a new campaign. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateCampaignRequestAttributes { + /// The description of the campaign. + #[serde(rename = "description")] + pub description: Option, + /// The due date of the campaign. + #[serde(rename = "due_date")] + pub due_date: Option>, + /// Entity scope query to filter entities for this campaign. + #[serde(rename = "entity_scope")] + pub entity_scope: Option, + /// Guidance for the campaign. + #[serde(rename = "guidance")] + pub guidance: Option, + /// The unique key for the campaign. + #[serde(rename = "key")] + pub key: String, + /// The name of the campaign. + #[serde(rename = "name")] + pub name: String, + /// The UUID of the campaign owner. + #[serde(rename = "owner_id")] + pub owner_id: String, + /// Array of rule IDs associated with this campaign. + #[serde(rename = "rule_ids")] + pub rule_ids: Vec, + /// The start date of the campaign. + #[serde(rename = "start_date")] + pub start_date: chrono::DateTime, + /// The status of the campaign. + #[serde(rename = "status")] + pub status: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateCampaignRequestAttributes { + pub fn new( + key: String, + name: String, + owner_id: String, + rule_ids: Vec, + start_date: chrono::DateTime, + ) -> CreateCampaignRequestAttributes { + CreateCampaignRequestAttributes { + description: None, + due_date: None, + entity_scope: None, + guidance: None, + key, + name, + owner_id, + rule_ids, + start_date, + status: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn due_date(mut self, value: chrono::DateTime) -> Self { + self.due_date = Some(value); + self + } + + pub fn entity_scope(mut self, value: String) -> Self { + self.entity_scope = Some(value); + self + } + + pub fn guidance(mut self, value: String) -> Self { + self.guidance = Some(value); + self + } + + pub fn status(mut self, value: crate::datadogV2::model::CampaignStatus) -> Self { + self.status = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateCampaignRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateCampaignRequestAttributesVisitor; + impl<'a> Visitor<'a> for CreateCampaignRequestAttributesVisitor { + type Value = CreateCampaignRequestAttributes; + + 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 description: Option = None; + let mut due_date: Option> = None; + let mut entity_scope: Option = None; + let mut guidance: Option = None; + let mut key: Option = None; + let mut name: Option = None; + let mut owner_id: Option = None; + let mut rule_ids: Option> = None; + let mut start_date: Option> = None; + let mut status: 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() { + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "due_date" => { + if v.is_null() { + continue; + } + due_date = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "entity_scope" => { + if v.is_null() { + continue; + } + entity_scope = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "guidance" => { + if v.is_null() { + continue; + } + guidance = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "key" => { + key = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "owner_id" => { + owner_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule_ids" => { + rule_ids = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "start_date" => { + start_date = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + if v.is_null() { + continue; + } + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::CampaignStatus::UnparsedObject( + _status, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let key = key.ok_or_else(|| M::Error::missing_field("key"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let owner_id = owner_id.ok_or_else(|| M::Error::missing_field("owner_id"))?; + let rule_ids = rule_ids.ok_or_else(|| M::Error::missing_field("rule_ids"))?; + let start_date = start_date.ok_or_else(|| M::Error::missing_field("start_date"))?; + + let content = CreateCampaignRequestAttributes { + description, + due_date, + entity_scope, + guidance, + key, + name, + owner_id, + rule_ids, + start_date, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateCampaignRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_campaign_request_data.rs b/src/datadogV2/model/model_create_campaign_request_data.rs new file mode 100644 index 000000000..b82737d33 --- /dev/null +++ b/src/datadogV2/model/model_create_campaign_request_data.rs @@ -0,0 +1,117 @@ +// 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}; + +/// Data for creating a new campaign. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateCampaignRequestData { + /// Attributes for creating a new campaign. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::CreateCampaignRequestAttributes, + /// The JSON:API type for campaigns. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::CampaignType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateCampaignRequestData { + pub fn new( + attributes: crate::datadogV2::model::CreateCampaignRequestAttributes, + type_: crate::datadogV2::model::CampaignType, + ) -> CreateCampaignRequestData { + CreateCampaignRequestData { + attributes, + 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 CreateCampaignRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateCampaignRequestDataVisitor; + impl<'a> Visitor<'a> for CreateCampaignRequestDataVisitor { + type Value = CreateCampaignRequestData; + + 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::CreateCampaignRequestAttributes, + > = 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" => { + attributes = 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::CampaignType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateCampaignRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateCampaignRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_default_rule_response_attributes.rs b/src/datadogV2/model/model_default_rule_response_attributes.rs new file mode 100644 index 000000000..5930d0472 --- /dev/null +++ b/src/datadogV2/model/model_default_rule_response_attributes.rs @@ -0,0 +1,175 @@ +// 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}; + +/// Default rule attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DefaultRuleResponseAttributes { + /// The description of the default rule. + #[serde(rename = "description")] + pub description: Option, + /// The maturity level of the rule. + #[serde(rename = "level")] + pub level: Option, + /// The name of the default rule. + #[serde(rename = "name")] + pub name: String, + /// Required scope for the rule. + #[serde(rename = "scope_required")] + pub scope_required: Option, + /// The description of the scorecard. + #[serde(rename = "scorecard_description")] + pub scorecard_description: Option, + /// The scorecard this rule belongs to. + #[serde(rename = "scorecard_name")] + pub scorecard_name: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DefaultRuleResponseAttributes { + pub fn new(name: String, scorecard_name: String) -> DefaultRuleResponseAttributes { + DefaultRuleResponseAttributes { + description: None, + level: None, + name, + scope_required: None, + scorecard_description: None, + scorecard_name, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn level(mut self, value: i64) -> Self { + self.level = Some(value); + self + } + + pub fn scope_required(mut self, value: String) -> Self { + self.scope_required = Some(value); + self + } + + pub fn scorecard_description(mut self, value: String) -> Self { + self.scorecard_description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DefaultRuleResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DefaultRuleResponseAttributesVisitor; + impl<'a> Visitor<'a> for DefaultRuleResponseAttributesVisitor { + type Value = DefaultRuleResponseAttributes; + + 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 description: Option = None; + let mut level: Option = None; + let mut name: Option = None; + let mut scope_required: Option = None; + let mut scorecard_description: Option = None; + let mut scorecard_name: 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() { + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "level" => { + if v.is_null() { + continue; + } + level = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scope_required" => { + if v.is_null() { + continue; + } + scope_required = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scorecard_description" => { + if v.is_null() { + continue; + } + scorecard_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scorecard_name" => { + scorecard_name = + 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let scorecard_name = + scorecard_name.ok_or_else(|| M::Error::missing_field("scorecard_name"))?; + + let content = DefaultRuleResponseAttributes { + description, + level, + name, + scope_required, + scorecard_description, + scorecard_name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DefaultRuleResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_default_rule_response_data.rs b/src/datadogV2/model/model_default_rule_response_data.rs new file mode 100644 index 000000000..9dc430f80 --- /dev/null +++ b/src/datadogV2/model/model_default_rule_response_data.rs @@ -0,0 +1,127 @@ +// 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}; + +/// Default rule data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DefaultRuleResponseData { + /// Default rule attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::DefaultRuleResponseAttributes, + /// The unique ID of the default rule. + #[serde(rename = "id")] + pub id: String, + /// The JSON:API type for default rules. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DefaultRuleType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DefaultRuleResponseData { + pub fn new( + attributes: crate::datadogV2::model::DefaultRuleResponseAttributes, + id: String, + type_: crate::datadogV2::model::DefaultRuleType, + ) -> DefaultRuleResponseData { + DefaultRuleResponseData { + attributes, + 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 DefaultRuleResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DefaultRuleResponseDataVisitor; + impl<'a> Visitor<'a> for DefaultRuleResponseDataVisitor { + type Value = DefaultRuleResponseData; + + 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 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" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "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::DefaultRuleType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DefaultRuleResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DefaultRuleResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_default_rule_type.rs b/src/datadogV2/model/model_default_rule_type.rs new file mode 100644 index 000000000..b7bab3d04 --- /dev/null +++ b/src/datadogV2/model/model_default_rule_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 DefaultRuleType { + DEFAULT_RULE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for DefaultRuleType { + fn to_string(&self) -> String { + match self { + Self::DEFAULT_RULE => String::from("default-rule"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for DefaultRuleType { + 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 DefaultRuleType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "default-rule" => Self::DEFAULT_RULE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_entity_owner_destination.rs b/src/datadogV2/model/model_entity_owner_destination.rs new file mode 100644 index 000000000..d987068ff --- /dev/null +++ b/src/datadogV2/model/model_entity_owner_destination.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}; + +/// Entity owner and Slack destination for team reports. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityOwnerDestination { + /// Slack routing options for report delivery. + #[serde(rename = "slack")] + pub slack: crate::datadogV2::model::SlackRoutingOptions, + /// Team UUID. + #[serde(rename = "team_id")] + pub team_id: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityOwnerDestination { + pub fn new( + slack: crate::datadogV2::model::SlackRoutingOptions, + team_id: String, + ) -> EntityOwnerDestination { + EntityOwnerDestination { + slack, + team_id, + 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 EntityOwnerDestination { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityOwnerDestinationVisitor; + impl<'a> Visitor<'a> for EntityOwnerDestinationVisitor { + type Value = EntityOwnerDestination; + + 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 slack: Option = None; + let mut team_id: 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() { + "slack" => { + slack = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "team_id" => { + team_id = 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 slack = slack.ok_or_else(|| M::Error::missing_field("slack"))?; + let team_id = team_id.ok_or_else(|| M::Error::missing_field("team_id"))?; + + let content = EntityOwnerDestination { + slack, + team_id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityOwnerDestinationVisitor) + } +} diff --git a/src/datadogV2/model/model_facet_item.rs b/src/datadogV2/model/model_facet_item.rs new file mode 100644 index 000000000..3d3180591 --- /dev/null +++ b/src/datadogV2/model/model_facet_item.rs @@ -0,0 +1,102 @@ +// 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}; + +/// Facet item with count. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FacetItem { + /// The name of the facet value. + #[serde(rename = "name")] + pub name: String, + /// The count for this facet value. + #[serde(rename = "value")] + pub value: i64, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FacetItem { + pub fn new(name: String, value: i64) -> FacetItem { + FacetItem { + name, + value, + 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 FacetItem { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FacetItemVisitor; + impl<'a> Visitor<'a> for FacetItemVisitor { + type Value = FacetItem; + + 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 name: Option = None; + let mut value: 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() { + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "value" => { + value = 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let value = value.ok_or_else(|| M::Error::missing_field("value"))?; + + let content = FacetItem { + name, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FacetItemVisitor) + } +} diff --git a/src/datadogV2/model/model_facet_response_attributes.rs b/src/datadogV2/model/model_facet_response_attributes.rs new file mode 100644 index 000000000..fe46ae1d2 --- /dev/null +++ b/src/datadogV2/model/model_facet_response_attributes.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}; + +/// Facet attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FacetResponseAttributes { + /// Array of facet values. + #[serde(rename = "items")] + pub items: Vec, + /// The key of the facet. + #[serde(rename = "key")] + pub key: String, + /// The display name of the facet. + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FacetResponseAttributes { + pub fn new( + items: Vec, + key: String, + ) -> FacetResponseAttributes { + FacetResponseAttributes { + items, + key, + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FacetResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FacetResponseAttributesVisitor; + impl<'a> Visitor<'a> for FacetResponseAttributesVisitor { + type Value = FacetResponseAttributes; + + 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 items: Option> = None; + let mut key: Option = None; + let mut name: 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() { + "items" => { + items = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "key" => { + key = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = 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 items = items.ok_or_else(|| M::Error::missing_field("items"))?; + let key = key.ok_or_else(|| M::Error::missing_field("key"))?; + + let content = FacetResponseAttributes { + items, + key, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FacetResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_facet_response_data.rs b/src/datadogV2/model/model_facet_response_data.rs new file mode 100644 index 000000000..d5fc97800 --- /dev/null +++ b/src/datadogV2/model/model_facet_response_data.rs @@ -0,0 +1,124 @@ +// 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}; + +/// Facet data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FacetResponseData { + /// Facet attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FacetResponseAttributes, + /// The unique ID of the facet. + #[serde(rename = "id")] + pub id: String, + /// The JSON:API type for facets. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FacetType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FacetResponseData { + pub fn new( + attributes: crate::datadogV2::model::FacetResponseAttributes, + id: String, + type_: crate::datadogV2::model::FacetType, + ) -> FacetResponseData { + FacetResponseData { + attributes, + 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 FacetResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FacetResponseDataVisitor; + impl<'a> Visitor<'a> for FacetResponseDataVisitor { + type Value = FacetResponseData; + + 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 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" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "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::FacetType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FacetResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FacetResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_facet_type.rs b/src/datadogV2/model/model_facet_type.rs new file mode 100644 index 000000000..dd4b5508b --- /dev/null +++ b/src/datadogV2/model/model_facet_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 FacetType { + FACET, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for FacetType { + fn to_string(&self) -> String { + match self { + Self::FACET => String::from("facet"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for FacetType { + 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 FacetType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "facet" => Self::FACET, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_generate_campaign_report_request.rs b/src/datadogV2/model/model_generate_campaign_report_request.rs new file mode 100644 index 000000000..a56a73f72 --- /dev/null +++ b/src/datadogV2/model/model_generate_campaign_report_request.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}; + +/// Request to generate a campaign report. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GenerateCampaignReportRequest { + /// Data for generating a campaign report. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::GenerateCampaignReportRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GenerateCampaignReportRequest { + pub fn new( + data: crate::datadogV2::model::GenerateCampaignReportRequestData, + ) -> GenerateCampaignReportRequest { + GenerateCampaignReportRequest { + 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 GenerateCampaignReportRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GenerateCampaignReportRequestVisitor; + impl<'a> Visitor<'a> for GenerateCampaignReportRequestVisitor { + type Value = GenerateCampaignReportRequest; + + 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 = GenerateCampaignReportRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GenerateCampaignReportRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_generate_campaign_report_request_attributes.rs b/src/datadogV2/model/model_generate_campaign_report_request_attributes.rs new file mode 100644 index 000000000..d5d7ac5d2 --- /dev/null +++ b/src/datadogV2/model/model_generate_campaign_report_request_attributes.rs @@ -0,0 +1,94 @@ +// 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}; + +/// Attributes for generating a campaign report. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GenerateCampaignReportRequestAttributes { + /// Slack routing options for report delivery. + #[serde(rename = "slack")] + pub slack: crate::datadogV2::model::SlackRoutingOptions, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GenerateCampaignReportRequestAttributes { + pub fn new( + slack: crate::datadogV2::model::SlackRoutingOptions, + ) -> GenerateCampaignReportRequestAttributes { + GenerateCampaignReportRequestAttributes { + slack, + 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 GenerateCampaignReportRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GenerateCampaignReportRequestAttributesVisitor; + impl<'a> Visitor<'a> for GenerateCampaignReportRequestAttributesVisitor { + type Value = GenerateCampaignReportRequestAttributes; + + 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 slack: 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() { + "slack" => { + slack = 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 slack = slack.ok_or_else(|| M::Error::missing_field("slack"))?; + + let content = GenerateCampaignReportRequestAttributes { + slack, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GenerateCampaignReportRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_generate_campaign_report_request_data.rs b/src/datadogV2/model/model_generate_campaign_report_request_data.rs new file mode 100644 index 000000000..1b92615c3 --- /dev/null +++ b/src/datadogV2/model/model_generate_campaign_report_request_data.rs @@ -0,0 +1,116 @@ +// 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}; + +/// Data for generating a campaign report. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GenerateCampaignReportRequestData { + /// Attributes for generating a campaign report. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::GenerateCampaignReportRequestAttributes, + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::GenerateCampaignReportRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GenerateCampaignReportRequestData { + pub fn new( + attributes: crate::datadogV2::model::GenerateCampaignReportRequestAttributes, + type_: crate::datadogV2::model::GenerateCampaignReportRequestDataType, + ) -> GenerateCampaignReportRequestData { + GenerateCampaignReportRequestData { + attributes, + 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 GenerateCampaignReportRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GenerateCampaignReportRequestDataVisitor; + impl<'a> Visitor<'a> for GenerateCampaignReportRequestDataVisitor { + type Value = GenerateCampaignReportRequestData; + + 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::GenerateCampaignReportRequestAttributes, + > = None; + let mut type_: Option< + crate::datadogV2::model::GenerateCampaignReportRequestDataType, + > = 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" => { + attributes = 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::GenerateCampaignReportRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = GenerateCampaignReportRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GenerateCampaignReportRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_generate_campaign_report_request_data_type.rs b/src/datadogV2/model/model_generate_campaign_report_request_data_type.rs new file mode 100644 index 000000000..2e16dfc20 --- /dev/null +++ b/src/datadogV2/model/model_generate_campaign_report_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 GenerateCampaignReportRequestDataType { + CAMPAIGN_REPORT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for GenerateCampaignReportRequestDataType { + fn to_string(&self) -> String { + match self { + Self::CAMPAIGN_REPORT => String::from("campaign-report"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for GenerateCampaignReportRequestDataType { + 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 GenerateCampaignReportRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "campaign-report" => Self::CAMPAIGN_REPORT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_generate_campaign_team_reports_request.rs b/src/datadogV2/model/model_generate_campaign_team_reports_request.rs new file mode 100644 index 000000000..aa00bc1ed --- /dev/null +++ b/src/datadogV2/model/model_generate_campaign_team_reports_request.rs @@ -0,0 +1,96 @@ +// 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}; + +/// Request to generate team-specific campaign reports. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GenerateCampaignTeamReportsRequest { + /// Data for generating team campaign reports. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::GenerateCampaignTeamReportsRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GenerateCampaignTeamReportsRequest { + pub fn new( + data: crate::datadogV2::model::GenerateCampaignTeamReportsRequestData, + ) -> GenerateCampaignTeamReportsRequest { + GenerateCampaignTeamReportsRequest { + 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 GenerateCampaignTeamReportsRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GenerateCampaignTeamReportsRequestVisitor; + impl<'a> Visitor<'a> for GenerateCampaignTeamReportsRequestVisitor { + type Value = GenerateCampaignTeamReportsRequest; + + 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< + crate::datadogV2::model::GenerateCampaignTeamReportsRequestData, + > = 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 = GenerateCampaignTeamReportsRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GenerateCampaignTeamReportsRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_generate_campaign_team_reports_request_attributes.rs b/src/datadogV2/model/model_generate_campaign_team_reports_request_attributes.rs new file mode 100644 index 000000000..9cde202ab --- /dev/null +++ b/src/datadogV2/model/model_generate_campaign_team_reports_request_attributes.rs @@ -0,0 +1,98 @@ +// 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}; + +/// Attributes for generating team campaign reports. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GenerateCampaignTeamReportsRequestAttributes { + /// List of entity owners and their Slack destinations. + #[serde(rename = "entity_owners")] + pub entity_owners: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GenerateCampaignTeamReportsRequestAttributes { + pub fn new( + entity_owners: Vec, + ) -> GenerateCampaignTeamReportsRequestAttributes { + GenerateCampaignTeamReportsRequestAttributes { + entity_owners, + 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 GenerateCampaignTeamReportsRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GenerateCampaignTeamReportsRequestAttributesVisitor; + impl<'a> Visitor<'a> for GenerateCampaignTeamReportsRequestAttributesVisitor { + type Value = GenerateCampaignTeamReportsRequestAttributes; + + 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 entity_owners: 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() { + "entity_owners" => { + entity_owners = + 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 entity_owners = + entity_owners.ok_or_else(|| M::Error::missing_field("entity_owners"))?; + + let content = GenerateCampaignTeamReportsRequestAttributes { + entity_owners, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GenerateCampaignTeamReportsRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_generate_campaign_team_reports_request_data.rs b/src/datadogV2/model/model_generate_campaign_team_reports_request_data.rs new file mode 100644 index 000000000..a817539c9 --- /dev/null +++ b/src/datadogV2/model/model_generate_campaign_team_reports_request_data.rs @@ -0,0 +1,116 @@ +// 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}; + +/// Data for generating team campaign reports. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GenerateCampaignTeamReportsRequestData { + /// Attributes for generating team campaign reports. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::GenerateCampaignTeamReportsRequestAttributes, + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::GenerateCampaignTeamReportsRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GenerateCampaignTeamReportsRequestData { + pub fn new( + attributes: crate::datadogV2::model::GenerateCampaignTeamReportsRequestAttributes, + type_: crate::datadogV2::model::GenerateCampaignTeamReportsRequestDataType, + ) -> GenerateCampaignTeamReportsRequestData { + GenerateCampaignTeamReportsRequestData { + attributes, + 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 GenerateCampaignTeamReportsRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GenerateCampaignTeamReportsRequestDataVisitor; + impl<'a> Visitor<'a> for GenerateCampaignTeamReportsRequestDataVisitor { + type Value = GenerateCampaignTeamReportsRequestData; + + 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::GenerateCampaignTeamReportsRequestAttributes, + > = None; + let mut type_: Option< + crate::datadogV2::model::GenerateCampaignTeamReportsRequestDataType, + > = 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" => { + attributes = 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::GenerateCampaignTeamReportsRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = GenerateCampaignTeamReportsRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GenerateCampaignTeamReportsRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_generate_campaign_team_reports_request_data_type.rs b/src/datadogV2/model/model_generate_campaign_team_reports_request_data_type.rs new file mode 100644 index 000000000..6c7d121a3 --- /dev/null +++ b/src/datadogV2/model/model_generate_campaign_team_reports_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 GenerateCampaignTeamReportsRequestDataType { + CAMPAIGN_TEAM_REPORT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for GenerateCampaignTeamReportsRequestDataType { + fn to_string(&self) -> String { + match self { + Self::CAMPAIGN_TEAM_REPORT => String::from("campaign-team-report"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for GenerateCampaignTeamReportsRequestDataType { + 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 GenerateCampaignTeamReportsRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "campaign-team-report" => Self::CAMPAIGN_TEAM_REPORT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_list_campaigns_response.rs b/src/datadogV2/model/model_list_campaigns_response.rs new file mode 100644 index 000000000..7b5f6d7bd --- /dev/null +++ b/src/datadogV2/model/model_list_campaigns_response.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}; + +/// Response containing a list of campaigns. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ListCampaignsResponse { + /// Array of campaigns. + #[serde(rename = "data")] + pub data: Vec, + /// Metadata for scores response. + #[serde(rename = "meta")] + pub meta: crate::datadogV2::model::PaginatedResponseMeta, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ListCampaignsResponse { + pub fn new( + data: Vec, + meta: crate::datadogV2::model::PaginatedResponseMeta, + ) -> ListCampaignsResponse { + ListCampaignsResponse { + data, + meta, + 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 ListCampaignsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ListCampaignsResponseVisitor; + impl<'a> Visitor<'a> for ListCampaignsResponseVisitor { + type Value = ListCampaignsResponse; + + 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 meta: 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)?); + } + "meta" => { + meta = 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 meta = meta.ok_or_else(|| M::Error::missing_field("meta"))?; + + let content = ListCampaignsResponse { + data, + meta, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ListCampaignsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_list_default_rules_response.rs b/src/datadogV2/model/model_list_default_rules_response.rs new file mode 100644 index 000000000..d2d0a5d70 --- /dev/null +++ b/src/datadogV2/model/model_list_default_rules_response.rs @@ -0,0 +1,94 @@ +// 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}; + +/// Response containing a list of default rules. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ListDefaultRulesResponse { + /// Array of default rules. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ListDefaultRulesResponse { + pub fn new( + data: Vec, + ) -> ListDefaultRulesResponse { + ListDefaultRulesResponse { + 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 ListDefaultRulesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ListDefaultRulesResponseVisitor; + impl<'a> Visitor<'a> for ListDefaultRulesResponseVisitor { + type Value = ListDefaultRulesResponse; + + 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 = ListDefaultRulesResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ListDefaultRulesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_list_facets_response.rs b/src/datadogV2/model/model_list_facets_response.rs new file mode 100644 index 000000000..a05f214c1 --- /dev/null +++ b/src/datadogV2/model/model_list_facets_response.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}; + +/// Response containing a list of facets. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ListFacetsResponse { + /// Array of facets. + #[serde(rename = "data")] + pub data: Vec, + /// Metadata for facets response. + #[serde(rename = "meta")] + pub meta: crate::datadogV2::model::ListFacetsResponseMeta, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ListFacetsResponse { + pub fn new( + data: Vec, + meta: crate::datadogV2::model::ListFacetsResponseMeta, + ) -> ListFacetsResponse { + ListFacetsResponse { + data, + meta, + 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 ListFacetsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ListFacetsResponseVisitor; + impl<'a> Visitor<'a> for ListFacetsResponseVisitor { + type Value = ListFacetsResponse; + + 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 meta: 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)?); + } + "meta" => { + meta = 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 meta = meta.ok_or_else(|| M::Error::missing_field("meta"))?; + + let content = ListFacetsResponse { + data, + meta, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ListFacetsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_list_facets_response_meta.rs b/src/datadogV2/model/model_list_facets_response_meta.rs new file mode 100644 index 000000000..b93b137cd --- /dev/null +++ b/src/datadogV2/model/model_list_facets_response_meta.rs @@ -0,0 +1,94 @@ +// 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}; + +/// Metadata for facets response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ListFacetsResponseMeta { + /// Total number of entities. + #[serde(rename = "total_entities")] + pub total_entities: i64, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ListFacetsResponseMeta { + pub fn new(total_entities: i64) -> ListFacetsResponseMeta { + ListFacetsResponseMeta { + total_entities, + 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 ListFacetsResponseMeta { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ListFacetsResponseMetaVisitor; + impl<'a> Visitor<'a> for ListFacetsResponseMetaVisitor { + type Value = ListFacetsResponseMeta; + + 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 total_entities: 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() { + "total_entities" => { + total_entities = + 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 total_entities = + total_entities.ok_or_else(|| M::Error::missing_field("total_entities"))?; + + let content = ListFacetsResponseMeta { + total_entities, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ListFacetsResponseMetaVisitor) + } +} diff --git a/src/datadogV2/model/model_list_scorecards_response.rs b/src/datadogV2/model/model_list_scorecards_response.rs new file mode 100644 index 000000000..fd04f276a --- /dev/null +++ b/src/datadogV2/model/model_list_scorecards_response.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}; + +/// Response containing a list of scorecards. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ListScorecardsResponse { + /// Array of scorecards. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ListScorecardsResponse { + pub fn new( + data: Vec, + ) -> ListScorecardsResponse { + ListScorecardsResponse { + 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 ListScorecardsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ListScorecardsResponseVisitor; + impl<'a> Visitor<'a> for ListScorecardsResponseVisitor { + type Value = ListScorecardsResponse; + + 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 = ListScorecardsResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ListScorecardsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_list_scores_response.rs b/src/datadogV2/model/model_list_scores_response.rs new file mode 100644 index 000000000..18cff420e --- /dev/null +++ b/src/datadogV2/model/model_list_scores_response.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}; + +/// Response containing a list of scores. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ListScoresResponse { + /// Array of scores. + #[serde(rename = "data")] + pub data: Vec, + /// Metadata for scores response. + #[serde(rename = "meta")] + pub meta: crate::datadogV2::model::PaginatedResponseMeta, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ListScoresResponse { + pub fn new( + data: Vec, + meta: crate::datadogV2::model::PaginatedResponseMeta, + ) -> ListScoresResponse { + ListScoresResponse { + data, + meta, + 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 ListScoresResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ListScoresResponseVisitor; + impl<'a> Visitor<'a> for ListScoresResponseVisitor { + type Value = ListScoresResponse; + + 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 meta: 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)?); + } + "meta" => { + meta = 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 meta = meta.ok_or_else(|| M::Error::missing_field("meta"))?; + + let content = ListScoresResponse { + data, + meta, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ListScoresResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_paginated_response_meta.rs b/src/datadogV2/model/model_paginated_response_meta.rs new file mode 100644 index 000000000..1bb155bd1 --- /dev/null +++ b/src/datadogV2/model/model_paginated_response_meta.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}; + +/// Metadata for scores response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PaginatedResponseMeta { + /// Number of entities in this response. + #[serde(rename = "count")] + pub count: i64, + /// Pagination limit. + #[serde(rename = "limit")] + pub limit: i64, + /// Pagination offset. + #[serde(rename = "offset")] + pub offset: i64, + /// Total number of entities available. + #[serde(rename = "total")] + pub total: i64, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PaginatedResponseMeta { + pub fn new(count: i64, limit: i64, offset: i64, total: i64) -> PaginatedResponseMeta { + PaginatedResponseMeta { + count, + limit, + offset, + total, + 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 PaginatedResponseMeta { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PaginatedResponseMetaVisitor; + impl<'a> Visitor<'a> for PaginatedResponseMetaVisitor { + type Value = PaginatedResponseMeta; + + 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 count: Option = None; + let mut limit: Option = None; + let mut offset: Option = None; + let mut total: 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() { + "count" => { + count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "limit" => { + limit = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "offset" => { + offset = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total" => { + total = 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 count = count.ok_or_else(|| M::Error::missing_field("count"))?; + let limit = limit.ok_or_else(|| M::Error::missing_field("limit"))?; + let offset = offset.ok_or_else(|| M::Error::missing_field("offset"))?; + let total = total.ok_or_else(|| M::Error::missing_field("total"))?; + + let content = PaginatedResponseMeta { + count, + limit, + offset, + total, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PaginatedResponseMetaVisitor) + } +} diff --git a/src/datadogV2/model/model_score_response_attributes.rs b/src/datadogV2/model/model_score_response_attributes.rs new file mode 100644 index 000000000..90d56b6c8 --- /dev/null +++ b/src/datadogV2/model/model_score_response_attributes.rs @@ -0,0 +1,177 @@ +// 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}; + +/// Score attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScoreResponseAttributes { + /// The aggregation type. + #[serde(rename = "aggregation")] + pub aggregation: String, + /// Score denominator. + #[serde(rename = "denominator")] + pub denominator: i64, + /// Score numerator. + #[serde(rename = "numerator")] + pub numerator: i64, + /// Calculated score value. + #[serde(rename = "score")] + pub score: f64, + /// Total number of failing rules. + #[serde(rename = "total_fail")] + pub total_fail: i64, + /// Total number of rules with no data. + #[serde(rename = "total_no_data")] + pub total_no_data: i64, + /// Total number of passing rules. + #[serde(rename = "total_pass")] + pub total_pass: i64, + /// Total number of skipped rules. + #[serde(rename = "total_skip")] + pub total_skip: i64, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScoreResponseAttributes { + pub fn new( + aggregation: String, + denominator: i64, + numerator: i64, + score: f64, + total_fail: i64, + total_no_data: i64, + total_pass: i64, + total_skip: i64, + ) -> ScoreResponseAttributes { + ScoreResponseAttributes { + aggregation, + denominator, + numerator, + score, + total_fail, + total_no_data, + total_pass, + total_skip, + 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 ScoreResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScoreResponseAttributesVisitor; + impl<'a> Visitor<'a> for ScoreResponseAttributesVisitor { + type Value = ScoreResponseAttributes; + + 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 aggregation: Option = None; + let mut denominator: Option = None; + let mut numerator: Option = None; + let mut score: Option = None; + let mut total_fail: Option = None; + let mut total_no_data: Option = None; + let mut total_pass: Option = None; + let mut total_skip: 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() { + "aggregation" => { + aggregation = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "denominator" => { + denominator = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "numerator" => { + numerator = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "score" => { + score = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_fail" => { + total_fail = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_no_data" => { + total_no_data = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_pass" => { + total_pass = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_skip" => { + total_skip = 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 aggregation = + aggregation.ok_or_else(|| M::Error::missing_field("aggregation"))?; + let denominator = + denominator.ok_or_else(|| M::Error::missing_field("denominator"))?; + let numerator = numerator.ok_or_else(|| M::Error::missing_field("numerator"))?; + let score = score.ok_or_else(|| M::Error::missing_field("score"))?; + let total_fail = total_fail.ok_or_else(|| M::Error::missing_field("total_fail"))?; + let total_no_data = + total_no_data.ok_or_else(|| M::Error::missing_field("total_no_data"))?; + let total_pass = total_pass.ok_or_else(|| M::Error::missing_field("total_pass"))?; + let total_skip = total_skip.ok_or_else(|| M::Error::missing_field("total_skip"))?; + + let content = ScoreResponseAttributes { + aggregation, + denominator, + numerator, + score, + total_fail, + total_no_data, + total_pass, + total_skip, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScoreResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_score_response_data.rs b/src/datadogV2/model/model_score_response_data.rs new file mode 100644 index 000000000..f49435078 --- /dev/null +++ b/src/datadogV2/model/model_score_response_data.rs @@ -0,0 +1,124 @@ +// 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}; + +/// Score data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScoreResponseData { + /// Score attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::ScoreResponseAttributes, + /// The unique ID of the score entity. + #[serde(rename = "id")] + pub id: String, + /// The JSON:API type for scores. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ScoreType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScoreResponseData { + pub fn new( + attributes: crate::datadogV2::model::ScoreResponseAttributes, + id: String, + type_: crate::datadogV2::model::ScoreType, + ) -> ScoreResponseData { + ScoreResponseData { + attributes, + 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 ScoreResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScoreResponseDataVisitor; + impl<'a> Visitor<'a> for ScoreResponseDataVisitor { + type Value = ScoreResponseData; + + 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 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" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "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::ScoreType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ScoreResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScoreResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_score_type.rs b/src/datadogV2/model/model_score_type.rs new file mode 100644 index 000000000..fc22e7c7e --- /dev/null +++ b/src/datadogV2/model/model_score_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 ScoreType { + SCORE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ScoreType { + fn to_string(&self) -> String { + match self { + Self::SCORE => String::from("score"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ScoreType { + 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 ScoreType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "score" => Self::SCORE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_scorecard_list_response_attributes.rs b/src/datadogV2/model/model_scorecard_list_response_attributes.rs new file mode 100644 index 000000000..292ba13a5 --- /dev/null +++ b/src/datadogV2/model/model_scorecard_list_response_attributes.rs @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Scorecard attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScorecardListResponseAttributes { + /// Creation time of the scorecard. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The description of the scorecard. + #[serde(rename = "description")] + pub description: Option, + /// Time of last scorecard modification. + #[serde(rename = "modified_at")] + pub modified_at: chrono::DateTime, + /// The name of the scorecard. + #[serde(rename = "name")] + pub name: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScorecardListResponseAttributes { + pub fn new( + created_at: chrono::DateTime, + modified_at: chrono::DateTime, + name: String, + ) -> ScorecardListResponseAttributes { + ScorecardListResponseAttributes { + created_at, + description: None, + modified_at, + name, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ScorecardListResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScorecardListResponseAttributesVisitor; + impl<'a> Visitor<'a> for ScorecardListResponseAttributesVisitor { + type Value = ScorecardListResponseAttributes; + + 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 created_at: Option> = None; + let mut description: Option = None; + let mut modified_at: Option> = None; + let mut name: 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() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = 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 created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = ScorecardListResponseAttributes { + created_at, + description, + modified_at, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScorecardListResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_scorecard_list_response_data.rs b/src/datadogV2/model/model_scorecard_list_response_data.rs new file mode 100644 index 000000000..193e09076 --- /dev/null +++ b/src/datadogV2/model/model_scorecard_list_response_data.rs @@ -0,0 +1,128 @@ +// 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}; + +/// Scorecard data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScorecardListResponseData { + /// Scorecard attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::ScorecardListResponseAttributes, + /// The unique ID of the scorecard. + #[serde(rename = "id")] + pub id: String, + /// The JSON:API type for scorecard list. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ScorecardListType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScorecardListResponseData { + pub fn new( + attributes: crate::datadogV2::model::ScorecardListResponseAttributes, + id: String, + type_: crate::datadogV2::model::ScorecardListType, + ) -> ScorecardListResponseData { + ScorecardListResponseData { + attributes, + 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 ScorecardListResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScorecardListResponseDataVisitor; + impl<'a> Visitor<'a> for ScorecardListResponseDataVisitor { + type Value = ScorecardListResponseData; + + 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::ScorecardListResponseAttributes, + > = 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" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "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::ScorecardListType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ScorecardListResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScorecardListResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_scorecard_list_type.rs b/src/datadogV2/model/model_scorecard_list_type.rs new file mode 100644 index 000000000..b29940637 --- /dev/null +++ b/src/datadogV2/model/model_scorecard_list_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 ScorecardListType { + SCORECARD, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ScorecardListType { + fn to_string(&self) -> String { + match self { + Self::SCORECARD => String::from("scorecard"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ScorecardListType { + 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 ScorecardListType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "scorecard" => Self::SCORECARD, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_setup_rules_request.rs b/src/datadogV2/model/model_setup_rules_request.rs new file mode 100644 index 000000000..5dddbe03b --- /dev/null +++ b/src/datadogV2/model/model_setup_rules_request.rs @@ -0,0 +1,92 @@ +// 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}; + +/// Request to set up rules for an organization. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SetupRulesRequest { + /// Data for setting up rules. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::SetupRulesRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SetupRulesRequest { + pub fn new(data: crate::datadogV2::model::SetupRulesRequestData) -> SetupRulesRequest { + SetupRulesRequest { + 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 SetupRulesRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SetupRulesRequestVisitor; + impl<'a> Visitor<'a> for SetupRulesRequestVisitor { + type Value = SetupRulesRequest; + + 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 = SetupRulesRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SetupRulesRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_setup_rules_request_attributes.rs b/src/datadogV2/model/model_setup_rules_request_attributes.rs new file mode 100644 index 000000000..220677010 --- /dev/null +++ b/src/datadogV2/model/model_setup_rules_request_attributes.rs @@ -0,0 +1,106 @@ +// 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}; + +/// Attributes for setting up rules. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SetupRulesRequestAttributes { + /// Array of default rule IDs to disable. + #[serde(rename = "disabled_default_rules")] + pub disabled_default_rules: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SetupRulesRequestAttributes { + pub fn new() -> SetupRulesRequestAttributes { + SetupRulesRequestAttributes { + disabled_default_rules: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn disabled_default_rules(mut self, value: Vec) -> Self { + self.disabled_default_rules = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SetupRulesRequestAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SetupRulesRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SetupRulesRequestAttributesVisitor; + impl<'a> Visitor<'a> for SetupRulesRequestAttributesVisitor { + type Value = SetupRulesRequestAttributes; + + 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 disabled_default_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() { + "disabled_default_rules" => { + if v.is_null() { + continue; + } + disabled_default_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 = SetupRulesRequestAttributes { + disabled_default_rules, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SetupRulesRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_setup_rules_request_data.rs b/src/datadogV2/model/model_setup_rules_request_data.rs new file mode 100644 index 000000000..35a42a6e5 --- /dev/null +++ b/src/datadogV2/model/model_setup_rules_request_data.rs @@ -0,0 +1,113 @@ +// 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}; + +/// Data for setting up rules. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SetupRulesRequestData { + /// Attributes for setting up rules. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::SetupRulesRequestAttributes, + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::SetupRulesRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SetupRulesRequestData { + pub fn new( + attributes: crate::datadogV2::model::SetupRulesRequestAttributes, + type_: crate::datadogV2::model::SetupRulesRequestDataType, + ) -> SetupRulesRequestData { + SetupRulesRequestData { + attributes, + 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 SetupRulesRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SetupRulesRequestDataVisitor; + impl<'a> Visitor<'a> for SetupRulesRequestDataVisitor { + type Value = SetupRulesRequestData; + + 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 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" => { + attributes = 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::SetupRulesRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = SetupRulesRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SetupRulesRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_setup_rules_request_data_type.rs b/src/datadogV2/model/model_setup_rules_request_data_type.rs new file mode 100644 index 000000000..1a0e62b93 --- /dev/null +++ b/src/datadogV2/model/model_setup_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 SetupRulesRequestDataType { + SETUP, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SetupRulesRequestDataType { + fn to_string(&self) -> String { + match self { + Self::SETUP => String::from("setup"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SetupRulesRequestDataType { + 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 SetupRulesRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "setup" => Self::SETUP, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_slack_routing_options.rs b/src/datadogV2/model/model_slack_routing_options.rs new file mode 100644 index 000000000..77db3c158 --- /dev/null +++ b/src/datadogV2/model/model_slack_routing_options.rs @@ -0,0 +1,159 @@ +// 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}; + +/// Slack routing options for report delivery. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SlackRoutingOptions { + /// Slack channel ID. + #[serde(rename = "channel_id")] + pub channel_id: Option, + /// Slack channel name. + #[serde(rename = "channel_name")] + pub channel_name: Option, + /// Slack workspace ID. + #[serde(rename = "workspace_id")] + pub workspace_id: Option, + /// Slack workspace name. + #[serde(rename = "workspace_name")] + pub workspace_name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SlackRoutingOptions { + pub fn new() -> SlackRoutingOptions { + SlackRoutingOptions { + channel_id: None, + channel_name: None, + workspace_id: None, + workspace_name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn channel_id(mut self, value: String) -> Self { + self.channel_id = Some(value); + self + } + + pub fn channel_name(mut self, value: String) -> Self { + self.channel_name = Some(value); + self + } + + pub fn workspace_id(mut self, value: String) -> Self { + self.workspace_id = Some(value); + self + } + + pub fn workspace_name(mut self, value: String) -> Self { + self.workspace_name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SlackRoutingOptions { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SlackRoutingOptions { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SlackRoutingOptionsVisitor; + impl<'a> Visitor<'a> for SlackRoutingOptionsVisitor { + type Value = SlackRoutingOptions; + + 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_id: Option = None; + let mut channel_name: Option = None; + let mut workspace_id: Option = None; + let mut workspace_name: 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_id" => { + if v.is_null() { + continue; + } + channel_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "channel_name" => { + if v.is_null() { + continue; + } + channel_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "workspace_id" => { + if v.is_null() { + continue; + } + workspace_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "workspace_name" => { + if v.is_null() { + continue; + } + workspace_name = + 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 = SlackRoutingOptions { + channel_id, + channel_name, + workspace_id, + workspace_name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SlackRoutingOptionsVisitor) + } +} diff --git a/src/datadogV2/model/model_update_campaign_request.rs b/src/datadogV2/model/model_update_campaign_request.rs new file mode 100644 index 000000000..2617f6aef --- /dev/null +++ b/src/datadogV2/model/model_update_campaign_request.rs @@ -0,0 +1,92 @@ +// 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}; + +/// Request to update a campaign. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateCampaignRequest { + /// Data for updating a campaign. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::UpdateCampaignRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateCampaignRequest { + pub fn new(data: crate::datadogV2::model::UpdateCampaignRequestData) -> UpdateCampaignRequest { + UpdateCampaignRequest { + 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 UpdateCampaignRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateCampaignRequestVisitor; + impl<'a> Visitor<'a> for UpdateCampaignRequestVisitor { + type Value = UpdateCampaignRequest; + + 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 = UpdateCampaignRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateCampaignRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_update_campaign_request_attributes.rs b/src/datadogV2/model/model_update_campaign_request_attributes.rs new file mode 100644 index 000000000..7435d3806 --- /dev/null +++ b/src/datadogV2/model/model_update_campaign_request_attributes.rs @@ -0,0 +1,225 @@ +// 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}; + +/// Attributes for updating a campaign. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateCampaignRequestAttributes { + /// The description of the campaign. + #[serde(rename = "description")] + pub description: Option, + /// The due date of the campaign. + #[serde(rename = "due_date")] + pub due_date: Option>, + /// Entity scope query to filter entities for this campaign. + #[serde(rename = "entity_scope")] + pub entity_scope: Option, + /// Guidance for the campaign. + #[serde(rename = "guidance")] + pub guidance: Option, + /// The unique key for the campaign. + #[serde(rename = "key")] + pub key: Option, + /// The name of the campaign. + #[serde(rename = "name")] + pub name: String, + /// The UUID of the campaign owner. + #[serde(rename = "owner_id")] + pub owner_id: String, + /// Array of rule IDs associated with this campaign. + #[serde(rename = "rule_ids")] + pub rule_ids: Vec, + /// The start date of the campaign. + #[serde(rename = "start_date")] + pub start_date: chrono::DateTime, + /// The status of the campaign. + #[serde(rename = "status")] + pub status: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateCampaignRequestAttributes { + pub fn new( + name: String, + owner_id: String, + rule_ids: Vec, + start_date: chrono::DateTime, + status: String, + ) -> UpdateCampaignRequestAttributes { + UpdateCampaignRequestAttributes { + description: None, + due_date: None, + entity_scope: None, + guidance: None, + key: None, + name, + owner_id, + rule_ids, + start_date, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn due_date(mut self, value: chrono::DateTime) -> Self { + self.due_date = Some(value); + self + } + + pub fn entity_scope(mut self, value: String) -> Self { + self.entity_scope = Some(value); + self + } + + pub fn guidance(mut self, value: String) -> Self { + self.guidance = Some(value); + self + } + + pub fn key(mut self, value: String) -> Self { + self.key = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for UpdateCampaignRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateCampaignRequestAttributesVisitor; + impl<'a> Visitor<'a> for UpdateCampaignRequestAttributesVisitor { + type Value = UpdateCampaignRequestAttributes; + + 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 description: Option = None; + let mut due_date: Option> = None; + let mut entity_scope: Option = None; + let mut guidance: Option = None; + let mut key: Option = None; + let mut name: Option = None; + let mut owner_id: Option = None; + let mut rule_ids: Option> = None; + let mut start_date: Option> = None; + let mut status: 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() { + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "due_date" => { + if v.is_null() { + continue; + } + due_date = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "entity_scope" => { + if v.is_null() { + continue; + } + entity_scope = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "guidance" => { + if v.is_null() { + continue; + } + guidance = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "key" => { + if v.is_null() { + continue; + } + key = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "owner_id" => { + owner_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule_ids" => { + rule_ids = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "start_date" => { + start_date = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let owner_id = owner_id.ok_or_else(|| M::Error::missing_field("owner_id"))?; + let rule_ids = rule_ids.ok_or_else(|| M::Error::missing_field("rule_ids"))?; + let start_date = start_date.ok_or_else(|| M::Error::missing_field("start_date"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = UpdateCampaignRequestAttributes { + description, + due_date, + entity_scope, + guidance, + key, + name, + owner_id, + rule_ids, + start_date, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateCampaignRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_update_campaign_request_data.rs b/src/datadogV2/model/model_update_campaign_request_data.rs new file mode 100644 index 000000000..4dc34ab53 --- /dev/null +++ b/src/datadogV2/model/model_update_campaign_request_data.rs @@ -0,0 +1,117 @@ +// 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}; + +/// Data for updating a campaign. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateCampaignRequestData { + /// Attributes for updating a campaign. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::UpdateCampaignRequestAttributes, + /// The JSON:API type for campaigns. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::CampaignType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateCampaignRequestData { + pub fn new( + attributes: crate::datadogV2::model::UpdateCampaignRequestAttributes, + type_: crate::datadogV2::model::CampaignType, + ) -> UpdateCampaignRequestData { + UpdateCampaignRequestData { + attributes, + 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 UpdateCampaignRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateCampaignRequestDataVisitor; + impl<'a> Visitor<'a> for UpdateCampaignRequestDataVisitor { + type Value = UpdateCampaignRequestData; + + 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::UpdateCampaignRequestAttributes, + > = 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" => { + attributes = 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::CampaignType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = UpdateCampaignRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateCampaignRequestDataVisitor) + } +} diff --git a/tests/scenarios/features/v2/service_scorecards.feature b/tests/scenarios/features/v2/service_scorecards.feature index 387f04cf7..c9a57e036 100644 --- a/tests/scenarios/features/v2/service_scorecards.feature +++ b/tests/scenarios/features/v2/service_scorecards.feature @@ -10,6 +10,49 @@ Feature: Service Scorecards And a valid "appKeyAuth" key in the system And an instance of "ServiceScorecards" API + @generated @skip @team:DataDog/service-catalog + Scenario: Associate workflow with rule returns "Bad Request" response + Given operation "UpdateScorecardRuleWorkflow" enabled + And new "UpdateScorecardRuleWorkflow" request + And request contains "rule_id" parameter from "REPLACE.ME" + And request contains "workflow_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Associate workflow with rule returns "No Content" response + Given operation "UpdateScorecardRuleWorkflow" enabled + And new "UpdateScorecardRuleWorkflow" request + And request contains "rule_id" parameter from "REPLACE.ME" + And request contains "workflow_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/service-catalog + Scenario: Associate workflow with rule returns "Not Found" response + Given operation "UpdateScorecardRuleWorkflow" enabled + And new "UpdateScorecardRuleWorkflow" request + And request contains "rule_id" parameter from "REPLACE.ME" + And request contains "workflow_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/service-catalog + Scenario: Create a new campaign returns "Bad Request" response + Given operation "CreateScorecardCampaign" enabled + And new "CreateScorecardCampaign" request + And body with value {"data": {"attributes": {"description": "Campaign to improve security posture for Q1 2024.", "due_date": "2024-03-31T23:59:59Z", "entity_scope": "kind:service AND team:platform", "guidance": "Please ensure all services pass the security requirements.", "key": "q1-security-2024", "name": "Q1 Security Campaign", "owner_id": "550e8400-e29b-41d4-a716-446655440000", "rule_ids": ["q8MQxk8TCqrHnWkx", "r9NRyl9UDrsIoXly"], "start_date": "2024-01-01T00:00:00Z", "status": "in_progress"}, "type": "campaign"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Create a new campaign returns "Created" response + Given operation "CreateScorecardCampaign" enabled + And new "CreateScorecardCampaign" request + And body with value {"data": {"attributes": {"description": "Campaign to improve security posture for Q1 2024.", "due_date": "2024-03-31T23:59:59Z", "entity_scope": "kind:service AND team:platform", "guidance": "Please ensure all services pass the security requirements.", "key": "q1-security-2024", "name": "Q1 Security Campaign", "owner_id": "550e8400-e29b-41d4-a716-446655440000", "rule_ids": ["q8MQxk8TCqrHnWkx", "r9NRyl9UDrsIoXly"], "start_date": "2024-01-01T00:00:00Z", "status": "in_progress"}, "type": "campaign"}} + When the request is sent + Then the response status is 201 Created + @team:DataDog/service-catalog Scenario: Create a new rule returns "Bad Request" response Given operation "CreateScorecardRule" enabled @@ -46,6 +89,30 @@ Feature: Service Scorecards When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/service-catalog + Scenario: Delete a campaign returns "Bad Request" response + Given operation "DeleteScorecardCampaign" enabled + And new "DeleteScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Delete a campaign returns "No Content" response + Given operation "DeleteScorecardCampaign" enabled + And new "DeleteScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/service-catalog + Scenario: Delete a campaign returns "Not Found" response + Given operation "DeleteScorecardCampaign" enabled + And new "DeleteScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/service-catalog Scenario: Delete a rule returns "Bad Request" response Given operation "DeleteScorecardRule" enabled @@ -71,6 +138,122 @@ Feature: Service Scorecards When the request is sent Then the response status is 204 OK + @generated @skip @team:DataDog/service-catalog + Scenario: Delete rule workflow returns "Bad Request" response + Given operation "DeleteScorecardRuleWorkflow" enabled + And new "DeleteScorecardRuleWorkflow" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Delete rule workflow returns "No Content" response + Given operation "DeleteScorecardRuleWorkflow" enabled + And new "DeleteScorecardRuleWorkflow" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/service-catalog + Scenario: Delete rule workflow returns "Not Found" response + Given operation "DeleteScorecardRuleWorkflow" enabled + And new "DeleteScorecardRuleWorkflow" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/service-catalog + Scenario: Generate campaign report returns "Accepted" response + Given operation "GenerateScorecardCampaignReport" enabled + And new "GenerateScorecardCampaignReport" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"slack": {"channel_id": "C024BDQ4N", "channel_name": "service-scorecards", "workspace_id": "T024BDQ4N", "workspace_name": "datadog-workspace"}}, "type": "campaign-report"}} + When the request is sent + Then the response status is 202 Accepted + + @generated @skip @team:DataDog/service-catalog + Scenario: Generate campaign report returns "Bad Request" response + Given operation "GenerateScorecardCampaignReport" enabled + And new "GenerateScorecardCampaignReport" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"slack": {"channel_id": "C024BDQ4N", "channel_name": "service-scorecards", "workspace_id": "T024BDQ4N", "workspace_name": "datadog-workspace"}}, "type": "campaign-report"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Generate campaign report returns "Not Found" response + Given operation "GenerateScorecardCampaignReport" enabled + And new "GenerateScorecardCampaignReport" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"slack": {"channel_id": "C024BDQ4N", "channel_name": "service-scorecards", "workspace_id": "T024BDQ4N", "workspace_name": "datadog-workspace"}}, "type": "campaign-report"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/service-catalog + Scenario: Generate team-specific campaign reports returns "Accepted" response + Given operation "GenerateScorecardCampaignTeamReports" enabled + And new "GenerateScorecardCampaignTeamReports" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"entity_owners": [{"slack": {"channel_id": "C024BDQ4N", "workspace_id": "T024BDQ4N"}, "team_id": "550e8400-e29b-41d4-a716-446655440000"}]}, "type": "campaign-team-report"}} + When the request is sent + Then the response status is 202 Accepted + + @generated @skip @team:DataDog/service-catalog + Scenario: Generate team-specific campaign reports returns "Bad Request" response + Given operation "GenerateScorecardCampaignTeamReports" enabled + And new "GenerateScorecardCampaignTeamReports" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"entity_owners": [{"slack": {"channel_id": "C024BDQ4N", "workspace_id": "T024BDQ4N"}, "team_id": "550e8400-e29b-41d4-a716-446655440000"}]}, "type": "campaign-team-report"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Generate team-specific campaign reports returns "Not Found" response + Given operation "GenerateScorecardCampaignTeamReports" enabled + And new "GenerateScorecardCampaignTeamReports" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"entity_owners": [{"slack": {"channel_id": "C024BDQ4N", "workspace_id": "T024BDQ4N"}, "team_id": "550e8400-e29b-41d4-a716-446655440000"}]}, "type": "campaign-team-report"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/service-catalog + Scenario: Get a campaign returns "Bad Request" response + Given operation "GetScorecardCampaign" enabled + And new "GetScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Get a campaign returns "Not Found" response + Given operation "GetScorecardCampaign" enabled + And new "GetScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/service-catalog + Scenario: Get a campaign returns "OK" response + Given operation "GetScorecardCampaign" enabled + And new "GetScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/service-catalog + Scenario: List all campaigns returns "Bad Request" response + Given operation "ListScorecardCampaigns" enabled + And new "ListScorecardCampaigns" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: List all campaigns returns "OK" response + Given operation "ListScorecardCampaigns" enabled + And new "ListScorecardCampaigns" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/service-catalog Scenario: List all rule outcomes returns "Bad Request" response Given operation "ListScorecardOutcomes" enabled @@ -121,6 +304,74 @@ Feature: Service Scorecards Then the response status is 200 OK And the response has 4 items + @generated @skip @team:DataDog/service-catalog + Scenario: List all scorecards returns "OK" response + Given operation "ListScorecards" enabled + And new "ListScorecards" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/service-catalog + Scenario: List default rules returns "OK" response + Given operation "ListScorecardDefaultRules" enabled + And new "ListScorecardDefaultRules" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/service-catalog + Scenario: List entity facets returns "Bad Request" response + Given operation "ListScorecardFacets" enabled + And new "ListScorecardFacets" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: List entity facets returns "OK" response + Given operation "ListScorecardFacets" enabled + And new "ListScorecardFacets" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/service-catalog + Scenario: List scores by aggregation returns "Bad Request" response + Given operation "ListScorecardScores" enabled + And new "ListScorecardScores" request + And request contains "aggregation" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: List scores by aggregation returns "OK" response + Given operation "ListScorecardScores" enabled + And new "ListScorecardScores" request + And request contains "aggregation" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/service-catalog + Scenario: Set up rules for organization returns "Bad Request" response + Given operation "SetupScorecardRules" enabled + And new "SetupScorecardRules" request + And body with value {"data": {"attributes": {"disabled_default_rules": ["q8MQxk8TCqrHnWkx", "r9NRyl9UDrsIoXly"]}, "type": "setup"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Set up rules for organization returns "No Content" response + Given operation "SetupScorecardRules" enabled + And new "SetupScorecardRules" request + And body with value {"data": {"attributes": {"disabled_default_rules": ["q8MQxk8TCqrHnWkx", "r9NRyl9UDrsIoXly"]}, "type": "setup"}} + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/service-catalog + Scenario: Set up rules for organization returns "Not Found" response + Given operation "SetupScorecardRules" enabled + And new "SetupScorecardRules" request + And body with value {"data": {"attributes": {"disabled_default_rules": ["q8MQxk8TCqrHnWkx", "r9NRyl9UDrsIoXly"]}, "type": "setup"}} + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/service-catalog Scenario: Update Scorecard outcomes asynchronously returns "Accepted" response Given operation "UpdateScorecardOutcomesAsync" enabled @@ -150,6 +401,33 @@ Feature: Service Scorecards Then the response status is 409 Conflict And the response "errors" has length 1 + @generated @skip @team:DataDog/service-catalog + Scenario: Update a campaign returns "Bad Request" response + Given operation "UpdateScorecardCampaign" enabled + And new "UpdateScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "Campaign to improve security posture for Q1 2024.", "due_date": "2024-03-31T23:59:59Z", "entity_scope": "kind:service AND team:platform", "guidance": "Please ensure all services pass the security requirements.", "key": "q1-security-2024", "name": "Q1 Security Campaign", "owner_id": "550e8400-e29b-41d4-a716-446655440000", "rule_ids": ["q8MQxk8TCqrHnWkx", "r9NRyl9UDrsIoXly"], "start_date": "2024-01-01T00:00:00Z", "status": "in_progress"}, "type": "campaign"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: Update a campaign returns "Not Found" response + Given operation "UpdateScorecardCampaign" enabled + And new "UpdateScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "Campaign to improve security posture for Q1 2024.", "due_date": "2024-03-31T23:59:59Z", "entity_scope": "kind:service AND team:platform", "guidance": "Please ensure all services pass the security requirements.", "key": "q1-security-2024", "name": "Q1 Security Campaign", "owner_id": "550e8400-e29b-41d4-a716-446655440000", "rule_ids": ["q8MQxk8TCqrHnWkx", "r9NRyl9UDrsIoXly"], "start_date": "2024-01-01T00:00:00Z", "status": "in_progress"}, "type": "campaign"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/service-catalog + Scenario: Update a campaign returns "OK" response + Given operation "UpdateScorecardCampaign" enabled + And new "UpdateScorecardCampaign" request + And request contains "campaign_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "Campaign to improve security posture for Q1 2024.", "due_date": "2024-03-31T23:59:59Z", "entity_scope": "kind:service AND team:platform", "guidance": "Please ensure all services pass the security requirements.", "key": "q1-security-2024", "name": "Q1 Security Campaign", "owner_id": "550e8400-e29b-41d4-a716-446655440000", "rule_ids": ["q8MQxk8TCqrHnWkx", "r9NRyl9UDrsIoXly"], "start_date": "2024-01-01T00:00:00Z", "status": "in_progress"}, "type": "campaign"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/service-catalog Scenario: Update an existing rule returns "Bad Request" response Given operation "UpdateScorecardRule" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index b5703b05a..69f2547d2 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4249,6 +4249,60 @@ "type": "idempotent" } }, + "ListScorecardCampaigns": { + "tag": "Service Scorecards", + "undo": { + "type": "safe" + } + }, + "CreateScorecardCampaign": { + "tag": "Service Scorecards", + "undo": { + "type": "unsafe" + } + }, + "DeleteScorecardCampaign": { + "tag": "Service Scorecards", + "undo": { + "type": "idempotent" + } + }, + "GetScorecardCampaign": { + "tag": "Service Scorecards", + "undo": { + "type": "safe" + } + }, + "UpdateScorecardCampaign": { + "tag": "Service Scorecards", + "undo": { + "type": "idempotent" + } + }, + "GenerateScorecardCampaignTeamReports": { + "tag": "Service Scorecards", + "undo": { + "type": "unsafe" + } + }, + "GenerateScorecardCampaignReport": { + "tag": "Service Scorecards", + "undo": { + "type": "unsafe" + } + }, + "ListScorecardDefaultRules": { + "tag": "Service Scorecards", + "undo": { + "type": "safe" + } + }, + "ListScorecardFacets": { + "tag": "Service Scorecards", + "undo": { + "type": "safe" + } + }, "ListScorecardOutcomes": { "tag": "Service Scorecards", "undo": { @@ -4298,6 +4352,36 @@ "type": "idempotent" } }, + "DeleteScorecardRuleWorkflow": { + "tag": "Service Scorecards", + "undo": { + "type": "idempotent" + } + }, + "UpdateScorecardRuleWorkflow": { + "tag": "Service Scorecards", + "undo": { + "type": "idempotent" + } + }, + "ListScorecards": { + "tag": "Service Scorecards", + "undo": { + "type": "safe" + } + }, + "ListScorecardScores": { + "tag": "Service Scorecards", + "undo": { + "type": "safe" + } + }, + "SetupScorecardRules": { + "tag": "Service Scorecards", + "undo": { + "type": "unsafe" + } + }, "UnassignSeatsUser": { "tag": "Seats", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 26d283903..0509e3878 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -4655,6 +4655,42 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ListRumReplayViewershipHistorySessions".into(), test_v2_list_rum_replay_viewership_history_sessions, ); + world.function_mappings.insert( + "v2.ListScorecardCampaigns".into(), + test_v2_list_scorecard_campaigns, + ); + world.function_mappings.insert( + "v2.CreateScorecardCampaign".into(), + test_v2_create_scorecard_campaign, + ); + world.function_mappings.insert( + "v2.DeleteScorecardCampaign".into(), + test_v2_delete_scorecard_campaign, + ); + world.function_mappings.insert( + "v2.GetScorecardCampaign".into(), + test_v2_get_scorecard_campaign, + ); + world.function_mappings.insert( + "v2.UpdateScorecardCampaign".into(), + test_v2_update_scorecard_campaign, + ); + world.function_mappings.insert( + "v2.GenerateScorecardCampaignTeamReports".into(), + test_v2_generate_scorecard_campaign_team_reports, + ); + world.function_mappings.insert( + "v2.GenerateScorecardCampaignReport".into(), + test_v2_generate_scorecard_campaign_report, + ); + world.function_mappings.insert( + "v2.ListScorecardDefaultRules".into(), + test_v2_list_scorecard_default_rules, + ); + world.function_mappings.insert( + "v2.ListScorecardFacets".into(), + test_v2_list_scorecard_facets, + ); world.function_mappings.insert( "v2.ListScorecardOutcomes".into(), test_v2_list_scorecard_outcomes, @@ -4690,6 +4726,25 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.UpdateScorecardRule".into(), test_v2_update_scorecard_rule, ); + world.function_mappings.insert( + "v2.DeleteScorecardRuleWorkflow".into(), + test_v2_delete_scorecard_rule_workflow, + ); + world.function_mappings.insert( + "v2.UpdateScorecardRuleWorkflow".into(), + test_v2_update_scorecard_rule_workflow, + ); + world + .function_mappings + .insert("v2.ListScorecards".into(), test_v2_list_scorecards); + world.function_mappings.insert( + "v2.ListScorecardScores".into(), + test_v2_list_scorecard_scores, + ); + world.function_mappings.insert( + "v2.SetupScorecardRules".into(), + test_v2_setup_scorecard_rules, + ); world .function_mappings .insert("v2.UnassignSeatsUser".into(), test_v2_unassign_seats_user); @@ -35528,6 +35583,298 @@ fn test_v2_list_rum_replay_viewership_history_sessions( world.response.code = response.status.as_u16(); } +fn test_v2_list_scorecard_campaigns( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let page_limit = _parameters + .get("page[limit]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_offset = _parameters + .get("page[offset]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_campaign_name = _parameters + .get("filter[campaign][name]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_campaign_status = _parameters + .get("filter[campaign][status]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_campaign_owner = _parameters + .get("filter[campaign][owner]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_service_scorecards::ListScorecardCampaignsOptionalParams::default(); + params.page_limit = page_limit; + params.page_offset = page_offset; + params.filter_campaign_name = filter_campaign_name; + params.filter_campaign_status = filter_campaign_status; + params.filter_campaign_owner = filter_campaign_owner; + let response = match block_on(api.list_scorecard_campaigns_with_http_info(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_create_scorecard_campaign( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_scorecard_campaign_with_http_info(body)) { + 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_delete_scorecard_campaign( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let campaign_id = + serde_json::from_value(_parameters.get("campaign_id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_scorecard_campaign_with_http_info(campaign_id)) { + 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_get_scorecard_campaign(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let campaign_id = + serde_json::from_value(_parameters.get("campaign_id").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let include_meta = _parameters + .get("include_meta") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_service_scorecards::GetScorecardCampaignOptionalParams::default(); + params.include = include; + params.include_meta = include_meta; + let response = match block_on(api.get_scorecard_campaign_with_http_info(campaign_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_update_scorecard_campaign( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let campaign_id = + serde_json::from_value(_parameters.get("campaign_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_scorecard_campaign_with_http_info(campaign_id, body)) { + 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_generate_scorecard_campaign_team_reports( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let campaign_id = + serde_json::from_value(_parameters.get("campaign_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on( + api.generate_scorecard_campaign_team_reports_with_http_info(campaign_id, body), + ) { + 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_generate_scorecard_campaign_report( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let campaign_id = + serde_json::from_value(_parameters.get("campaign_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = + match block_on(api.generate_scorecard_campaign_report_with_http_info(campaign_id, body)) { + 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_scorecard_default_rules( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.list_scorecard_default_rules_with_http_info()) { + 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_scorecard_facets(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let filter_entity_query = _parameters + .get("filter[entity][query]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_service_scorecards::ListScorecardFacetsOptionalParams::default(); + params.filter_entity_query = filter_entity_query; + let response = match block_on(api.list_scorecard_facets_with_http_info(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_scorecard_outcomes(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances @@ -35946,6 +36293,191 @@ fn test_v2_update_scorecard_rule(world: &mut DatadogWorld, _parameters: &HashMap world.response.code = response.status.as_u16(); } +fn test_v2_delete_scorecard_rule_workflow( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let rule_id = serde_json::from_value(_parameters.get("rule_id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_scorecard_rule_workflow_with_http_info(rule_id)) { + 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_update_scorecard_rule_workflow( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let rule_id = serde_json::from_value(_parameters.get("rule_id").unwrap().clone()).unwrap(); + let workflow_id = + serde_json::from_value(_parameters.get("workflow_id").unwrap().clone()).unwrap(); + let response = + match block_on(api.update_scorecard_rule_workflow_with_http_info(rule_id, workflow_id)) { + 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_scorecards(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let page_offset = _parameters + .get("page[offset]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_scorecard_id = _parameters + .get("filter[scorecard][id]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_scorecard_name = _parameters + .get("filter[scorecard][name]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_scorecard_description = _parameters + .get("filter[scorecard][description]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_service_scorecards::ListScorecardsOptionalParams::default(); + params.page_offset = page_offset; + params.page_size = page_size; + params.filter_scorecard_id = filter_scorecard_id; + params.filter_scorecard_name = filter_scorecard_name; + params.filter_scorecard_description = filter_scorecard_description; + let response = match block_on(api.list_scorecards_with_http_info(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_scorecard_scores(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let aggregation = + serde_json::from_value(_parameters.get("aggregation").unwrap().clone()).unwrap(); + let page_limit = _parameters + .get("page[limit]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_offset = _parameters + .get("page[offset]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_entity_query = _parameters + .get("filter[entity][query]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_rule_id = _parameters + .get("filter[rule][id]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_rule_enabled = _parameters + .get("filter[rule][enabled]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_rule_custom = _parameters + .get("filter[rule][custom]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let sort = _parameters + .get("sort") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_service_scorecards::ListScorecardScoresOptionalParams::default(); + params.page_limit = page_limit; + params.page_offset = page_offset; + params.filter_entity_query = filter_entity_query; + params.filter_rule_id = filter_rule_id; + params.filter_rule_enabled = filter_rule_enabled; + params.filter_rule_custom = filter_rule_custom; + params.sort = sort; + let response = match block_on(api.list_scorecard_scores_with_http_info(aggregation, 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_setup_scorecard_rules(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_service_scorecards + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.setup_scorecard_rules_with_http_info(body)) { + 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_unassign_seats_user(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances