From bced761b801b9c599f0d6785ef384526927aa1b8 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 9 Jun 2026 10:58:30 +0000 Subject: [PATCH] Regenerate client from commit 9ba78ad of spec repo --- .generator/schemas/v2/openapi.yaml | 1058 ++++++++++++++++ ...2_csm-ownership_CreateOwnershipFeedback.rs | 36 + .../v2_csm-ownership_GetOwnershipEvidence.rs | 24 + .../v2_csm-ownership_GetOwnershipInference.rs | 24 + .../v2_csm-ownership_ListOwnershipHistory.rs | 22 + ...nership_ListOwnershipHistoryByOwnerType.rs | 24 + ...2_csm-ownership_ListOwnershipInferences.rs | 18 + src/datadog/configuration.rs | 6 + src/datadogV2/api/api_csm_ownership.rs | 1082 +++++++++++++++++ src/datadogV2/api/mod.rs | 1 + src/datadogV2/mod.rs | 1 + src/datadogV2/model/mod.rs | 60 + .../model_ownership_evidence_attributes.rs | 99 ++ .../model/model_ownership_evidence_data.rs | 125 ++ .../model_ownership_evidence_response.rs | 92 ++ .../model/model_ownership_evidence_type.rs | 48 + .../model/model_ownership_feedback_action.rs | 57 + .../model/model_ownership_feedback_request.rs | 94 ++ ...l_ownership_feedback_request_attributes.rs | 191 +++ .../model_ownership_feedback_request_data.rs | 115 ++ .../model_ownership_feedback_response.rs | 94 ++ ...el_ownership_feedback_result_attributes.rs | 206 ++++ .../model_ownership_feedback_result_data.rs | 126 ++ .../model_ownership_feedback_result_type.rs | 48 + .../model/model_ownership_feedback_type.rs | 48 + .../model_ownership_history_attributes.rs | 106 ++ .../model/model_ownership_history_data.rs | 125 ++ .../model/model_ownership_history_item.rs | 297 +++++ .../model_ownership_history_pagination.rs | 111 ++ .../model/model_ownership_history_response.rs | 92 ++ .../model/model_ownership_history_type.rs | 48 + .../model_ownership_inference_attributes.rs | 228 ++++ .../model/model_ownership_inference_data.rs | 125 ++ .../model/model_ownership_inference_item.rs | 239 ++++ ...del_ownership_inference_list_attributes.rs | 94 ++ .../model_ownership_inference_list_data.rs | 126 ++ ...model_ownership_inference_list_response.rs | 94 ++ .../model_ownership_inference_response.rs | 94 ++ .../model/model_ownership_inference_status.rs | 60 + .../model/model_ownership_inference_type.rs | 48 + .../model/model_ownership_inferences_type.rs | 48 + .../model/model_ownership_owner_type.rs | 57 + .../features/v2/csm_ownership.feature | 165 +++ tests/scenarios/features/v2/undo.json | 36 + tests/scenarios/function_mappings.rs | 248 ++++ 45 files changed, 6140 insertions(+) create mode 100644 examples/v2_csm-ownership_CreateOwnershipFeedback.rs create mode 100644 examples/v2_csm-ownership_GetOwnershipEvidence.rs create mode 100644 examples/v2_csm-ownership_GetOwnershipInference.rs create mode 100644 examples/v2_csm-ownership_ListOwnershipHistory.rs create mode 100644 examples/v2_csm-ownership_ListOwnershipHistoryByOwnerType.rs create mode 100644 examples/v2_csm-ownership_ListOwnershipInferences.rs create mode 100644 src/datadogV2/api/api_csm_ownership.rs create mode 100644 src/datadogV2/model/model_ownership_evidence_attributes.rs create mode 100644 src/datadogV2/model/model_ownership_evidence_data.rs create mode 100644 src/datadogV2/model/model_ownership_evidence_response.rs create mode 100644 src/datadogV2/model/model_ownership_evidence_type.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_action.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_request.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_request_attributes.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_request_data.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_response.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_result_attributes.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_result_data.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_result_type.rs create mode 100644 src/datadogV2/model/model_ownership_feedback_type.rs create mode 100644 src/datadogV2/model/model_ownership_history_attributes.rs create mode 100644 src/datadogV2/model/model_ownership_history_data.rs create mode 100644 src/datadogV2/model/model_ownership_history_item.rs create mode 100644 src/datadogV2/model/model_ownership_history_pagination.rs create mode 100644 src/datadogV2/model/model_ownership_history_response.rs create mode 100644 src/datadogV2/model/model_ownership_history_type.rs create mode 100644 src/datadogV2/model/model_ownership_inference_attributes.rs create mode 100644 src/datadogV2/model/model_ownership_inference_data.rs create mode 100644 src/datadogV2/model/model_ownership_inference_item.rs create mode 100644 src/datadogV2/model/model_ownership_inference_list_attributes.rs create mode 100644 src/datadogV2/model/model_ownership_inference_list_data.rs create mode 100644 src/datadogV2/model/model_ownership_inference_list_response.rs create mode 100644 src/datadogV2/model/model_ownership_inference_response.rs create mode 100644 src/datadogV2/model/model_ownership_inference_status.rs create mode 100644 src/datadogV2/model/model_ownership_inference_type.rs create mode 100644 src/datadogV2/model/model_ownership_inferences_type.rs create mode 100644 src/datadogV2/model/model_ownership_owner_type.rs create mode 100644 tests/scenarios/features/v2/csm_ownership.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2d470c8f2..6078ec8b4 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -66972,6 +66972,569 @@ components: required: - data type: object + OwnershipEvidenceAttributes: + description: The attributes of an ownership evidence response. + properties: + evidence_versions: + $ref: "#/components/schemas/OwnershipEvidenceVersions" + required: + - evidence_versions + type: object + OwnershipEvidenceData: + description: The data wrapper for an ownership evidence response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipEvidenceAttributes" + id: + description: The identifier of the resource the evidence applies to. + example: test-resource + type: string + type: + $ref: "#/components/schemas/OwnershipEvidenceType" + required: + - id + - type + - attributes + type: object + OwnershipEvidenceResponse: + description: The response returned when retrieving the evidence backing an ownership inference for an owner type. + properties: + data: + $ref: "#/components/schemas/OwnershipEvidenceData" + required: + - data + type: object + OwnershipEvidenceType: + default: ownership_evidence + description: The type of the ownership evidence resource. The value should always be `ownership_evidence`. + enum: + - ownership_evidence + example: ownership_evidence + type: string + x-enum-varnames: + - OWNERSHIP_EVIDENCE + OwnershipEvidenceVersion: + additionalProperties: {} + description: A single evidence version entry describing how an inference was produced. + example: + pipeline_id: p1 + version: v3 + type: object + OwnershipEvidenceVersions: + description: The list of evidence versions associated with an inference. + example: + - pipeline_id: p1 + version: v3 + items: + $ref: "#/components/schemas/OwnershipEvidenceVersion" + nullable: true + type: array + OwnershipFeedbackAction: + description: The feedback action to apply to an inference. + enum: + - confirm + - reject + - correct + - persist + example: confirm + type: string + x-enum-varnames: + - CONFIRM + - REJECT + - CORRECT + - PERSIST + OwnershipFeedbackRequest: + description: The request body for submitting ownership feedback. + properties: + data: + $ref: "#/components/schemas/OwnershipFeedbackRequestData" + required: + - data + type: object + OwnershipFeedbackRequestAttributes: + description: The attributes of an ownership feedback request. + properties: + action: + $ref: "#/components/schemas/OwnershipFeedbackAction" + actor_handle: + description: The handle of the actor submitting the feedback. + example: user@example.com + type: string + actor_type: + description: The type of actor submitting the feedback, for example `user` or `service`. + example: user + type: string + corrected_owner_handle: + description: The corrected owner handle. Required when `action` is `correct`. + example: team-b + nullable: true + type: string + corrected_owner_type: + description: The corrected owner type. Required when `action` is `correct`. + example: team + nullable: true + type: string + inference_checksum: + description: The checksum of the inference being acted upon. Must match the current inference checksum or the request returns a conflict. + example: abc123 + type: string + reason: + description: An optional free-form reason explaining the feedback. + example: Confirmed by team lead. + nullable: true + type: string + required: + - action + - actor_handle + - actor_type + - inference_checksum + type: object + OwnershipFeedbackRequestData: + description: The data wrapper for an ownership feedback request. + properties: + attributes: + $ref: "#/components/schemas/OwnershipFeedbackRequestAttributes" + type: + $ref: "#/components/schemas/OwnershipFeedbackType" + required: + - type + - attributes + type: object + OwnershipFeedbackResponse: + description: The response returned after applying ownership feedback to an inference. + properties: + data: + $ref: "#/components/schemas/OwnershipFeedbackResultData" + required: + - data + type: object + OwnershipFeedbackResultAttributes: + description: The attributes of an ownership feedback result. + properties: + action: + $ref: "#/components/schemas/OwnershipFeedbackAction" + checksum: + description: The checksum of the inference after the feedback was applied. + example: abc123 + type: string + new_status: + $ref: "#/components/schemas/OwnershipInferenceStatus" + owner_type: + $ref: "#/components/schemas/OwnershipOwnerType" + previous_status: + $ref: "#/components/schemas/OwnershipInferenceStatus" + primary_contact_ref: + description: The primary contact reference for the inferred owner after the feedback was applied, formatted as `ref:handle/`. + example: ref:handle/team-a + nullable: true + type: string + updated_at: + description: The time when the inference was updated by the feedback. + example: "2026-01-15T10:00:00Z" + format: date-time + type: string + required: + - action + - previous_status + - new_status + - owner_type + - checksum + - updated_at + type: object + OwnershipFeedbackResultData: + description: The data wrapper for an ownership feedback result response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipFeedbackResultAttributes" + id: + description: The identifier of the resource that the feedback was applied to. + example: res-1 + type: string + type: + $ref: "#/components/schemas/OwnershipFeedbackResultType" + required: + - id + - type + - attributes + type: object + OwnershipFeedbackResultType: + default: ownership_feedback_result + description: The type of the ownership feedback result resource. The value should always be `ownership_feedback_result`. + enum: + - ownership_feedback_result + example: ownership_feedback_result + type: string + x-enum-varnames: + - OWNERSHIP_FEEDBACK_RESULT + OwnershipFeedbackType: + default: ownership_feedback + description: The type of the ownership feedback request resource. The value should always be `ownership_feedback`. + enum: + - ownership_feedback + example: ownership_feedback + type: string + x-enum-varnames: + - OWNERSHIP_FEEDBACK + OwnershipHistoryAttributes: + description: The attributes of an ownership history response. + properties: + items: + $ref: "#/components/schemas/OwnershipHistoryItems" + pagination: + $ref: "#/components/schemas/OwnershipHistoryPagination" + required: + - items + - pagination + type: object + OwnershipHistoryData: + description: The data wrapper for an ownership history response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipHistoryAttributes" + id: + description: The resource identifier for which history is returned. + example: res-1 + type: string + type: + $ref: "#/components/schemas/OwnershipHistoryType" + required: + - id + - type + - attributes + type: object + OwnershipHistoryItem: + description: A single ownership inference history entry. + properties: + checksum: + description: A checksum identifying the state of the inference at this point in time. + example: "" + type: string + confidence: + description: The confidence score of the inference, expressed as a numeric string with up to four decimal places. + example: "0.9000" + type: string + created_at: + description: The time this history entry was created. + example: "2026-01-15T10:00:00Z" + format: date-time + type: string + evidence_versions: + $ref: "#/components/schemas/OwnershipEvidenceVersions" + explanation: + description: A human-readable explanation of how the inference was produced. + example: "" + type: string + failed_at: + description: The time when this inference failed, if applicable. + example: "2026-01-15T10:00:00Z" + format: date-time + nullable: true + type: string + failure_reason: + description: The reason why this inference failed, if applicable. + example: missing evidence + nullable: true + type: string + id: + description: The unique identifier of the history entry. + example: 100 + format: int64 + type: integer + owner_type: + $ref: "#/components/schemas/OwnershipOwnerType" + primary_contact_ref: + description: The primary contact reference for the inferred owner, formatted as `ref:handle/`. + example: ref:handle/team-a + nullable: true + type: string + resource_id: + description: The identifier of the resource that the inference applies to. + example: res-1 + type: string + retry_schedule: + description: The scheduled retry time for a failed inference, if applicable. + example: "2026-01-15T11:00:00Z" + format: date-time + nullable: true + type: string + sources: + $ref: "#/components/schemas/OwnershipInferenceSources" + status: + $ref: "#/components/schemas/OwnershipInferenceStatus" + required: + - id + - resource_id + - owner_type + - confidence + - explanation + - evidence_versions + - sources + - checksum + - status + - created_at + type: object + OwnershipHistoryItems: + description: The list of history entries returned for this page. + items: + $ref: "#/components/schemas/OwnershipHistoryItem" + type: array + OwnershipHistoryPagination: + description: Cursor-based pagination metadata for the history response. + properties: + has_more: + description: Whether more history entries are available beyond this page. + example: false + type: boolean + next_cursor: + description: An opaque, base64-encoded cursor token. Pass it as the `cursor` query parameter to retrieve the next page. Absent or `null` when there are no further pages. + example: eyJpZCI6OTh9 + nullable: true + type: string + required: + - has_more + type: object + OwnershipHistoryResponse: + description: The response returned when listing the inference history for a resource. + properties: + data: + $ref: "#/components/schemas/OwnershipHistoryData" + required: + - data + type: object + OwnershipHistoryType: + default: ownership_history + description: The type of the ownership history resource. The value should always be `ownership_history`. + enum: + - ownership_history + example: ownership_history + type: string + x-enum-varnames: + - OWNERSHIP_HISTORY + OwnershipInferenceAttributes: + description: The attributes of a single ownership inference. + properties: + checksum: + description: A checksum that uniquely identifies the current state of the inference. Required when submitting feedback. + example: abc123 + type: string + confidence: + description: The confidence score of the inference, expressed as a numeric string with up to four decimal places. + example: "0.9500" + type: string + created_at: + description: The time when the inference was created. + example: "2026-01-15T10:00:00Z" + format: date-time + type: string + evidence_versions: + $ref: "#/components/schemas/OwnershipEvidenceVersions" + explanation: + description: A human-readable explanation of how the inference was produced. + example: High confidence match + type: string + owner_type: + $ref: "#/components/schemas/OwnershipOwnerType" + primary_contact_ref: + description: The primary contact reference for the inferred owner, formatted as `ref:handle/`. + example: ref:handle/team-a + nullable: true + type: string + sources: + $ref: "#/components/schemas/OwnershipInferenceSources" + status: + $ref: "#/components/schemas/OwnershipInferenceStatus" + updated_at: + description: The time when the inference was last updated. + example: "2026-01-15T10:00:00Z" + format: date-time + type: string + required: + - owner_type + - confidence + - explanation + - evidence_versions + - sources + - status + - checksum + - created_at + - updated_at + type: object + OwnershipInferenceData: + description: The data wrapper for a single ownership inference response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipInferenceAttributes" + id: + description: The identifier of the inference, formatted as `resource_id:owner_type`. + example: test-resource:team + type: string + type: + $ref: "#/components/schemas/OwnershipInferenceType" + required: + - id + - type + - attributes + type: object + OwnershipInferenceItem: + description: A single ownership inference, scoped to a specific owner type. + properties: + checksum: + description: A checksum that uniquely identifies the current state of the inference. Required when submitting feedback. + example: abc123 + type: string + confidence: + description: The confidence score of the inference, expressed as a numeric string with up to four decimal places. + example: "0.9500" + type: string + created_at: + description: The time when the inference was created. + example: "2026-01-15T10:00:00Z" + format: date-time + type: string + evidence_versions: + $ref: "#/components/schemas/OwnershipEvidenceVersions" + explanation: + description: A human-readable explanation of how the inference was produced. + example: High confidence match + type: string + id: + description: The identifier of the inference, formatted as `resource_id:owner_type`. + example: test-resource:team + type: string + owner_type: + $ref: "#/components/schemas/OwnershipOwnerType" + primary_contact_ref: + description: The primary contact reference for the inferred owner, formatted as `ref:handle/`. + example: ref:handle/team-a + nullable: true + type: string + sources: + $ref: "#/components/schemas/OwnershipInferenceSources" + status: + $ref: "#/components/schemas/OwnershipInferenceStatus" + updated_at: + description: The time when the inference was last updated. + example: "2026-01-15T10:00:00Z" + format: date-time + type: string + required: + - id + - owner_type + - confidence + - explanation + - evidence_versions + - sources + - status + - checksum + - created_at + - updated_at + type: object + OwnershipInferenceItems: + description: The list of inferences for a resource, with one inference per owner type. + items: + $ref: "#/components/schemas/OwnershipInferenceItem" + type: array + OwnershipInferenceListAttributes: + description: The attributes of the ownership inferences collection response. + properties: + items: + $ref: "#/components/schemas/OwnershipInferenceItems" + required: + - items + type: object + OwnershipInferenceListData: + description: The data wrapper for the ownership inferences collection response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipInferenceListAttributes" + id: + description: The resource identifier associated with the returned inferences. + example: test-resource + type: string + type: + $ref: "#/components/schemas/OwnershipInferencesType" + required: + - id + - type + - attributes + type: object + OwnershipInferenceListResponse: + description: The response returned when listing all current ownership inferences for a resource. + properties: + data: + $ref: "#/components/schemas/OwnershipInferenceListData" + required: + - data + type: object + OwnershipInferenceResponse: + description: The response returned when retrieving a single ownership inference for an owner type. + properties: + data: + $ref: "#/components/schemas/OwnershipInferenceData" + required: + - data + type: object + OwnershipInferenceSource: + additionalProperties: {} + description: A source describing how an inference was derived. + example: + kind: code_owners + type: object + OwnershipInferenceSources: + description: The list of sources backing an ownership inference. Empty when the inference status is not whitelisted to expose sources. + example: + - kind: code_owners + items: + $ref: "#/components/schemas/OwnershipInferenceSource" + type: array + OwnershipInferenceStatus: + description: The lifecycle status of an ownership inference. + enum: + - suggested + - persisted + - overridden + - failed + - unknown + example: suggested + type: string + x-enum-varnames: + - SUGGESTED + - PERSISTED + - OVERRIDDEN + - FAILED + - UNKNOWN + OwnershipInferenceType: + default: ownership_inference + description: The type of the ownership inference resource. The value should always be `ownership_inference`. + enum: + - ownership_inference + example: ownership_inference + type: string + x-enum-varnames: + - OWNERSHIP_INFERENCE + OwnershipInferencesType: + default: ownership_inferences + description: The type of the ownership inferences collection resource. The value should always be `ownership_inferences`. + enum: + - ownership_inferences + example: ownership_inferences + type: string + x-enum-varnames: + - OWNERSHIP_INFERENCES + OwnershipOwnerType: + description: The owner type for an ownership inference. + enum: + - user + - team + - service + - unknown + example: team + type: string + x-enum-varnames: + - USER + - TEAM + - SERVICE + - UNKNOWN PageAnnotationsAttributes: description: Attributes of the annotations on a page. properties: @@ -119900,6 +120463,494 @@ paths: $ref: "#/components/responses/TooManyRequestsResponse" summary: Get all CSM Serverless Agents tags: ["CSM Agents"] + /api/v2/csm/ownership/{resource_id}: + get: + description: Get all current ownership inferences for a resource, one per owner type (`user`, `team`, `service`, `unknown`). + operationId: ListOwnershipInferences + parameters: + - description: The identifier of the resource to retrieve ownership inferences for. + in: path + name: resource_id + required: true + schema: + example: test-resource + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + items: + - checksum: abc123 + confidence: "0.9500" + created_at: "2026-01-15T10:00:00Z" + evidence_versions: + - pipeline_id: p1 + explanation: High confidence match + id: test-resource:team + owner_type: team + primary_contact_ref: ref:handle/team-a + sources: [] + status: suggested + updated_at: "2026-01-15T10:00:00Z" + id: test-resource + type: ownership_inferences + schema: + $ref: "#/components/schemas/OwnershipInferenceListResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List ownership inferences for a resource + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/csm/ownership/{resource_id}/history: + get: + description: List inference history entries for a resource across all owner types, ordered from most recent to oldest. Uses cursor-based pagination. + operationId: ListOwnershipHistory + parameters: + - description: The identifier of the resource to retrieve inference history for. + in: path + name: resource_id + required: true + schema: + example: res-1 + type: string + - description: An opaque, base64-encoded cursor token returned by a previous call in `pagination.next_cursor`. Omit to fetch the first page. + in: query + name: cursor + required: false + schema: + example: eyJpZCI6OTh9 + type: string + - description: The maximum number of history entries to return per page. + in: query + name: limit + required: false + schema: + default: 25 + example: 25 + format: int32 + maximum: 100 + minimum: 1 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + items: + - checksum: "" + confidence: "0.9000" + created_at: "2026-01-15T10:00:00Z" + evidence_versions: + explanation: "" + failed_at: + failure_reason: + id: 100 + owner_type: team + primary_contact_ref: ref:handle/team-a + resource_id: res-1 + retry_schedule: + sources: [] + status: suggested + pagination: + has_more: false + next_cursor: + id: res-1 + type: ownership_history + schema: + $ref: "#/components/schemas/OwnershipHistoryResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List ownership inference history for a resource + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/csm/ownership/{resource_id}/{owner_type}: + get: + description: |- + Get the current ownership inference for a resource for a specific owner type. + + This endpoint supports ETag-based caching. Pass the previously returned `ETag` value in the `If-None-Match` request header to receive a `304 Not Modified` response when the inference has not changed. + operationId: GetOwnershipInference + parameters: + - description: The identifier of the resource to retrieve the ownership inference for. + in: path + name: resource_id + required: true + schema: + example: test-resource + type: string + - description: The owner type of the inference to retrieve. + in: path + name: owner_type + required: true + schema: + $ref: "#/components/schemas/OwnershipOwnerType" + - description: A previously returned `ETag` value. When supplied and the resource has not changed, the endpoint returns `304 Not Modified`. + in: header + name: If-None-Match + required: false + schema: + example: '"abc123"' + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + checksum: abc123 + confidence: "0.9500" + created_at: "2026-01-15T10:00:00Z" + evidence_versions: + - pipeline_id: p1 + explanation: High confidence match + owner_type: team + primary_contact_ref: ref:handle/team-a + sources: [] + status: suggested + updated_at: "2026-01-15T10:00:00Z" + id: test-resource:team + type: ownership_inference + schema: + $ref: "#/components/schemas/OwnershipInferenceResponse" + description: OK + headers: + Cache-Control: + description: The cache control directives applied to the response. + schema: + example: private, max-age=60 + type: string + ETag: + description: A strong validator that identifies the current state of the inference. + schema: + example: '"abc123"' + type: string + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get an ownership inference by owner type + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/csm/ownership/{resource_id}/{owner_type}/evidence: + get: + description: |- + Get the evidence versions backing the current ownership inference for a resource and owner type. + + This endpoint supports weak ETag caching. Pass the previously returned `ETag` value in the `If-None-Match` request header to receive a `304 Not Modified` response when the evidence has not changed. + operationId: GetOwnershipEvidence + parameters: + - description: The identifier of the resource to retrieve evidence for. + in: path + name: resource_id + required: true + schema: + example: test-resource + type: string + - description: The owner type of the inference to retrieve evidence for. + in: path + name: owner_type + required: true + schema: + $ref: "#/components/schemas/OwnershipOwnerType" + - description: A previously returned weak `ETag` value. When supplied and the evidence has not changed, the endpoint returns `304 Not Modified`. + in: header + name: If-None-Match + required: false + schema: + example: W/"f2e126916327bda8" + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + evidence_versions: + - pipeline_id: p1 + version: v3 + id: test-resource + type: ownership_evidence + schema: + $ref: "#/components/schemas/OwnershipEvidenceResponse" + description: OK + headers: + ETag: + description: A weak validator that identifies the current state of the evidence. + schema: + example: W/"f2e126916327bda8" + type: string + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get the evidence for an ownership inference + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/csm/ownership/{resource_id}/{owner_type}/feedback: + post: + description: |- + Submit feedback on the current ownership inference for a resource and owner type. Valid actions are `confirm`, `reject`, `correct`, and `persist`. + + The request must include the current inference `checksum` in `inference_checksum`. If the checksum does not match the current inference state, the endpoint returns `409 Conflict`. + + When `action` is `correct`, `corrected_owner_handle` and `corrected_owner_type` are required. + operationId: CreateOwnershipFeedback + parameters: + - description: The identifier of the resource that the feedback applies to. + in: path + name: resource_id + required: true + schema: + example: res-1 + type: string + - description: The type of owner that the feedback applies to. + in: path + name: owner_type + required: true + schema: + $ref: "#/components/schemas/OwnershipOwnerType" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + action: confirm + actor_handle: user@example.com + actor_type: user + inference_checksum: abc123 + type: ownership_feedback + schema: + $ref: "#/components/schemas/OwnershipFeedbackRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + action: confirm + checksum: abc123 + new_status: suggested + owner_type: team + previous_status: suggested + primary_contact_ref: ref:handle/team-a + updated_at: "2026-01-15T10:00:00Z" + id: res-1 + type: ownership_feedback_result + schema: + $ref: "#/components/schemas/OwnershipFeedbackResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/OwnershipInferenceResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Submit feedback on an ownership inference + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/csm/ownership/{resource_id}/{owner_type}/history: + get: + description: List inference history entries for a resource filtered by owner type, ordered from most recent to oldest. Uses cursor-based pagination. + operationId: ListOwnershipHistoryByOwnerType + parameters: + - description: The identifier of the resource to retrieve inference history for. + in: path + name: resource_id + required: true + schema: + example: res-1 + type: string + - description: The owner type to filter history by. + in: path + name: owner_type + required: true + schema: + $ref: "#/components/schemas/OwnershipOwnerType" + - description: An opaque, base64-encoded cursor token returned by a previous call in `pagination.next_cursor`. Omit to fetch the first page. + in: query + name: cursor + required: false + schema: + example: eyJpZCI6OTh9 + type: string + - description: The maximum number of history entries to return per page. + in: query + name: limit + required: false + schema: + default: 25 + example: 25 + format: int32 + maximum: 100 + minimum: 1 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + items: + - checksum: "" + confidence: "0.9000" + created_at: "2026-01-15T10:00:00Z" + evidence_versions: + explanation: "" + failed_at: + failure_reason: + id: 100 + owner_type: team + primary_contact_ref: ref:handle/team-a + resource_id: res-1 + retry_schedule: + sources: [] + status: suggested + pagination: + has_more: false + next_cursor: + id: res-1 + type: ownership_history + schema: + $ref: "#/components/schemas/OwnershipHistoryResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List ownership history by owner type + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/current_user: get: description: |- @@ -181119,6 +182170,13 @@ tags: all in a unified view for seamless collaboration and faster remediation. Go to https://docs.datadoghq.com/security/cloud_security_management to learn more. name: "CSM Coverage Analysis" + - description: |- + Datadog Cloud Security Management (CSM) Ownership infers the most likely owner + for a cloud resource by combining ownership signals from across the platform, + and lets you review the inference, inspect its evidence, and submit feedback to + persist, override, or correct the inferred owner. + For more information, see [Cloud Security Management](https://docs.datadoghq.com/security/cloud_security_management). + name: "CSM Ownership" - description: |- Workload Protection monitors file, network, and process activity across your environment to detect real-time threats to your infrastructure. See [Workload Protection](https://docs.datadoghq.com/security/workload_protection/) for more information on setting up Workload Protection. diff --git a/examples/v2_csm-ownership_CreateOwnershipFeedback.rs b/examples/v2_csm-ownership_CreateOwnershipFeedback.rs new file mode 100644 index 000000000..fc6f6e6af --- /dev/null +++ b/examples/v2_csm-ownership_CreateOwnershipFeedback.rs @@ -0,0 +1,36 @@ +// Submit feedback on an ownership inference returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_ownership::CSMOwnershipAPI; +use datadog_api_client::datadogV2::model::OwnershipFeedbackAction; +use datadog_api_client::datadogV2::model::OwnershipFeedbackRequest; +use datadog_api_client::datadogV2::model::OwnershipFeedbackRequestAttributes; +use datadog_api_client::datadogV2::model::OwnershipFeedbackRequestData; +use datadog_api_client::datadogV2::model::OwnershipFeedbackType; +use datadog_api_client::datadogV2::model::OwnershipOwnerType; + +#[tokio::main] +async fn main() { + let body = OwnershipFeedbackRequest::new(OwnershipFeedbackRequestData::new( + OwnershipFeedbackRequestAttributes::new( + OwnershipFeedbackAction::CONFIRM, + "user@example.com".to_string(), + "user".to_string(), + "abc123".to_string(), + ) + .corrected_owner_handle(Some("team-b".to_string())) + .corrected_owner_type(Some("team".to_string())) + .reason(Some("Confirmed by team lead.".to_string())), + OwnershipFeedbackType::OWNERSHIP_FEEDBACK, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateOwnershipFeedback", true); + let api = CSMOwnershipAPI::with_config(configuration); + let resp = api + .create_ownership_feedback("res-1".to_string(), OwnershipOwnerType::TEAM, body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_csm-ownership_GetOwnershipEvidence.rs b/examples/v2_csm-ownership_GetOwnershipEvidence.rs new file mode 100644 index 000000000..503f0f4bd --- /dev/null +++ b/examples/v2_csm-ownership_GetOwnershipEvidence.rs @@ -0,0 +1,24 @@ +// Get the evidence for an ownership inference returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_ownership::CSMOwnershipAPI; +use datadog_api_client::datadogV2::api_csm_ownership::GetOwnershipEvidenceOptionalParams; +use datadog_api_client::datadogV2::model::OwnershipOwnerType; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetOwnershipEvidence", true); + let api = CSMOwnershipAPI::with_config(configuration); + let resp = api + .get_ownership_evidence( + "test-resource".to_string(), + OwnershipOwnerType::TEAM, + GetOwnershipEvidenceOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_csm-ownership_GetOwnershipInference.rs b/examples/v2_csm-ownership_GetOwnershipInference.rs new file mode 100644 index 000000000..6e22f4336 --- /dev/null +++ b/examples/v2_csm-ownership_GetOwnershipInference.rs @@ -0,0 +1,24 @@ +// Get an ownership inference by owner type returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_ownership::CSMOwnershipAPI; +use datadog_api_client::datadogV2::api_csm_ownership::GetOwnershipInferenceOptionalParams; +use datadog_api_client::datadogV2::model::OwnershipOwnerType; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetOwnershipInference", true); + let api = CSMOwnershipAPI::with_config(configuration); + let resp = api + .get_ownership_inference( + "test-resource".to_string(), + OwnershipOwnerType::TEAM, + GetOwnershipInferenceOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_csm-ownership_ListOwnershipHistory.rs b/examples/v2_csm-ownership_ListOwnershipHistory.rs new file mode 100644 index 000000000..2da87b156 --- /dev/null +++ b/examples/v2_csm-ownership_ListOwnershipHistory.rs @@ -0,0 +1,22 @@ +// List ownership inference history for a resource returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_ownership::CSMOwnershipAPI; +use datadog_api_client::datadogV2::api_csm_ownership::ListOwnershipHistoryOptionalParams; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListOwnershipHistory", true); + let api = CSMOwnershipAPI::with_config(configuration); + let resp = api + .list_ownership_history( + "res-1".to_string(), + ListOwnershipHistoryOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_csm-ownership_ListOwnershipHistoryByOwnerType.rs b/examples/v2_csm-ownership_ListOwnershipHistoryByOwnerType.rs new file mode 100644 index 000000000..3a5f88531 --- /dev/null +++ b/examples/v2_csm-ownership_ListOwnershipHistoryByOwnerType.rs @@ -0,0 +1,24 @@ +// List ownership history by owner type returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_ownership::CSMOwnershipAPI; +use datadog_api_client::datadogV2::api_csm_ownership::ListOwnershipHistoryByOwnerTypeOptionalParams; +use datadog_api_client::datadogV2::model::OwnershipOwnerType; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListOwnershipHistoryByOwnerType", true); + let api = CSMOwnershipAPI::with_config(configuration); + let resp = api + .list_ownership_history_by_owner_type( + "res-1".to_string(), + OwnershipOwnerType::TEAM, + ListOwnershipHistoryByOwnerTypeOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_csm-ownership_ListOwnershipInferences.rs b/examples/v2_csm-ownership_ListOwnershipInferences.rs new file mode 100644 index 000000000..c101ab3b0 --- /dev/null +++ b/examples/v2_csm-ownership_ListOwnershipInferences.rs @@ -0,0 +1,18 @@ +// List ownership inferences for a resource returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_ownership::CSMOwnershipAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListOwnershipInferences", true); + let api = CSMOwnershipAPI::with_config(configuration); + let resp = api + .list_ownership_inferences("test-resource".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 77317e521..abccf16e9 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -420,6 +420,12 @@ impl Default for Configuration { ("v2.list_cost_tag_metadata_months".to_owned(), false), ("v2.list_cost_tag_metadata_orchestrators".to_owned(), false), ("v2.search_cost_recommendations".to_owned(), false), + ("v2.create_ownership_feedback".to_owned(), false), + ("v2.get_ownership_evidence".to_owned(), false), + ("v2.get_ownership_inference".to_owned(), false), + ("v2.list_ownership_history".to_owned(), false), + ("v2.list_ownership_history_by_owner_type".to_owned(), false), + ("v2.list_ownership_inferences".to_owned(), false), ("v2.create_dashboard_secure_embed".to_owned(), false), ("v2.delete_dashboard_secure_embed".to_owned(), false), ("v2.get_dashboard_secure_embed".to_owned(), false), diff --git a/src/datadogV2/api/api_csm_ownership.rs b/src/datadogV2/api/api_csm_ownership.rs new file mode 100644 index 000000000..ed68337cd --- /dev/null +++ b/src/datadogV2/api/api_csm_ownership.rs @@ -0,0 +1,1082 @@ +// 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 crate::datadog; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use log::warn; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// GetOwnershipEvidenceOptionalParams is a struct for passing parameters to the method [`CSMOwnershipAPI::get_ownership_evidence`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetOwnershipEvidenceOptionalParams { + /// A previously returned weak `ETag` value. When supplied and the evidence has not changed, the endpoint returns `304 Not Modified`. + pub if_none_match: Option, +} + +impl GetOwnershipEvidenceOptionalParams { + /// A previously returned weak `ETag` value. When supplied and the evidence has not changed, the endpoint returns `304 Not Modified`. + pub fn if_none_match(mut self, value: String) -> Self { + self.if_none_match = Some(value); + self + } +} + +/// GetOwnershipInferenceOptionalParams is a struct for passing parameters to the method [`CSMOwnershipAPI::get_ownership_inference`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetOwnershipInferenceOptionalParams { + /// A previously returned `ETag` value. When supplied and the resource has not changed, the endpoint returns `304 Not Modified`. + pub if_none_match: Option, +} + +impl GetOwnershipInferenceOptionalParams { + /// A previously returned `ETag` value. When supplied and the resource has not changed, the endpoint returns `304 Not Modified`. + pub fn if_none_match(mut self, value: String) -> Self { + self.if_none_match = Some(value); + self + } +} + +/// ListOwnershipHistoryOptionalParams is a struct for passing parameters to the method [`CSMOwnershipAPI::list_ownership_history`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListOwnershipHistoryOptionalParams { + /// An opaque, base64-encoded cursor token returned by a previous call in `pagination.next_cursor`. Omit to fetch the first page. + pub cursor: Option, + /// The maximum number of history entries to return per page. + pub limit: Option, +} + +impl ListOwnershipHistoryOptionalParams { + /// An opaque, base64-encoded cursor token returned by a previous call in `pagination.next_cursor`. Omit to fetch the first page. + pub fn cursor(mut self, value: String) -> Self { + self.cursor = Some(value); + self + } + /// The maximum number of history entries to return per page. + pub fn limit(mut self, value: i32) -> Self { + self.limit = Some(value); + self + } +} + +/// ListOwnershipHistoryByOwnerTypeOptionalParams is a struct for passing parameters to the method [`CSMOwnershipAPI::list_ownership_history_by_owner_type`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListOwnershipHistoryByOwnerTypeOptionalParams { + /// An opaque, base64-encoded cursor token returned by a previous call in `pagination.next_cursor`. Omit to fetch the first page. + pub cursor: Option, + /// The maximum number of history entries to return per page. + pub limit: Option, +} + +impl ListOwnershipHistoryByOwnerTypeOptionalParams { + /// An opaque, base64-encoded cursor token returned by a previous call in `pagination.next_cursor`. Omit to fetch the first page. + pub fn cursor(mut self, value: String) -> Self { + self.cursor = Some(value); + self + } + /// The maximum number of history entries to return per page. + pub fn limit(mut self, value: i32) -> Self { + self.limit = Some(value); + self + } +} + +/// CreateOwnershipFeedbackError is a struct for typed errors of method [`CSMOwnershipAPI::create_ownership_feedback`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateOwnershipFeedbackError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + OwnershipInferenceResponse(crate::datadogV2::model::OwnershipInferenceResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetOwnershipEvidenceError is a struct for typed errors of method [`CSMOwnershipAPI::get_ownership_evidence`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOwnershipEvidenceError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetOwnershipInferenceError is a struct for typed errors of method [`CSMOwnershipAPI::get_ownership_inference`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOwnershipInferenceError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListOwnershipHistoryError is a struct for typed errors of method [`CSMOwnershipAPI::list_ownership_history`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListOwnershipHistoryError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListOwnershipHistoryByOwnerTypeError is a struct for typed errors of method [`CSMOwnershipAPI::list_ownership_history_by_owner_type`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListOwnershipHistoryByOwnerTypeError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListOwnershipInferencesError is a struct for typed errors of method [`CSMOwnershipAPI::list_ownership_inferences`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListOwnershipInferencesError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Datadog Cloud Security Management (CSM) Ownership infers the most likely owner +/// for a cloud resource by combining ownership signals from across the platform, +/// and lets you review the inference, inspect its evidence, and submit feedback to +/// persist, override, or correct the inferred owner. +/// For more information, see [Cloud Security Management](). +#[derive(Debug, Clone)] +pub struct CSMOwnershipAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for CSMOwnershipAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl CSMOwnershipAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let reqwest_client_builder = { + let builder = reqwest::Client::builder(); + #[cfg(not(target_arch = "wasm32"))] + let builder = if let Some(proxy_url) = &config.proxy_url { + builder.proxy(reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL")) + } else { + builder + }; + builder + }; + + let middleware_client_builder = { + let builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + #[cfg(feature = "retry")] + let builder = if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + builder.with(retry_middleware) + } else { + builder + }; + builder + }; + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Submit feedback on the current ownership inference for a resource and owner type. Valid actions are `confirm`, `reject`, `correct`, and `persist`. + /// + /// The request must include the current inference `checksum` in `inference_checksum`. If the checksum does not match the current inference state, the endpoint returns `409 Conflict`. + /// + /// When `action` is `correct`, `corrected_owner_handle` and `corrected_owner_type` are required. + pub async fn create_ownership_feedback( + &self, + resource_id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + body: crate::datadogV2::model::OwnershipFeedbackRequest, + ) -> Result< + crate::datadogV2::model::OwnershipFeedbackResponse, + datadog::Error, + > { + match self + .create_ownership_feedback_with_http_info(resource_id, owner_type, 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), + } + } + + /// Submit feedback on the current ownership inference for a resource and owner type. Valid actions are `confirm`, `reject`, `correct`, and `persist`. + /// + /// The request must include the current inference `checksum` in `inference_checksum`. If the checksum does not match the current inference state, the endpoint returns `409 Conflict`. + /// + /// When `action` is `correct`, `corrected_owner_handle` and `corrected_owner_type` are required. + pub async fn create_ownership_feedback_with_http_info( + &self, + resource_id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + body: crate::datadogV2::model::OwnershipFeedbackRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_ownership_feedback"; + 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_ownership_feedback' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/ownership/{resource_id}/{owner_type}/feedback", + local_configuration.get_operation_host(operation_id), + resource_id = datadog::urlencode(resource_id), + owner_type = datadog::urlencode(owner_type.to_string()) + ); + 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)), + } + } + #[cfg(feature = "zstd")] + "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)) + } + } + + /// Get the evidence versions backing the current ownership inference for a resource and owner type. + /// + /// This endpoint supports weak ETag caching. Pass the previously returned `ETag` value in the `If-None-Match` request header to receive a `304 Not Modified` response when the evidence has not changed. + pub async fn get_ownership_evidence( + &self, + resource_id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + params: GetOwnershipEvidenceOptionalParams, + ) -> Result< + crate::datadogV2::model::OwnershipEvidenceResponse, + datadog::Error, + > { + match self + .get_ownership_evidence_with_http_info(resource_id, owner_type, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the evidence versions backing the current ownership inference for a resource and owner type. + /// + /// This endpoint supports weak ETag caching. Pass the previously returned `ETag` value in the `If-None-Match` request header to receive a `304 Not Modified` response when the evidence has not changed. + pub async fn get_ownership_evidence_with_http_info( + &self, + resource_id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + params: GetOwnershipEvidenceOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_ownership_evidence"; + 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_ownership_evidence' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let if_none_match = params.if_none_match; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/ownership/{resource_id}/{owner_type}/evidence", + local_configuration.get_operation_host(operation_id), + resource_id = datadog::urlencode(resource_id), + owner_type = datadog::urlencode(owner_type.to_string()) + ); + 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")); + + if let Some(ref local) = if_none_match { + headers.insert( + "If-None-Match", + local + .to_string() + .parse() + .expect("failed to parse If-None-Match header"), + ); + } + + // 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)) + } + } + + /// Get the current ownership inference for a resource for a specific owner type. + /// + /// This endpoint supports ETag-based caching. Pass the previously returned `ETag` value in the `If-None-Match` request header to receive a `304 Not Modified` response when the inference has not changed. + pub async fn get_ownership_inference( + &self, + resource_id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + params: GetOwnershipInferenceOptionalParams, + ) -> Result< + crate::datadogV2::model::OwnershipInferenceResponse, + datadog::Error, + > { + match self + .get_ownership_inference_with_http_info(resource_id, owner_type, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the current ownership inference for a resource for a specific owner type. + /// + /// This endpoint supports ETag-based caching. Pass the previously returned `ETag` value in the `If-None-Match` request header to receive a `304 Not Modified` response when the inference has not changed. + pub async fn get_ownership_inference_with_http_info( + &self, + resource_id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + params: GetOwnershipInferenceOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_ownership_inference"; + 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_ownership_inference' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let if_none_match = params.if_none_match; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/ownership/{resource_id}/{owner_type}", + local_configuration.get_operation_host(operation_id), + resource_id = datadog::urlencode(resource_id), + owner_type = datadog::urlencode(owner_type.to_string()) + ); + 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")); + + if let Some(ref local) = if_none_match { + headers.insert( + "If-None-Match", + local + .to_string() + .parse() + .expect("failed to parse If-None-Match header"), + ); + } + + // 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)) + } + } + + /// List inference history entries for a resource across all owner types, ordered from most recent to oldest. Uses cursor-based pagination. + pub async fn list_ownership_history( + &self, + resource_id: String, + params: ListOwnershipHistoryOptionalParams, + ) -> Result< + crate::datadogV2::model::OwnershipHistoryResponse, + datadog::Error, + > { + match self + .list_ownership_history_with_http_info(resource_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), + } + } + + /// List inference history entries for a resource across all owner types, ordered from most recent to oldest. Uses cursor-based pagination. + pub async fn list_ownership_history_with_http_info( + &self, + resource_id: String, + params: ListOwnershipHistoryOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_ownership_history"; + 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_ownership_history' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let cursor = params.cursor; + let limit = params.limit; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/ownership/{resource_id}/history", + local_configuration.get_operation_host(operation_id), + resource_id = datadog::urlencode(resource_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = cursor { + local_req_builder = + local_req_builder.query(&[("cursor", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = limit { + local_req_builder = + local_req_builder.query(&[("limit", &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)) + } + } + + /// List inference history entries for a resource filtered by owner type, ordered from most recent to oldest. Uses cursor-based pagination. + pub async fn list_ownership_history_by_owner_type( + &self, + resource_id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + params: ListOwnershipHistoryByOwnerTypeOptionalParams, + ) -> Result< + crate::datadogV2::model::OwnershipHistoryResponse, + datadog::Error, + > { + match self + .list_ownership_history_by_owner_type_with_http_info(resource_id, owner_type, 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), + } + } + + /// List inference history entries for a resource filtered by owner type, ordered from most recent to oldest. Uses cursor-based pagination. + pub async fn list_ownership_history_by_owner_type_with_http_info( + &self, + resource_id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + params: ListOwnershipHistoryByOwnerTypeOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_ownership_history_by_owner_type"; + 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_ownership_history_by_owner_type' is not enabled" + .to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let cursor = params.cursor; + let limit = params.limit; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/ownership/{resource_id}/{owner_type}/history", + local_configuration.get_operation_host(operation_id), + resource_id = datadog::urlencode(resource_id), + owner_type = datadog::urlencode(owner_type.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = cursor { + local_req_builder = + local_req_builder.query(&[("cursor", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = limit { + local_req_builder = + local_req_builder.query(&[("limit", &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)) + } + } + + /// Get all current ownership inferences for a resource, one per owner type (`user`, `team`, `service`, `unknown`). + pub async fn list_ownership_inferences( + &self, + resource_id: String, + ) -> Result< + crate::datadogV2::model::OwnershipInferenceListResponse, + datadog::Error, + > { + match self + .list_ownership_inferences_with_http_info(resource_id) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get all current ownership inferences for a resource, one per owner type (`user`, `team`, `service`, `unknown`). + pub async fn list_ownership_inferences_with_http_info( + &self, + resource_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_ownership_inferences"; + 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_ownership_inferences' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/ownership/{resource_id}", + local_configuration.get_operation_host(operation_id), + resource_id = datadog::urlencode(resource_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)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 95caad2d5..f3b7f6a70 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -34,6 +34,7 @@ pub mod api_container_images; pub mod api_containers; pub mod api_csm_agents; pub mod api_csm_coverage_analysis; +pub mod api_csm_ownership; pub mod api_csm_threats; pub mod api_customer_org; pub mod api_dashboard_lists; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index 86e3734f4..2cfc24b4f 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -35,6 +35,7 @@ pub use self::api::api_container_images; pub use self::api::api_containers; pub use self::api::api_csm_agents; pub use self::api::api_csm_coverage_analysis; +pub use self::api::api_csm_ownership; pub use self::api::api_csm_threats; pub use self::api::api_customer_org; pub use self::api::api_dashboard_lists; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index dc9baf5f5..3213686d7 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -3124,6 +3124,66 @@ pub mod model_csm_serverless_coverage_analysis_data; pub use self::model_csm_serverless_coverage_analysis_data::CsmServerlessCoverageAnalysisData; pub mod model_csm_serverless_coverage_analysis_attributes; pub use self::model_csm_serverless_coverage_analysis_attributes::CsmServerlessCoverageAnalysisAttributes; +pub mod model_ownership_inference_list_response; +pub use self::model_ownership_inference_list_response::OwnershipInferenceListResponse; +pub mod model_ownership_inference_list_data; +pub use self::model_ownership_inference_list_data::OwnershipInferenceListData; +pub mod model_ownership_inference_list_attributes; +pub use self::model_ownership_inference_list_attributes::OwnershipInferenceListAttributes; +pub mod model_ownership_inference_item; +pub use self::model_ownership_inference_item::OwnershipInferenceItem; +pub mod model_ownership_owner_type; +pub use self::model_ownership_owner_type::OwnershipOwnerType; +pub mod model_ownership_inference_status; +pub use self::model_ownership_inference_status::OwnershipInferenceStatus; +pub mod model_ownership_inferences_type; +pub use self::model_ownership_inferences_type::OwnershipInferencesType; +pub mod model_ownership_history_response; +pub use self::model_ownership_history_response::OwnershipHistoryResponse; +pub mod model_ownership_history_data; +pub use self::model_ownership_history_data::OwnershipHistoryData; +pub mod model_ownership_history_attributes; +pub use self::model_ownership_history_attributes::OwnershipHistoryAttributes; +pub mod model_ownership_history_item; +pub use self::model_ownership_history_item::OwnershipHistoryItem; +pub mod model_ownership_history_pagination; +pub use self::model_ownership_history_pagination::OwnershipHistoryPagination; +pub mod model_ownership_history_type; +pub use self::model_ownership_history_type::OwnershipHistoryType; +pub mod model_ownership_inference_response; +pub use self::model_ownership_inference_response::OwnershipInferenceResponse; +pub mod model_ownership_inference_data; +pub use self::model_ownership_inference_data::OwnershipInferenceData; +pub mod model_ownership_inference_attributes; +pub use self::model_ownership_inference_attributes::OwnershipInferenceAttributes; +pub mod model_ownership_inference_type; +pub use self::model_ownership_inference_type::OwnershipInferenceType; +pub mod model_ownership_evidence_response; +pub use self::model_ownership_evidence_response::OwnershipEvidenceResponse; +pub mod model_ownership_evidence_data; +pub use self::model_ownership_evidence_data::OwnershipEvidenceData; +pub mod model_ownership_evidence_attributes; +pub use self::model_ownership_evidence_attributes::OwnershipEvidenceAttributes; +pub mod model_ownership_evidence_type; +pub use self::model_ownership_evidence_type::OwnershipEvidenceType; +pub mod model_ownership_feedback_request; +pub use self::model_ownership_feedback_request::OwnershipFeedbackRequest; +pub mod model_ownership_feedback_request_data; +pub use self::model_ownership_feedback_request_data::OwnershipFeedbackRequestData; +pub mod model_ownership_feedback_request_attributes; +pub use self::model_ownership_feedback_request_attributes::OwnershipFeedbackRequestAttributes; +pub mod model_ownership_feedback_action; +pub use self::model_ownership_feedback_action::OwnershipFeedbackAction; +pub mod model_ownership_feedback_type; +pub use self::model_ownership_feedback_type::OwnershipFeedbackType; +pub mod model_ownership_feedback_response; +pub use self::model_ownership_feedback_response::OwnershipFeedbackResponse; +pub mod model_ownership_feedback_result_data; +pub use self::model_ownership_feedback_result_data::OwnershipFeedbackResultData; +pub mod model_ownership_feedback_result_attributes; +pub use self::model_ownership_feedback_result_attributes::OwnershipFeedbackResultAttributes; +pub mod model_ownership_feedback_result_type; +pub use self::model_ownership_feedback_result_type::OwnershipFeedbackResultType; pub mod model_user_response; pub use self::model_user_response::UserResponse; pub mod model_organization; diff --git a/src/datadogV2/model/model_ownership_evidence_attributes.rs b/src/datadogV2/model/model_ownership_evidence_attributes.rs new file mode 100644 index 000000000..bffefd904 --- /dev/null +++ b/src/datadogV2/model/model_ownership_evidence_attributes.rs @@ -0,0 +1,99 @@ +// 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}; + +/// The attributes of an ownership evidence response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipEvidenceAttributes { + /// The list of evidence versions associated with an inference. + #[serialize_always] + #[serde(rename = "evidence_versions")] + pub evidence_versions: Option>>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipEvidenceAttributes { + pub fn new( + evidence_versions: Option>>, + ) -> OwnershipEvidenceAttributes { + OwnershipEvidenceAttributes { + evidence_versions, + 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 OwnershipEvidenceAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipEvidenceAttributesVisitor; + impl<'a> Visitor<'a> for OwnershipEvidenceAttributesVisitor { + type Value = OwnershipEvidenceAttributes; + + 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 evidence_versions: Option< + 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() { + "evidence_versions" => { + evidence_versions = + 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 evidence_versions = evidence_versions + .ok_or_else(|| M::Error::missing_field("evidence_versions"))?; + + let content = OwnershipEvidenceAttributes { + evidence_versions, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipEvidenceAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_evidence_data.rs b/src/datadogV2/model/model_ownership_evidence_data.rs new file mode 100644 index 000000000..c4e64dc61 --- /dev/null +++ b/src/datadogV2/model/model_ownership_evidence_data.rs @@ -0,0 +1,125 @@ +// 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}; + +/// The data wrapper for an ownership evidence response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipEvidenceData { + /// The attributes of an ownership evidence response. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::OwnershipEvidenceAttributes, + /// The identifier of the resource the evidence applies to. + #[serde(rename = "id")] + pub id: String, + /// The type of the ownership evidence resource. The value should always be `ownership_evidence`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::OwnershipEvidenceType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipEvidenceData { + pub fn new( + attributes: crate::datadogV2::model::OwnershipEvidenceAttributes, + id: String, + type_: crate::datadogV2::model::OwnershipEvidenceType, + ) -> OwnershipEvidenceData { + OwnershipEvidenceData { + 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 OwnershipEvidenceData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipEvidenceDataVisitor; + impl<'a> Visitor<'a> for OwnershipEvidenceDataVisitor { + type Value = OwnershipEvidenceData; + + 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::OwnershipEvidenceType::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 = OwnershipEvidenceData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipEvidenceDataVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_evidence_response.rs b/src/datadogV2/model/model_ownership_evidence_response.rs new file mode 100644 index 000000000..49c2bf446 --- /dev/null +++ b/src/datadogV2/model/model_ownership_evidence_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}; + +/// The response returned when retrieving the evidence backing an ownership inference for an owner type. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipEvidenceResponse { + /// The data wrapper for an ownership evidence response. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::OwnershipEvidenceData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipEvidenceResponse { + pub fn new(data: crate::datadogV2::model::OwnershipEvidenceData) -> OwnershipEvidenceResponse { + OwnershipEvidenceResponse { + 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 OwnershipEvidenceResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipEvidenceResponseVisitor; + impl<'a> Visitor<'a> for OwnershipEvidenceResponseVisitor { + type Value = OwnershipEvidenceResponse; + + 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 = OwnershipEvidenceResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipEvidenceResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_evidence_type.rs b/src/datadogV2/model/model_ownership_evidence_type.rs new file mode 100644 index 000000000..de84f3a59 --- /dev/null +++ b/src/datadogV2/model/model_ownership_evidence_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 OwnershipEvidenceType { + OWNERSHIP_EVIDENCE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipEvidenceType { + fn to_string(&self) -> String { + match self { + Self::OWNERSHIP_EVIDENCE => String::from("ownership_evidence"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipEvidenceType { + 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 OwnershipEvidenceType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "ownership_evidence" => Self::OWNERSHIP_EVIDENCE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_action.rs b/src/datadogV2/model/model_ownership_feedback_action.rs new file mode 100644 index 000000000..771048716 --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_action.rs @@ -0,0 +1,57 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum OwnershipFeedbackAction { + CONFIRM, + REJECT, + CORRECT, + PERSIST, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipFeedbackAction { + fn to_string(&self) -> String { + match self { + Self::CONFIRM => String::from("confirm"), + Self::REJECT => String::from("reject"), + Self::CORRECT => String::from("correct"), + Self::PERSIST => String::from("persist"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipFeedbackAction { + 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 OwnershipFeedbackAction { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "confirm" => Self::CONFIRM, + "reject" => Self::REJECT, + "correct" => Self::CORRECT, + "persist" => Self::PERSIST, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_request.rs b/src/datadogV2/model/model_ownership_feedback_request.rs new file mode 100644 index 000000000..98cb4ab77 --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_request.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}; + +/// The request body for submitting ownership feedback. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipFeedbackRequest { + /// The data wrapper for an ownership feedback request. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::OwnershipFeedbackRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipFeedbackRequest { + pub fn new( + data: crate::datadogV2::model::OwnershipFeedbackRequestData, + ) -> OwnershipFeedbackRequest { + OwnershipFeedbackRequest { + 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 OwnershipFeedbackRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipFeedbackRequestVisitor; + impl<'a> Visitor<'a> for OwnershipFeedbackRequestVisitor { + type Value = OwnershipFeedbackRequest; + + 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 = OwnershipFeedbackRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipFeedbackRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_request_attributes.rs b/src/datadogV2/model/model_ownership_feedback_request_attributes.rs new file mode 100644 index 000000000..dbd183787 --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_request_attributes.rs @@ -0,0 +1,191 @@ +// 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}; + +/// The attributes of an ownership feedback request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipFeedbackRequestAttributes { + /// The feedback action to apply to an inference. + #[serde(rename = "action")] + pub action: crate::datadogV2::model::OwnershipFeedbackAction, + /// The handle of the actor submitting the feedback. + #[serde(rename = "actor_handle")] + pub actor_handle: String, + /// The type of actor submitting the feedback, for example `user` or `service`. + #[serde(rename = "actor_type")] + pub actor_type: String, + /// The corrected owner handle. Required when `action` is `correct`. + #[serde( + rename = "corrected_owner_handle", + default, + with = "::serde_with::rust::double_option" + )] + pub corrected_owner_handle: Option>, + /// The corrected owner type. Required when `action` is `correct`. + #[serde( + rename = "corrected_owner_type", + default, + with = "::serde_with::rust::double_option" + )] + pub corrected_owner_type: Option>, + /// The checksum of the inference being acted upon. Must match the current inference checksum or the request returns a conflict. + #[serde(rename = "inference_checksum")] + pub inference_checksum: String, + /// An optional free-form reason explaining the feedback. + #[serde(rename = "reason", default, with = "::serde_with::rust::double_option")] + pub reason: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipFeedbackRequestAttributes { + pub fn new( + action: crate::datadogV2::model::OwnershipFeedbackAction, + actor_handle: String, + actor_type: String, + inference_checksum: String, + ) -> OwnershipFeedbackRequestAttributes { + OwnershipFeedbackRequestAttributes { + action, + actor_handle, + actor_type, + corrected_owner_handle: None, + corrected_owner_type: None, + inference_checksum, + reason: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn corrected_owner_handle(mut self, value: Option) -> Self { + self.corrected_owner_handle = Some(value); + self + } + + pub fn corrected_owner_type(mut self, value: Option) -> Self { + self.corrected_owner_type = Some(value); + self + } + + pub fn reason(mut self, value: Option) -> Self { + self.reason = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for OwnershipFeedbackRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipFeedbackRequestAttributesVisitor; + impl<'a> Visitor<'a> for OwnershipFeedbackRequestAttributesVisitor { + type Value = OwnershipFeedbackRequestAttributes; + + 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 action: Option = None; + let mut actor_handle: Option = None; + let mut actor_type: Option = None; + let mut corrected_owner_handle: Option> = None; + let mut corrected_owner_type: Option> = None; + let mut inference_checksum: Option = None; + let mut reason: 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() { + "action" => { + action = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _action) = action { + match _action { + crate::datadogV2::model::OwnershipFeedbackAction::UnparsedObject(_action) => { + _unparsed = true; + }, + _ => {} + } + } + } + "actor_handle" => { + actor_handle = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "actor_type" => { + actor_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "corrected_owner_handle" => { + corrected_owner_handle = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "corrected_owner_type" => { + corrected_owner_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "inference_checksum" => { + inference_checksum = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "reason" => { + reason = 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 action = action.ok_or_else(|| M::Error::missing_field("action"))?; + let actor_handle = + actor_handle.ok_or_else(|| M::Error::missing_field("actor_handle"))?; + let actor_type = actor_type.ok_or_else(|| M::Error::missing_field("actor_type"))?; + let inference_checksum = inference_checksum + .ok_or_else(|| M::Error::missing_field("inference_checksum"))?; + + let content = OwnershipFeedbackRequestAttributes { + action, + actor_handle, + actor_type, + corrected_owner_handle, + corrected_owner_type, + inference_checksum, + reason, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipFeedbackRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_request_data.rs b/src/datadogV2/model/model_ownership_feedback_request_data.rs new file mode 100644 index 000000000..d654d4eaa --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_request_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data wrapper for an ownership feedback request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipFeedbackRequestData { + /// The attributes of an ownership feedback request. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::OwnershipFeedbackRequestAttributes, + /// The type of the ownership feedback request resource. The value should always be `ownership_feedback`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::OwnershipFeedbackType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipFeedbackRequestData { + pub fn new( + attributes: crate::datadogV2::model::OwnershipFeedbackRequestAttributes, + type_: crate::datadogV2::model::OwnershipFeedbackType, + ) -> OwnershipFeedbackRequestData { + OwnershipFeedbackRequestData { + 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 OwnershipFeedbackRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipFeedbackRequestDataVisitor; + impl<'a> Visitor<'a> for OwnershipFeedbackRequestDataVisitor { + type Value = OwnershipFeedbackRequestData; + + 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::OwnershipFeedbackRequestAttributes, + > = 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::OwnershipFeedbackType::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 = OwnershipFeedbackRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipFeedbackRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_response.rs b/src/datadogV2/model/model_ownership_feedback_response.rs new file mode 100644 index 000000000..95aee627a --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_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}; + +/// The response returned after applying ownership feedback to an inference. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipFeedbackResponse { + /// The data wrapper for an ownership feedback result response. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::OwnershipFeedbackResultData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipFeedbackResponse { + pub fn new( + data: crate::datadogV2::model::OwnershipFeedbackResultData, + ) -> OwnershipFeedbackResponse { + OwnershipFeedbackResponse { + 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 OwnershipFeedbackResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipFeedbackResponseVisitor; + impl<'a> Visitor<'a> for OwnershipFeedbackResponseVisitor { + type Value = OwnershipFeedbackResponse; + + 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 = OwnershipFeedbackResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipFeedbackResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_result_attributes.rs b/src/datadogV2/model/model_ownership_feedback_result_attributes.rs new file mode 100644 index 000000000..f40698a87 --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_result_attributes.rs @@ -0,0 +1,206 @@ +// 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}; + +/// The attributes of an ownership feedback result. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipFeedbackResultAttributes { + /// The feedback action to apply to an inference. + #[serde(rename = "action")] + pub action: crate::datadogV2::model::OwnershipFeedbackAction, + /// The checksum of the inference after the feedback was applied. + #[serde(rename = "checksum")] + pub checksum: String, + /// The lifecycle status of an ownership inference. + #[serde(rename = "new_status")] + pub new_status: crate::datadogV2::model::OwnershipInferenceStatus, + /// The owner type for an ownership inference. + #[serde(rename = "owner_type")] + pub owner_type: crate::datadogV2::model::OwnershipOwnerType, + /// The lifecycle status of an ownership inference. + #[serde(rename = "previous_status")] + pub previous_status: crate::datadogV2::model::OwnershipInferenceStatus, + /// The primary contact reference for the inferred owner after the feedback was applied, formatted as `ref:handle/`. + #[serde( + rename = "primary_contact_ref", + default, + with = "::serde_with::rust::double_option" + )] + pub primary_contact_ref: Option>, + /// The time when the inference was updated by the feedback. + #[serde(rename = "updated_at")] + pub updated_at: chrono::DateTime, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipFeedbackResultAttributes { + pub fn new( + action: crate::datadogV2::model::OwnershipFeedbackAction, + checksum: String, + new_status: crate::datadogV2::model::OwnershipInferenceStatus, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + previous_status: crate::datadogV2::model::OwnershipInferenceStatus, + updated_at: chrono::DateTime, + ) -> OwnershipFeedbackResultAttributes { + OwnershipFeedbackResultAttributes { + action, + checksum, + new_status, + owner_type, + previous_status, + primary_contact_ref: None, + updated_at, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn primary_contact_ref(mut self, value: Option) -> Self { + self.primary_contact_ref = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for OwnershipFeedbackResultAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipFeedbackResultAttributesVisitor; + impl<'a> Visitor<'a> for OwnershipFeedbackResultAttributesVisitor { + type Value = OwnershipFeedbackResultAttributes; + + 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 action: Option = None; + let mut checksum: Option = None; + let mut new_status: Option = + None; + let mut owner_type: Option = None; + let mut previous_status: Option = + None; + let mut primary_contact_ref: Option> = None; + let mut updated_at: 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() { + "action" => { + action = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _action) = action { + match _action { + crate::datadogV2::model::OwnershipFeedbackAction::UnparsedObject(_action) => { + _unparsed = true; + }, + _ => {} + } + } + } + "checksum" => { + checksum = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "new_status" => { + new_status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _new_status) = new_status { + match _new_status { + crate::datadogV2::model::OwnershipInferenceStatus::UnparsedObject(_new_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + "owner_type" => { + owner_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _owner_type) = owner_type { + match _owner_type { + crate::datadogV2::model::OwnershipOwnerType::UnparsedObject( + _owner_type, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "previous_status" => { + previous_status = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _previous_status) = previous_status { + match _previous_status { + crate::datadogV2::model::OwnershipInferenceStatus::UnparsedObject(_previous_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + "primary_contact_ref" => { + primary_contact_ref = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "updated_at" => { + updated_at = 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 action = action.ok_or_else(|| M::Error::missing_field("action"))?; + let checksum = checksum.ok_or_else(|| M::Error::missing_field("checksum"))?; + let new_status = new_status.ok_or_else(|| M::Error::missing_field("new_status"))?; + let owner_type = owner_type.ok_or_else(|| M::Error::missing_field("owner_type"))?; + let previous_status = + previous_status.ok_or_else(|| M::Error::missing_field("previous_status"))?; + let updated_at = updated_at.ok_or_else(|| M::Error::missing_field("updated_at"))?; + + let content = OwnershipFeedbackResultAttributes { + action, + checksum, + new_status, + owner_type, + previous_status, + primary_contact_ref, + updated_at, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipFeedbackResultAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_result_data.rs b/src/datadogV2/model/model_ownership_feedback_result_data.rs new file mode 100644 index 000000000..23edf913d --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_result_data.rs @@ -0,0 +1,126 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data wrapper for an ownership feedback result response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipFeedbackResultData { + /// The attributes of an ownership feedback result. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::OwnershipFeedbackResultAttributes, + /// The identifier of the resource that the feedback was applied to. + #[serde(rename = "id")] + pub id: String, + /// The type of the ownership feedback result resource. The value should always be `ownership_feedback_result`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::OwnershipFeedbackResultType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipFeedbackResultData { + pub fn new( + attributes: crate::datadogV2::model::OwnershipFeedbackResultAttributes, + id: String, + type_: crate::datadogV2::model::OwnershipFeedbackResultType, + ) -> OwnershipFeedbackResultData { + OwnershipFeedbackResultData { + 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 OwnershipFeedbackResultData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipFeedbackResultDataVisitor; + impl<'a> Visitor<'a> for OwnershipFeedbackResultDataVisitor { + type Value = OwnershipFeedbackResultData; + + 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::OwnershipFeedbackResultAttributes, + > = 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::OwnershipFeedbackResultType::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 = OwnershipFeedbackResultData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipFeedbackResultDataVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_result_type.rs b/src/datadogV2/model/model_ownership_feedback_result_type.rs new file mode 100644 index 000000000..cf88bafab --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_result_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 OwnershipFeedbackResultType { + OWNERSHIP_FEEDBACK_RESULT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipFeedbackResultType { + fn to_string(&self) -> String { + match self { + Self::OWNERSHIP_FEEDBACK_RESULT => String::from("ownership_feedback_result"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipFeedbackResultType { + 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 OwnershipFeedbackResultType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "ownership_feedback_result" => Self::OWNERSHIP_FEEDBACK_RESULT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ownership_feedback_type.rs b/src/datadogV2/model/model_ownership_feedback_type.rs new file mode 100644 index 000000000..11c18d3ff --- /dev/null +++ b/src/datadogV2/model/model_ownership_feedback_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 OwnershipFeedbackType { + OWNERSHIP_FEEDBACK, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipFeedbackType { + fn to_string(&self) -> String { + match self { + Self::OWNERSHIP_FEEDBACK => String::from("ownership_feedback"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipFeedbackType { + 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 OwnershipFeedbackType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "ownership_feedback" => Self::OWNERSHIP_FEEDBACK, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ownership_history_attributes.rs b/src/datadogV2/model/model_ownership_history_attributes.rs new file mode 100644 index 000000000..c4b4083d1 --- /dev/null +++ b/src/datadogV2/model/model_ownership_history_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}; + +/// The attributes of an ownership history response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipHistoryAttributes { + /// The list of history entries returned for this page. + #[serde(rename = "items")] + pub items: Vec, + /// Cursor-based pagination metadata for the history response. + #[serde(rename = "pagination")] + pub pagination: crate::datadogV2::model::OwnershipHistoryPagination, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipHistoryAttributes { + pub fn new( + items: Vec, + pagination: crate::datadogV2::model::OwnershipHistoryPagination, + ) -> OwnershipHistoryAttributes { + OwnershipHistoryAttributes { + items, + pagination, + 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 OwnershipHistoryAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipHistoryAttributesVisitor; + impl<'a> Visitor<'a> for OwnershipHistoryAttributesVisitor { + type Value = OwnershipHistoryAttributes; + + 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 pagination: 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)?); + } + "pagination" => { + pagination = 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 pagination = pagination.ok_or_else(|| M::Error::missing_field("pagination"))?; + + let content = OwnershipHistoryAttributes { + items, + pagination, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipHistoryAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_history_data.rs b/src/datadogV2/model/model_ownership_history_data.rs new file mode 100644 index 000000000..4c548c210 --- /dev/null +++ b/src/datadogV2/model/model_ownership_history_data.rs @@ -0,0 +1,125 @@ +// 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}; + +/// The data wrapper for an ownership history response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipHistoryData { + /// The attributes of an ownership history response. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::OwnershipHistoryAttributes, + /// The resource identifier for which history is returned. + #[serde(rename = "id")] + pub id: String, + /// The type of the ownership history resource. The value should always be `ownership_history`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::OwnershipHistoryType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipHistoryData { + pub fn new( + attributes: crate::datadogV2::model::OwnershipHistoryAttributes, + id: String, + type_: crate::datadogV2::model::OwnershipHistoryType, + ) -> OwnershipHistoryData { + OwnershipHistoryData { + 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 OwnershipHistoryData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipHistoryDataVisitor; + impl<'a> Visitor<'a> for OwnershipHistoryDataVisitor { + type Value = OwnershipHistoryData; + + 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::OwnershipHistoryType::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 = OwnershipHistoryData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipHistoryDataVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_history_item.rs b/src/datadogV2/model/model_ownership_history_item.rs new file mode 100644 index 000000000..f8d69d2eb --- /dev/null +++ b/src/datadogV2/model/model_ownership_history_item.rs @@ -0,0 +1,297 @@ +// 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}; + +/// A single ownership inference history entry. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipHistoryItem { + /// A checksum identifying the state of the inference at this point in time. + #[serde(rename = "checksum")] + pub checksum: String, + /// The confidence score of the inference, expressed as a numeric string with up to four decimal places. + #[serde(rename = "confidence")] + pub confidence: String, + /// The time this history entry was created. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The list of evidence versions associated with an inference. + #[serialize_always] + #[serde(rename = "evidence_versions")] + pub evidence_versions: Option>>, + /// A human-readable explanation of how the inference was produced. + #[serde(rename = "explanation")] + pub explanation: String, + /// The time when this inference failed, if applicable. + #[serde( + rename = "failed_at", + default, + with = "::serde_with::rust::double_option" + )] + pub failed_at: Option>>, + /// The reason why this inference failed, if applicable. + #[serde( + rename = "failure_reason", + default, + with = "::serde_with::rust::double_option" + )] + pub failure_reason: Option>, + /// The unique identifier of the history entry. + #[serde(rename = "id")] + pub id: i64, + /// The owner type for an ownership inference. + #[serde(rename = "owner_type")] + pub owner_type: crate::datadogV2::model::OwnershipOwnerType, + /// The primary contact reference for the inferred owner, formatted as `ref:handle/`. + #[serde( + rename = "primary_contact_ref", + default, + with = "::serde_with::rust::double_option" + )] + pub primary_contact_ref: Option>, + /// The identifier of the resource that the inference applies to. + #[serde(rename = "resource_id")] + pub resource_id: String, + /// The scheduled retry time for a failed inference, if applicable. + #[serde( + rename = "retry_schedule", + default, + with = "::serde_with::rust::double_option" + )] + pub retry_schedule: Option>>, + /// The list of sources backing an ownership inference. Empty when the inference status is not whitelisted to expose sources. + #[serde(rename = "sources")] + pub sources: Vec>, + /// The lifecycle status of an ownership inference. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::OwnershipInferenceStatus, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipHistoryItem { + pub fn new( + checksum: String, + confidence: String, + created_at: chrono::DateTime, + evidence_versions: Option>>, + explanation: String, + id: i64, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + resource_id: String, + sources: Vec>, + status: crate::datadogV2::model::OwnershipInferenceStatus, + ) -> OwnershipHistoryItem { + OwnershipHistoryItem { + checksum, + confidence, + created_at, + evidence_versions, + explanation, + failed_at: None, + failure_reason: None, + id, + owner_type, + primary_contact_ref: None, + resource_id, + retry_schedule: None, + sources, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn failed_at(mut self, value: Option>) -> Self { + self.failed_at = Some(value); + self + } + + pub fn failure_reason(mut self, value: Option) -> Self { + self.failure_reason = Some(value); + self + } + + pub fn primary_contact_ref(mut self, value: Option) -> Self { + self.primary_contact_ref = Some(value); + self + } + + pub fn retry_schedule(mut self, value: Option>) -> Self { + self.retry_schedule = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for OwnershipHistoryItem { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipHistoryItemVisitor; + impl<'a> Visitor<'a> for OwnershipHistoryItemVisitor { + type Value = OwnershipHistoryItem; + + 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 checksum: Option = None; + let mut confidence: Option = None; + let mut created_at: Option> = None; + let mut evidence_versions: Option< + Option>>, + > = None; + let mut explanation: Option = None; + let mut failed_at: Option>> = None; + let mut failure_reason: Option> = None; + let mut id: Option = None; + let mut owner_type: Option = None; + let mut primary_contact_ref: Option> = None; + let mut resource_id: Option = None; + let mut retry_schedule: Option>> = None; + let mut sources: Option< + Vec>, + > = 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() { + "checksum" => { + checksum = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "confidence" => { + confidence = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "evidence_versions" => { + evidence_versions = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "explanation" => { + explanation = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "failed_at" => { + failed_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "failure_reason" => { + failure_reason = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "owner_type" => { + owner_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _owner_type) = owner_type { + match _owner_type { + crate::datadogV2::model::OwnershipOwnerType::UnparsedObject( + _owner_type, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "primary_contact_ref" => { + primary_contact_ref = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_id" => { + resource_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "retry_schedule" => { + retry_schedule = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sources" => { + sources = 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 Some(ref _status) = status { + match _status { + crate::datadogV2::model::OwnershipInferenceStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let checksum = checksum.ok_or_else(|| M::Error::missing_field("checksum"))?; + let confidence = confidence.ok_or_else(|| M::Error::missing_field("confidence"))?; + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let evidence_versions = evidence_versions + .ok_or_else(|| M::Error::missing_field("evidence_versions"))?; + let explanation = + explanation.ok_or_else(|| M::Error::missing_field("explanation"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let owner_type = owner_type.ok_or_else(|| M::Error::missing_field("owner_type"))?; + let resource_id = + resource_id.ok_or_else(|| M::Error::missing_field("resource_id"))?; + let sources = sources.ok_or_else(|| M::Error::missing_field("sources"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = OwnershipHistoryItem { + checksum, + confidence, + created_at, + evidence_versions, + explanation, + failed_at, + failure_reason, + id, + owner_type, + primary_contact_ref, + resource_id, + retry_schedule, + sources, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipHistoryItemVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_history_pagination.rs b/src/datadogV2/model/model_ownership_history_pagination.rs new file mode 100644 index 000000000..3e3a943e4 --- /dev/null +++ b/src/datadogV2/model/model_ownership_history_pagination.rs @@ -0,0 +1,111 @@ +// 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}; + +/// Cursor-based pagination metadata for the history response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipHistoryPagination { + /// Whether more history entries are available beyond this page. + #[serde(rename = "has_more")] + pub has_more: bool, + /// An opaque, base64-encoded cursor token. Pass it as the `cursor` query parameter to retrieve the next page. Absent or `null` when there are no further pages. + #[serde( + rename = "next_cursor", + default, + with = "::serde_with::rust::double_option" + )] + pub next_cursor: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipHistoryPagination { + pub fn new(has_more: bool) -> OwnershipHistoryPagination { + OwnershipHistoryPagination { + has_more, + next_cursor: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn next_cursor(mut self, value: Option) -> Self { + self.next_cursor = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for OwnershipHistoryPagination { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipHistoryPaginationVisitor; + impl<'a> Visitor<'a> for OwnershipHistoryPaginationVisitor { + type Value = OwnershipHistoryPagination; + + 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 has_more: Option = None; + let mut next_cursor: 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() { + "has_more" => { + has_more = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "next_cursor" => { + next_cursor = + 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 has_more = has_more.ok_or_else(|| M::Error::missing_field("has_more"))?; + + let content = OwnershipHistoryPagination { + has_more, + next_cursor, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipHistoryPaginationVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_history_response.rs b/src/datadogV2/model/model_ownership_history_response.rs new file mode 100644 index 000000000..ec7e22832 --- /dev/null +++ b/src/datadogV2/model/model_ownership_history_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}; + +/// The response returned when listing the inference history for a resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipHistoryResponse { + /// The data wrapper for an ownership history response. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::OwnershipHistoryData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipHistoryResponse { + pub fn new(data: crate::datadogV2::model::OwnershipHistoryData) -> OwnershipHistoryResponse { + OwnershipHistoryResponse { + 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 OwnershipHistoryResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipHistoryResponseVisitor; + impl<'a> Visitor<'a> for OwnershipHistoryResponseVisitor { + type Value = OwnershipHistoryResponse; + + 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 = OwnershipHistoryResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipHistoryResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_history_type.rs b/src/datadogV2/model/model_ownership_history_type.rs new file mode 100644 index 000000000..214450a09 --- /dev/null +++ b/src/datadogV2/model/model_ownership_history_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 OwnershipHistoryType { + OWNERSHIP_HISTORY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipHistoryType { + fn to_string(&self) -> String { + match self { + Self::OWNERSHIP_HISTORY => String::from("ownership_history"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipHistoryType { + 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 OwnershipHistoryType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "ownership_history" => Self::OWNERSHIP_HISTORY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_attributes.rs b/src/datadogV2/model/model_ownership_inference_attributes.rs new file mode 100644 index 000000000..5a03ca721 --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_attributes.rs @@ -0,0 +1,228 @@ +// 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}; + +/// The attributes of a single ownership inference. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipInferenceAttributes { + /// A checksum that uniquely identifies the current state of the inference. Required when submitting feedback. + #[serde(rename = "checksum")] + pub checksum: String, + /// The confidence score of the inference, expressed as a numeric string with up to four decimal places. + #[serde(rename = "confidence")] + pub confidence: String, + /// The time when the inference was created. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The list of evidence versions associated with an inference. + #[serialize_always] + #[serde(rename = "evidence_versions")] + pub evidence_versions: Option>>, + /// A human-readable explanation of how the inference was produced. + #[serde(rename = "explanation")] + pub explanation: String, + /// The owner type for an ownership inference. + #[serde(rename = "owner_type")] + pub owner_type: crate::datadogV2::model::OwnershipOwnerType, + /// The primary contact reference for the inferred owner, formatted as `ref:handle/`. + #[serde( + rename = "primary_contact_ref", + default, + with = "::serde_with::rust::double_option" + )] + pub primary_contact_ref: Option>, + /// The list of sources backing an ownership inference. Empty when the inference status is not whitelisted to expose sources. + #[serde(rename = "sources")] + pub sources: Vec>, + /// The lifecycle status of an ownership inference. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::OwnershipInferenceStatus, + /// The time when the inference was last updated. + #[serde(rename = "updated_at")] + pub updated_at: chrono::DateTime, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipInferenceAttributes { + pub fn new( + checksum: String, + confidence: String, + created_at: chrono::DateTime, + evidence_versions: Option>>, + explanation: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + sources: Vec>, + status: crate::datadogV2::model::OwnershipInferenceStatus, + updated_at: chrono::DateTime, + ) -> OwnershipInferenceAttributes { + OwnershipInferenceAttributes { + checksum, + confidence, + created_at, + evidence_versions, + explanation, + owner_type, + primary_contact_ref: None, + sources, + status, + updated_at, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn primary_contact_ref(mut self, value: Option) -> Self { + self.primary_contact_ref = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for OwnershipInferenceAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipInferenceAttributesVisitor; + impl<'a> Visitor<'a> for OwnershipInferenceAttributesVisitor { + type Value = OwnershipInferenceAttributes; + + 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 checksum: Option = None; + let mut confidence: Option = None; + let mut created_at: Option> = None; + let mut evidence_versions: Option< + Option>>, + > = None; + let mut explanation: Option = None; + let mut owner_type: Option = None; + let mut primary_contact_ref: Option> = None; + let mut sources: Option< + Vec>, + > = None; + let mut status: Option = None; + let mut updated_at: 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() { + "checksum" => { + checksum = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "confidence" => { + confidence = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "evidence_versions" => { + evidence_versions = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "explanation" => { + explanation = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "owner_type" => { + owner_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _owner_type) = owner_type { + match _owner_type { + crate::datadogV2::model::OwnershipOwnerType::UnparsedObject( + _owner_type, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "primary_contact_ref" => { + primary_contact_ref = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sources" => { + sources = 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 Some(ref _status) = status { + match _status { + crate::datadogV2::model::OwnershipInferenceStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + "updated_at" => { + updated_at = 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 checksum = checksum.ok_or_else(|| M::Error::missing_field("checksum"))?; + let confidence = confidence.ok_or_else(|| M::Error::missing_field("confidence"))?; + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let evidence_versions = evidence_versions + .ok_or_else(|| M::Error::missing_field("evidence_versions"))?; + let explanation = + explanation.ok_or_else(|| M::Error::missing_field("explanation"))?; + let owner_type = owner_type.ok_or_else(|| M::Error::missing_field("owner_type"))?; + let sources = sources.ok_or_else(|| M::Error::missing_field("sources"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + let updated_at = updated_at.ok_or_else(|| M::Error::missing_field("updated_at"))?; + + let content = OwnershipInferenceAttributes { + checksum, + confidence, + created_at, + evidence_versions, + explanation, + owner_type, + primary_contact_ref, + sources, + status, + updated_at, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipInferenceAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_data.rs b/src/datadogV2/model/model_ownership_inference_data.rs new file mode 100644 index 000000000..04908b292 --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_data.rs @@ -0,0 +1,125 @@ +// 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}; + +/// The data wrapper for a single ownership inference response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipInferenceData { + /// The attributes of a single ownership inference. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::OwnershipInferenceAttributes, + /// The identifier of the inference, formatted as `resource_id:owner_type`. + #[serde(rename = "id")] + pub id: String, + /// The type of the ownership inference resource. The value should always be `ownership_inference`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::OwnershipInferenceType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipInferenceData { + pub fn new( + attributes: crate::datadogV2::model::OwnershipInferenceAttributes, + id: String, + type_: crate::datadogV2::model::OwnershipInferenceType, + ) -> OwnershipInferenceData { + OwnershipInferenceData { + 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 OwnershipInferenceData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipInferenceDataVisitor; + impl<'a> Visitor<'a> for OwnershipInferenceDataVisitor { + type Value = OwnershipInferenceData; + + 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::OwnershipInferenceType::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 = OwnershipInferenceData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipInferenceDataVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_item.rs b/src/datadogV2/model/model_ownership_inference_item.rs new file mode 100644 index 000000000..9f7abde1d --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_item.rs @@ -0,0 +1,239 @@ +// 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}; + +/// A single ownership inference, scoped to a specific owner type. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipInferenceItem { + /// A checksum that uniquely identifies the current state of the inference. Required when submitting feedback. + #[serde(rename = "checksum")] + pub checksum: String, + /// The confidence score of the inference, expressed as a numeric string with up to four decimal places. + #[serde(rename = "confidence")] + pub confidence: String, + /// The time when the inference was created. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The list of evidence versions associated with an inference. + #[serialize_always] + #[serde(rename = "evidence_versions")] + pub evidence_versions: Option>>, + /// A human-readable explanation of how the inference was produced. + #[serde(rename = "explanation")] + pub explanation: String, + /// The identifier of the inference, formatted as `resource_id:owner_type`. + #[serde(rename = "id")] + pub id: String, + /// The owner type for an ownership inference. + #[serde(rename = "owner_type")] + pub owner_type: crate::datadogV2::model::OwnershipOwnerType, + /// The primary contact reference for the inferred owner, formatted as `ref:handle/`. + #[serde( + rename = "primary_contact_ref", + default, + with = "::serde_with::rust::double_option" + )] + pub primary_contact_ref: Option>, + /// The list of sources backing an ownership inference. Empty when the inference status is not whitelisted to expose sources. + #[serde(rename = "sources")] + pub sources: Vec>, + /// The lifecycle status of an ownership inference. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::OwnershipInferenceStatus, + /// The time when the inference was last updated. + #[serde(rename = "updated_at")] + pub updated_at: chrono::DateTime, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipInferenceItem { + pub fn new( + checksum: String, + confidence: String, + created_at: chrono::DateTime, + evidence_versions: Option>>, + explanation: String, + id: String, + owner_type: crate::datadogV2::model::OwnershipOwnerType, + sources: Vec>, + status: crate::datadogV2::model::OwnershipInferenceStatus, + updated_at: chrono::DateTime, + ) -> OwnershipInferenceItem { + OwnershipInferenceItem { + checksum, + confidence, + created_at, + evidence_versions, + explanation, + id, + owner_type, + primary_contact_ref: None, + sources, + status, + updated_at, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn primary_contact_ref(mut self, value: Option) -> Self { + self.primary_contact_ref = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for OwnershipInferenceItem { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipInferenceItemVisitor; + impl<'a> Visitor<'a> for OwnershipInferenceItemVisitor { + type Value = OwnershipInferenceItem; + + 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 checksum: Option = None; + let mut confidence: Option = None; + let mut created_at: Option> = None; + let mut evidence_versions: Option< + Option>>, + > = None; + let mut explanation: Option = None; + let mut id: Option = None; + let mut owner_type: Option = None; + let mut primary_contact_ref: Option> = None; + let mut sources: Option< + Vec>, + > = None; + let mut status: Option = None; + let mut updated_at: 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() { + "checksum" => { + checksum = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "confidence" => { + confidence = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "evidence_versions" => { + evidence_versions = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "explanation" => { + explanation = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "owner_type" => { + owner_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _owner_type) = owner_type { + match _owner_type { + crate::datadogV2::model::OwnershipOwnerType::UnparsedObject( + _owner_type, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "primary_contact_ref" => { + primary_contact_ref = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sources" => { + sources = 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 Some(ref _status) = status { + match _status { + crate::datadogV2::model::OwnershipInferenceStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + "updated_at" => { + updated_at = 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 checksum = checksum.ok_or_else(|| M::Error::missing_field("checksum"))?; + let confidence = confidence.ok_or_else(|| M::Error::missing_field("confidence"))?; + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let evidence_versions = evidence_versions + .ok_or_else(|| M::Error::missing_field("evidence_versions"))?; + let explanation = + explanation.ok_or_else(|| M::Error::missing_field("explanation"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let owner_type = owner_type.ok_or_else(|| M::Error::missing_field("owner_type"))?; + let sources = sources.ok_or_else(|| M::Error::missing_field("sources"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + let updated_at = updated_at.ok_or_else(|| M::Error::missing_field("updated_at"))?; + + let content = OwnershipInferenceItem { + checksum, + confidence, + created_at, + evidence_versions, + explanation, + id, + owner_type, + primary_contact_ref, + sources, + status, + updated_at, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipInferenceItemVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_list_attributes.rs b/src/datadogV2/model/model_ownership_inference_list_attributes.rs new file mode 100644 index 000000000..5c08317c8 --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_list_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}; + +/// The attributes of the ownership inferences collection response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipInferenceListAttributes { + /// The list of inferences for a resource, with one inference per owner type. + #[serde(rename = "items")] + pub items: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipInferenceListAttributes { + pub fn new( + items: Vec, + ) -> OwnershipInferenceListAttributes { + OwnershipInferenceListAttributes { + items, + 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 OwnershipInferenceListAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipInferenceListAttributesVisitor; + impl<'a> Visitor<'a> for OwnershipInferenceListAttributesVisitor { + type Value = OwnershipInferenceListAttributes; + + 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 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)?); + } + &_ => { + 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 content = OwnershipInferenceListAttributes { + items, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipInferenceListAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_list_data.rs b/src/datadogV2/model/model_ownership_inference_list_data.rs new file mode 100644 index 000000000..8c79d3bf9 --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_list_data.rs @@ -0,0 +1,126 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data wrapper for the ownership inferences collection response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipInferenceListData { + /// The attributes of the ownership inferences collection response. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::OwnershipInferenceListAttributes, + /// The resource identifier associated with the returned inferences. + #[serde(rename = "id")] + pub id: String, + /// The type of the ownership inferences collection resource. The value should always be `ownership_inferences`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::OwnershipInferencesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipInferenceListData { + pub fn new( + attributes: crate::datadogV2::model::OwnershipInferenceListAttributes, + id: String, + type_: crate::datadogV2::model::OwnershipInferencesType, + ) -> OwnershipInferenceListData { + OwnershipInferenceListData { + 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 OwnershipInferenceListData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipInferenceListDataVisitor; + impl<'a> Visitor<'a> for OwnershipInferenceListDataVisitor { + type Value = OwnershipInferenceListData; + + 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::OwnershipInferenceListAttributes, + > = 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::OwnershipInferencesType::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 = OwnershipInferenceListData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipInferenceListDataVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_list_response.rs b/src/datadogV2/model/model_ownership_inference_list_response.rs new file mode 100644 index 000000000..cf82a4b11 --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_list_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}; + +/// The response returned when listing all current ownership inferences for a resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipInferenceListResponse { + /// The data wrapper for the ownership inferences collection response. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::OwnershipInferenceListData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipInferenceListResponse { + pub fn new( + data: crate::datadogV2::model::OwnershipInferenceListData, + ) -> OwnershipInferenceListResponse { + OwnershipInferenceListResponse { + 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 OwnershipInferenceListResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipInferenceListResponseVisitor; + impl<'a> Visitor<'a> for OwnershipInferenceListResponseVisitor { + type Value = OwnershipInferenceListResponse; + + 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 = OwnershipInferenceListResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipInferenceListResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_response.rs b/src/datadogV2/model/model_ownership_inference_response.rs new file mode 100644 index 000000000..57ba1cc31 --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_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}; + +/// The response returned when retrieving a single ownership inference for an owner type. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OwnershipInferenceResponse { + /// The data wrapper for a single ownership inference response. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::OwnershipInferenceData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OwnershipInferenceResponse { + pub fn new( + data: crate::datadogV2::model::OwnershipInferenceData, + ) -> OwnershipInferenceResponse { + OwnershipInferenceResponse { + 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 OwnershipInferenceResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OwnershipInferenceResponseVisitor; + impl<'a> Visitor<'a> for OwnershipInferenceResponseVisitor { + type Value = OwnershipInferenceResponse; + + 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 = OwnershipInferenceResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OwnershipInferenceResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_status.rs b/src/datadogV2/model/model_ownership_inference_status.rs new file mode 100644 index 000000000..1e4dc290a --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_status.rs @@ -0,0 +1,60 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum OwnershipInferenceStatus { + SUGGESTED, + PERSISTED, + OVERRIDDEN, + FAILED, + UNKNOWN, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipInferenceStatus { + fn to_string(&self) -> String { + match self { + Self::SUGGESTED => String::from("suggested"), + Self::PERSISTED => String::from("persisted"), + Self::OVERRIDDEN => String::from("overridden"), + Self::FAILED => String::from("failed"), + Self::UNKNOWN => String::from("unknown"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipInferenceStatus { + 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 OwnershipInferenceStatus { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "suggested" => Self::SUGGESTED, + "persisted" => Self::PERSISTED, + "overridden" => Self::OVERRIDDEN, + "failed" => Self::FAILED, + "unknown" => Self::UNKNOWN, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ownership_inference_type.rs b/src/datadogV2/model/model_ownership_inference_type.rs new file mode 100644 index 000000000..452a48ef0 --- /dev/null +++ b/src/datadogV2/model/model_ownership_inference_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 OwnershipInferenceType { + OWNERSHIP_INFERENCE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipInferenceType { + fn to_string(&self) -> String { + match self { + Self::OWNERSHIP_INFERENCE => String::from("ownership_inference"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipInferenceType { + 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 OwnershipInferenceType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "ownership_inference" => Self::OWNERSHIP_INFERENCE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ownership_inferences_type.rs b/src/datadogV2/model/model_ownership_inferences_type.rs new file mode 100644 index 000000000..ad5ee30bf --- /dev/null +++ b/src/datadogV2/model/model_ownership_inferences_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 OwnershipInferencesType { + OWNERSHIP_INFERENCES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipInferencesType { + fn to_string(&self) -> String { + match self { + Self::OWNERSHIP_INFERENCES => String::from("ownership_inferences"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipInferencesType { + 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 OwnershipInferencesType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "ownership_inferences" => Self::OWNERSHIP_INFERENCES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ownership_owner_type.rs b/src/datadogV2/model/model_ownership_owner_type.rs new file mode 100644 index 000000000..f46f21e8b --- /dev/null +++ b/src/datadogV2/model/model_ownership_owner_type.rs @@ -0,0 +1,57 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum OwnershipOwnerType { + USER, + TEAM, + SERVICE, + UNKNOWN, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OwnershipOwnerType { + fn to_string(&self) -> String { + match self { + Self::USER => String::from("user"), + Self::TEAM => String::from("team"), + Self::SERVICE => String::from("service"), + Self::UNKNOWN => String::from("unknown"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OwnershipOwnerType { + 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 OwnershipOwnerType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "user" => Self::USER, + "team" => Self::TEAM, + "service" => Self::SERVICE, + "unknown" => Self::UNKNOWN, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/csm_ownership.feature b/tests/scenarios/features/v2/csm_ownership.feature new file mode 100644 index 000000000..58498ca15 --- /dev/null +++ b/tests/scenarios/features/v2/csm_ownership.feature @@ -0,0 +1,165 @@ +@endpoint(csm-ownership) @endpoint(csm-ownership-v2) +Feature: CSM Ownership + Datadog Cloud Security Management (CSM) Ownership infers the most likely + owner for a cloud resource by combining ownership signals from across the + platform, and lets you review the inference, inspect its evidence, and + submit feedback to persist, override, or correct the inferred owner. For + more information, see [Cloud Security Management](https://docs.datadoghq.c + om/security/cloud_security_management). + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "CSMOwnership" API + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get an ownership inference by owner type returns "Bad Request" response + Given operation "GetOwnershipInference" enabled + And new "GetOwnershipInference" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get an ownership inference by owner type returns "Not Found" response + Given operation "GetOwnershipInference" enabled + And new "GetOwnershipInference" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get an ownership inference by owner type returns "OK" response + Given operation "GetOwnershipInference" enabled + And new "GetOwnershipInference" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get the evidence for an ownership inference returns "Bad Request" response + Given operation "GetOwnershipEvidence" enabled + And new "GetOwnershipEvidence" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get the evidence for an ownership inference returns "Not Found" response + Given operation "GetOwnershipEvidence" enabled + And new "GetOwnershipEvidence" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get the evidence for an ownership inference returns "OK" response + Given operation "GetOwnershipEvidence" enabled + And new "GetOwnershipEvidence" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: List ownership history by owner type returns "Bad Request" response + Given operation "ListOwnershipHistoryByOwnerType" enabled + And new "ListOwnershipHistoryByOwnerType" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: List ownership history by owner type returns "OK" response + Given operation "ListOwnershipHistoryByOwnerType" enabled + And new "ListOwnershipHistoryByOwnerType" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: List ownership inference history for a resource returns "Bad Request" response + Given operation "ListOwnershipHistory" enabled + And new "ListOwnershipHistory" request + And request contains "resource_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: List ownership inference history for a resource returns "OK" response + Given operation "ListOwnershipHistory" enabled + And new "ListOwnershipHistory" request + And request contains "resource_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: List ownership inferences for a resource returns "Bad Request" response + Given operation "ListOwnershipInferences" enabled + And new "ListOwnershipInferences" request + And request contains "resource_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: List ownership inferences for a resource returns "Not Found" response + Given operation "ListOwnershipInferences" enabled + And new "ListOwnershipInferences" request + And request contains "resource_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: List ownership inferences for a resource returns "OK" response + Given operation "ListOwnershipInferences" enabled + And new "ListOwnershipInferences" request + And request contains "resource_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Submit feedback on an ownership inference returns "Bad Request" response + Given operation "CreateOwnershipFeedback" enabled + And new "CreateOwnershipFeedback" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": "confirm", "actor_handle": "user@example.com", "actor_type": "user", "corrected_owner_handle": "team-b", "corrected_owner_type": "team", "inference_checksum": "abc123", "reason": "Confirmed by team lead."}, "type": "ownership_feedback"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Submit feedback on an ownership inference returns "Conflict" response + Given operation "CreateOwnershipFeedback" enabled + And new "CreateOwnershipFeedback" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": "confirm", "actor_handle": "user@example.com", "actor_type": "user", "corrected_owner_handle": "team-b", "corrected_owner_type": "team", "inference_checksum": "abc123", "reason": "Confirmed by team lead."}, "type": "ownership_feedback"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Submit feedback on an ownership inference returns "Created" response + Given operation "CreateOwnershipFeedback" enabled + And new "CreateOwnershipFeedback" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": "confirm", "actor_handle": "user@example.com", "actor_type": "user", "corrected_owner_handle": "team-b", "corrected_owner_type": "team", "inference_checksum": "abc123", "reason": "Confirmed by team lead."}, "type": "ownership_feedback"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Submit feedback on an ownership inference returns "Not Found" response + Given operation "CreateOwnershipFeedback" enabled + And new "CreateOwnershipFeedback" request + And request contains "resource_id" parameter from "REPLACE.ME" + And request contains "owner_type" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": "confirm", "actor_handle": "user@example.com", "actor_type": "user", "corrected_owner_handle": "team-b", "corrected_owner_type": "team", "inference_checksum": "abc123", "reason": "Confirmed by team lead."}, "type": "ownership_feedback"}} + When the request is sent + Then the response status is 404 Not Found diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 9101d0155..8fc2c9e12 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2031,6 +2031,42 @@ "type": "safe" } }, + "ListOwnershipInferences": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, + "ListOwnershipHistory": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, + "GetOwnershipInference": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, + "GetOwnershipEvidence": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, + "CreateOwnershipFeedback": { + "tag": "CSM Ownership", + "undo": { + "type": "idempotent" + } + }, + "ListOwnershipHistoryByOwnerType": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, "GetCurrentUser": { "tag": "Users", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 1b05e3166..609c99c8e 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -93,6 +93,7 @@ pub struct ApiInstances { pub v2_api_csm_agents: Option, pub v2_api_csm_coverage_analysis: Option, + pub v2_api_csm_ownership: Option, pub v2_api_dashboard_lists: Option, pub v2_api_dashboard_secure_embed: Option, @@ -789,6 +790,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { world.http_client.as_ref().unwrap().clone() )); } + "CSMOwnership" => { + world.api_instances.v2_api_csm_ownership = Some( + datadogV2::api_csm_ownership::CSMOwnershipAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "DashboardSecureEmbed" => { world.api_instances.v2_api_dashboard_secure_embed = Some(datadogV2::api_dashboard_secure_embed::DashboardSecureEmbedAPI::with_client_and_config( world.config.clone(), @@ -4182,6 +4191,30 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.GetCSMServerlessCoverageAnalysis".into(), test_v2_get_csm_serverless_coverage_analysis, ); + world.function_mappings.insert( + "v2.ListOwnershipInferences".into(), + test_v2_list_ownership_inferences, + ); + world.function_mappings.insert( + "v2.ListOwnershipHistory".into(), + test_v2_list_ownership_history, + ); + world.function_mappings.insert( + "v2.GetOwnershipInference".into(), + test_v2_get_ownership_inference, + ); + world.function_mappings.insert( + "v2.GetOwnershipEvidence".into(), + test_v2_get_ownership_evidence, + ); + world.function_mappings.insert( + "v2.CreateOwnershipFeedback".into(), + test_v2_create_ownership_feedback, + ); + world.function_mappings.insert( + "v2.ListOwnershipHistoryByOwnerType".into(), + test_v2_list_ownership_history_by_owner_type, + ); world.function_mappings.insert( "v2.DeleteDashboardListItems".into(), test_v2_delete_dashboard_list_items, @@ -31941,6 +31974,221 @@ fn test_v2_get_csm_serverless_coverage_analysis( world.response.code = response.status.as_u16(); } +fn test_v2_list_ownership_inferences( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_csm_ownership + .as_ref() + .expect("api instance not found"); + let resource_id = + serde_json::from_value(_parameters.get("resource_id").unwrap().clone()).unwrap(); + let response = match block_on(api.list_ownership_inferences_with_http_info(resource_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_ownership_history(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_csm_ownership + .as_ref() + .expect("api instance not found"); + let resource_id = + serde_json::from_value(_parameters.get("resource_id").unwrap().clone()).unwrap(); + let cursor = _parameters + .get("cursor") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let limit = _parameters + .get("limit") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_csm_ownership::ListOwnershipHistoryOptionalParams::default(); + params.cursor = cursor; + params.limit = limit; + let response = match block_on(api.list_ownership_history_with_http_info(resource_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_get_ownership_inference(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_csm_ownership + .as_ref() + .expect("api instance not found"); + let resource_id = + serde_json::from_value(_parameters.get("resource_id").unwrap().clone()).unwrap(); + let owner_type = + serde_json::from_value(_parameters.get("owner_type").unwrap().clone()).unwrap(); + let if_none_match = _parameters + .get("If-None-Match") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_csm_ownership::GetOwnershipInferenceOptionalParams::default(); + params.if_none_match = if_none_match; + let response = + match block_on(api.get_ownership_inference_with_http_info(resource_id, owner_type, 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_get_ownership_evidence(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_csm_ownership + .as_ref() + .expect("api instance not found"); + let resource_id = + serde_json::from_value(_parameters.get("resource_id").unwrap().clone()).unwrap(); + let owner_type = + serde_json::from_value(_parameters.get("owner_type").unwrap().clone()).unwrap(); + let if_none_match = _parameters + .get("If-None-Match") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_csm_ownership::GetOwnershipEvidenceOptionalParams::default(); + params.if_none_match = if_none_match; + let response = match block_on(api.get_ownership_evidence_with_http_info( + resource_id, + owner_type, + 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_ownership_feedback( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_csm_ownership + .as_ref() + .expect("api instance not found"); + let resource_id = + serde_json::from_value(_parameters.get("resource_id").unwrap().clone()).unwrap(); + let owner_type = + serde_json::from_value(_parameters.get("owner_type").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = + match block_on(api.create_ownership_feedback_with_http_info(resource_id, owner_type, 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_ownership_history_by_owner_type( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_csm_ownership + .as_ref() + .expect("api instance not found"); + let resource_id = + serde_json::from_value(_parameters.get("resource_id").unwrap().clone()).unwrap(); + let owner_type = + serde_json::from_value(_parameters.get("owner_type").unwrap().clone()).unwrap(); + let cursor = _parameters + .get("cursor") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let limit = _parameters + .get("limit") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_csm_ownership::ListOwnershipHistoryByOwnerTypeOptionalParams::default(); + params.cursor = cursor; + params.limit = limit; + let response = match block_on(api.list_ownership_history_by_owner_type_with_http_info( + resource_id, + owner_type, + 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_delete_dashboard_list_items( world: &mut DatadogWorld, _parameters: &HashMap,