diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4b6dc560f32..759d9cf0624 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -29047,6 +29047,64 @@ components: $ref: "#/components/schemas/GetInterfacesData" type: array type: object + GetInvestigationResponse: + description: Response for a single Bits AI investigation. + properties: + data: + $ref: "#/components/schemas/GetInvestigationResponseData" + links: + $ref: "#/components/schemas/GetInvestigationResponseLinks" + required: + - data + - links + type: object + GetInvestigationResponseData: + description: Data for the get investigation response. + properties: + attributes: + $ref: "#/components/schemas/GetInvestigationResponseDataAttributes" + id: + description: The unique identifier of the investigation. + example: "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + type: string + type: + $ref: "#/components/schemas/InvestigationType" + required: + - id + - type + - attributes + type: object + GetInvestigationResponseDataAttributes: + description: Attributes of the investigation. + properties: + conclusions: + description: The conclusions drawn from the investigation. + items: + $ref: "#/components/schemas/InvestigationConclusion" + type: array + status: + description: The current status of the investigation. + example: "conclusive" + type: string + title: + description: The title of the investigation. + example: "Monitor alert investigation for web-server-01" + type: string + required: + - title + - status + - conclusions + type: object + GetInvestigationResponseLinks: + description: Links related to the investigation. + properties: + self: + description: The URL to the investigation in the Datadog app. + example: "https://app.datadoghq.com/bits-ai/investigations/a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + type: string + required: + - self + type: object GetIssueIncludeQueryParameterItem: description: Relationship object that should be included in the response. enum: @@ -34510,6 +34568,34 @@ components: - DOWN - WARNING - "OFF" + InvestigationConclusion: + description: A full explanation of the finding, including root cause analysis and supporting evidence. + properties: + description: + description: A full explanation of the finding, including root cause analysis and supporting evidence. + example: "The investigation found that a memory leak in payments-service caused CPU usage to spike above 95% starting at 14:32 UTC." + type: string + summary: + description: A summary of the finding, including affected components and timeframe. + example: "CPU usage exceeded 95% for over 10 minutes on web-server-01." + type: string + title: + description: The title of the conclusion. + example: "High CPU usage detected on web-server-01" + type: string + required: + - title + - summary + - description + type: object + InvestigationType: + description: The resource type for investigations. + enum: + - investigation + example: investigation + type: string + x-enum-varnames: + - INVESTIGATION Issue: description: The issue matching the request. properties: @@ -38356,6 +38442,113 @@ components: description: The type of the resource. The value should always be tags. type: string type: object + ListInvestigationsResponse: + description: Response for listing investigations. + properties: + data: + description: List of investigations. + items: + $ref: "#/components/schemas/ListInvestigationsResponseData" + type: array + links: + $ref: "#/components/schemas/ListInvestigationsResponseLinks" + meta: + $ref: "#/components/schemas/ListInvestigationsResponseMeta" + required: + - data + - meta + - links + type: object + ListInvestigationsResponseData: + description: Data for an investigation list item. + properties: + attributes: + $ref: "#/components/schemas/ListInvestigationsResponseDataAttributes" + id: + description: The unique identifier of the investigation. + example: "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + type: string + type: + $ref: "#/components/schemas/InvestigationType" + required: + - id + - type + - attributes + type: object + ListInvestigationsResponseDataAttributes: + description: Attributes of an investigation list item. + properties: + status: + description: The current status of the investigation. + example: "conclusive" + type: string + title: + description: The title of the investigation. + example: "Monitor alert investigation for web-server-01" + type: string + required: + - status + - title + type: object + ListInvestigationsResponseLinks: + description: Pagination links for the list investigations response. + properties: + first: + description: Link to the first page. + example: "https://api.datadoghq.com/api/v2/bits-ai/investigations?page[offset]=0&page[limit]=10" + type: string + last: + description: Link to the last page. + nullable: true + type: string + next: + description: Link to the next page. + example: "https://api.datadoghq.com/api/v2/bits-ai/investigations?page[offset]=10&page[limit]=10" + type: string + prev: + description: Link to the previous page. + nullable: true + type: string + self: + description: Link to the current page. + example: "https://api.datadoghq.com/api/v2/bits-ai/investigations?page[offset]=0&page[limit]=10" + type: string + required: + - first + - next + - self + type: object + ListInvestigationsResponseMeta: + description: Metadata for the list investigations response. + properties: + page: + $ref: "#/components/schemas/ListInvestigationsResponseMetaPage" + required: + - page + type: object + ListInvestigationsResponseMetaPage: + description: Pagination metadata. + properties: + limit: + description: Maximum number of results per page. + example: 10 + format: int64 + type: integer + offset: + description: Offset of the current page. + example: 0 + format: int64 + type: integer + total: + description: Total number of investigations. + example: 50 + format: int64 + type: integer + required: + - total + - limit + - offset + type: object ListKindCatalogResponse: description: List kind response. properties: @@ -41727,6 +41920,28 @@ components: maxLength: 255 type: string type: object + MonitorAlertTriggerAttributes: + description: Attributes for a monitor alert trigger. + properties: + event_id: + description: The event ID associated with the monitor alert. + example: "1234567890123456789" + type: string + event_ts: + description: The timestamp of the event in Unix milliseconds. + example: 1700000000000 + format: int64 + type: integer + monitor_id: + description: The monitor ID that triggered the alert. + example: 12345678 + format: int64 + type: integer + required: + - monitor_id + - event_id + - event_ts + type: object MonitorConfigPolicyAttributeCreateRequest: description: Policy and policy type for a monitor configuration policy. properties: @@ -44467,6 +44682,40 @@ components: type: string x-enum-varnames: - ELASTICSEARCH + ObservabilityPipelineEnrichmentTableFieldEventLookup: + description: Looks up a value from a field path in the log event. + properties: + event: + description: The path to the field in the log event to use as the lookup key. + example: log.user.id + type: string + required: + - event + type: object + ObservabilityPipelineEnrichmentTableFieldSecretLookup: + description: Looks up a value stored as a pipeline secret. + properties: + secret: + description: The name of the secret containing the lookup key value. + example: MY_LOOKUP_SECRET + type: string + required: + - secret + type: object + ObservabilityPipelineEnrichmentTableFieldStringPath: + description: A plain field path in the log event, used as the lookup key. + example: log.user.id + type: string + ObservabilityPipelineEnrichmentTableFieldVrlLookup: + description: Evaluates a VRL expression to produce the lookup key. + properties: + vrl: + description: A VRL expression that returns the value to use as the lookup key. + example: .log.user.id + type: string + required: + - vrl + type: object ObservabilityPipelineEnrichmentTableFile: description: Defines a static enrichment table loaded from a CSV file. properties: @@ -44517,6 +44766,16 @@ components: type: string x-enum-varnames: - CSV + ObservabilityPipelineEnrichmentTableFileKeyItemField: + description: |- + Specifies the source of the key value used for enrichment table lookups. + Can be a plain field path string or an object specifying `event`, `vrl`, or `secret`. + example: log.user.id + oneOf: + - $ref: "#/components/schemas/ObservabilityPipelineEnrichmentTableFieldStringPath" + - $ref: "#/components/schemas/ObservabilityPipelineEnrichmentTableFieldEventLookup" + - $ref: "#/components/schemas/ObservabilityPipelineEnrichmentTableFieldVrlLookup" + - $ref: "#/components/schemas/ObservabilityPipelineEnrichmentTableFieldSecretLookup" ObservabilityPipelineEnrichmentTableFileKeyItems: description: Defines how to map log fields to enrichment table columns during lookups. properties: @@ -44527,9 +44786,7 @@ components: comparison: $ref: "#/components/schemas/ObservabilityPipelineEnrichmentTableFileKeyItemsComparison" field: - description: The `items` `field`. - example: log.user.id - type: string + $ref: "#/components/schemas/ObservabilityPipelineEnrichmentTableFileKeyItemField" required: - column - comparison @@ -47550,6 +47807,8 @@ components: description: Name of the environment variable or secret that holds the Splunk HEC token. example: SPLUNK_HEC_TOKEN type: string + token_strategy: + $ref: "#/components/schemas/ObservabilityPipelineSplunkHecDestinationTokenStrategy" type: $ref: "#/components/schemas/ObservabilityPipelineSplunkHecDestinationType" required: @@ -47568,6 +47827,16 @@ components: x-enum-varnames: - JSON - RAW_MESSAGE + ObservabilityPipelineSplunkHecDestinationTokenStrategy: + description: Controls how the Splunk HEC token is supplied. Use `custom` to provide a token with `token_key`, or `from_source` to forward the token received from an upstream Splunk HEC source. + enum: + - custom + - from_source + example: custom + type: string + x-enum-varnames: + - CUSTOM + - FROM_SOURCE ObservabilityPipelineSplunkHecDestinationType: default: splunk_hec description: The destination type. Always `splunk_hec`. @@ -47591,6 +47860,12 @@ components: description: The unique identifier for this component. Used in other parts of the pipeline to reference this component (for example, as the `input` to downstream components). example: splunk-hec-source type: string + store_hec_token: + description: |- + When `true`, the Splunk HEC token from the incoming request is stored in the event metadata. + This allows downstream components to forward the token to other Splunk HEC destinations. + example: true + type: boolean tls: $ref: "#/components/schemas/ObservabilityPipelineTls" type: @@ -70721,6 +70996,286 @@ components: type: string x-enum-varnames: - TEST_OPTIMIZATION_DELETE_SERVICE_SETTINGS_REQUEST + TestOptimizationFlakyTestsManagementPoliciesAttemptToFix: + description: Configuration for the attempt-to-fix Flaky Tests Management policy. + properties: + retries: + description: Number of retries when attempting to fix a flaky test. Must be greater than 0. + example: 3 + format: int64 + type: integer + type: object + TestOptimizationFlakyTestsManagementPoliciesAttributes: + description: Attributes of the Flaky Tests Management policies for a repository. + properties: + attempt_to_fix: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesAttemptToFix" + disabled: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesDisabled" + quarantined: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesQuarantined" + repository_id: + description: The repository identifier. + example: github.com/datadog/shopist + type: string + type: object + TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule: + description: Automatic disable triggering rule based on a time window and test status. + properties: + enabled: + description: Whether this auto-disable rule is enabled. + example: false + type: boolean + status: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesDisabledStatus" + window_seconds: + description: Time window in seconds over which flakiness is evaluated. Must be greater than 0. + example: 3600 + format: int64 + type: integer + type: object + TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule: + description: Automatic quarantine triggering rule based on a time window. + properties: + enabled: + description: Whether this auto-quarantine rule is enabled. + example: true + type: boolean + window_seconds: + description: Time window in seconds over which flakiness is evaluated. Must be greater than 0. + example: 3600 + format: int64 + type: integer + type: object + TestOptimizationFlakyTestsManagementPoliciesBranchRule: + description: Branch filtering rule for a Flaky Tests Management policy. + properties: + branches: + description: List of branches to which the policy applies. + example: + - main + items: + description: A branch name. + type: string + type: array + enabled: + description: Whether this branch rule is enabled. + example: true + type: boolean + excluded_branches: + description: List of branches excluded from the policy. + example: [] + items: + description: A branch name. + type: string + type: array + excluded_test_services: + description: List of test services excluded from the policy. + example: [] + items: + description: A test service name. + type: string + type: array + type: object + TestOptimizationFlakyTestsManagementPoliciesData: + description: Data object for Flaky Tests Management policies response. + properties: + attributes: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesAttributes" + id: + description: The repository identifier used as the resource ID. + example: github.com/datadog/shopist + type: string + type: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesType" + type: object + TestOptimizationFlakyTestsManagementPoliciesDisabled: + description: Configuration for the disabled Flaky Tests Management policy. + properties: + auto_disable_rule: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule" + branch_rule: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesBranchRule" + enabled: + description: Whether the disabled policy is enabled. + example: false + type: boolean + failure_rate_rule: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule" + type: object + TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule: + description: Failure-rate-based rule for the disabled policy. + properties: + branches: + description: List of branches to which this rule applies. + example: [] + items: + description: A branch name. + type: string + type: array + enabled: + description: Whether this failure rate rule is enabled. + example: false + type: boolean + min_runs: + description: Minimum number of runs required before the rule is evaluated. Must be greater than or equal to 0. + example: 10 + format: int64 + type: integer + status: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesDisabledStatus" + threshold: + description: Failure rate threshold (0.0–1.0) above which the rule triggers. + example: 0.5 + format: double + type: number + type: object + TestOptimizationFlakyTestsManagementPoliciesDisabledStatus: + description: |- + Test status that the disable policy applies to. + Must be either `active` or `quarantined`. + enum: + - active + - quarantined + example: active + type: string + x-enum-varnames: + - ACTIVE + - QUARANTINED + TestOptimizationFlakyTestsManagementPoliciesGetRequest: + description: Request object for getting Flaky Tests Management policies. + properties: + data: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesGetRequestData" + required: + - data + type: object + TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes: + description: Attributes for requesting Flaky Tests Management policies. + properties: + repository_id: + description: The repository identifier. + example: github.com/datadog/shopist + minLength: 1 + type: string + required: + - repository_id + type: object + TestOptimizationFlakyTestsManagementPoliciesGetRequestData: + description: Data object for get Flaky Tests Management policies request. + properties: + attributes: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes" + type: + $ref: "#/components/schemas/TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType" + required: + - type + - attributes + type: object + TestOptimizationFlakyTestsManagementPoliciesQuarantined: + description: Configuration for the quarantined Flaky Tests Management policy. + properties: + auto_quarantine_rule: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule" + branch_rule: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesBranchRule" + enabled: + description: Whether the quarantined policy is enabled. + example: true + type: boolean + failure_rate_rule: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule" + type: object + TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule: + description: Failure-rate-based rule for the quarantined policy. + properties: + branches: + description: List of branches to which this rule applies. + example: + - main + items: + description: A branch name. + type: string + type: array + enabled: + description: Whether this failure rate rule is enabled. + example: true + type: boolean + min_runs: + description: Minimum number of runs required before the rule is evaluated. Must be greater than or equal to 0. + example: 10 + format: int64 + type: integer + threshold: + description: Failure rate threshold (0.0–1.0) above which the rule triggers. + example: 0.5 + format: double + type: number + type: object + TestOptimizationFlakyTestsManagementPoliciesResponse: + description: Response object containing Flaky Tests Management policies for a repository. + properties: + data: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesData" + type: object + TestOptimizationFlakyTestsManagementPoliciesType: + description: |- + JSON:API type for Flaky Tests Management policies response. + The value must always be `test_optimization_flaky_tests_management_policies`. + enum: + - test_optimization_flaky_tests_management_policies + example: test_optimization_flaky_tests_management_policies + type: string + x-enum-varnames: + - TEST_OPTIMIZATION_FLAKY_TESTS_MANAGEMENT_POLICIES + TestOptimizationFlakyTestsManagementPoliciesUpdateRequest: + description: Request object for updating Flaky Tests Management policies. + properties: + data: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData" + required: + - data + type: object + TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes: + description: |- + Attributes for updating Flaky Tests Management policies. + Only provided policy blocks are updated; omitted blocks are left unchanged. + properties: + attempt_to_fix: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesAttemptToFix" + disabled: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesDisabled" + quarantined: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesQuarantined" + repository_id: + description: The repository identifier. + example: github.com/datadog/shopist + minLength: 1 + type: string + required: + - repository_id + type: object + TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData: + description: Data object for update Flaky Tests Management policies request. + properties: + attributes: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes" + type: + $ref: "#/components/schemas/TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType" + required: + - type + - attributes + type: object + TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType: + description: |- + JSON:API type for get Flaky Tests Management policies request. + The value must always be `test_optimization_get_flaky_tests_management_policies_request`. + enum: + - test_optimization_get_flaky_tests_management_policies_request + example: test_optimization_get_flaky_tests_management_policies_request + type: string + x-enum-varnames: + - TEST_OPTIMIZATION_GET_FLAKY_TESTS_MANAGEMENT_POLICIES_REQUEST TestOptimizationGetServiceSettingsRequest: description: Request object for getting Test Optimization service settings. properties: @@ -70839,6 +71394,16 @@ components: type: string x-enum-varnames: - TEST_OPTIMIZATION_SERVICE_SETTINGS + TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType: + description: |- + JSON:API type for update Flaky Tests Management policies request. + The value must always be `test_optimization_update_flaky_tests_management_policies_request`. + enum: + - test_optimization_update_flaky_tests_management_policies_request + example: test_optimization_update_flaky_tests_management_policies_request + type: string + x-enum-varnames: + - TEST_OPTIMIZATION_UPDATE_FLAKY_TESTS_MANAGEMENT_POLICIES_REQUEST TestOptimizationUpdateServiceSettingsRequest: description: Request object for updating Test Optimization service settings. properties: @@ -71386,6 +71951,94 @@ components: - $ref: "#/components/schemas/SlackTriggerWrapper" - $ref: "#/components/schemas/SoftwareCatalogTriggerWrapper" - $ref: "#/components/schemas/WorkflowTriggerWrapper" + TriggerAttributes: + description: The trigger definition for starting an investigation. + properties: + monitor_alert_trigger: + $ref: "#/components/schemas/MonitorAlertTriggerAttributes" + type: + $ref: "#/components/schemas/TriggerType" + required: + - type + - monitor_alert_trigger + type: object + TriggerInvestigationRequest: + description: Request to trigger a new investigation. + properties: + data: + $ref: "#/components/schemas/TriggerInvestigationRequestData" + required: + - data + type: object + TriggerInvestigationRequestData: + description: Data for the trigger investigation request. + properties: + attributes: + $ref: "#/components/schemas/TriggerInvestigationRequestDataAttributes" + type: + $ref: "#/components/schemas/TriggerInvestigationRequestType" + required: + - type + - attributes + type: object + TriggerInvestigationRequestDataAttributes: + description: Attributes for the trigger investigation request. + properties: + trigger: + $ref: "#/components/schemas/TriggerAttributes" + required: + - trigger + type: object + TriggerInvestigationRequestType: + description: The resource type for trigger investigation requests. + enum: + - trigger_investigation_request + example: trigger_investigation_request + type: string + x-enum-varnames: + - TRIGGER_INVESTIGATION_REQUEST + TriggerInvestigationResponse: + description: Response after triggering an investigation. + properties: + data: + $ref: "#/components/schemas/TriggerInvestigationResponseData" + required: + - data + type: object + TriggerInvestigationResponseData: + description: Data for the trigger investigation response. + properties: + attributes: + $ref: "#/components/schemas/TriggerInvestigationResponseDataAttributes" + id: + description: Unique identifier for the trigger response. + example: "f5e6a7b8-c9d0-1e2f-3a4b-5c6d7e8f9a0b" + type: string + type: + $ref: "#/components/schemas/TriggerInvestigationResponseType" + required: + - id + - type + - attributes + type: object + TriggerInvestigationResponseDataAttributes: + description: Attributes for the trigger investigation response. + properties: + investigation_id: + description: The ID of the investigation that was created. + example: "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + type: string + required: + - investigation_id + type: object + TriggerInvestigationResponseType: + description: The resource type for trigger investigation responses. + enum: + - trigger_investigation_response + example: trigger_investigation_response + type: string + x-enum-varnames: + - TRIGGER_INVESTIGATION_RESPONSE TriggerRateLimit: description: Defines a rate limit for a trigger. properties: @@ -71409,6 +72062,14 @@ components: x-enum-varnames: - SECURITY_FINDINGS - SECURITY_SIGNALS + TriggerType: + description: The type of trigger for the investigation. + enum: + - monitor_alert_trigger + example: monitor_alert_trigger + type: string + x-enum-varnames: + - MONITOR_ALERT_TRIGGER UCConfigPair: description: The definition of `UCConfigPair` object. example: @@ -75286,6 +75947,8 @@ components: apm_service_catalog_write: Add, modify, and delete service catalog definitions when those definitions are maintained by Datadog. appsec_vm_read: View infrastructure, application code, and library vulnerability findings. billing_read: View your organization's billing information. + bits_investigations_read: View Bits AI investigations. + bits_investigations_write: Create and manage Bits AI investigations. cases_read: View Cases. cases_write: Create and update cases. ci_visibility_pipelines_write: Create CI Visibility pipeline spans using the API. @@ -79376,6 +80039,213 @@ paths: operator: OR permissions: - user_access_manage + /api/v2/bits-ai/investigations: + get: + description: List all Bits AI investigations for the organization. + operationId: ListInvestigations + parameters: + - description: Offset for pagination. + example: 0 + in: query + name: page[offset] + required: false + schema: + format: int64 + type: integer + - description: Maximum number of investigations to return. + example: 25 + in: query + name: page[limit] + required: false + schema: + default: 25 + format: int64 + maximum: 100 + type: integer + - description: Filter investigations by monitor ID. + example: 12345678 + in: query + name: filter[monitor_id] + required: false + schema: + format: int64 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + status: "conclusive" + title: "Monitor alert investigation for web-server-01" + id: "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + type: investigation + links: + first: "https://api.datadoghq.com/api/v2/bits-ai/investigations?page[offset]=0&page[limit]=10" + next: "https://api.datadoghq.com/api/v2/bits-ai/investigations?page[offset]=10&page[limit]=10" + self: "https://api.datadoghq.com/api/v2/bits-ai/investigations?page[offset]=0&page[limit]=10" + meta: + page: + limit: 10 + offset: 0 + total: 50 + schema: + $ref: "#/components/schemas/ListInvestigationsResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - bits_investigations_read + summary: List Bits AI investigations + tags: + - Bits AI + x-pagination: + limitParam: page[limit] + pageOffsetParam: page[offset] + resultsPath: data + "x-permission": + operator: OR + permissions: + - bits_investigations_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: Trigger a new Bits AI investigation based on a monitor alert. + operationId: TriggerInvestigation + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + trigger: + monitor_alert_trigger: + event_id: "1234567890123456789" + event_ts: 1700000000000 + monitor_id: 12345678 + type: monitor_alert_trigger + type: trigger_investigation_request + schema: + $ref: "#/components/schemas/TriggerInvestigationRequest" + description: Trigger investigation request body. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + investigation_id: "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + id: "f5e6a7b8-c9d0-1e2f-3a4b-5c6d7e8f9a0b" + type: trigger_investigation_response + schema: + $ref: "#/components/schemas/TriggerInvestigationResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - bits_investigations_write + summary: Trigger a Bits AI investigation + tags: + - Bits AI + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - bits_investigations_write + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/bits-ai/investigations/{id}: + get: + description: Get a specific Bits AI investigation by ID. + operationId: GetInvestigation + parameters: + - description: The ID of the investigation. + example: "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + in: path + name: id + required: true + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + conclusions: + - description: "The investigation found that a memory leak in payments-service caused CPU usage to spike above 95% starting at 14:32 UTC." + summary: "CPU usage exceeded 95% for over 10 minutes on web-server-01." + title: "High CPU usage detected on web-server-01" + status: "conclusive" + title: "Monitor alert investigation for web-server-01" + id: "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + type: investigation + links: + self: "https://app.datadoghq.com/bits-ai/investigations/a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d" + schema: + $ref: "#/components/schemas/GetInvestigationResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - bits_investigations_read + summary: Get a Bits AI investigation + tags: + - Bits AI + "x-permission": + operator: OR + permissions: + - bits_investigations_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/cases: get: description: >- @@ -81597,6 +82467,88 @@ paths: operator: OR permissions: - ci_visibility_read + /api/v2/ci/test-optimization/settings/policies: + patch: + description: |- + Partially update Flaky Tests Management repository-level policies for the given repository. + Only provided policy blocks are updated; omitted blocks are left unchanged. + operationId: UpdateFlakyTestsManagementPolicies + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesUpdateRequest" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - test_optimization_settings_write + summary: Update Flaky Tests Management policies + tags: ["Test Optimization"] + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - test_optimization_settings_write + 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/). + post: + description: |- + Retrieve Flaky Tests Management repository-level policies for the given repository. + operationId: GetFlakyTestsManagementPolicies + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesGetRequest" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/TestOptimizationFlakyTestsManagementPoliciesResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - test_optimization_read + summary: Get Flaky Tests Management policies + tags: ["Test Optimization"] + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - test_optimization_read + 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/ci/test-optimization/settings/service: delete: description: |- @@ -116395,6 +117347,9 @@ tags: is used to automatically map groups of users to roles in Datadog using attributes sent from Identity Providers. Use these endpoints to manage your AuthN Mappings. name: AuthN Mappings + - description: |- + Use the Bits AI endpoints to retrieve AI-powered investigations. + name: Bits AI - description: |- Search or aggregate your CI Visibility pipeline events and send them to your Datadog site over HTTP. See the [CI Pipeline Visibility in Datadog page](https://docs.datadoghq.com/continuous_integration/pipelines/) for more information. name: CI Visibility Pipelines diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 9d704509870..867bd6f587c 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -668,6 +668,9 @@ func NewConfiguration() *Configuration { "v2.GetOpenAPI": false, "v2.ListAPIs": false, "v2.UpdateOpenAPI": false, + "v2.GetInvestigation": false, + "v2.ListInvestigations": false, + "v2.TriggerInvestigation": false, "v2.CreateCaseJiraIssue": false, "v2.CreateCaseNotebook": false, "v2.CreateCaseServiceNowTicket": false, @@ -682,9 +685,11 @@ func NewConfiguration() *Configuration { "v2.UpdateChangeRequest": false, "v2.UpdateChangeRequestDecision": false, "v2.DeleteTestOptimizationServiceSettings": false, + "v2.GetFlakyTestsManagementPolicies": false, "v2.GetTestOptimizationServiceSettings": false, "v2.SearchFlakyTests": false, "v2.UpdateFlakyTests": false, + "v2.UpdateFlakyTestsManagementPolicies": false, "v2.UpdateTestOptimizationServiceSettings": false, "v2.CreateAWSCloudAuthPersonaMapping": false, "v2.DeleteAWSCloudAuthPersonaMapping": false, diff --git a/api/datadogV2/api_bits_ai.go b/api/datadogV2/api_bits_ai.go new file mode 100644 index 00000000000..80e7f216770 --- /dev/null +++ b/api/datadogV2/api_bits_ai.go @@ -0,0 +1,412 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + _context "context" + _fmt "fmt" + _log "log" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// BitsAIApi service type +type BitsAIApi datadog.Service + +// GetInvestigation Get a Bits AI investigation. +// Get a specific Bits AI investigation by ID. +func (a *BitsAIApi) GetInvestigation(ctx _context.Context, id string) (GetInvestigationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GetInvestigationResponse + ) + + operationId := "v2.GetInvestigation" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.BitsAIApi.GetInvestigation") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/bits-ai/investigations/{id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListInvestigationsOptionalParameters holds optional parameters for ListInvestigations. +type ListInvestigationsOptionalParameters struct { + PageOffset *int64 + PageLimit *int64 + FilterMonitorId *int64 +} + +// NewListInvestigationsOptionalParameters creates an empty struct for parameters. +func NewListInvestigationsOptionalParameters() *ListInvestigationsOptionalParameters { + this := ListInvestigationsOptionalParameters{} + return &this +} + +// WithPageOffset sets the corresponding parameter name and returns the struct. +func (r *ListInvestigationsOptionalParameters) WithPageOffset(pageOffset int64) *ListInvestigationsOptionalParameters { + r.PageOffset = &pageOffset + return r +} + +// WithPageLimit sets the corresponding parameter name and returns the struct. +func (r *ListInvestigationsOptionalParameters) WithPageLimit(pageLimit int64) *ListInvestigationsOptionalParameters { + r.PageLimit = &pageLimit + return r +} + +// WithFilterMonitorId sets the corresponding parameter name and returns the struct. +func (r *ListInvestigationsOptionalParameters) WithFilterMonitorId(filterMonitorId int64) *ListInvestigationsOptionalParameters { + r.FilterMonitorId = &filterMonitorId + return r +} + +// ListInvestigations List Bits AI investigations. +// List all Bits AI investigations for the organization. +func (a *BitsAIApi) ListInvestigations(ctx _context.Context, o ...ListInvestigationsOptionalParameters) (ListInvestigationsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ListInvestigationsResponse + optionalParams ListInvestigationsOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListInvestigationsOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListInvestigations" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.BitsAIApi.ListInvestigations") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/bits-ai/investigations" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageOffset != nil { + localVarQueryParams.Add("page[offset]", datadog.ParameterToString(*optionalParams.PageOffset, "")) + } + if optionalParams.PageLimit != nil { + localVarQueryParams.Add("page[limit]", datadog.ParameterToString(*optionalParams.PageLimit, "")) + } + if optionalParams.FilterMonitorId != nil { + localVarQueryParams.Add("filter[monitor_id]", datadog.ParameterToString(*optionalParams.FilterMonitorId, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListInvestigationsWithPagination provides a paginated version of ListInvestigations returning a channel with all items. +func (a *BitsAIApi) ListInvestigationsWithPagination(ctx _context.Context, o ...ListInvestigationsOptionalParameters) (<-chan datadog.PaginationResult[ListInvestigationsResponseData], func()) { + ctx, cancel := _context.WithCancel(ctx) + pageSize_ := int64(25) + if len(o) == 0 { + o = append(o, ListInvestigationsOptionalParameters{}) + } + if o[0].PageLimit != nil { + pageSize_ = *o[0].PageLimit + } + o[0].PageLimit = &pageSize_ + + items := make(chan datadog.PaginationResult[ListInvestigationsResponseData], pageSize_) + go func() { + for { + resp, _, err := a.ListInvestigations(ctx, o...) + if err != nil { + var returnItem ListInvestigationsResponseData + items <- datadog.PaginationResult[ListInvestigationsResponseData]{Item: returnItem, Error: err} + break + } + respData, ok := resp.GetDataOk() + if !ok { + break + } + results := *respData + + for _, item := range results { + select { + case items <- datadog.PaginationResult[ListInvestigationsResponseData]{Item: item, Error: nil}: + case <-ctx.Done(): + close(items) + return + } + } + if len(results) < int(pageSize_) { + break + } + if o[0].PageOffset == nil { + o[0].PageOffset = &pageSize_ + } else { + pageOffset_ := *o[0].PageOffset + pageSize_ + o[0].PageOffset = &pageOffset_ + } + } + close(items) + }() + return items, cancel +} + +// TriggerInvestigation Trigger a Bits AI investigation. +// Trigger a new Bits AI investigation based on a monitor alert. +func (a *BitsAIApi) TriggerInvestigation(ctx _context.Context, body TriggerInvestigationRequest) (TriggerInvestigationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue TriggerInvestigationResponse + ) + + operationId := "v2.TriggerInvestigation" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.BitsAIApi.TriggerInvestigation") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/bits-ai/investigations" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// NewBitsAIApi Returns NewBitsAIApi. +func NewBitsAIApi(client *datadog.APIClient) *BitsAIApi { + return &BitsAIApi{ + Client: client, + } +} diff --git a/api/datadogV2/api_test_optimization.go b/api/datadogV2/api_test_optimization.go index 899363db686..e241b115229 100644 --- a/api/datadogV2/api_test_optimization.go +++ b/api/datadogV2/api_test_optimization.go @@ -96,6 +96,95 @@ func (a *TestOptimizationApi) DeleteTestOptimizationServiceSettings(ctx _context return localVarHTTPResponse, nil } +// GetFlakyTestsManagementPolicies Get Flaky Tests Management policies. +// Retrieve Flaky Tests Management repository-level policies for the given repository. +func (a *TestOptimizationApi) GetFlakyTestsManagementPolicies(ctx _context.Context, body TestOptimizationFlakyTestsManagementPoliciesGetRequest) (TestOptimizationFlakyTestsManagementPoliciesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue TestOptimizationFlakyTestsManagementPoliciesResponse + ) + + operationId := "v2.GetFlakyTestsManagementPolicies" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.TestOptimizationApi.GetFlakyTestsManagementPolicies") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/ci/test-optimization/settings/policies" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // GetTestOptimizationServiceSettings Get Test Optimization service settings. // Retrieve Test Optimization settings for a specific service identified by repository, service name, and environment. func (a *TestOptimizationApi) GetTestOptimizationServiceSettings(ctx _context.Context, body TestOptimizationGetServiceSettingsRequest) (TestOptimizationServiceSettingsResponse, *_nethttp.Response, error) { @@ -473,6 +562,96 @@ func (a *TestOptimizationApi) UpdateFlakyTests(ctx _context.Context, body Update return localVarReturnValue, localVarHTTPResponse, nil } +// UpdateFlakyTestsManagementPolicies Update Flaky Tests Management policies. +// Partially update Flaky Tests Management repository-level policies for the given repository. +// Only provided policy blocks are updated; omitted blocks are left unchanged. +func (a *TestOptimizationApi) UpdateFlakyTestsManagementPolicies(ctx _context.Context, body TestOptimizationFlakyTestsManagementPoliciesUpdateRequest) (TestOptimizationFlakyTestsManagementPoliciesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue TestOptimizationFlakyTestsManagementPoliciesResponse + ) + + operationId := "v2.UpdateFlakyTestsManagementPolicies" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.TestOptimizationApi.UpdateFlakyTestsManagementPolicies") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/ci/test-optimization/settings/policies" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // UpdateTestOptimizationServiceSettings Update Test Optimization service settings. // Partially update Test Optimization settings for a specific service identified by repository, service name, and environment. // Only provided fields are updated; null or omitted fields are left unchanged. diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index f3c77c2b3c4..fcd43ce66bc 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -94,6 +94,9 @@ // - [AuthNMappingsApi.GetAuthNMapping] // - [AuthNMappingsApi.ListAuthNMappings] // - [AuthNMappingsApi.UpdateAuthNMapping] +// - [BitsAIApi.GetInvestigation] +// - [BitsAIApi.ListInvestigations] +// - [BitsAIApi.TriggerInvestigation] // - [CIVisibilityPipelinesApi.AggregateCIAppPipelineEvents] // - [CIVisibilityPipelinesApi.CreateCIAppPipelineEvent] // - [CIVisibilityPipelinesApi.ListCIAppPipelineEvents] @@ -923,9 +926,11 @@ // - [TeamsApi.UpdateTeamNotificationRule] // - [TeamsApi.UpdateTeamPermissionSetting] // - [TestOptimizationApi.DeleteTestOptimizationServiceSettings] +// - [TestOptimizationApi.GetFlakyTestsManagementPolicies] // - [TestOptimizationApi.GetTestOptimizationServiceSettings] // - [TestOptimizationApi.SearchFlakyTests] // - [TestOptimizationApi.UpdateFlakyTests] +// - [TestOptimizationApi.UpdateFlakyTestsManagementPolicies] // - [TestOptimizationApi.UpdateTestOptimizationServiceSettings] // - [UsageMeteringApi.GetActiveBillingDimensions] // - [UsageMeteringApi.GetBillingDimensionMapping] diff --git a/api/datadogV2/model_get_investigation_response.go b/api/datadogV2/model_get_investigation_response.go new file mode 100644 index 00000000000..dad987413c4 --- /dev/null +++ b/api/datadogV2/model_get_investigation_response.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GetInvestigationResponse Response for a single Bits AI investigation. +type GetInvestigationResponse struct { + // Data for the get investigation response. + Data GetInvestigationResponseData `json:"data"` + // Links related to the investigation. + Links GetInvestigationResponseLinks `json:"links"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGetInvestigationResponse instantiates a new GetInvestigationResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewGetInvestigationResponse(data GetInvestigationResponseData, links GetInvestigationResponseLinks) *GetInvestigationResponse { + this := GetInvestigationResponse{} + this.Data = data + this.Links = links + return &this +} + +// NewGetInvestigationResponseWithDefaults instantiates a new GetInvestigationResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewGetInvestigationResponseWithDefaults() *GetInvestigationResponse { + this := GetInvestigationResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *GetInvestigationResponse) GetData() GetInvestigationResponseData { + if o == nil { + var ret GetInvestigationResponseData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponse) GetDataOk() (*GetInvestigationResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GetInvestigationResponse) SetData(v GetInvestigationResponseData) { + o.Data = v +} + +// GetLinks returns the Links field value. +func (o *GetInvestigationResponse) GetLinks() GetInvestigationResponseLinks { + if o == nil { + var ret GetInvestigationResponseLinks + return ret + } + return o.Links +} + +// GetLinksOk returns a tuple with the Links field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponse) GetLinksOk() (*GetInvestigationResponseLinks, bool) { + if o == nil { + return nil, false + } + return &o.Links, true +} + +// SetLinks sets field value. +func (o *GetInvestigationResponse) SetLinks(v GetInvestigationResponseLinks) { + o.Links = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GetInvestigationResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + toSerialize["links"] = o.Links + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GetInvestigationResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GetInvestigationResponseData `json:"data"` + Links *GetInvestigationResponseLinks `json:"links"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + if all.Links == nil { + return fmt.Errorf("required field links missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "links"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + if all.Links.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Links = *all.Links + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_get_investigation_response_data.go b/api/datadogV2/model_get_investigation_response_data.go new file mode 100644 index 00000000000..0631f337f20 --- /dev/null +++ b/api/datadogV2/model_get_investigation_response_data.go @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GetInvestigationResponseData Data for the get investigation response. +type GetInvestigationResponseData struct { + // Attributes of the investigation. + Attributes GetInvestigationResponseDataAttributes `json:"attributes"` + // The unique identifier of the investigation. + Id string `json:"id"` + // The resource type for investigations. + Type InvestigationType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGetInvestigationResponseData instantiates a new GetInvestigationResponseData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewGetInvestigationResponseData(attributes GetInvestigationResponseDataAttributes, id string, typeVar InvestigationType) *GetInvestigationResponseData { + this := GetInvestigationResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewGetInvestigationResponseDataWithDefaults instantiates a new GetInvestigationResponseData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewGetInvestigationResponseDataWithDefaults() *GetInvestigationResponseData { + this := GetInvestigationResponseData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *GetInvestigationResponseData) GetAttributes() GetInvestigationResponseDataAttributes { + if o == nil { + var ret GetInvestigationResponseDataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponseData) GetAttributesOk() (*GetInvestigationResponseDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *GetInvestigationResponseData) SetAttributes(v GetInvestigationResponseDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *GetInvestigationResponseData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *GetInvestigationResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *GetInvestigationResponseData) GetType() InvestigationType { + if o == nil { + var ret InvestigationType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponseData) GetTypeOk() (*InvestigationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *GetInvestigationResponseData) SetType(v InvestigationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GetInvestigationResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GetInvestigationResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GetInvestigationResponseDataAttributes `json:"attributes"` + Id *string `json:"id"` + Type *InvestigationType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_get_investigation_response_data_attributes.go b/api/datadogV2/model_get_investigation_response_data_attributes.go new file mode 100644 index 00000000000..b6f112c9722 --- /dev/null +++ b/api/datadogV2/model_get_investigation_response_data_attributes.go @@ -0,0 +1,165 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GetInvestigationResponseDataAttributes Attributes of the investigation. +type GetInvestigationResponseDataAttributes struct { + // The conclusions drawn from the investigation. + Conclusions []InvestigationConclusion `json:"conclusions"` + // The current status of the investigation. + Status string `json:"status"` + // The title of the investigation. + Title string `json:"title"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGetInvestigationResponseDataAttributes instantiates a new GetInvestigationResponseDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewGetInvestigationResponseDataAttributes(conclusions []InvestigationConclusion, status string, title string) *GetInvestigationResponseDataAttributes { + this := GetInvestigationResponseDataAttributes{} + this.Conclusions = conclusions + this.Status = status + this.Title = title + return &this +} + +// NewGetInvestigationResponseDataAttributesWithDefaults instantiates a new GetInvestigationResponseDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewGetInvestigationResponseDataAttributesWithDefaults() *GetInvestigationResponseDataAttributes { + this := GetInvestigationResponseDataAttributes{} + return &this +} + +// GetConclusions returns the Conclusions field value. +func (o *GetInvestigationResponseDataAttributes) GetConclusions() []InvestigationConclusion { + if o == nil { + var ret []InvestigationConclusion + return ret + } + return o.Conclusions +} + +// GetConclusionsOk returns a tuple with the Conclusions field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponseDataAttributes) GetConclusionsOk() (*[]InvestigationConclusion, bool) { + if o == nil { + return nil, false + } + return &o.Conclusions, true +} + +// SetConclusions sets field value. +func (o *GetInvestigationResponseDataAttributes) SetConclusions(v []InvestigationConclusion) { + o.Conclusions = v +} + +// GetStatus returns the Status field value. +func (o *GetInvestigationResponseDataAttributes) GetStatus() string { + if o == nil { + var ret string + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponseDataAttributes) GetStatusOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *GetInvestigationResponseDataAttributes) SetStatus(v string) { + o.Status = v +} + +// GetTitle returns the Title field value. +func (o *GetInvestigationResponseDataAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponseDataAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *GetInvestigationResponseDataAttributes) SetTitle(v string) { + o.Title = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GetInvestigationResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["conclusions"] = o.Conclusions + toSerialize["status"] = o.Status + toSerialize["title"] = o.Title + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GetInvestigationResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Conclusions *[]InvestigationConclusion `json:"conclusions"` + Status *string `json:"status"` + Title *string `json:"title"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Conclusions == nil { + return fmt.Errorf("required field conclusions missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"conclusions", "status", "title"}) + } else { + return err + } + o.Conclusions = *all.Conclusions + o.Status = *all.Status + o.Title = *all.Title + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_get_investigation_response_links.go b/api/datadogV2/model_get_investigation_response_links.go new file mode 100644 index 00000000000..84f82140edb --- /dev/null +++ b/api/datadogV2/model_get_investigation_response_links.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GetInvestigationResponseLinks Links related to the investigation. +type GetInvestigationResponseLinks struct { + // The URL to the investigation in the Datadog app. + Self string `json:"self"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGetInvestigationResponseLinks instantiates a new GetInvestigationResponseLinks object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewGetInvestigationResponseLinks(self string) *GetInvestigationResponseLinks { + this := GetInvestigationResponseLinks{} + this.Self = self + return &this +} + +// NewGetInvestigationResponseLinksWithDefaults instantiates a new GetInvestigationResponseLinks object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewGetInvestigationResponseLinksWithDefaults() *GetInvestigationResponseLinks { + this := GetInvestigationResponseLinks{} + return &this +} + +// GetSelf returns the Self field value. +func (o *GetInvestigationResponseLinks) GetSelf() string { + if o == nil { + var ret string + return ret + } + return o.Self +} + +// GetSelfOk returns a tuple with the Self field value +// and a boolean to check if the value has been set. +func (o *GetInvestigationResponseLinks) GetSelfOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Self, true +} + +// SetSelf sets field value. +func (o *GetInvestigationResponseLinks) SetSelf(v string) { + o.Self = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GetInvestigationResponseLinks) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["self"] = o.Self + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GetInvestigationResponseLinks) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Self *string `json:"self"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Self == nil { + return fmt.Errorf("required field self missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"self"}) + } else { + return err + } + o.Self = *all.Self + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_investigation_conclusion.go b/api/datadogV2/model_investigation_conclusion.go new file mode 100644 index 00000000000..c26c44352e1 --- /dev/null +++ b/api/datadogV2/model_investigation_conclusion.go @@ -0,0 +1,165 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// InvestigationConclusion A full explanation of the finding, including root cause analysis and supporting evidence. +type InvestigationConclusion struct { + // A full explanation of the finding, including root cause analysis and supporting evidence. + Description string `json:"description"` + // A summary of the finding, including affected components and timeframe. + Summary string `json:"summary"` + // The title of the conclusion. + Title string `json:"title"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewInvestigationConclusion instantiates a new InvestigationConclusion object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewInvestigationConclusion(description string, summary string, title string) *InvestigationConclusion { + this := InvestigationConclusion{} + this.Description = description + this.Summary = summary + this.Title = title + return &this +} + +// NewInvestigationConclusionWithDefaults instantiates a new InvestigationConclusion object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewInvestigationConclusionWithDefaults() *InvestigationConclusion { + this := InvestigationConclusion{} + return &this +} + +// GetDescription returns the Description field value. +func (o *InvestigationConclusion) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *InvestigationConclusion) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *InvestigationConclusion) SetDescription(v string) { + o.Description = v +} + +// GetSummary returns the Summary field value. +func (o *InvestigationConclusion) GetSummary() string { + if o == nil { + var ret string + return ret + } + return o.Summary +} + +// GetSummaryOk returns a tuple with the Summary field value +// and a boolean to check if the value has been set. +func (o *InvestigationConclusion) GetSummaryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Summary, true +} + +// SetSummary sets field value. +func (o *InvestigationConclusion) SetSummary(v string) { + o.Summary = v +} + +// GetTitle returns the Title field value. +func (o *InvestigationConclusion) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *InvestigationConclusion) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *InvestigationConclusion) SetTitle(v string) { + o.Title = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o InvestigationConclusion) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["description"] = o.Description + toSerialize["summary"] = o.Summary + toSerialize["title"] = o.Title + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *InvestigationConclusion) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description"` + Summary *string `json:"summary"` + Title *string `json:"title"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.Summary == nil { + return fmt.Errorf("required field summary missing") + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "summary", "title"}) + } else { + return err + } + o.Description = *all.Description + o.Summary = *all.Summary + o.Title = *all.Title + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_investigation_type.go b/api/datadogV2/model_investigation_type.go new file mode 100644 index 00000000000..02ac5a13bee --- /dev/null +++ b/api/datadogV2/model_investigation_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// InvestigationType The resource type for investigations. +type InvestigationType string + +// List of InvestigationType. +const ( + INVESTIGATIONTYPE_INVESTIGATION InvestigationType = "investigation" +) + +var allowedInvestigationTypeEnumValues = []InvestigationType{ + INVESTIGATIONTYPE_INVESTIGATION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *InvestigationType) GetAllowedValues() []InvestigationType { + return allowedInvestigationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *InvestigationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = InvestigationType(value) + return nil +} + +// NewInvestigationTypeFromValue returns a pointer to a valid InvestigationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewInvestigationTypeFromValue(v string) (*InvestigationType, error) { + ev := InvestigationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for InvestigationType: valid values are %v", v, allowedInvestigationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v InvestigationType) IsValid() bool { + for _, existing := range allowedInvestigationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to InvestigationType value. +func (v InvestigationType) Ptr() *InvestigationType { + return &v +} diff --git a/api/datadogV2/model_list_investigations_response.go b/api/datadogV2/model_list_investigations_response.go new file mode 100644 index 00000000000..34ed436f360 --- /dev/null +++ b/api/datadogV2/model_list_investigations_response.go @@ -0,0 +1,177 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListInvestigationsResponse Response for listing investigations. +type ListInvestigationsResponse struct { + // List of investigations. + Data []ListInvestigationsResponseData `json:"data"` + // Pagination links for the list investigations response. + Links ListInvestigationsResponseLinks `json:"links"` + // Metadata for the list investigations response. + Meta ListInvestigationsResponseMeta `json:"meta"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListInvestigationsResponse instantiates a new ListInvestigationsResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListInvestigationsResponse(data []ListInvestigationsResponseData, links ListInvestigationsResponseLinks, meta ListInvestigationsResponseMeta) *ListInvestigationsResponse { + this := ListInvestigationsResponse{} + this.Data = data + this.Links = links + this.Meta = meta + return &this +} + +// NewListInvestigationsResponseWithDefaults instantiates a new ListInvestigationsResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListInvestigationsResponseWithDefaults() *ListInvestigationsResponse { + this := ListInvestigationsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ListInvestigationsResponse) GetData() []ListInvestigationsResponseData { + if o == nil { + var ret []ListInvestigationsResponseData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponse) GetDataOk() (*[]ListInvestigationsResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ListInvestigationsResponse) SetData(v []ListInvestigationsResponseData) { + o.Data = v +} + +// GetLinks returns the Links field value. +func (o *ListInvestigationsResponse) GetLinks() ListInvestigationsResponseLinks { + if o == nil { + var ret ListInvestigationsResponseLinks + return ret + } + return o.Links +} + +// GetLinksOk returns a tuple with the Links field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponse) GetLinksOk() (*ListInvestigationsResponseLinks, bool) { + if o == nil { + return nil, false + } + return &o.Links, true +} + +// SetLinks sets field value. +func (o *ListInvestigationsResponse) SetLinks(v ListInvestigationsResponseLinks) { + o.Links = v +} + +// GetMeta returns the Meta field value. +func (o *ListInvestigationsResponse) GetMeta() ListInvestigationsResponseMeta { + if o == nil { + var ret ListInvestigationsResponseMeta + return ret + } + return o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponse) GetMetaOk() (*ListInvestigationsResponseMeta, bool) { + if o == nil { + return nil, false + } + return &o.Meta, true +} + +// SetMeta sets field value. +func (o *ListInvestigationsResponse) SetMeta(v ListInvestigationsResponseMeta) { + o.Meta = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListInvestigationsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + toSerialize["links"] = o.Links + toSerialize["meta"] = o.Meta + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListInvestigationsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]ListInvestigationsResponseData `json:"data"` + Links *ListInvestigationsResponseLinks `json:"links"` + Meta *ListInvestigationsResponseMeta `json:"meta"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + if all.Links == nil { + return fmt.Errorf("required field links missing") + } + if all.Meta == nil { + return fmt.Errorf("required field meta missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "links", "meta"}) + } else { + return err + } + + hasInvalidField := false + o.Data = *all.Data + if all.Links.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Links = *all.Links + if all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = *all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_list_investigations_response_data.go b/api/datadogV2/model_list_investigations_response_data.go new file mode 100644 index 00000000000..f124fd86463 --- /dev/null +++ b/api/datadogV2/model_list_investigations_response_data.go @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListInvestigationsResponseData Data for an investigation list item. +type ListInvestigationsResponseData struct { + // Attributes of an investigation list item. + Attributes ListInvestigationsResponseDataAttributes `json:"attributes"` + // The unique identifier of the investigation. + Id string `json:"id"` + // The resource type for investigations. + Type InvestigationType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListInvestigationsResponseData instantiates a new ListInvestigationsResponseData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListInvestigationsResponseData(attributes ListInvestigationsResponseDataAttributes, id string, typeVar InvestigationType) *ListInvestigationsResponseData { + this := ListInvestigationsResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewListInvestigationsResponseDataWithDefaults instantiates a new ListInvestigationsResponseData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListInvestigationsResponseDataWithDefaults() *ListInvestigationsResponseData { + this := ListInvestigationsResponseData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ListInvestigationsResponseData) GetAttributes() ListInvestigationsResponseDataAttributes { + if o == nil { + var ret ListInvestigationsResponseDataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseData) GetAttributesOk() (*ListInvestigationsResponseDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ListInvestigationsResponseData) SetAttributes(v ListInvestigationsResponseDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *ListInvestigationsResponseData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *ListInvestigationsResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *ListInvestigationsResponseData) GetType() InvestigationType { + if o == nil { + var ret InvestigationType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseData) GetTypeOk() (*InvestigationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ListInvestigationsResponseData) SetType(v InvestigationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListInvestigationsResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListInvestigationsResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ListInvestigationsResponseDataAttributes `json:"attributes"` + Id *string `json:"id"` + Type *InvestigationType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_list_investigations_response_data_attributes.go b/api/datadogV2/model_list_investigations_response_data_attributes.go new file mode 100644 index 00000000000..317196c43d9 --- /dev/null +++ b/api/datadogV2/model_list_investigations_response_data_attributes.go @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListInvestigationsResponseDataAttributes Attributes of an investigation list item. +type ListInvestigationsResponseDataAttributes struct { + // The current status of the investigation. + Status string `json:"status"` + // The title of the investigation. + Title string `json:"title"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListInvestigationsResponseDataAttributes instantiates a new ListInvestigationsResponseDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListInvestigationsResponseDataAttributes(status string, title string) *ListInvestigationsResponseDataAttributes { + this := ListInvestigationsResponseDataAttributes{} + this.Status = status + this.Title = title + return &this +} + +// NewListInvestigationsResponseDataAttributesWithDefaults instantiates a new ListInvestigationsResponseDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListInvestigationsResponseDataAttributesWithDefaults() *ListInvestigationsResponseDataAttributes { + this := ListInvestigationsResponseDataAttributes{} + return &this +} + +// GetStatus returns the Status field value. +func (o *ListInvestigationsResponseDataAttributes) GetStatus() string { + if o == nil { + var ret string + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseDataAttributes) GetStatusOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *ListInvestigationsResponseDataAttributes) SetStatus(v string) { + o.Status = v +} + +// GetTitle returns the Title field value. +func (o *ListInvestigationsResponseDataAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseDataAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *ListInvestigationsResponseDataAttributes) SetTitle(v string) { + o.Title = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListInvestigationsResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["status"] = o.Status + toSerialize["title"] = o.Title + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListInvestigationsResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Status *string `json:"status"` + Title *string `json:"title"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"status", "title"}) + } else { + return err + } + o.Status = *all.Status + o.Title = *all.Title + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_list_investigations_response_links.go b/api/datadogV2/model_list_investigations_response_links.go new file mode 100644 index 00000000000..9f511cdd06d --- /dev/null +++ b/api/datadogV2/model_list_investigations_response_links.go @@ -0,0 +1,257 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListInvestigationsResponseLinks Pagination links for the list investigations response. +type ListInvestigationsResponseLinks struct { + // Link to the first page. + First string `json:"first"` + // Link to the last page. + Last datadog.NullableString `json:"last,omitempty"` + // Link to the next page. + Next string `json:"next"` + // Link to the previous page. + Prev datadog.NullableString `json:"prev,omitempty"` + // Link to the current page. + Self string `json:"self"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListInvestigationsResponseLinks instantiates a new ListInvestigationsResponseLinks object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListInvestigationsResponseLinks(first string, next string, self string) *ListInvestigationsResponseLinks { + this := ListInvestigationsResponseLinks{} + this.First = first + this.Next = next + this.Self = self + return &this +} + +// NewListInvestigationsResponseLinksWithDefaults instantiates a new ListInvestigationsResponseLinks object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListInvestigationsResponseLinksWithDefaults() *ListInvestigationsResponseLinks { + this := ListInvestigationsResponseLinks{} + return &this +} + +// GetFirst returns the First field value. +func (o *ListInvestigationsResponseLinks) GetFirst() string { + if o == nil { + var ret string + return ret + } + return o.First +} + +// GetFirstOk returns a tuple with the First field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseLinks) GetFirstOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.First, true +} + +// SetFirst sets field value. +func (o *ListInvestigationsResponseLinks) SetFirst(v string) { + o.First = v +} + +// GetLast returns the Last field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ListInvestigationsResponseLinks) GetLast() string { + if o == nil || o.Last.Get() == nil { + var ret string + return ret + } + return *o.Last.Get() +} + +// GetLastOk returns a tuple with the Last field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *ListInvestigationsResponseLinks) GetLastOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Last.Get(), o.Last.IsSet() +} + +// HasLast returns a boolean if a field has been set. +func (o *ListInvestigationsResponseLinks) HasLast() bool { + return o != nil && o.Last.IsSet() +} + +// SetLast gets a reference to the given datadog.NullableString and assigns it to the Last field. +func (o *ListInvestigationsResponseLinks) SetLast(v string) { + o.Last.Set(&v) +} + +// SetLastNil sets the value for Last to be an explicit nil. +func (o *ListInvestigationsResponseLinks) SetLastNil() { + o.Last.Set(nil) +} + +// UnsetLast ensures that no value is present for Last, not even an explicit nil. +func (o *ListInvestigationsResponseLinks) UnsetLast() { + o.Last.Unset() +} + +// GetNext returns the Next field value. +func (o *ListInvestigationsResponseLinks) GetNext() string { + if o == nil { + var ret string + return ret + } + return o.Next +} + +// GetNextOk returns a tuple with the Next field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseLinks) GetNextOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Next, true +} + +// SetNext sets field value. +func (o *ListInvestigationsResponseLinks) SetNext(v string) { + o.Next = v +} + +// GetPrev returns the Prev field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ListInvestigationsResponseLinks) GetPrev() string { + if o == nil || o.Prev.Get() == nil { + var ret string + return ret + } + return *o.Prev.Get() +} + +// GetPrevOk returns a tuple with the Prev field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *ListInvestigationsResponseLinks) GetPrevOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Prev.Get(), o.Prev.IsSet() +} + +// HasPrev returns a boolean if a field has been set. +func (o *ListInvestigationsResponseLinks) HasPrev() bool { + return o != nil && o.Prev.IsSet() +} + +// SetPrev gets a reference to the given datadog.NullableString and assigns it to the Prev field. +func (o *ListInvestigationsResponseLinks) SetPrev(v string) { + o.Prev.Set(&v) +} + +// SetPrevNil sets the value for Prev to be an explicit nil. +func (o *ListInvestigationsResponseLinks) SetPrevNil() { + o.Prev.Set(nil) +} + +// UnsetPrev ensures that no value is present for Prev, not even an explicit nil. +func (o *ListInvestigationsResponseLinks) UnsetPrev() { + o.Prev.Unset() +} + +// GetSelf returns the Self field value. +func (o *ListInvestigationsResponseLinks) GetSelf() string { + if o == nil { + var ret string + return ret + } + return o.Self +} + +// GetSelfOk returns a tuple with the Self field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseLinks) GetSelfOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Self, true +} + +// SetSelf sets field value. +func (o *ListInvestigationsResponseLinks) SetSelf(v string) { + o.Self = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListInvestigationsResponseLinks) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["first"] = o.First + if o.Last.IsSet() { + toSerialize["last"] = o.Last.Get() + } + toSerialize["next"] = o.Next + if o.Prev.IsSet() { + toSerialize["prev"] = o.Prev.Get() + } + toSerialize["self"] = o.Self + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListInvestigationsResponseLinks) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + First *string `json:"first"` + Last datadog.NullableString `json:"last,omitempty"` + Next *string `json:"next"` + Prev datadog.NullableString `json:"prev,omitempty"` + Self *string `json:"self"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.First == nil { + return fmt.Errorf("required field first missing") + } + if all.Next == nil { + return fmt.Errorf("required field next missing") + } + if all.Self == nil { + return fmt.Errorf("required field self missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"first", "last", "next", "prev", "self"}) + } else { + return err + } + o.First = *all.First + o.Last = all.Last + o.Next = *all.Next + o.Prev = all.Prev + o.Self = *all.Self + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_list_investigations_response_meta.go b/api/datadogV2/model_list_investigations_response_meta.go new file mode 100644 index 00000000000..a0edaf43df8 --- /dev/null +++ b/api/datadogV2/model_list_investigations_response_meta.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListInvestigationsResponseMeta Metadata for the list investigations response. +type ListInvestigationsResponseMeta struct { + // Pagination metadata. + Page ListInvestigationsResponseMetaPage `json:"page"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListInvestigationsResponseMeta instantiates a new ListInvestigationsResponseMeta object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListInvestigationsResponseMeta(page ListInvestigationsResponseMetaPage) *ListInvestigationsResponseMeta { + this := ListInvestigationsResponseMeta{} + this.Page = page + return &this +} + +// NewListInvestigationsResponseMetaWithDefaults instantiates a new ListInvestigationsResponseMeta object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListInvestigationsResponseMetaWithDefaults() *ListInvestigationsResponseMeta { + this := ListInvestigationsResponseMeta{} + return &this +} + +// GetPage returns the Page field value. +func (o *ListInvestigationsResponseMeta) GetPage() ListInvestigationsResponseMetaPage { + if o == nil { + var ret ListInvestigationsResponseMetaPage + return ret + } + return o.Page +} + +// GetPageOk returns a tuple with the Page field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseMeta) GetPageOk() (*ListInvestigationsResponseMetaPage, bool) { + if o == nil { + return nil, false + } + return &o.Page, true +} + +// SetPage sets field value. +func (o *ListInvestigationsResponseMeta) SetPage(v ListInvestigationsResponseMetaPage) { + o.Page = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListInvestigationsResponseMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["page"] = o.Page + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListInvestigationsResponseMeta) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Page *ListInvestigationsResponseMetaPage `json:"page"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Page == nil { + return fmt.Errorf("required field page missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"page"}) + } else { + return err + } + + hasInvalidField := false + if all.Page.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Page = *all.Page + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_list_investigations_response_meta_page.go b/api/datadogV2/model_list_investigations_response_meta_page.go new file mode 100644 index 00000000000..2bf90b101ec --- /dev/null +++ b/api/datadogV2/model_list_investigations_response_meta_page.go @@ -0,0 +1,165 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListInvestigationsResponseMetaPage Pagination metadata. +type ListInvestigationsResponseMetaPage struct { + // Maximum number of results per page. + Limit int64 `json:"limit"` + // Offset of the current page. + Offset int64 `json:"offset"` + // Total number of investigations. + Total int64 `json:"total"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListInvestigationsResponseMetaPage instantiates a new ListInvestigationsResponseMetaPage object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListInvestigationsResponseMetaPage(limit int64, offset int64, total int64) *ListInvestigationsResponseMetaPage { + this := ListInvestigationsResponseMetaPage{} + this.Limit = limit + this.Offset = offset + this.Total = total + return &this +} + +// NewListInvestigationsResponseMetaPageWithDefaults instantiates a new ListInvestigationsResponseMetaPage object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListInvestigationsResponseMetaPageWithDefaults() *ListInvestigationsResponseMetaPage { + this := ListInvestigationsResponseMetaPage{} + return &this +} + +// GetLimit returns the Limit field value. +func (o *ListInvestigationsResponseMetaPage) GetLimit() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseMetaPage) GetLimitOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Limit, true +} + +// SetLimit sets field value. +func (o *ListInvestigationsResponseMetaPage) SetLimit(v int64) { + o.Limit = v +} + +// GetOffset returns the Offset field value. +func (o *ListInvestigationsResponseMetaPage) GetOffset() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Offset +} + +// GetOffsetOk returns a tuple with the Offset field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseMetaPage) GetOffsetOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Offset, true +} + +// SetOffset sets field value. +func (o *ListInvestigationsResponseMetaPage) SetOffset(v int64) { + o.Offset = v +} + +// GetTotal returns the Total field value. +func (o *ListInvestigationsResponseMetaPage) GetTotal() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Total +} + +// GetTotalOk returns a tuple with the Total field value +// and a boolean to check if the value has been set. +func (o *ListInvestigationsResponseMetaPage) GetTotalOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Total, true +} + +// SetTotal sets field value. +func (o *ListInvestigationsResponseMetaPage) SetTotal(v int64) { + o.Total = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListInvestigationsResponseMetaPage) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["limit"] = o.Limit + toSerialize["offset"] = o.Offset + toSerialize["total"] = o.Total + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListInvestigationsResponseMetaPage) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Limit *int64 `json:"limit"` + Offset *int64 `json:"offset"` + Total *int64 `json:"total"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Limit == nil { + return fmt.Errorf("required field limit missing") + } + if all.Offset == nil { + return fmt.Errorf("required field offset missing") + } + if all.Total == nil { + return fmt.Errorf("required field total missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"limit", "offset", "total"}) + } else { + return err + } + o.Limit = *all.Limit + o.Offset = *all.Offset + o.Total = *all.Total + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_monitor_alert_trigger_attributes.go b/api/datadogV2/model_monitor_alert_trigger_attributes.go new file mode 100644 index 00000000000..2cae9436bfb --- /dev/null +++ b/api/datadogV2/model_monitor_alert_trigger_attributes.go @@ -0,0 +1,165 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MonitorAlertTriggerAttributes Attributes for a monitor alert trigger. +type MonitorAlertTriggerAttributes struct { + // The event ID associated with the monitor alert. + EventId string `json:"event_id"` + // The timestamp of the event in Unix milliseconds. + EventTs int64 `json:"event_ts"` + // The monitor ID that triggered the alert. + MonitorId int64 `json:"monitor_id"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewMonitorAlertTriggerAttributes instantiates a new MonitorAlertTriggerAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewMonitorAlertTriggerAttributes(eventId string, eventTs int64, monitorId int64) *MonitorAlertTriggerAttributes { + this := MonitorAlertTriggerAttributes{} + this.EventId = eventId + this.EventTs = eventTs + this.MonitorId = monitorId + return &this +} + +// NewMonitorAlertTriggerAttributesWithDefaults instantiates a new MonitorAlertTriggerAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewMonitorAlertTriggerAttributesWithDefaults() *MonitorAlertTriggerAttributes { + this := MonitorAlertTriggerAttributes{} + return &this +} + +// GetEventId returns the EventId field value. +func (o *MonitorAlertTriggerAttributes) GetEventId() string { + if o == nil { + var ret string + return ret + } + return o.EventId +} + +// GetEventIdOk returns a tuple with the EventId field value +// and a boolean to check if the value has been set. +func (o *MonitorAlertTriggerAttributes) GetEventIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.EventId, true +} + +// SetEventId sets field value. +func (o *MonitorAlertTriggerAttributes) SetEventId(v string) { + o.EventId = v +} + +// GetEventTs returns the EventTs field value. +func (o *MonitorAlertTriggerAttributes) GetEventTs() int64 { + if o == nil { + var ret int64 + return ret + } + return o.EventTs +} + +// GetEventTsOk returns a tuple with the EventTs field value +// and a boolean to check if the value has been set. +func (o *MonitorAlertTriggerAttributes) GetEventTsOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.EventTs, true +} + +// SetEventTs sets field value. +func (o *MonitorAlertTriggerAttributes) SetEventTs(v int64) { + o.EventTs = v +} + +// GetMonitorId returns the MonitorId field value. +func (o *MonitorAlertTriggerAttributes) GetMonitorId() int64 { + if o == nil { + var ret int64 + return ret + } + return o.MonitorId +} + +// GetMonitorIdOk returns a tuple with the MonitorId field value +// and a boolean to check if the value has been set. +func (o *MonitorAlertTriggerAttributes) GetMonitorIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.MonitorId, true +} + +// SetMonitorId sets field value. +func (o *MonitorAlertTriggerAttributes) SetMonitorId(v int64) { + o.MonitorId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MonitorAlertTriggerAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["event_id"] = o.EventId + toSerialize["event_ts"] = o.EventTs + toSerialize["monitor_id"] = o.MonitorId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MonitorAlertTriggerAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + EventId *string `json:"event_id"` + EventTs *int64 `json:"event_ts"` + MonitorId *int64 `json:"monitor_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.EventId == nil { + return fmt.Errorf("required field event_id missing") + } + if all.EventTs == nil { + return fmt.Errorf("required field event_ts missing") + } + if all.MonitorId == nil { + return fmt.Errorf("required field monitor_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"event_id", "event_ts", "monitor_id"}) + } else { + return err + } + o.EventId = *all.EventId + o.EventTs = *all.EventTs + o.MonitorId = *all.MonitorId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_observability_pipeline_enrichment_table_field_event_lookup.go b/api/datadogV2/model_observability_pipeline_enrichment_table_field_event_lookup.go new file mode 100644 index 00000000000..cc06a7a2244 --- /dev/null +++ b/api/datadogV2/model_observability_pipeline_enrichment_table_field_event_lookup.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ObservabilityPipelineEnrichmentTableFieldEventLookup Looks up a value from a field path in the log event. +type ObservabilityPipelineEnrichmentTableFieldEventLookup struct { + // The path to the field in the log event to use as the lookup key. + Event string `json:"event"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewObservabilityPipelineEnrichmentTableFieldEventLookup instantiates a new ObservabilityPipelineEnrichmentTableFieldEventLookup object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewObservabilityPipelineEnrichmentTableFieldEventLookup(event string) *ObservabilityPipelineEnrichmentTableFieldEventLookup { + this := ObservabilityPipelineEnrichmentTableFieldEventLookup{} + this.Event = event + return &this +} + +// NewObservabilityPipelineEnrichmentTableFieldEventLookupWithDefaults instantiates a new ObservabilityPipelineEnrichmentTableFieldEventLookup object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewObservabilityPipelineEnrichmentTableFieldEventLookupWithDefaults() *ObservabilityPipelineEnrichmentTableFieldEventLookup { + this := ObservabilityPipelineEnrichmentTableFieldEventLookup{} + return &this +} + +// GetEvent returns the Event field value. +func (o *ObservabilityPipelineEnrichmentTableFieldEventLookup) GetEvent() string { + if o == nil { + var ret string + return ret + } + return o.Event +} + +// GetEventOk returns a tuple with the Event field value +// and a boolean to check if the value has been set. +func (o *ObservabilityPipelineEnrichmentTableFieldEventLookup) GetEventOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Event, true +} + +// SetEvent sets field value. +func (o *ObservabilityPipelineEnrichmentTableFieldEventLookup) SetEvent(v string) { + o.Event = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ObservabilityPipelineEnrichmentTableFieldEventLookup) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["event"] = o.Event + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ObservabilityPipelineEnrichmentTableFieldEventLookup) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Event *string `json:"event"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Event == nil { + return fmt.Errorf("required field event missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"event"}) + } else { + return err + } + o.Event = *all.Event + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_observability_pipeline_enrichment_table_field_secret_lookup.go b/api/datadogV2/model_observability_pipeline_enrichment_table_field_secret_lookup.go new file mode 100644 index 00000000000..54993379ecc --- /dev/null +++ b/api/datadogV2/model_observability_pipeline_enrichment_table_field_secret_lookup.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ObservabilityPipelineEnrichmentTableFieldSecretLookup Looks up a value stored as a pipeline secret. +type ObservabilityPipelineEnrichmentTableFieldSecretLookup struct { + // The name of the secret containing the lookup key value. + Secret string `json:"secret"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewObservabilityPipelineEnrichmentTableFieldSecretLookup instantiates a new ObservabilityPipelineEnrichmentTableFieldSecretLookup object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewObservabilityPipelineEnrichmentTableFieldSecretLookup(secret string) *ObservabilityPipelineEnrichmentTableFieldSecretLookup { + this := ObservabilityPipelineEnrichmentTableFieldSecretLookup{} + this.Secret = secret + return &this +} + +// NewObservabilityPipelineEnrichmentTableFieldSecretLookupWithDefaults instantiates a new ObservabilityPipelineEnrichmentTableFieldSecretLookup object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewObservabilityPipelineEnrichmentTableFieldSecretLookupWithDefaults() *ObservabilityPipelineEnrichmentTableFieldSecretLookup { + this := ObservabilityPipelineEnrichmentTableFieldSecretLookup{} + return &this +} + +// GetSecret returns the Secret field value. +func (o *ObservabilityPipelineEnrichmentTableFieldSecretLookup) GetSecret() string { + if o == nil { + var ret string + return ret + } + return o.Secret +} + +// GetSecretOk returns a tuple with the Secret field value +// and a boolean to check if the value has been set. +func (o *ObservabilityPipelineEnrichmentTableFieldSecretLookup) GetSecretOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Secret, true +} + +// SetSecret sets field value. +func (o *ObservabilityPipelineEnrichmentTableFieldSecretLookup) SetSecret(v string) { + o.Secret = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ObservabilityPipelineEnrichmentTableFieldSecretLookup) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["secret"] = o.Secret + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ObservabilityPipelineEnrichmentTableFieldSecretLookup) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Secret *string `json:"secret"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Secret == nil { + return fmt.Errorf("required field secret missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"secret"}) + } else { + return err + } + o.Secret = *all.Secret + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_observability_pipeline_enrichment_table_field_vrl_lookup.go b/api/datadogV2/model_observability_pipeline_enrichment_table_field_vrl_lookup.go new file mode 100644 index 00000000000..3f674a6b17a --- /dev/null +++ b/api/datadogV2/model_observability_pipeline_enrichment_table_field_vrl_lookup.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ObservabilityPipelineEnrichmentTableFieldVrlLookup Evaluates a VRL expression to produce the lookup key. +type ObservabilityPipelineEnrichmentTableFieldVrlLookup struct { + // A VRL expression that returns the value to use as the lookup key. + Vrl string `json:"vrl"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewObservabilityPipelineEnrichmentTableFieldVrlLookup instantiates a new ObservabilityPipelineEnrichmentTableFieldVrlLookup object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewObservabilityPipelineEnrichmentTableFieldVrlLookup(vrl string) *ObservabilityPipelineEnrichmentTableFieldVrlLookup { + this := ObservabilityPipelineEnrichmentTableFieldVrlLookup{} + this.Vrl = vrl + return &this +} + +// NewObservabilityPipelineEnrichmentTableFieldVrlLookupWithDefaults instantiates a new ObservabilityPipelineEnrichmentTableFieldVrlLookup object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewObservabilityPipelineEnrichmentTableFieldVrlLookupWithDefaults() *ObservabilityPipelineEnrichmentTableFieldVrlLookup { + this := ObservabilityPipelineEnrichmentTableFieldVrlLookup{} + return &this +} + +// GetVrl returns the Vrl field value. +func (o *ObservabilityPipelineEnrichmentTableFieldVrlLookup) GetVrl() string { + if o == nil { + var ret string + return ret + } + return o.Vrl +} + +// GetVrlOk returns a tuple with the Vrl field value +// and a boolean to check if the value has been set. +func (o *ObservabilityPipelineEnrichmentTableFieldVrlLookup) GetVrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Vrl, true +} + +// SetVrl sets field value. +func (o *ObservabilityPipelineEnrichmentTableFieldVrlLookup) SetVrl(v string) { + o.Vrl = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ObservabilityPipelineEnrichmentTableFieldVrlLookup) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["vrl"] = o.Vrl + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ObservabilityPipelineEnrichmentTableFieldVrlLookup) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Vrl *string `json:"vrl"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Vrl == nil { + return fmt.Errorf("required field vrl missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"vrl"}) + } else { + return err + } + o.Vrl = *all.Vrl + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_observability_pipeline_enrichment_table_file_key_item_field.go b/api/datadogV2/model_observability_pipeline_enrichment_table_file_key_item_field.go new file mode 100644 index 00000000000..28adc6157bb --- /dev/null +++ b/api/datadogV2/model_observability_pipeline_enrichment_table_file_key_item_field.go @@ -0,0 +1,170 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ObservabilityPipelineEnrichmentTableFileKeyItemField - Specifies the source of the key value used for enrichment table lookups. +// Can be a plain field path string or an object specifying `event`, `vrl`, or `secret`. +type ObservabilityPipelineEnrichmentTableFileKeyItemField struct { + ObservabilityPipelineEnrichmentTableFieldStringPath *string + ObservabilityPipelineEnrichmentTableFieldEventLookup *ObservabilityPipelineEnrichmentTableFieldEventLookup + ObservabilityPipelineEnrichmentTableFieldVrlLookup *ObservabilityPipelineEnrichmentTableFieldVrlLookup + ObservabilityPipelineEnrichmentTableFieldSecretLookup *ObservabilityPipelineEnrichmentTableFieldSecretLookup + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// ObservabilityPipelineEnrichmentTableFieldStringPathAsObservabilityPipelineEnrichmentTableFileKeyItemField is a convenience function that returns string wrapped in ObservabilityPipelineEnrichmentTableFileKeyItemField. +func ObservabilityPipelineEnrichmentTableFieldStringPathAsObservabilityPipelineEnrichmentTableFileKeyItemField(v *string) ObservabilityPipelineEnrichmentTableFileKeyItemField { + return ObservabilityPipelineEnrichmentTableFileKeyItemField{ObservabilityPipelineEnrichmentTableFieldStringPath: v} +} + +// ObservabilityPipelineEnrichmentTableFieldEventLookupAsObservabilityPipelineEnrichmentTableFileKeyItemField is a convenience function that returns ObservabilityPipelineEnrichmentTableFieldEventLookup wrapped in ObservabilityPipelineEnrichmentTableFileKeyItemField. +func ObservabilityPipelineEnrichmentTableFieldEventLookupAsObservabilityPipelineEnrichmentTableFileKeyItemField(v *ObservabilityPipelineEnrichmentTableFieldEventLookup) ObservabilityPipelineEnrichmentTableFileKeyItemField { + return ObservabilityPipelineEnrichmentTableFileKeyItemField{ObservabilityPipelineEnrichmentTableFieldEventLookup: v} +} + +// ObservabilityPipelineEnrichmentTableFieldVrlLookupAsObservabilityPipelineEnrichmentTableFileKeyItemField is a convenience function that returns ObservabilityPipelineEnrichmentTableFieldVrlLookup wrapped in ObservabilityPipelineEnrichmentTableFileKeyItemField. +func ObservabilityPipelineEnrichmentTableFieldVrlLookupAsObservabilityPipelineEnrichmentTableFileKeyItemField(v *ObservabilityPipelineEnrichmentTableFieldVrlLookup) ObservabilityPipelineEnrichmentTableFileKeyItemField { + return ObservabilityPipelineEnrichmentTableFileKeyItemField{ObservabilityPipelineEnrichmentTableFieldVrlLookup: v} +} + +// ObservabilityPipelineEnrichmentTableFieldSecretLookupAsObservabilityPipelineEnrichmentTableFileKeyItemField is a convenience function that returns ObservabilityPipelineEnrichmentTableFieldSecretLookup wrapped in ObservabilityPipelineEnrichmentTableFileKeyItemField. +func ObservabilityPipelineEnrichmentTableFieldSecretLookupAsObservabilityPipelineEnrichmentTableFileKeyItemField(v *ObservabilityPipelineEnrichmentTableFieldSecretLookup) ObservabilityPipelineEnrichmentTableFileKeyItemField { + return ObservabilityPipelineEnrichmentTableFileKeyItemField{ObservabilityPipelineEnrichmentTableFieldSecretLookup: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *ObservabilityPipelineEnrichmentTableFileKeyItemField) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into ObservabilityPipelineEnrichmentTableFieldStringPath + err = datadog.Unmarshal(data, &obj.ObservabilityPipelineEnrichmentTableFieldStringPath) + if err == nil { + if obj.ObservabilityPipelineEnrichmentTableFieldStringPath != nil { + jsonObservabilityPipelineEnrichmentTableFieldStringPath, _ := datadog.Marshal(obj.ObservabilityPipelineEnrichmentTableFieldStringPath) + if string(jsonObservabilityPipelineEnrichmentTableFieldStringPath) == "{}" { // empty struct + obj.ObservabilityPipelineEnrichmentTableFieldStringPath = nil + } else { + match++ + } + } else { + obj.ObservabilityPipelineEnrichmentTableFieldStringPath = nil + } + } else { + obj.ObservabilityPipelineEnrichmentTableFieldStringPath = nil + } + + // try to unmarshal data into ObservabilityPipelineEnrichmentTableFieldEventLookup + err = datadog.Unmarshal(data, &obj.ObservabilityPipelineEnrichmentTableFieldEventLookup) + if err == nil { + if obj.ObservabilityPipelineEnrichmentTableFieldEventLookup != nil && obj.ObservabilityPipelineEnrichmentTableFieldEventLookup.UnparsedObject == nil { + jsonObservabilityPipelineEnrichmentTableFieldEventLookup, _ := datadog.Marshal(obj.ObservabilityPipelineEnrichmentTableFieldEventLookup) + if string(jsonObservabilityPipelineEnrichmentTableFieldEventLookup) == "{}" { // empty struct + obj.ObservabilityPipelineEnrichmentTableFieldEventLookup = nil + } else { + match++ + } + } else { + obj.ObservabilityPipelineEnrichmentTableFieldEventLookup = nil + } + } else { + obj.ObservabilityPipelineEnrichmentTableFieldEventLookup = nil + } + + // try to unmarshal data into ObservabilityPipelineEnrichmentTableFieldVrlLookup + err = datadog.Unmarshal(data, &obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup) + if err == nil { + if obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup != nil && obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup.UnparsedObject == nil { + jsonObservabilityPipelineEnrichmentTableFieldVrlLookup, _ := datadog.Marshal(obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup) + if string(jsonObservabilityPipelineEnrichmentTableFieldVrlLookup) == "{}" { // empty struct + obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup = nil + } else { + match++ + } + } else { + obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup = nil + } + } else { + obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup = nil + } + + // try to unmarshal data into ObservabilityPipelineEnrichmentTableFieldSecretLookup + err = datadog.Unmarshal(data, &obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup) + if err == nil { + if obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup != nil && obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup.UnparsedObject == nil { + jsonObservabilityPipelineEnrichmentTableFieldSecretLookup, _ := datadog.Marshal(obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup) + if string(jsonObservabilityPipelineEnrichmentTableFieldSecretLookup) == "{}" { // empty struct + obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup = nil + } else { + match++ + } + } else { + obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup = nil + } + } else { + obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.ObservabilityPipelineEnrichmentTableFieldStringPath = nil + obj.ObservabilityPipelineEnrichmentTableFieldEventLookup = nil + obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup = nil + obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj ObservabilityPipelineEnrichmentTableFileKeyItemField) MarshalJSON() ([]byte, error) { + if obj.ObservabilityPipelineEnrichmentTableFieldStringPath != nil { + return datadog.Marshal(&obj.ObservabilityPipelineEnrichmentTableFieldStringPath) + } + + if obj.ObservabilityPipelineEnrichmentTableFieldEventLookup != nil { + return datadog.Marshal(&obj.ObservabilityPipelineEnrichmentTableFieldEventLookup) + } + + if obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup != nil { + return datadog.Marshal(&obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup) + } + + if obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup != nil { + return datadog.Marshal(&obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *ObservabilityPipelineEnrichmentTableFileKeyItemField) GetActualInstance() interface{} { + if obj.ObservabilityPipelineEnrichmentTableFieldStringPath != nil { + return obj.ObservabilityPipelineEnrichmentTableFieldStringPath + } + + if obj.ObservabilityPipelineEnrichmentTableFieldEventLookup != nil { + return obj.ObservabilityPipelineEnrichmentTableFieldEventLookup + } + + if obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup != nil { + return obj.ObservabilityPipelineEnrichmentTableFieldVrlLookup + } + + if obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup != nil { + return obj.ObservabilityPipelineEnrichmentTableFieldSecretLookup + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_observability_pipeline_enrichment_table_file_key_items.go b/api/datadogV2/model_observability_pipeline_enrichment_table_file_key_items.go index 08680caf0df..a1f124c4430 100644 --- a/api/datadogV2/model_observability_pipeline_enrichment_table_file_key_items.go +++ b/api/datadogV2/model_observability_pipeline_enrichment_table_file_key_items.go @@ -16,8 +16,9 @@ type ObservabilityPipelineEnrichmentTableFileKeyItems struct { Column string `json:"column"` // Defines how to compare key fields for enrichment table lookups. Comparison ObservabilityPipelineEnrichmentTableFileKeyItemsComparison `json:"comparison"` - // The `items` `field`. - Field string `json:"field"` + // Specifies the source of the key value used for enrichment table lookups. + // Can be a plain field path string or an object specifying `event`, `vrl`, or `secret`. + Field ObservabilityPipelineEnrichmentTableFileKeyItemField `json:"field"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject map[string]interface{} `json:"-"` AdditionalProperties map[string]interface{} `json:"-"` @@ -27,7 +28,7 @@ type ObservabilityPipelineEnrichmentTableFileKeyItems struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed. -func NewObservabilityPipelineEnrichmentTableFileKeyItems(column string, comparison ObservabilityPipelineEnrichmentTableFileKeyItemsComparison, field string) *ObservabilityPipelineEnrichmentTableFileKeyItems { +func NewObservabilityPipelineEnrichmentTableFileKeyItems(column string, comparison ObservabilityPipelineEnrichmentTableFileKeyItemsComparison, field ObservabilityPipelineEnrichmentTableFileKeyItemField) *ObservabilityPipelineEnrichmentTableFileKeyItems { this := ObservabilityPipelineEnrichmentTableFileKeyItems{} this.Column = column this.Comparison = comparison @@ -90,9 +91,9 @@ func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) SetComparison(v Obser } // GetField returns the Field field value. -func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) GetField() string { +func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) GetField() ObservabilityPipelineEnrichmentTableFileKeyItemField { if o == nil { - var ret string + var ret ObservabilityPipelineEnrichmentTableFileKeyItemField return ret } return o.Field @@ -100,7 +101,7 @@ func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) GetField() string { // GetFieldOk returns a tuple with the Field field value // and a boolean to check if the value has been set. -func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) GetFieldOk() (*string, bool) { +func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) GetFieldOk() (*ObservabilityPipelineEnrichmentTableFileKeyItemField, bool) { if o == nil { return nil, false } @@ -108,7 +109,7 @@ func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) GetFieldOk() (*string } // SetField sets field value. -func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) SetField(v string) { +func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) SetField(v ObservabilityPipelineEnrichmentTableFileKeyItemField) { o.Field = v } @@ -133,7 +134,7 @@ func (o *ObservabilityPipelineEnrichmentTableFileKeyItems) UnmarshalJSON(bytes [ all := struct { Column *string `json:"column"` Comparison *ObservabilityPipelineEnrichmentTableFileKeyItemsComparison `json:"comparison"` - Field *string `json:"field"` + Field *ObservabilityPipelineEnrichmentTableFileKeyItemField `json:"field"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) diff --git a/api/datadogV2/model_observability_pipeline_splunk_hec_destination.go b/api/datadogV2/model_observability_pipeline_splunk_hec_destination.go index 233a799c3e1..357ff9c6f49 100644 --- a/api/datadogV2/model_observability_pipeline_splunk_hec_destination.go +++ b/api/datadogV2/model_observability_pipeline_splunk_hec_destination.go @@ -35,6 +35,8 @@ type ObservabilityPipelineSplunkHecDestination struct { Sourcetype *string `json:"sourcetype,omitempty"` // Name of the environment variable or secret that holds the Splunk HEC token. TokenKey *string `json:"token_key,omitempty"` + // Controls how the Splunk HEC token is supplied. Use `custom` to provide a token with `token_key`, or `from_source` to forward the token received from an upstream Splunk HEC source. + TokenStrategy *ObservabilityPipelineSplunkHecDestinationTokenStrategy `json:"token_strategy,omitempty"` // The destination type. Always `splunk_hec`. Type ObservabilityPipelineSplunkHecDestinationType `json:"type"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -334,6 +336,34 @@ func (o *ObservabilityPipelineSplunkHecDestination) SetTokenKey(v string) { o.TokenKey = &v } +// GetTokenStrategy returns the TokenStrategy field value if set, zero value otherwise. +func (o *ObservabilityPipelineSplunkHecDestination) GetTokenStrategy() ObservabilityPipelineSplunkHecDestinationTokenStrategy { + if o == nil || o.TokenStrategy == nil { + var ret ObservabilityPipelineSplunkHecDestinationTokenStrategy + return ret + } + return *o.TokenStrategy +} + +// GetTokenStrategyOk returns a tuple with the TokenStrategy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ObservabilityPipelineSplunkHecDestination) GetTokenStrategyOk() (*ObservabilityPipelineSplunkHecDestinationTokenStrategy, bool) { + if o == nil || o.TokenStrategy == nil { + return nil, false + } + return o.TokenStrategy, true +} + +// HasTokenStrategy returns a boolean if a field has been set. +func (o *ObservabilityPipelineSplunkHecDestination) HasTokenStrategy() bool { + return o != nil && o.TokenStrategy != nil +} + +// SetTokenStrategy gets a reference to the given ObservabilityPipelineSplunkHecDestinationTokenStrategy and assigns it to the TokenStrategy field. +func (o *ObservabilityPipelineSplunkHecDestination) SetTokenStrategy(v ObservabilityPipelineSplunkHecDestinationTokenStrategy) { + o.TokenStrategy = &v +} + // GetType returns the Type field value. func (o *ObservabilityPipelineSplunkHecDestination) GetType() ObservabilityPipelineSplunkHecDestinationType { if o == nil { @@ -389,6 +419,9 @@ func (o ObservabilityPipelineSplunkHecDestination) MarshalJSON() ([]byte, error) if o.TokenKey != nil { toSerialize["token_key"] = o.TokenKey } + if o.TokenStrategy != nil { + toSerialize["token_strategy"] = o.TokenStrategy + } toSerialize["type"] = o.Type for key, value := range o.AdditionalProperties { @@ -400,17 +433,18 @@ func (o ObservabilityPipelineSplunkHecDestination) MarshalJSON() ([]byte, error) // UnmarshalJSON deserializes the given payload. func (o *ObservabilityPipelineSplunkHecDestination) UnmarshalJSON(bytes []byte) (err error) { all := struct { - AutoExtractTimestamp *bool `json:"auto_extract_timestamp,omitempty"` - Buffer *ObservabilityPipelineBufferOptions `json:"buffer,omitempty"` - Encoding *ObservabilityPipelineSplunkHecDestinationEncoding `json:"encoding,omitempty"` - EndpointUrlKey *string `json:"endpoint_url_key,omitempty"` - Id *string `json:"id"` - Index *string `json:"index,omitempty"` - IndexedFields []string `json:"indexed_fields,omitempty"` - Inputs *[]string `json:"inputs"` - Sourcetype *string `json:"sourcetype,omitempty"` - TokenKey *string `json:"token_key,omitempty"` - Type *ObservabilityPipelineSplunkHecDestinationType `json:"type"` + AutoExtractTimestamp *bool `json:"auto_extract_timestamp,omitempty"` + Buffer *ObservabilityPipelineBufferOptions `json:"buffer,omitempty"` + Encoding *ObservabilityPipelineSplunkHecDestinationEncoding `json:"encoding,omitempty"` + EndpointUrlKey *string `json:"endpoint_url_key,omitempty"` + Id *string `json:"id"` + Index *string `json:"index,omitempty"` + IndexedFields []string `json:"indexed_fields,omitempty"` + Inputs *[]string `json:"inputs"` + Sourcetype *string `json:"sourcetype,omitempty"` + TokenKey *string `json:"token_key,omitempty"` + TokenStrategy *ObservabilityPipelineSplunkHecDestinationTokenStrategy `json:"token_strategy,omitempty"` + Type *ObservabilityPipelineSplunkHecDestinationType `json:"type"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -426,7 +460,7 @@ func (o *ObservabilityPipelineSplunkHecDestination) UnmarshalJSON(bytes []byte) } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"auto_extract_timestamp", "buffer", "encoding", "endpoint_url_key", "id", "index", "indexed_fields", "inputs", "sourcetype", "token_key", "type"}) + datadog.DeleteKeys(additionalProperties, &[]string{"auto_extract_timestamp", "buffer", "encoding", "endpoint_url_key", "id", "index", "indexed_fields", "inputs", "sourcetype", "token_key", "token_strategy", "type"}) } else { return err } @@ -446,6 +480,11 @@ func (o *ObservabilityPipelineSplunkHecDestination) UnmarshalJSON(bytes []byte) o.Inputs = *all.Inputs o.Sourcetype = all.Sourcetype o.TokenKey = all.TokenKey + if all.TokenStrategy != nil && !all.TokenStrategy.IsValid() { + hasInvalidField = true + } else { + o.TokenStrategy = all.TokenStrategy + } if !all.Type.IsValid() { hasInvalidField = true } else { diff --git a/api/datadogV2/model_observability_pipeline_splunk_hec_destination_token_strategy.go b/api/datadogV2/model_observability_pipeline_splunk_hec_destination_token_strategy.go new file mode 100644 index 00000000000..611833b960f --- /dev/null +++ b/api/datadogV2/model_observability_pipeline_splunk_hec_destination_token_strategy.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ObservabilityPipelineSplunkHecDestinationTokenStrategy Controls how the Splunk HEC token is supplied. Use `custom` to provide a token with `token_key`, or `from_source` to forward the token received from an upstream Splunk HEC source. +type ObservabilityPipelineSplunkHecDestinationTokenStrategy string + +// List of ObservabilityPipelineSplunkHecDestinationTokenStrategy. +const ( + OBSERVABILITYPIPELINESPLUNKHECDESTINATIONTOKENSTRATEGY_CUSTOM ObservabilityPipelineSplunkHecDestinationTokenStrategy = "custom" + OBSERVABILITYPIPELINESPLUNKHECDESTINATIONTOKENSTRATEGY_FROM_SOURCE ObservabilityPipelineSplunkHecDestinationTokenStrategy = "from_source" +) + +var allowedObservabilityPipelineSplunkHecDestinationTokenStrategyEnumValues = []ObservabilityPipelineSplunkHecDestinationTokenStrategy{ + OBSERVABILITYPIPELINESPLUNKHECDESTINATIONTOKENSTRATEGY_CUSTOM, + OBSERVABILITYPIPELINESPLUNKHECDESTINATIONTOKENSTRATEGY_FROM_SOURCE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ObservabilityPipelineSplunkHecDestinationTokenStrategy) GetAllowedValues() []ObservabilityPipelineSplunkHecDestinationTokenStrategy { + return allowedObservabilityPipelineSplunkHecDestinationTokenStrategyEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ObservabilityPipelineSplunkHecDestinationTokenStrategy) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ObservabilityPipelineSplunkHecDestinationTokenStrategy(value) + return nil +} + +// NewObservabilityPipelineSplunkHecDestinationTokenStrategyFromValue returns a pointer to a valid ObservabilityPipelineSplunkHecDestinationTokenStrategy +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewObservabilityPipelineSplunkHecDestinationTokenStrategyFromValue(v string) (*ObservabilityPipelineSplunkHecDestinationTokenStrategy, error) { + ev := ObservabilityPipelineSplunkHecDestinationTokenStrategy(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ObservabilityPipelineSplunkHecDestinationTokenStrategy: valid values are %v", v, allowedObservabilityPipelineSplunkHecDestinationTokenStrategyEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ObservabilityPipelineSplunkHecDestinationTokenStrategy) IsValid() bool { + for _, existing := range allowedObservabilityPipelineSplunkHecDestinationTokenStrategyEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ObservabilityPipelineSplunkHecDestinationTokenStrategy value. +func (v ObservabilityPipelineSplunkHecDestinationTokenStrategy) Ptr() *ObservabilityPipelineSplunkHecDestinationTokenStrategy { + return &v +} diff --git a/api/datadogV2/model_observability_pipeline_splunk_hec_source.go b/api/datadogV2/model_observability_pipeline_splunk_hec_source.go index e83f24b3e87..6ca97f87892 100644 --- a/api/datadogV2/model_observability_pipeline_splunk_hec_source.go +++ b/api/datadogV2/model_observability_pipeline_splunk_hec_source.go @@ -18,6 +18,9 @@ type ObservabilityPipelineSplunkHecSource struct { AddressKey *string `json:"address_key,omitempty"` // The unique identifier for this component. Used in other parts of the pipeline to reference this component (for example, as the `input` to downstream components). Id string `json:"id"` + // When `true`, the Splunk HEC token from the incoming request is stored in the event metadata. + // This allows downstream components to forward the token to other Splunk HEC destinations. + StoreHecToken *bool `json:"store_hec_token,omitempty"` // Configuration for enabling TLS encryption between the pipeline component and external services. Tls *ObservabilityPipelineTls `json:"tls,omitempty"` // The source type. Always `splunk_hec`. @@ -99,6 +102,34 @@ func (o *ObservabilityPipelineSplunkHecSource) SetId(v string) { o.Id = v } +// GetStoreHecToken returns the StoreHecToken field value if set, zero value otherwise. +func (o *ObservabilityPipelineSplunkHecSource) GetStoreHecToken() bool { + if o == nil || o.StoreHecToken == nil { + var ret bool + return ret + } + return *o.StoreHecToken +} + +// GetStoreHecTokenOk returns a tuple with the StoreHecToken field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ObservabilityPipelineSplunkHecSource) GetStoreHecTokenOk() (*bool, bool) { + if o == nil || o.StoreHecToken == nil { + return nil, false + } + return o.StoreHecToken, true +} + +// HasStoreHecToken returns a boolean if a field has been set. +func (o *ObservabilityPipelineSplunkHecSource) HasStoreHecToken() bool { + return o != nil && o.StoreHecToken != nil +} + +// SetStoreHecToken gets a reference to the given bool and assigns it to the StoreHecToken field. +func (o *ObservabilityPipelineSplunkHecSource) SetStoreHecToken(v bool) { + o.StoreHecToken = &v +} + // GetTls returns the Tls field value if set, zero value otherwise. func (o *ObservabilityPipelineSplunkHecSource) GetTls() ObservabilityPipelineTls { if o == nil || o.Tls == nil { @@ -160,6 +191,9 @@ func (o ObservabilityPipelineSplunkHecSource) MarshalJSON() ([]byte, error) { toSerialize["address_key"] = o.AddressKey } toSerialize["id"] = o.Id + if o.StoreHecToken != nil { + toSerialize["store_hec_token"] = o.StoreHecToken + } if o.Tls != nil { toSerialize["tls"] = o.Tls } @@ -174,10 +208,11 @@ func (o ObservabilityPipelineSplunkHecSource) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *ObservabilityPipelineSplunkHecSource) UnmarshalJSON(bytes []byte) (err error) { all := struct { - AddressKey *string `json:"address_key,omitempty"` - Id *string `json:"id"` - Tls *ObservabilityPipelineTls `json:"tls,omitempty"` - Type *ObservabilityPipelineSplunkHecSourceType `json:"type"` + AddressKey *string `json:"address_key,omitempty"` + Id *string `json:"id"` + StoreHecToken *bool `json:"store_hec_token,omitempty"` + Tls *ObservabilityPipelineTls `json:"tls,omitempty"` + Type *ObservabilityPipelineSplunkHecSourceType `json:"type"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -190,7 +225,7 @@ func (o *ObservabilityPipelineSplunkHecSource) UnmarshalJSON(bytes []byte) (err } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"address_key", "id", "tls", "type"}) + datadog.DeleteKeys(additionalProperties, &[]string{"address_key", "id", "store_hec_token", "tls", "type"}) } else { return err } @@ -198,6 +233,7 @@ func (o *ObservabilityPipelineSplunkHecSource) UnmarshalJSON(bytes []byte) (err hasInvalidField := false o.AddressKey = all.AddressKey o.Id = *all.Id + o.StoreHecToken = all.StoreHecToken if all.Tls != nil && all.Tls.UnparsedObject != nil && o.UnparsedObject == nil { hasInvalidField = true } diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_attempt_to_fix.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_attempt_to_fix.go new file mode 100644 index 00000000000..ccc27fc2fb7 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_attempt_to_fix.go @@ -0,0 +1,102 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesAttemptToFix Configuration for the attempt-to-fix Flaky Tests Management policy. +type TestOptimizationFlakyTestsManagementPoliciesAttemptToFix struct { + // Number of retries when attempting to fix a flaky test. Must be greater than 0. + Retries *int64 `json:"retries,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesAttemptToFix instantiates a new TestOptimizationFlakyTestsManagementPoliciesAttemptToFix object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesAttemptToFix() *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix { + this := TestOptimizationFlakyTestsManagementPoliciesAttemptToFix{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesAttemptToFixWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesAttemptToFix object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesAttemptToFixWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix { + this := TestOptimizationFlakyTestsManagementPoliciesAttemptToFix{} + return &this +} + +// GetRetries returns the Retries field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix) GetRetries() int64 { + if o == nil || o.Retries == nil { + var ret int64 + return ret + } + return *o.Retries +} + +// GetRetriesOk returns a tuple with the Retries field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix) GetRetriesOk() (*int64, bool) { + if o == nil || o.Retries == nil { + return nil, false + } + return o.Retries, true +} + +// HasRetries returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix) HasRetries() bool { + return o != nil && o.Retries != nil +} + +// SetRetries gets a reference to the given int64 and assigns it to the Retries field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix) SetRetries(v int64) { + o.Retries = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesAttemptToFix) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Retries != nil { + toSerialize["retries"] = o.Retries + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Retries *int64 `json:"retries,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"retries"}) + } else { + return err + } + o.Retries = all.Retries + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_attributes.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_attributes.go new file mode 100644 index 00000000000..54b96523b6f --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_attributes.go @@ -0,0 +1,222 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesAttributes Attributes of the Flaky Tests Management policies for a repository. +type TestOptimizationFlakyTestsManagementPoliciesAttributes struct { + // Configuration for the attempt-to-fix Flaky Tests Management policy. + AttemptToFix *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix `json:"attempt_to_fix,omitempty"` + // Configuration for the disabled Flaky Tests Management policy. + Disabled *TestOptimizationFlakyTestsManagementPoliciesDisabled `json:"disabled,omitempty"` + // Configuration for the quarantined Flaky Tests Management policy. + Quarantined *TestOptimizationFlakyTestsManagementPoliciesQuarantined `json:"quarantined,omitempty"` + // The repository identifier. + RepositoryId *string `json:"repository_id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesAttributes instantiates a new TestOptimizationFlakyTestsManagementPoliciesAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesAttributes() *TestOptimizationFlakyTestsManagementPoliciesAttributes { + this := TestOptimizationFlakyTestsManagementPoliciesAttributes{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesAttributesWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesAttributesWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesAttributes { + this := TestOptimizationFlakyTestsManagementPoliciesAttributes{} + return &this +} + +// GetAttemptToFix returns the AttemptToFix field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) GetAttemptToFix() TestOptimizationFlakyTestsManagementPoliciesAttemptToFix { + if o == nil || o.AttemptToFix == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesAttemptToFix + return ret + } + return *o.AttemptToFix +} + +// GetAttemptToFixOk returns a tuple with the AttemptToFix field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) GetAttemptToFixOk() (*TestOptimizationFlakyTestsManagementPoliciesAttemptToFix, bool) { + if o == nil || o.AttemptToFix == nil { + return nil, false + } + return o.AttemptToFix, true +} + +// HasAttemptToFix returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) HasAttemptToFix() bool { + return o != nil && o.AttemptToFix != nil +} + +// SetAttemptToFix gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesAttemptToFix and assigns it to the AttemptToFix field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) SetAttemptToFix(v TestOptimizationFlakyTestsManagementPoliciesAttemptToFix) { + o.AttemptToFix = &v +} + +// GetDisabled returns the Disabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) GetDisabled() TestOptimizationFlakyTestsManagementPoliciesDisabled { + if o == nil || o.Disabled == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesDisabled + return ret + } + return *o.Disabled +} + +// GetDisabledOk returns a tuple with the Disabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) GetDisabledOk() (*TestOptimizationFlakyTestsManagementPoliciesDisabled, bool) { + if o == nil || o.Disabled == nil { + return nil, false + } + return o.Disabled, true +} + +// HasDisabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) HasDisabled() bool { + return o != nil && o.Disabled != nil +} + +// SetDisabled gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesDisabled and assigns it to the Disabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) SetDisabled(v TestOptimizationFlakyTestsManagementPoliciesDisabled) { + o.Disabled = &v +} + +// GetQuarantined returns the Quarantined field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) GetQuarantined() TestOptimizationFlakyTestsManagementPoliciesQuarantined { + if o == nil || o.Quarantined == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesQuarantined + return ret + } + return *o.Quarantined +} + +// GetQuarantinedOk returns a tuple with the Quarantined field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) GetQuarantinedOk() (*TestOptimizationFlakyTestsManagementPoliciesQuarantined, bool) { + if o == nil || o.Quarantined == nil { + return nil, false + } + return o.Quarantined, true +} + +// HasQuarantined returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) HasQuarantined() bool { + return o != nil && o.Quarantined != nil +} + +// SetQuarantined gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesQuarantined and assigns it to the Quarantined field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) SetQuarantined(v TestOptimizationFlakyTestsManagementPoliciesQuarantined) { + o.Quarantined = &v +} + +// GetRepositoryId returns the RepositoryId field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) GetRepositoryId() string { + if o == nil || o.RepositoryId == nil { + var ret string + return ret + } + return *o.RepositoryId +} + +// GetRepositoryIdOk returns a tuple with the RepositoryId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) GetRepositoryIdOk() (*string, bool) { + if o == nil || o.RepositoryId == nil { + return nil, false + } + return o.RepositoryId, true +} + +// HasRepositoryId returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) HasRepositoryId() bool { + return o != nil && o.RepositoryId != nil +} + +// SetRepositoryId gets a reference to the given string and assigns it to the RepositoryId field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) SetRepositoryId(v string) { + o.RepositoryId = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AttemptToFix != nil { + toSerialize["attempt_to_fix"] = o.AttemptToFix + } + if o.Disabled != nil { + toSerialize["disabled"] = o.Disabled + } + if o.Quarantined != nil { + toSerialize["quarantined"] = o.Quarantined + } + if o.RepositoryId != nil { + toSerialize["repository_id"] = o.RepositoryId + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AttemptToFix *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix `json:"attempt_to_fix,omitempty"` + Disabled *TestOptimizationFlakyTestsManagementPoliciesDisabled `json:"disabled,omitempty"` + Quarantined *TestOptimizationFlakyTestsManagementPoliciesQuarantined `json:"quarantined,omitempty"` + RepositoryId *string `json:"repository_id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attempt_to_fix", "disabled", "quarantined", "repository_id"}) + } else { + return err + } + + hasInvalidField := false + if all.AttemptToFix != nil && all.AttemptToFix.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.AttemptToFix = all.AttemptToFix + if all.Disabled != nil && all.Disabled.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Disabled = all.Disabled + if all.Quarantined != nil && all.Quarantined.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Quarantined = all.Quarantined + o.RepositoryId = all.RepositoryId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_auto_disable_rule.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_auto_disable_rule.go new file mode 100644 index 00000000000..57ac4ca8ea1 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_auto_disable_rule.go @@ -0,0 +1,183 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule Automatic disable triggering rule based on a time window and test status. +type TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule struct { + // Whether this auto-disable rule is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Test status that the disable policy applies to. + // Must be either `active` or `quarantined`. + Status *TestOptimizationFlakyTestsManagementPoliciesDisabledStatus `json:"status,omitempty"` + // Time window in seconds over which flakiness is evaluated. Must be greater than 0. + WindowSeconds *int64 `json:"window_seconds,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesAutoDisableRule instantiates a new TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesAutoDisableRule() *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule { + this := TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesAutoDisableRuleWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesAutoDisableRuleWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule { + this := TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule{} + return &this +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) GetStatus() TestOptimizationFlakyTestsManagementPoliciesDisabledStatus { + if o == nil || o.Status == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesDisabledStatus + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) GetStatusOk() (*TestOptimizationFlakyTestsManagementPoliciesDisabledStatus, bool) { + if o == nil || o.Status == nil { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) HasStatus() bool { + return o != nil && o.Status != nil +} + +// SetStatus gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesDisabledStatus and assigns it to the Status field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) SetStatus(v TestOptimizationFlakyTestsManagementPoliciesDisabledStatus) { + o.Status = &v +} + +// GetWindowSeconds returns the WindowSeconds field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) GetWindowSeconds() int64 { + if o == nil || o.WindowSeconds == nil { + var ret int64 + return ret + } + return *o.WindowSeconds +} + +// GetWindowSecondsOk returns a tuple with the WindowSeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) GetWindowSecondsOk() (*int64, bool) { + if o == nil || o.WindowSeconds == nil { + return nil, false + } + return o.WindowSeconds, true +} + +// HasWindowSeconds returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) HasWindowSeconds() bool { + return o != nil && o.WindowSeconds != nil +} + +// SetWindowSeconds gets a reference to the given int64 and assigns it to the WindowSeconds field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) SetWindowSeconds(v int64) { + o.WindowSeconds = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.Status != nil { + toSerialize["status"] = o.Status + } + if o.WindowSeconds != nil { + toSerialize["window_seconds"] = o.WindowSeconds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Enabled *bool `json:"enabled,omitempty"` + Status *TestOptimizationFlakyTestsManagementPoliciesDisabledStatus `json:"status,omitempty"` + WindowSeconds *int64 `json:"window_seconds,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"enabled", "status", "window_seconds"}) + } else { + return err + } + + hasInvalidField := false + o.Enabled = all.Enabled + if all.Status != nil && !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = all.Status + } + o.WindowSeconds = all.WindowSeconds + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_auto_quarantine_rule.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_auto_quarantine_rule.go new file mode 100644 index 00000000000..a226bacb835 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_auto_quarantine_rule.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule Automatic quarantine triggering rule based on a time window. +type TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule struct { + // Whether this auto-quarantine rule is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Time window in seconds over which flakiness is evaluated. Must be greater than 0. + WindowSeconds *int64 `json:"window_seconds,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule instantiates a new TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule() *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule { + this := TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRuleWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRuleWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule { + this := TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule{} + return &this +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetWindowSeconds returns the WindowSeconds field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) GetWindowSeconds() int64 { + if o == nil || o.WindowSeconds == nil { + var ret int64 + return ret + } + return *o.WindowSeconds +} + +// GetWindowSecondsOk returns a tuple with the WindowSeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) GetWindowSecondsOk() (*int64, bool) { + if o == nil || o.WindowSeconds == nil { + return nil, false + } + return o.WindowSeconds, true +} + +// HasWindowSeconds returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) HasWindowSeconds() bool { + return o != nil && o.WindowSeconds != nil +} + +// SetWindowSeconds gets a reference to the given int64 and assigns it to the WindowSeconds field. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) SetWindowSeconds(v int64) { + o.WindowSeconds = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.WindowSeconds != nil { + toSerialize["window_seconds"] = o.WindowSeconds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Enabled *bool `json:"enabled,omitempty"` + WindowSeconds *int64 `json:"window_seconds,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"enabled", "window_seconds"}) + } else { + return err + } + o.Enabled = all.Enabled + o.WindowSeconds = all.WindowSeconds + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_branch_rule.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_branch_rule.go new file mode 100644 index 00000000000..c27ac243213 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_branch_rule.go @@ -0,0 +1,207 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesBranchRule Branch filtering rule for a Flaky Tests Management policy. +type TestOptimizationFlakyTestsManagementPoliciesBranchRule struct { + // List of branches to which the policy applies. + Branches []string `json:"branches,omitempty"` + // Whether this branch rule is enabled. + Enabled *bool `json:"enabled,omitempty"` + // List of branches excluded from the policy. + ExcludedBranches []string `json:"excluded_branches,omitempty"` + // List of test services excluded from the policy. + ExcludedTestServices []string `json:"excluded_test_services,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesBranchRule instantiates a new TestOptimizationFlakyTestsManagementPoliciesBranchRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesBranchRule() *TestOptimizationFlakyTestsManagementPoliciesBranchRule { + this := TestOptimizationFlakyTestsManagementPoliciesBranchRule{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesBranchRuleWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesBranchRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesBranchRuleWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesBranchRule { + this := TestOptimizationFlakyTestsManagementPoliciesBranchRule{} + return &this +} + +// GetBranches returns the Branches field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) GetBranches() []string { + if o == nil || o.Branches == nil { + var ret []string + return ret + } + return o.Branches +} + +// GetBranchesOk returns a tuple with the Branches field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) GetBranchesOk() (*[]string, bool) { + if o == nil || o.Branches == nil { + return nil, false + } + return &o.Branches, true +} + +// HasBranches returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) HasBranches() bool { + return o != nil && o.Branches != nil +} + +// SetBranches gets a reference to the given []string and assigns it to the Branches field. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) SetBranches(v []string) { + o.Branches = v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetExcludedBranches returns the ExcludedBranches field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) GetExcludedBranches() []string { + if o == nil || o.ExcludedBranches == nil { + var ret []string + return ret + } + return o.ExcludedBranches +} + +// GetExcludedBranchesOk returns a tuple with the ExcludedBranches field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) GetExcludedBranchesOk() (*[]string, bool) { + if o == nil || o.ExcludedBranches == nil { + return nil, false + } + return &o.ExcludedBranches, true +} + +// HasExcludedBranches returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) HasExcludedBranches() bool { + return o != nil && o.ExcludedBranches != nil +} + +// SetExcludedBranches gets a reference to the given []string and assigns it to the ExcludedBranches field. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) SetExcludedBranches(v []string) { + o.ExcludedBranches = v +} + +// GetExcludedTestServices returns the ExcludedTestServices field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) GetExcludedTestServices() []string { + if o == nil || o.ExcludedTestServices == nil { + var ret []string + return ret + } + return o.ExcludedTestServices +} + +// GetExcludedTestServicesOk returns a tuple with the ExcludedTestServices field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) GetExcludedTestServicesOk() (*[]string, bool) { + if o == nil || o.ExcludedTestServices == nil { + return nil, false + } + return &o.ExcludedTestServices, true +} + +// HasExcludedTestServices returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) HasExcludedTestServices() bool { + return o != nil && o.ExcludedTestServices != nil +} + +// SetExcludedTestServices gets a reference to the given []string and assigns it to the ExcludedTestServices field. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) SetExcludedTestServices(v []string) { + o.ExcludedTestServices = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesBranchRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Branches != nil { + toSerialize["branches"] = o.Branches + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.ExcludedBranches != nil { + toSerialize["excluded_branches"] = o.ExcludedBranches + } + if o.ExcludedTestServices != nil { + toSerialize["excluded_test_services"] = o.ExcludedTestServices + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesBranchRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Branches []string `json:"branches,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + ExcludedBranches []string `json:"excluded_branches,omitempty"` + ExcludedTestServices []string `json:"excluded_test_services,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"branches", "enabled", "excluded_branches", "excluded_test_services"}) + } else { + return err + } + o.Branches = all.Branches + o.Enabled = all.Enabled + o.ExcludedBranches = all.ExcludedBranches + o.ExcludedTestServices = all.ExcludedTestServices + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_data.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_data.go new file mode 100644 index 00000000000..50945d8c3f7 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_data.go @@ -0,0 +1,186 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesData Data object for Flaky Tests Management policies response. +type TestOptimizationFlakyTestsManagementPoliciesData struct { + // Attributes of the Flaky Tests Management policies for a repository. + Attributes *TestOptimizationFlakyTestsManagementPoliciesAttributes `json:"attributes,omitempty"` + // The repository identifier used as the resource ID. + Id *string `json:"id,omitempty"` + // JSON:API type for Flaky Tests Management policies response. + // The value must always be `test_optimization_flaky_tests_management_policies`. + Type *TestOptimizationFlakyTestsManagementPoliciesType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesData instantiates a new TestOptimizationFlakyTestsManagementPoliciesData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesData() *TestOptimizationFlakyTestsManagementPoliciesData { + this := TestOptimizationFlakyTestsManagementPoliciesData{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesDataWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesDataWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesData { + this := TestOptimizationFlakyTestsManagementPoliciesData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) GetAttributes() TestOptimizationFlakyTestsManagementPoliciesAttributes { + if o == nil || o.Attributes == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) GetAttributesOk() (*TestOptimizationFlakyTestsManagementPoliciesAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesAttributes and assigns it to the Attributes field. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) SetAttributes(v TestOptimizationFlakyTestsManagementPoliciesAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) GetType() TestOptimizationFlakyTestsManagementPoliciesType { + if o == nil || o.Type == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) GetTypeOk() (*TestOptimizationFlakyTestsManagementPoliciesType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesType and assigns it to the Type field. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) SetType(v TestOptimizationFlakyTestsManagementPoliciesType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *TestOptimizationFlakyTestsManagementPoliciesAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *TestOptimizationFlakyTestsManagementPoliciesType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled.go new file mode 100644 index 00000000000..28507bf934d --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled.go @@ -0,0 +1,222 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesDisabled Configuration for the disabled Flaky Tests Management policy. +type TestOptimizationFlakyTestsManagementPoliciesDisabled struct { + // Automatic disable triggering rule based on a time window and test status. + AutoDisableRule *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule `json:"auto_disable_rule,omitempty"` + // Branch filtering rule for a Flaky Tests Management policy. + BranchRule *TestOptimizationFlakyTestsManagementPoliciesBranchRule `json:"branch_rule,omitempty"` + // Whether the disabled policy is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Failure-rate-based rule for the disabled policy. + FailureRateRule *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule `json:"failure_rate_rule,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesDisabled instantiates a new TestOptimizationFlakyTestsManagementPoliciesDisabled object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesDisabled() *TestOptimizationFlakyTestsManagementPoliciesDisabled { + this := TestOptimizationFlakyTestsManagementPoliciesDisabled{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesDisabledWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesDisabled object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesDisabledWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesDisabled { + this := TestOptimizationFlakyTestsManagementPoliciesDisabled{} + return &this +} + +// GetAutoDisableRule returns the AutoDisableRule field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) GetAutoDisableRule() TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule { + if o == nil || o.AutoDisableRule == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule + return ret + } + return *o.AutoDisableRule +} + +// GetAutoDisableRuleOk returns a tuple with the AutoDisableRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) GetAutoDisableRuleOk() (*TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule, bool) { + if o == nil || o.AutoDisableRule == nil { + return nil, false + } + return o.AutoDisableRule, true +} + +// HasAutoDisableRule returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) HasAutoDisableRule() bool { + return o != nil && o.AutoDisableRule != nil +} + +// SetAutoDisableRule gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule and assigns it to the AutoDisableRule field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) SetAutoDisableRule(v TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule) { + o.AutoDisableRule = &v +} + +// GetBranchRule returns the BranchRule field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) GetBranchRule() TestOptimizationFlakyTestsManagementPoliciesBranchRule { + if o == nil || o.BranchRule == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesBranchRule + return ret + } + return *o.BranchRule +} + +// GetBranchRuleOk returns a tuple with the BranchRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) GetBranchRuleOk() (*TestOptimizationFlakyTestsManagementPoliciesBranchRule, bool) { + if o == nil || o.BranchRule == nil { + return nil, false + } + return o.BranchRule, true +} + +// HasBranchRule returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) HasBranchRule() bool { + return o != nil && o.BranchRule != nil +} + +// SetBranchRule gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesBranchRule and assigns it to the BranchRule field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) SetBranchRule(v TestOptimizationFlakyTestsManagementPoliciesBranchRule) { + o.BranchRule = &v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetFailureRateRule returns the FailureRateRule field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) GetFailureRateRule() TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule { + if o == nil || o.FailureRateRule == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule + return ret + } + return *o.FailureRateRule +} + +// GetFailureRateRuleOk returns a tuple with the FailureRateRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) GetFailureRateRuleOk() (*TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule, bool) { + if o == nil || o.FailureRateRule == nil { + return nil, false + } + return o.FailureRateRule, true +} + +// HasFailureRateRule returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) HasFailureRateRule() bool { + return o != nil && o.FailureRateRule != nil +} + +// SetFailureRateRule gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule and assigns it to the FailureRateRule field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) SetFailureRateRule(v TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) { + o.FailureRateRule = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesDisabled) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AutoDisableRule != nil { + toSerialize["auto_disable_rule"] = o.AutoDisableRule + } + if o.BranchRule != nil { + toSerialize["branch_rule"] = o.BranchRule + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.FailureRateRule != nil { + toSerialize["failure_rate_rule"] = o.FailureRateRule + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabled) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AutoDisableRule *TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule `json:"auto_disable_rule,omitempty"` + BranchRule *TestOptimizationFlakyTestsManagementPoliciesBranchRule `json:"branch_rule,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FailureRateRule *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule `json:"failure_rate_rule,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"auto_disable_rule", "branch_rule", "enabled", "failure_rate_rule"}) + } else { + return err + } + + hasInvalidField := false + if all.AutoDisableRule != nil && all.AutoDisableRule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.AutoDisableRule = all.AutoDisableRule + if all.BranchRule != nil && all.BranchRule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.BranchRule = all.BranchRule + o.Enabled = all.Enabled + if all.FailureRateRule != nil && all.FailureRateRule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.FailureRateRule = all.FailureRateRule + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled_failure_rate_rule.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled_failure_rate_rule.go new file mode 100644 index 00000000000..aee478986d5 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled_failure_rate_rule.go @@ -0,0 +1,253 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule Failure-rate-based rule for the disabled policy. +type TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule struct { + // List of branches to which this rule applies. + Branches []string `json:"branches,omitempty"` + // Whether this failure rate rule is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Minimum number of runs required before the rule is evaluated. Must be greater than or equal to 0. + MinRuns *int64 `json:"min_runs,omitempty"` + // Test status that the disable policy applies to. + // Must be either `active` or `quarantined`. + Status *TestOptimizationFlakyTestsManagementPoliciesDisabledStatus `json:"status,omitempty"` + // Failure rate threshold (0.0–1.0) above which the rule triggers. + Threshold *float64 `json:"threshold,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule instantiates a new TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule() *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule { + this := TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRuleWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRuleWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule { + this := TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule{} + return &this +} + +// GetBranches returns the Branches field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetBranches() []string { + if o == nil || o.Branches == nil { + var ret []string + return ret + } + return o.Branches +} + +// GetBranchesOk returns a tuple with the Branches field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetBranchesOk() (*[]string, bool) { + if o == nil || o.Branches == nil { + return nil, false + } + return &o.Branches, true +} + +// HasBranches returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) HasBranches() bool { + return o != nil && o.Branches != nil +} + +// SetBranches gets a reference to the given []string and assigns it to the Branches field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) SetBranches(v []string) { + o.Branches = v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetMinRuns returns the MinRuns field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetMinRuns() int64 { + if o == nil || o.MinRuns == nil { + var ret int64 + return ret + } + return *o.MinRuns +} + +// GetMinRunsOk returns a tuple with the MinRuns field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetMinRunsOk() (*int64, bool) { + if o == nil || o.MinRuns == nil { + return nil, false + } + return o.MinRuns, true +} + +// HasMinRuns returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) HasMinRuns() bool { + return o != nil && o.MinRuns != nil +} + +// SetMinRuns gets a reference to the given int64 and assigns it to the MinRuns field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) SetMinRuns(v int64) { + o.MinRuns = &v +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetStatus() TestOptimizationFlakyTestsManagementPoliciesDisabledStatus { + if o == nil || o.Status == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesDisabledStatus + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetStatusOk() (*TestOptimizationFlakyTestsManagementPoliciesDisabledStatus, bool) { + if o == nil || o.Status == nil { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) HasStatus() bool { + return o != nil && o.Status != nil +} + +// SetStatus gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesDisabledStatus and assigns it to the Status field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) SetStatus(v TestOptimizationFlakyTestsManagementPoliciesDisabledStatus) { + o.Status = &v +} + +// GetThreshold returns the Threshold field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetThreshold() float64 { + if o == nil || o.Threshold == nil { + var ret float64 + return ret + } + return *o.Threshold +} + +// GetThresholdOk returns a tuple with the Threshold field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) GetThresholdOk() (*float64, bool) { + if o == nil || o.Threshold == nil { + return nil, false + } + return o.Threshold, true +} + +// HasThreshold returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) HasThreshold() bool { + return o != nil && o.Threshold != nil +} + +// SetThreshold gets a reference to the given float64 and assigns it to the Threshold field. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) SetThreshold(v float64) { + o.Threshold = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Branches != nil { + toSerialize["branches"] = o.Branches + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.MinRuns != nil { + toSerialize["min_runs"] = o.MinRuns + } + if o.Status != nil { + toSerialize["status"] = o.Status + } + if o.Threshold != nil { + toSerialize["threshold"] = o.Threshold + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Branches []string `json:"branches,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + MinRuns *int64 `json:"min_runs,omitempty"` + Status *TestOptimizationFlakyTestsManagementPoliciesDisabledStatus `json:"status,omitempty"` + Threshold *float64 `json:"threshold,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"branches", "enabled", "min_runs", "status", "threshold"}) + } else { + return err + } + + hasInvalidField := false + o.Branches = all.Branches + o.Enabled = all.Enabled + o.MinRuns = all.MinRuns + if all.Status != nil && !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = all.Status + } + o.Threshold = all.Threshold + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled_status.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled_status.go new file mode 100644 index 00000000000..875ff39622d --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_disabled_status.go @@ -0,0 +1,67 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesDisabledStatus Test status that the disable policy applies to. +// Must be either `active` or `quarantined`. +type TestOptimizationFlakyTestsManagementPoliciesDisabledStatus string + +// List of TestOptimizationFlakyTestsManagementPoliciesDisabledStatus. +const ( + TESTOPTIMIZATIONFLAKYTESTSMANAGEMENTPOLICIESDISABLEDSTATUS_ACTIVE TestOptimizationFlakyTestsManagementPoliciesDisabledStatus = "active" + TESTOPTIMIZATIONFLAKYTESTSMANAGEMENTPOLICIESDISABLEDSTATUS_QUARANTINED TestOptimizationFlakyTestsManagementPoliciesDisabledStatus = "quarantined" +) + +var allowedTestOptimizationFlakyTestsManagementPoliciesDisabledStatusEnumValues = []TestOptimizationFlakyTestsManagementPoliciesDisabledStatus{ + TESTOPTIMIZATIONFLAKYTESTSMANAGEMENTPOLICIESDISABLEDSTATUS_ACTIVE, + TESTOPTIMIZATIONFLAKYTESTSMANAGEMENTPOLICIESDISABLEDSTATUS_QUARANTINED, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TestOptimizationFlakyTestsManagementPoliciesDisabledStatus) GetAllowedValues() []TestOptimizationFlakyTestsManagementPoliciesDisabledStatus { + return allowedTestOptimizationFlakyTestsManagementPoliciesDisabledStatusEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TestOptimizationFlakyTestsManagementPoliciesDisabledStatus) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TestOptimizationFlakyTestsManagementPoliciesDisabledStatus(value) + return nil +} + +// NewTestOptimizationFlakyTestsManagementPoliciesDisabledStatusFromValue returns a pointer to a valid TestOptimizationFlakyTestsManagementPoliciesDisabledStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTestOptimizationFlakyTestsManagementPoliciesDisabledStatusFromValue(v string) (*TestOptimizationFlakyTestsManagementPoliciesDisabledStatus, error) { + ev := TestOptimizationFlakyTestsManagementPoliciesDisabledStatus(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TestOptimizationFlakyTestsManagementPoliciesDisabledStatus: valid values are %v", v, allowedTestOptimizationFlakyTestsManagementPoliciesDisabledStatusEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TestOptimizationFlakyTestsManagementPoliciesDisabledStatus) IsValid() bool { + for _, existing := range allowedTestOptimizationFlakyTestsManagementPoliciesDisabledStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TestOptimizationFlakyTestsManagementPoliciesDisabledStatus value. +func (v TestOptimizationFlakyTestsManagementPoliciesDisabledStatus) Ptr() *TestOptimizationFlakyTestsManagementPoliciesDisabledStatus { + return &v +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request.go new file mode 100644 index 00000000000..83b44be06ad --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesGetRequest Request object for getting Flaky Tests Management policies. +type TestOptimizationFlakyTestsManagementPoliciesGetRequest struct { + // Data object for get Flaky Tests Management policies request. + Data TestOptimizationFlakyTestsManagementPoliciesGetRequestData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesGetRequest instantiates a new TestOptimizationFlakyTestsManagementPoliciesGetRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesGetRequest(data TestOptimizationFlakyTestsManagementPoliciesGetRequestData) *TestOptimizationFlakyTestsManagementPoliciesGetRequest { + this := TestOptimizationFlakyTestsManagementPoliciesGetRequest{} + this.Data = data + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesGetRequestWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesGetRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesGetRequestWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesGetRequest { + this := TestOptimizationFlakyTestsManagementPoliciesGetRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequest) GetData() TestOptimizationFlakyTestsManagementPoliciesGetRequestData { + if o == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesGetRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequest) GetDataOk() (*TestOptimizationFlakyTestsManagementPoliciesGetRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequest) SetData(v TestOptimizationFlakyTestsManagementPoliciesGetRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesGetRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *TestOptimizationFlakyTestsManagementPoliciesGetRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request_attributes.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request_attributes.go new file mode 100644 index 00000000000..943f96735c0 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request_attributes.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes Attributes for requesting Flaky Tests Management policies. +type TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes struct { + // The repository identifier. + RepositoryId string `json:"repository_id"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes instantiates a new TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes(repositoryId string) *TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes { + this := TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes{} + this.RepositoryId = repositoryId + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesGetRequestAttributesWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesGetRequestAttributesWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes { + this := TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes{} + return &this +} + +// GetRepositoryId returns the RepositoryId field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes) GetRepositoryId() string { + if o == nil { + var ret string + return ret + } + return o.RepositoryId +} + +// GetRepositoryIdOk returns a tuple with the RepositoryId field value +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes) GetRepositoryIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RepositoryId, true +} + +// SetRepositoryId sets field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes) SetRepositoryId(v string) { + o.RepositoryId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["repository_id"] = o.RepositoryId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + RepositoryId *string `json:"repository_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.RepositoryId == nil { + return fmt.Errorf("required field repository_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"repository_id"}) + } else { + return err + } + o.RepositoryId = *all.RepositoryId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request_data.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request_data.go new file mode 100644 index 00000000000..3ebc1ebea4b --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_get_request_data.go @@ -0,0 +1,147 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesGetRequestData Data object for get Flaky Tests Management policies request. +type TestOptimizationFlakyTestsManagementPoliciesGetRequestData struct { + // Attributes for requesting Flaky Tests Management policies. + Attributes TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes `json:"attributes"` + // JSON:API type for get Flaky Tests Management policies request. + // The value must always be `test_optimization_get_flaky_tests_management_policies_request`. + Type TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesGetRequestData instantiates a new TestOptimizationFlakyTestsManagementPoliciesGetRequestData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesGetRequestData(attributes TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes, typeVar TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType) *TestOptimizationFlakyTestsManagementPoliciesGetRequestData { + this := TestOptimizationFlakyTestsManagementPoliciesGetRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesGetRequestDataWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesGetRequestData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesGetRequestDataWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesGetRequestData { + this := TestOptimizationFlakyTestsManagementPoliciesGetRequestData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestData) GetAttributes() TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes { + if o == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestData) GetAttributesOk() (*TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestData) SetAttributes(v TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestData) GetType() TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType { + if o == nil { + var ret TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestData) GetTypeOk() (*TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestData) SetType(v TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesGetRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesGetRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes `json:"attributes"` + Type *TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_quarantined.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_quarantined.go new file mode 100644 index 00000000000..9d1044bab1b --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_quarantined.go @@ -0,0 +1,222 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesQuarantined Configuration for the quarantined Flaky Tests Management policy. +type TestOptimizationFlakyTestsManagementPoliciesQuarantined struct { + // Automatic quarantine triggering rule based on a time window. + AutoQuarantineRule *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule `json:"auto_quarantine_rule,omitempty"` + // Branch filtering rule for a Flaky Tests Management policy. + BranchRule *TestOptimizationFlakyTestsManagementPoliciesBranchRule `json:"branch_rule,omitempty"` + // Whether the quarantined policy is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Failure-rate-based rule for the quarantined policy. + FailureRateRule *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule `json:"failure_rate_rule,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesQuarantined instantiates a new TestOptimizationFlakyTestsManagementPoliciesQuarantined object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesQuarantined() *TestOptimizationFlakyTestsManagementPoliciesQuarantined { + this := TestOptimizationFlakyTestsManagementPoliciesQuarantined{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesQuarantinedWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesQuarantined object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesQuarantinedWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesQuarantined { + this := TestOptimizationFlakyTestsManagementPoliciesQuarantined{} + return &this +} + +// GetAutoQuarantineRule returns the AutoQuarantineRule field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) GetAutoQuarantineRule() TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule { + if o == nil || o.AutoQuarantineRule == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule + return ret + } + return *o.AutoQuarantineRule +} + +// GetAutoQuarantineRuleOk returns a tuple with the AutoQuarantineRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) GetAutoQuarantineRuleOk() (*TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule, bool) { + if o == nil || o.AutoQuarantineRule == nil { + return nil, false + } + return o.AutoQuarantineRule, true +} + +// HasAutoQuarantineRule returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) HasAutoQuarantineRule() bool { + return o != nil && o.AutoQuarantineRule != nil +} + +// SetAutoQuarantineRule gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule and assigns it to the AutoQuarantineRule field. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) SetAutoQuarantineRule(v TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule) { + o.AutoQuarantineRule = &v +} + +// GetBranchRule returns the BranchRule field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) GetBranchRule() TestOptimizationFlakyTestsManagementPoliciesBranchRule { + if o == nil || o.BranchRule == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesBranchRule + return ret + } + return *o.BranchRule +} + +// GetBranchRuleOk returns a tuple with the BranchRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) GetBranchRuleOk() (*TestOptimizationFlakyTestsManagementPoliciesBranchRule, bool) { + if o == nil || o.BranchRule == nil { + return nil, false + } + return o.BranchRule, true +} + +// HasBranchRule returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) HasBranchRule() bool { + return o != nil && o.BranchRule != nil +} + +// SetBranchRule gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesBranchRule and assigns it to the BranchRule field. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) SetBranchRule(v TestOptimizationFlakyTestsManagementPoliciesBranchRule) { + o.BranchRule = &v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetFailureRateRule returns the FailureRateRule field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) GetFailureRateRule() TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule { + if o == nil || o.FailureRateRule == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule + return ret + } + return *o.FailureRateRule +} + +// GetFailureRateRuleOk returns a tuple with the FailureRateRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) GetFailureRateRuleOk() (*TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule, bool) { + if o == nil || o.FailureRateRule == nil { + return nil, false + } + return o.FailureRateRule, true +} + +// HasFailureRateRule returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) HasFailureRateRule() bool { + return o != nil && o.FailureRateRule != nil +} + +// SetFailureRateRule gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule and assigns it to the FailureRateRule field. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) SetFailureRateRule(v TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) { + o.FailureRateRule = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesQuarantined) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AutoQuarantineRule != nil { + toSerialize["auto_quarantine_rule"] = o.AutoQuarantineRule + } + if o.BranchRule != nil { + toSerialize["branch_rule"] = o.BranchRule + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.FailureRateRule != nil { + toSerialize["failure_rate_rule"] = o.FailureRateRule + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantined) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AutoQuarantineRule *TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule `json:"auto_quarantine_rule,omitempty"` + BranchRule *TestOptimizationFlakyTestsManagementPoliciesBranchRule `json:"branch_rule,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FailureRateRule *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule `json:"failure_rate_rule,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"auto_quarantine_rule", "branch_rule", "enabled", "failure_rate_rule"}) + } else { + return err + } + + hasInvalidField := false + if all.AutoQuarantineRule != nil && all.AutoQuarantineRule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.AutoQuarantineRule = all.AutoQuarantineRule + if all.BranchRule != nil && all.BranchRule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.BranchRule = all.BranchRule + o.Enabled = all.Enabled + if all.FailureRateRule != nil && all.FailureRateRule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.FailureRateRule = all.FailureRateRule + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_quarantined_failure_rate_rule.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_quarantined_failure_rate_rule.go new file mode 100644 index 00000000000..f7f4984d413 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_quarantined_failure_rate_rule.go @@ -0,0 +1,207 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule Failure-rate-based rule for the quarantined policy. +type TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule struct { + // List of branches to which this rule applies. + Branches []string `json:"branches,omitempty"` + // Whether this failure rate rule is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Minimum number of runs required before the rule is evaluated. Must be greater than or equal to 0. + MinRuns *int64 `json:"min_runs,omitempty"` + // Failure rate threshold (0.0–1.0) above which the rule triggers. + Threshold *float64 `json:"threshold,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule instantiates a new TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule() *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule { + this := TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRuleWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRuleWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule { + this := TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule{} + return &this +} + +// GetBranches returns the Branches field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) GetBranches() []string { + if o == nil || o.Branches == nil { + var ret []string + return ret + } + return o.Branches +} + +// GetBranchesOk returns a tuple with the Branches field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) GetBranchesOk() (*[]string, bool) { + if o == nil || o.Branches == nil { + return nil, false + } + return &o.Branches, true +} + +// HasBranches returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) HasBranches() bool { + return o != nil && o.Branches != nil +} + +// SetBranches gets a reference to the given []string and assigns it to the Branches field. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) SetBranches(v []string) { + o.Branches = v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetMinRuns returns the MinRuns field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) GetMinRuns() int64 { + if o == nil || o.MinRuns == nil { + var ret int64 + return ret + } + return *o.MinRuns +} + +// GetMinRunsOk returns a tuple with the MinRuns field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) GetMinRunsOk() (*int64, bool) { + if o == nil || o.MinRuns == nil { + return nil, false + } + return o.MinRuns, true +} + +// HasMinRuns returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) HasMinRuns() bool { + return o != nil && o.MinRuns != nil +} + +// SetMinRuns gets a reference to the given int64 and assigns it to the MinRuns field. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) SetMinRuns(v int64) { + o.MinRuns = &v +} + +// GetThreshold returns the Threshold field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) GetThreshold() float64 { + if o == nil || o.Threshold == nil { + var ret float64 + return ret + } + return *o.Threshold +} + +// GetThresholdOk returns a tuple with the Threshold field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) GetThresholdOk() (*float64, bool) { + if o == nil || o.Threshold == nil { + return nil, false + } + return o.Threshold, true +} + +// HasThreshold returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) HasThreshold() bool { + return o != nil && o.Threshold != nil +} + +// SetThreshold gets a reference to the given float64 and assigns it to the Threshold field. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) SetThreshold(v float64) { + o.Threshold = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Branches != nil { + toSerialize["branches"] = o.Branches + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.MinRuns != nil { + toSerialize["min_runs"] = o.MinRuns + } + if o.Threshold != nil { + toSerialize["threshold"] = o.Threshold + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Branches []string `json:"branches,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + MinRuns *int64 `json:"min_runs,omitempty"` + Threshold *float64 `json:"threshold,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"branches", "enabled", "min_runs", "threshold"}) + } else { + return err + } + o.Branches = all.Branches + o.Enabled = all.Enabled + o.MinRuns = all.MinRuns + o.Threshold = all.Threshold + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_response.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_response.go new file mode 100644 index 00000000000..dd4d54c291e --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_response.go @@ -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. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesResponse Response object containing Flaky Tests Management policies for a repository. +type TestOptimizationFlakyTestsManagementPoliciesResponse struct { + // Data object for Flaky Tests Management policies response. + Data *TestOptimizationFlakyTestsManagementPoliciesData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesResponse instantiates a new TestOptimizationFlakyTestsManagementPoliciesResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesResponse() *TestOptimizationFlakyTestsManagementPoliciesResponse { + this := TestOptimizationFlakyTestsManagementPoliciesResponse{} + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesResponseWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesResponseWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesResponse { + this := TestOptimizationFlakyTestsManagementPoliciesResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesResponse) GetData() TestOptimizationFlakyTestsManagementPoliciesData { + if o == nil || o.Data == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesResponse) GetDataOk() (*TestOptimizationFlakyTestsManagementPoliciesData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesData and assigns it to the Data field. +func (o *TestOptimizationFlakyTestsManagementPoliciesResponse) SetData(v TestOptimizationFlakyTestsManagementPoliciesData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *TestOptimizationFlakyTestsManagementPoliciesData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_type.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_type.go new file mode 100644 index 00000000000..8a69335ea26 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_type.go @@ -0,0 +1,65 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesType JSON:API type for Flaky Tests Management policies response. +// The value must always be `test_optimization_flaky_tests_management_policies`. +type TestOptimizationFlakyTestsManagementPoliciesType string + +// List of TestOptimizationFlakyTestsManagementPoliciesType. +const ( + TESTOPTIMIZATIONFLAKYTESTSMANAGEMENTPOLICIESTYPE_TEST_OPTIMIZATION_FLAKY_TESTS_MANAGEMENT_POLICIES TestOptimizationFlakyTestsManagementPoliciesType = "test_optimization_flaky_tests_management_policies" +) + +var allowedTestOptimizationFlakyTestsManagementPoliciesTypeEnumValues = []TestOptimizationFlakyTestsManagementPoliciesType{ + TESTOPTIMIZATIONFLAKYTESTSMANAGEMENTPOLICIESTYPE_TEST_OPTIMIZATION_FLAKY_TESTS_MANAGEMENT_POLICIES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TestOptimizationFlakyTestsManagementPoliciesType) GetAllowedValues() []TestOptimizationFlakyTestsManagementPoliciesType { + return allowedTestOptimizationFlakyTestsManagementPoliciesTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TestOptimizationFlakyTestsManagementPoliciesType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TestOptimizationFlakyTestsManagementPoliciesType(value) + return nil +} + +// NewTestOptimizationFlakyTestsManagementPoliciesTypeFromValue returns a pointer to a valid TestOptimizationFlakyTestsManagementPoliciesType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTestOptimizationFlakyTestsManagementPoliciesTypeFromValue(v string) (*TestOptimizationFlakyTestsManagementPoliciesType, error) { + ev := TestOptimizationFlakyTestsManagementPoliciesType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TestOptimizationFlakyTestsManagementPoliciesType: valid values are %v", v, allowedTestOptimizationFlakyTestsManagementPoliciesTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TestOptimizationFlakyTestsManagementPoliciesType) IsValid() bool { + for _, existing := range allowedTestOptimizationFlakyTestsManagementPoliciesTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TestOptimizationFlakyTestsManagementPoliciesType value. +func (v TestOptimizationFlakyTestsManagementPoliciesType) Ptr() *TestOptimizationFlakyTestsManagementPoliciesType { + return &v +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request.go new file mode 100644 index 00000000000..25a17df1fd1 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesUpdateRequest Request object for updating Flaky Tests Management policies. +type TestOptimizationFlakyTestsManagementPoliciesUpdateRequest struct { + // Data object for update Flaky Tests Management policies request. + Data TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequest instantiates a new TestOptimizationFlakyTestsManagementPoliciesUpdateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequest(data TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) *TestOptimizationFlakyTestsManagementPoliciesUpdateRequest { + this := TestOptimizationFlakyTestsManagementPoliciesUpdateRequest{} + this.Data = data + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesUpdateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesUpdateRequest { + this := TestOptimizationFlakyTestsManagementPoliciesUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequest) GetData() TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData { + if o == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequest) GetDataOk() (*TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequest) SetData(v TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request_attributes.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request_attributes.go new file mode 100644 index 00000000000..c7343ae2f9b --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request_attributes.go @@ -0,0 +1,222 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes Attributes for updating Flaky Tests Management policies. +// Only provided policy blocks are updated; omitted blocks are left unchanged. +type TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes struct { + // Configuration for the attempt-to-fix Flaky Tests Management policy. + AttemptToFix *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix `json:"attempt_to_fix,omitempty"` + // Configuration for the disabled Flaky Tests Management policy. + Disabled *TestOptimizationFlakyTestsManagementPoliciesDisabled `json:"disabled,omitempty"` + // Configuration for the quarantined Flaky Tests Management policy. + Quarantined *TestOptimizationFlakyTestsManagementPoliciesQuarantined `json:"quarantined,omitempty"` + // The repository identifier. + RepositoryId string `json:"repository_id"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes instantiates a new TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes(repositoryId string) *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes { + this := TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes{} + this.RepositoryId = repositoryId + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributesWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributesWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes { + this := TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes{} + return &this +} + +// GetAttemptToFix returns the AttemptToFix field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) GetAttemptToFix() TestOptimizationFlakyTestsManagementPoliciesAttemptToFix { + if o == nil || o.AttemptToFix == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesAttemptToFix + return ret + } + return *o.AttemptToFix +} + +// GetAttemptToFixOk returns a tuple with the AttemptToFix field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) GetAttemptToFixOk() (*TestOptimizationFlakyTestsManagementPoliciesAttemptToFix, bool) { + if o == nil || o.AttemptToFix == nil { + return nil, false + } + return o.AttemptToFix, true +} + +// HasAttemptToFix returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) HasAttemptToFix() bool { + return o != nil && o.AttemptToFix != nil +} + +// SetAttemptToFix gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesAttemptToFix and assigns it to the AttemptToFix field. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) SetAttemptToFix(v TestOptimizationFlakyTestsManagementPoliciesAttemptToFix) { + o.AttemptToFix = &v +} + +// GetDisabled returns the Disabled field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) GetDisabled() TestOptimizationFlakyTestsManagementPoliciesDisabled { + if o == nil || o.Disabled == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesDisabled + return ret + } + return *o.Disabled +} + +// GetDisabledOk returns a tuple with the Disabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) GetDisabledOk() (*TestOptimizationFlakyTestsManagementPoliciesDisabled, bool) { + if o == nil || o.Disabled == nil { + return nil, false + } + return o.Disabled, true +} + +// HasDisabled returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) HasDisabled() bool { + return o != nil && o.Disabled != nil +} + +// SetDisabled gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesDisabled and assigns it to the Disabled field. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) SetDisabled(v TestOptimizationFlakyTestsManagementPoliciesDisabled) { + o.Disabled = &v +} + +// GetQuarantined returns the Quarantined field value if set, zero value otherwise. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) GetQuarantined() TestOptimizationFlakyTestsManagementPoliciesQuarantined { + if o == nil || o.Quarantined == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesQuarantined + return ret + } + return *o.Quarantined +} + +// GetQuarantinedOk returns a tuple with the Quarantined field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) GetQuarantinedOk() (*TestOptimizationFlakyTestsManagementPoliciesQuarantined, bool) { + if o == nil || o.Quarantined == nil { + return nil, false + } + return o.Quarantined, true +} + +// HasQuarantined returns a boolean if a field has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) HasQuarantined() bool { + return o != nil && o.Quarantined != nil +} + +// SetQuarantined gets a reference to the given TestOptimizationFlakyTestsManagementPoliciesQuarantined and assigns it to the Quarantined field. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) SetQuarantined(v TestOptimizationFlakyTestsManagementPoliciesQuarantined) { + o.Quarantined = &v +} + +// GetRepositoryId returns the RepositoryId field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) GetRepositoryId() string { + if o == nil { + var ret string + return ret + } + return o.RepositoryId +} + +// GetRepositoryIdOk returns a tuple with the RepositoryId field value +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) GetRepositoryIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RepositoryId, true +} + +// SetRepositoryId sets field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) SetRepositoryId(v string) { + o.RepositoryId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AttemptToFix != nil { + toSerialize["attempt_to_fix"] = o.AttemptToFix + } + if o.Disabled != nil { + toSerialize["disabled"] = o.Disabled + } + if o.Quarantined != nil { + toSerialize["quarantined"] = o.Quarantined + } + toSerialize["repository_id"] = o.RepositoryId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AttemptToFix *TestOptimizationFlakyTestsManagementPoliciesAttemptToFix `json:"attempt_to_fix,omitempty"` + Disabled *TestOptimizationFlakyTestsManagementPoliciesDisabled `json:"disabled,omitempty"` + Quarantined *TestOptimizationFlakyTestsManagementPoliciesQuarantined `json:"quarantined,omitempty"` + RepositoryId *string `json:"repository_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.RepositoryId == nil { + return fmt.Errorf("required field repository_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attempt_to_fix", "disabled", "quarantined", "repository_id"}) + } else { + return err + } + + hasInvalidField := false + if all.AttemptToFix != nil && all.AttemptToFix.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.AttemptToFix = all.AttemptToFix + if all.Disabled != nil && all.Disabled.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Disabled = all.Disabled + if all.Quarantined != nil && all.Quarantined.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Quarantined = all.Quarantined + o.RepositoryId = *all.RepositoryId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request_data.go b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request_data.go new file mode 100644 index 00000000000..17535028071 --- /dev/null +++ b/api/datadogV2/model_test_optimization_flaky_tests_management_policies_update_request_data.go @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData Data object for update Flaky Tests Management policies request. +type TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData struct { + // Attributes for updating Flaky Tests Management policies. + // Only provided policy blocks are updated; omitted blocks are left unchanged. + Attributes TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes `json:"attributes"` + // JSON:API type for update Flaky Tests Management policies request. + // The value must always be `test_optimization_update_flaky_tests_management_policies_request`. + Type TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestData instantiates a new TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestData(attributes TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes, typeVar TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType) *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData { + this := TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestDataWithDefaults instantiates a new TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTestOptimizationFlakyTestsManagementPoliciesUpdateRequestDataWithDefaults() *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData { + this := TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) GetAttributes() TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes { + if o == nil { + var ret TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) GetAttributesOk() (*TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) SetAttributes(v TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) GetType() TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType { + if o == nil { + var ret TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) GetTypeOk() (*TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) SetType(v TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes `json:"attributes"` + Type *TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_test_optimization_get_flaky_tests_management_policies_request_data_type.go b/api/datadogV2/model_test_optimization_get_flaky_tests_management_policies_request_data_type.go new file mode 100644 index 00000000000..f1e1130b7a3 --- /dev/null +++ b/api/datadogV2/model_test_optimization_get_flaky_tests_management_policies_request_data_type.go @@ -0,0 +1,65 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType JSON:API type for get Flaky Tests Management policies request. +// The value must always be `test_optimization_get_flaky_tests_management_policies_request`. +type TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType string + +// List of TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType. +const ( + TESTOPTIMIZATIONGETFLAKYTESTSMANAGEMENTPOLICIESREQUESTDATATYPE_TEST_OPTIMIZATION_GET_FLAKY_TESTS_MANAGEMENT_POLICIES_REQUEST TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType = "test_optimization_get_flaky_tests_management_policies_request" +) + +var allowedTestOptimizationGetFlakyTestsManagementPoliciesRequestDataTypeEnumValues = []TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType{ + TESTOPTIMIZATIONGETFLAKYTESTSMANAGEMENTPOLICIESREQUESTDATATYPE_TEST_OPTIMIZATION_GET_FLAKY_TESTS_MANAGEMENT_POLICIES_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType) GetAllowedValues() []TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType { + return allowedTestOptimizationGetFlakyTestsManagementPoliciesRequestDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType(value) + return nil +} + +// NewTestOptimizationGetFlakyTestsManagementPoliciesRequestDataTypeFromValue returns a pointer to a valid TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTestOptimizationGetFlakyTestsManagementPoliciesRequestDataTypeFromValue(v string) (*TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType, error) { + ev := TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType: valid values are %v", v, allowedTestOptimizationGetFlakyTestsManagementPoliciesRequestDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType) IsValid() bool { + for _, existing := range allowedTestOptimizationGetFlakyTestsManagementPoliciesRequestDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType value. +func (v TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType) Ptr() *TestOptimizationGetFlakyTestsManagementPoliciesRequestDataType { + return &v +} diff --git a/api/datadogV2/model_test_optimization_update_flaky_tests_management_policies_request_data_type.go b/api/datadogV2/model_test_optimization_update_flaky_tests_management_policies_request_data_type.go new file mode 100644 index 00000000000..72704f2297f --- /dev/null +++ b/api/datadogV2/model_test_optimization_update_flaky_tests_management_policies_request_data_type.go @@ -0,0 +1,65 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType JSON:API type for update Flaky Tests Management policies request. +// The value must always be `test_optimization_update_flaky_tests_management_policies_request`. +type TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType string + +// List of TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType. +const ( + TESTOPTIMIZATIONUPDATEFLAKYTESTSMANAGEMENTPOLICIESREQUESTDATATYPE_TEST_OPTIMIZATION_UPDATE_FLAKY_TESTS_MANAGEMENT_POLICIES_REQUEST TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType = "test_optimization_update_flaky_tests_management_policies_request" +) + +var allowedTestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataTypeEnumValues = []TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType{ + TESTOPTIMIZATIONUPDATEFLAKYTESTSMANAGEMENTPOLICIESREQUESTDATATYPE_TEST_OPTIMIZATION_UPDATE_FLAKY_TESTS_MANAGEMENT_POLICIES_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType) GetAllowedValues() []TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType { + return allowedTestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType(value) + return nil +} + +// NewTestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataTypeFromValue returns a pointer to a valid TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataTypeFromValue(v string) (*TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType, error) { + ev := TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType: valid values are %v", v, allowedTestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType) IsValid() bool { + for _, existing := range allowedTestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType value. +func (v TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType) Ptr() *TestOptimizationUpdateFlakyTestsManagementPoliciesRequestDataType { + return &v +} diff --git a/api/datadogV2/model_trigger_attributes.go b/api/datadogV2/model_trigger_attributes.go new file mode 100644 index 00000000000..42aa0e6c58f --- /dev/null +++ b/api/datadogV2/model_trigger_attributes.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerAttributes The trigger definition for starting an investigation. +type TriggerAttributes struct { + // Attributes for a monitor alert trigger. + MonitorAlertTrigger MonitorAlertTriggerAttributes `json:"monitor_alert_trigger"` + // The type of trigger for the investigation. + Type TriggerType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTriggerAttributes instantiates a new TriggerAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTriggerAttributes(monitorAlertTrigger MonitorAlertTriggerAttributes, typeVar TriggerType) *TriggerAttributes { + this := TriggerAttributes{} + this.MonitorAlertTrigger = monitorAlertTrigger + this.Type = typeVar + return &this +} + +// NewTriggerAttributesWithDefaults instantiates a new TriggerAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTriggerAttributesWithDefaults() *TriggerAttributes { + this := TriggerAttributes{} + return &this +} + +// GetMonitorAlertTrigger returns the MonitorAlertTrigger field value. +func (o *TriggerAttributes) GetMonitorAlertTrigger() MonitorAlertTriggerAttributes { + if o == nil { + var ret MonitorAlertTriggerAttributes + return ret + } + return o.MonitorAlertTrigger +} + +// GetMonitorAlertTriggerOk returns a tuple with the MonitorAlertTrigger field value +// and a boolean to check if the value has been set. +func (o *TriggerAttributes) GetMonitorAlertTriggerOk() (*MonitorAlertTriggerAttributes, bool) { + if o == nil { + return nil, false + } + return &o.MonitorAlertTrigger, true +} + +// SetMonitorAlertTrigger sets field value. +func (o *TriggerAttributes) SetMonitorAlertTrigger(v MonitorAlertTriggerAttributes) { + o.MonitorAlertTrigger = v +} + +// GetType returns the Type field value. +func (o *TriggerAttributes) GetType() TriggerType { + if o == nil { + var ret TriggerType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *TriggerAttributes) GetTypeOk() (*TriggerType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *TriggerAttributes) SetType(v TriggerType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TriggerAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["monitor_alert_trigger"] = o.MonitorAlertTrigger + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TriggerAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + MonitorAlertTrigger *MonitorAlertTriggerAttributes `json:"monitor_alert_trigger"` + Type *TriggerType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.MonitorAlertTrigger == nil { + return fmt.Errorf("required field monitor_alert_trigger missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"monitor_alert_trigger", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.MonitorAlertTrigger.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.MonitorAlertTrigger = *all.MonitorAlertTrigger + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_trigger_investigation_request.go b/api/datadogV2/model_trigger_investigation_request.go new file mode 100644 index 00000000000..e9d1ffbf5af --- /dev/null +++ b/api/datadogV2/model_trigger_investigation_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerInvestigationRequest Request to trigger a new investigation. +type TriggerInvestigationRequest struct { + // Data for the trigger investigation request. + Data TriggerInvestigationRequestData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTriggerInvestigationRequest instantiates a new TriggerInvestigationRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTriggerInvestigationRequest(data TriggerInvestigationRequestData) *TriggerInvestigationRequest { + this := TriggerInvestigationRequest{} + this.Data = data + return &this +} + +// NewTriggerInvestigationRequestWithDefaults instantiates a new TriggerInvestigationRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTriggerInvestigationRequestWithDefaults() *TriggerInvestigationRequest { + this := TriggerInvestigationRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *TriggerInvestigationRequest) GetData() TriggerInvestigationRequestData { + if o == nil { + var ret TriggerInvestigationRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationRequest) GetDataOk() (*TriggerInvestigationRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *TriggerInvestigationRequest) SetData(v TriggerInvestigationRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TriggerInvestigationRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TriggerInvestigationRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *TriggerInvestigationRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_trigger_investigation_request_data.go b/api/datadogV2/model_trigger_investigation_request_data.go new file mode 100644 index 00000000000..4a4988f56d3 --- /dev/null +++ b/api/datadogV2/model_trigger_investigation_request_data.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerInvestigationRequestData Data for the trigger investigation request. +type TriggerInvestigationRequestData struct { + // Attributes for the trigger investigation request. + Attributes TriggerInvestigationRequestDataAttributes `json:"attributes"` + // The resource type for trigger investigation requests. + Type TriggerInvestigationRequestType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTriggerInvestigationRequestData instantiates a new TriggerInvestigationRequestData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTriggerInvestigationRequestData(attributes TriggerInvestigationRequestDataAttributes, typeVar TriggerInvestigationRequestType) *TriggerInvestigationRequestData { + this := TriggerInvestigationRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewTriggerInvestigationRequestDataWithDefaults instantiates a new TriggerInvestigationRequestData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTriggerInvestigationRequestDataWithDefaults() *TriggerInvestigationRequestData { + this := TriggerInvestigationRequestData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *TriggerInvestigationRequestData) GetAttributes() TriggerInvestigationRequestDataAttributes { + if o == nil { + var ret TriggerInvestigationRequestDataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationRequestData) GetAttributesOk() (*TriggerInvestigationRequestDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *TriggerInvestigationRequestData) SetAttributes(v TriggerInvestigationRequestDataAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *TriggerInvestigationRequestData) GetType() TriggerInvestigationRequestType { + if o == nil { + var ret TriggerInvestigationRequestType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationRequestData) GetTypeOk() (*TriggerInvestigationRequestType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *TriggerInvestigationRequestData) SetType(v TriggerInvestigationRequestType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TriggerInvestigationRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TriggerInvestigationRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *TriggerInvestigationRequestDataAttributes `json:"attributes"` + Type *TriggerInvestigationRequestType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_trigger_investigation_request_data_attributes.go b/api/datadogV2/model_trigger_investigation_request_data_attributes.go new file mode 100644 index 00000000000..1aaacf84205 --- /dev/null +++ b/api/datadogV2/model_trigger_investigation_request_data_attributes.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerInvestigationRequestDataAttributes Attributes for the trigger investigation request. +type TriggerInvestigationRequestDataAttributes struct { + // The trigger definition for starting an investigation. + Trigger TriggerAttributes `json:"trigger"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTriggerInvestigationRequestDataAttributes instantiates a new TriggerInvestigationRequestDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTriggerInvestigationRequestDataAttributes(trigger TriggerAttributes) *TriggerInvestigationRequestDataAttributes { + this := TriggerInvestigationRequestDataAttributes{} + this.Trigger = trigger + return &this +} + +// NewTriggerInvestigationRequestDataAttributesWithDefaults instantiates a new TriggerInvestigationRequestDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTriggerInvestigationRequestDataAttributesWithDefaults() *TriggerInvestigationRequestDataAttributes { + this := TriggerInvestigationRequestDataAttributes{} + return &this +} + +// GetTrigger returns the Trigger field value. +func (o *TriggerInvestigationRequestDataAttributes) GetTrigger() TriggerAttributes { + if o == nil { + var ret TriggerAttributes + return ret + } + return o.Trigger +} + +// GetTriggerOk returns a tuple with the Trigger field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationRequestDataAttributes) GetTriggerOk() (*TriggerAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Trigger, true +} + +// SetTrigger sets field value. +func (o *TriggerInvestigationRequestDataAttributes) SetTrigger(v TriggerAttributes) { + o.Trigger = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TriggerInvestigationRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["trigger"] = o.Trigger + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TriggerInvestigationRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Trigger *TriggerAttributes `json:"trigger"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Trigger == nil { + return fmt.Errorf("required field trigger missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"trigger"}) + } else { + return err + } + + hasInvalidField := false + if all.Trigger.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Trigger = *all.Trigger + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_trigger_investigation_request_type.go b/api/datadogV2/model_trigger_investigation_request_type.go new file mode 100644 index 00000000000..4455aa6a8ad --- /dev/null +++ b/api/datadogV2/model_trigger_investigation_request_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerInvestigationRequestType The resource type for trigger investigation requests. +type TriggerInvestigationRequestType string + +// List of TriggerInvestigationRequestType. +const ( + TRIGGERINVESTIGATIONREQUESTTYPE_TRIGGER_INVESTIGATION_REQUEST TriggerInvestigationRequestType = "trigger_investigation_request" +) + +var allowedTriggerInvestigationRequestTypeEnumValues = []TriggerInvestigationRequestType{ + TRIGGERINVESTIGATIONREQUESTTYPE_TRIGGER_INVESTIGATION_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TriggerInvestigationRequestType) GetAllowedValues() []TriggerInvestigationRequestType { + return allowedTriggerInvestigationRequestTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TriggerInvestigationRequestType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TriggerInvestigationRequestType(value) + return nil +} + +// NewTriggerInvestigationRequestTypeFromValue returns a pointer to a valid TriggerInvestigationRequestType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTriggerInvestigationRequestTypeFromValue(v string) (*TriggerInvestigationRequestType, error) { + ev := TriggerInvestigationRequestType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TriggerInvestigationRequestType: valid values are %v", v, allowedTriggerInvestigationRequestTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TriggerInvestigationRequestType) IsValid() bool { + for _, existing := range allowedTriggerInvestigationRequestTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TriggerInvestigationRequestType value. +func (v TriggerInvestigationRequestType) Ptr() *TriggerInvestigationRequestType { + return &v +} diff --git a/api/datadogV2/model_trigger_investigation_response.go b/api/datadogV2/model_trigger_investigation_response.go new file mode 100644 index 00000000000..2e584355023 --- /dev/null +++ b/api/datadogV2/model_trigger_investigation_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerInvestigationResponse Response after triggering an investigation. +type TriggerInvestigationResponse struct { + // Data for the trigger investigation response. + Data TriggerInvestigationResponseData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTriggerInvestigationResponse instantiates a new TriggerInvestigationResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTriggerInvestigationResponse(data TriggerInvestigationResponseData) *TriggerInvestigationResponse { + this := TriggerInvestigationResponse{} + this.Data = data + return &this +} + +// NewTriggerInvestigationResponseWithDefaults instantiates a new TriggerInvestigationResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTriggerInvestigationResponseWithDefaults() *TriggerInvestigationResponse { + this := TriggerInvestigationResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *TriggerInvestigationResponse) GetData() TriggerInvestigationResponseData { + if o == nil { + var ret TriggerInvestigationResponseData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationResponse) GetDataOk() (*TriggerInvestigationResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *TriggerInvestigationResponse) SetData(v TriggerInvestigationResponseData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TriggerInvestigationResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TriggerInvestigationResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *TriggerInvestigationResponseData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_trigger_investigation_response_data.go b/api/datadogV2/model_trigger_investigation_response_data.go new file mode 100644 index 00000000000..68f65f15448 --- /dev/null +++ b/api/datadogV2/model_trigger_investigation_response_data.go @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerInvestigationResponseData Data for the trigger investigation response. +type TriggerInvestigationResponseData struct { + // Attributes for the trigger investigation response. + Attributes TriggerInvestigationResponseDataAttributes `json:"attributes"` + // Unique identifier for the trigger response. + Id string `json:"id"` + // The resource type for trigger investigation responses. + Type TriggerInvestigationResponseType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTriggerInvestigationResponseData instantiates a new TriggerInvestigationResponseData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTriggerInvestigationResponseData(attributes TriggerInvestigationResponseDataAttributes, id string, typeVar TriggerInvestigationResponseType) *TriggerInvestigationResponseData { + this := TriggerInvestigationResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewTriggerInvestigationResponseDataWithDefaults instantiates a new TriggerInvestigationResponseData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTriggerInvestigationResponseDataWithDefaults() *TriggerInvestigationResponseData { + this := TriggerInvestigationResponseData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *TriggerInvestigationResponseData) GetAttributes() TriggerInvestigationResponseDataAttributes { + if o == nil { + var ret TriggerInvestigationResponseDataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationResponseData) GetAttributesOk() (*TriggerInvestigationResponseDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *TriggerInvestigationResponseData) SetAttributes(v TriggerInvestigationResponseDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *TriggerInvestigationResponseData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *TriggerInvestigationResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *TriggerInvestigationResponseData) GetType() TriggerInvestigationResponseType { + if o == nil { + var ret TriggerInvestigationResponseType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationResponseData) GetTypeOk() (*TriggerInvestigationResponseType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *TriggerInvestigationResponseData) SetType(v TriggerInvestigationResponseType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TriggerInvestigationResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TriggerInvestigationResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *TriggerInvestigationResponseDataAttributes `json:"attributes"` + Id *string `json:"id"` + Type *TriggerInvestigationResponseType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_trigger_investigation_response_data_attributes.go b/api/datadogV2/model_trigger_investigation_response_data_attributes.go new file mode 100644 index 00000000000..2555130fc6c --- /dev/null +++ b/api/datadogV2/model_trigger_investigation_response_data_attributes.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerInvestigationResponseDataAttributes Attributes for the trigger investigation response. +type TriggerInvestigationResponseDataAttributes struct { + // The ID of the investigation that was created. + InvestigationId string `json:"investigation_id"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewTriggerInvestigationResponseDataAttributes instantiates a new TriggerInvestigationResponseDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTriggerInvestigationResponseDataAttributes(investigationId string) *TriggerInvestigationResponseDataAttributes { + this := TriggerInvestigationResponseDataAttributes{} + this.InvestigationId = investigationId + return &this +} + +// NewTriggerInvestigationResponseDataAttributesWithDefaults instantiates a new TriggerInvestigationResponseDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTriggerInvestigationResponseDataAttributesWithDefaults() *TriggerInvestigationResponseDataAttributes { + this := TriggerInvestigationResponseDataAttributes{} + return &this +} + +// GetInvestigationId returns the InvestigationId field value. +func (o *TriggerInvestigationResponseDataAttributes) GetInvestigationId() string { + if o == nil { + var ret string + return ret + } + return o.InvestigationId +} + +// GetInvestigationIdOk returns a tuple with the InvestigationId field value +// and a boolean to check if the value has been set. +func (o *TriggerInvestigationResponseDataAttributes) GetInvestigationIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.InvestigationId, true +} + +// SetInvestigationId sets field value. +func (o *TriggerInvestigationResponseDataAttributes) SetInvestigationId(v string) { + o.InvestigationId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TriggerInvestigationResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["investigation_id"] = o.InvestigationId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TriggerInvestigationResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + InvestigationId *string `json:"investigation_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.InvestigationId == nil { + return fmt.Errorf("required field investigation_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"investigation_id"}) + } else { + return err + } + o.InvestigationId = *all.InvestigationId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_trigger_investigation_response_type.go b/api/datadogV2/model_trigger_investigation_response_type.go new file mode 100644 index 00000000000..9d2a8b71e3f --- /dev/null +++ b/api/datadogV2/model_trigger_investigation_response_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerInvestigationResponseType The resource type for trigger investigation responses. +type TriggerInvestigationResponseType string + +// List of TriggerInvestigationResponseType. +const ( + TRIGGERINVESTIGATIONRESPONSETYPE_TRIGGER_INVESTIGATION_RESPONSE TriggerInvestigationResponseType = "trigger_investigation_response" +) + +var allowedTriggerInvestigationResponseTypeEnumValues = []TriggerInvestigationResponseType{ + TRIGGERINVESTIGATIONRESPONSETYPE_TRIGGER_INVESTIGATION_RESPONSE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TriggerInvestigationResponseType) GetAllowedValues() []TriggerInvestigationResponseType { + return allowedTriggerInvestigationResponseTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TriggerInvestigationResponseType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TriggerInvestigationResponseType(value) + return nil +} + +// NewTriggerInvestigationResponseTypeFromValue returns a pointer to a valid TriggerInvestigationResponseType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTriggerInvestigationResponseTypeFromValue(v string) (*TriggerInvestigationResponseType, error) { + ev := TriggerInvestigationResponseType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TriggerInvestigationResponseType: valid values are %v", v, allowedTriggerInvestigationResponseTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TriggerInvestigationResponseType) IsValid() bool { + for _, existing := range allowedTriggerInvestigationResponseTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TriggerInvestigationResponseType value. +func (v TriggerInvestigationResponseType) Ptr() *TriggerInvestigationResponseType { + return &v +} diff --git a/api/datadogV2/model_trigger_type.go b/api/datadogV2/model_trigger_type.go new file mode 100644 index 00000000000..fb1bcdfe249 --- /dev/null +++ b/api/datadogV2/model_trigger_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// TriggerType The type of trigger for the investigation. +type TriggerType string + +// List of TriggerType. +const ( + TRIGGERTYPE_MONITOR_ALERT_TRIGGER TriggerType = "monitor_alert_trigger" +) + +var allowedTriggerTypeEnumValues = []TriggerType{ + TRIGGERTYPE_MONITOR_ALERT_TRIGGER, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TriggerType) GetAllowedValues() []TriggerType { + return allowedTriggerTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TriggerType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TriggerType(value) + return nil +} + +// NewTriggerTypeFromValue returns a pointer to a valid TriggerType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTriggerTypeFromValue(v string) (*TriggerType, error) { + ev := TriggerType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TriggerType: valid values are %v", v, allowedTriggerTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TriggerType) IsValid() bool { + for _, existing := range allowedTriggerTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TriggerType value. +func (v TriggerType) Ptr() *TriggerType { + return &v +} diff --git a/examples/v2/bits-ai/GetInvestigation.go b/examples/v2/bits-ai/GetInvestigation.go new file mode 100644 index 00000000000..58948f5b12d --- /dev/null +++ b/examples/v2/bits-ai/GetInvestigation.go @@ -0,0 +1,30 @@ +// Get a Bits AI investigation returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetInvestigation", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewBitsAIApi(apiClient) + resp, r, err := api.GetInvestigation(ctx, "id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `BitsAIApi.GetInvestigation`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `BitsAIApi.GetInvestigation`:\n%s\n", responseContent) +} diff --git a/examples/v2/bits-ai/ListInvestigations.go b/examples/v2/bits-ai/ListInvestigations.go new file mode 100644 index 00000000000..eaaa1d5cd05 --- /dev/null +++ b/examples/v2/bits-ai/ListInvestigations.go @@ -0,0 +1,30 @@ +// List Bits AI investigations returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListInvestigations", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewBitsAIApi(apiClient) + resp, r, err := api.ListInvestigations(ctx, *datadogV2.NewListInvestigationsOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `BitsAIApi.ListInvestigations`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `BitsAIApi.ListInvestigations`:\n%s\n", responseContent) +} diff --git a/examples/v2/bits-ai/ListInvestigations_130750454.go b/examples/v2/bits-ai/ListInvestigations_130750454.go new file mode 100644 index 00000000000..f8d5b194f47 --- /dev/null +++ b/examples/v2/bits-ai/ListInvestigations_130750454.go @@ -0,0 +1,30 @@ +// List Bits AI investigations returns "OK" response with pagination + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListInvestigations", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewBitsAIApi(apiClient) + resp, _ := api.ListInvestigationsWithPagination(ctx, *datadogV2.NewListInvestigationsOptionalParameters()) + + for paginationResult := range resp { + if paginationResult.Error != nil { + fmt.Fprintf(os.Stderr, "Error when calling `BitsAIApi.ListInvestigations`: %v\n", paginationResult.Error) + } + responseContent, _ := json.MarshalIndent(paginationResult.Item, "", " ") + fmt.Fprintf(os.Stdout, "%s\n", responseContent) + } +} diff --git a/examples/v2/bits-ai/TriggerInvestigation.go b/examples/v2/bits-ai/TriggerInvestigation.go new file mode 100644 index 00000000000..2a0aa3800c7 --- /dev/null +++ b/examples/v2/bits-ai/TriggerInvestigation.go @@ -0,0 +1,45 @@ +// Trigger a Bits AI investigation returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.TriggerInvestigationRequest{ + Data: datadogV2.TriggerInvestigationRequestData{ + Attributes: datadogV2.TriggerInvestigationRequestDataAttributes{ + Trigger: datadogV2.TriggerAttributes{ + MonitorAlertTrigger: datadogV2.MonitorAlertTriggerAttributes{ + EventId: "1234567890123456789", + EventTs: 1700000000000, + MonitorId: 12345678, + }, + Type: datadogV2.TRIGGERTYPE_MONITOR_ALERT_TRIGGER, + }, + }, + Type: datadogV2.TRIGGERINVESTIGATIONREQUESTTYPE_TRIGGER_INVESTIGATION_REQUEST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.TriggerInvestigation", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewBitsAIApi(apiClient) + resp, r, err := api.TriggerInvestigation(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `BitsAIApi.TriggerInvestigation`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `BitsAIApi.TriggerInvestigation`:\n%s\n", responseContent) +} diff --git a/examples/v2/observability-pipelines/ValidatePipeline_1267410221.go b/examples/v2/observability-pipelines/ValidatePipeline_1267410221.go new file mode 100644 index 00000000000..63a912ee233 --- /dev/null +++ b/examples/v2/observability-pipelines/ValidatePipeline_1267410221.go @@ -0,0 +1,77 @@ +// Validate an observability pipeline with Splunk HEC destination token_strategy returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.ObservabilityPipelineSpec{ + Data: datadogV2.ObservabilityPipelineSpecData{ + Attributes: datadogV2.ObservabilityPipelineDataAttributes{ + Config: datadogV2.ObservabilityPipelineConfig{ + Destinations: []datadogV2.ObservabilityPipelineConfigDestinationItem{ + datadogV2.ObservabilityPipelineConfigDestinationItem{ + ObservabilityPipelineSplunkHecDestination: &datadogV2.ObservabilityPipelineSplunkHecDestination{ + Id: "splunk-hec-destination", + Inputs: []string{ + "my-processor-group", + }, + Type: datadogV2.OBSERVABILITYPIPELINESPLUNKHECDESTINATIONTYPE_SPLUNK_HEC, + TokenKey: datadog.PtrString("SPLUNK_HEC_TOKEN"), + TokenStrategy: datadogV2.OBSERVABILITYPIPELINESPLUNKHECDESTINATIONTOKENSTRATEGY_CUSTOM.Ptr(), + }}, + }, + ProcessorGroups: []datadogV2.ObservabilityPipelineConfigProcessorGroup{ + { + Enabled: true, + Id: "my-processor-group", + Include: "service:my-service", + Inputs: []string{ + "datadog-agent-source", + }, + Processors: []datadogV2.ObservabilityPipelineConfigProcessorItem{ + datadogV2.ObservabilityPipelineConfigProcessorItem{ + ObservabilityPipelineFilterProcessor: &datadogV2.ObservabilityPipelineFilterProcessor{ + Enabled: true, + Id: "filter-processor", + Include: "status:error", + Type: datadogV2.OBSERVABILITYPIPELINEFILTERPROCESSORTYPE_FILTER, + }}, + }, + }, + }, + Sources: []datadogV2.ObservabilityPipelineConfigSourceItem{ + datadogV2.ObservabilityPipelineConfigSourceItem{ + ObservabilityPipelineDatadogAgentSource: &datadogV2.ObservabilityPipelineDatadogAgentSource{ + Id: "datadog-agent-source", + Type: datadogV2.OBSERVABILITYPIPELINEDATADOGAGENTSOURCETYPE_DATADOG_AGENT, + }}, + }, + }, + Name: "Pipeline with Splunk HEC token_strategy", + }, + Type: "pipelines", + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewObservabilityPipelinesApi(apiClient) + resp, r, err := api.ValidatePipeline(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ObservabilityPipelinesApi.ValidatePipeline`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ObservabilityPipelinesApi.ValidatePipeline`:\n%s\n", responseContent) +} diff --git a/examples/v2/observability-pipelines/ValidatePipeline_2960728933.go b/examples/v2/observability-pipelines/ValidatePipeline_2960728933.go new file mode 100644 index 00000000000..9f40fe6e092 --- /dev/null +++ b/examples/v2/observability-pipelines/ValidatePipeline_2960728933.go @@ -0,0 +1,76 @@ +// Validate an observability pipeline with Splunk HEC source store_hec_token returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.ObservabilityPipelineSpec{ + Data: datadogV2.ObservabilityPipelineSpecData{ + Attributes: datadogV2.ObservabilityPipelineDataAttributes{ + Config: datadogV2.ObservabilityPipelineConfig{ + Destinations: []datadogV2.ObservabilityPipelineConfigDestinationItem{ + datadogV2.ObservabilityPipelineConfigDestinationItem{ + ObservabilityPipelineDatadogLogsDestination: &datadogV2.ObservabilityPipelineDatadogLogsDestination{ + Id: "datadog-logs-destination", + Inputs: []string{ + "my-processor-group", + }, + Type: datadogV2.OBSERVABILITYPIPELINEDATADOGLOGSDESTINATIONTYPE_DATADOG_LOGS, + }}, + }, + ProcessorGroups: []datadogV2.ObservabilityPipelineConfigProcessorGroup{ + { + Enabled: true, + Id: "my-processor-group", + Include: "service:my-service", + Inputs: []string{ + "splunk-hec-source", + }, + Processors: []datadogV2.ObservabilityPipelineConfigProcessorItem{ + datadogV2.ObservabilityPipelineConfigProcessorItem{ + ObservabilityPipelineFilterProcessor: &datadogV2.ObservabilityPipelineFilterProcessor{ + Enabled: true, + Id: "filter-processor", + Include: "status:error", + Type: datadogV2.OBSERVABILITYPIPELINEFILTERPROCESSORTYPE_FILTER, + }}, + }, + }, + }, + Sources: []datadogV2.ObservabilityPipelineConfigSourceItem{ + datadogV2.ObservabilityPipelineConfigSourceItem{ + ObservabilityPipelineSplunkHecSource: &datadogV2.ObservabilityPipelineSplunkHecSource{ + Id: "splunk-hec-source", + Type: datadogV2.OBSERVABILITYPIPELINESPLUNKHECSOURCETYPE_SPLUNK_HEC, + StoreHecToken: datadog.PtrBool(true), + }}, + }, + }, + Name: "Pipeline with Splunk HEC store_hec_token", + }, + Type: "pipelines", + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewObservabilityPipelinesApi(apiClient) + resp, r, err := api.ValidatePipeline(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ObservabilityPipelinesApi.ValidatePipeline`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ObservabilityPipelinesApi.ValidatePipeline`:\n%s\n", responseContent) +} diff --git a/examples/v2/observability-pipelines/ValidatePipeline_815080644.go b/examples/v2/observability-pipelines/ValidatePipeline_815080644.go new file mode 100644 index 00000000000..b16141eaba0 --- /dev/null +++ b/examples/v2/observability-pipelines/ValidatePipeline_815080644.go @@ -0,0 +1,100 @@ +// Validate an observability pipeline with enrichment table secret field lookup returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.ObservabilityPipelineSpec{ + Data: datadogV2.ObservabilityPipelineSpecData{ + Attributes: datadogV2.ObservabilityPipelineDataAttributes{ + Config: datadogV2.ObservabilityPipelineConfig{ + Destinations: []datadogV2.ObservabilityPipelineConfigDestinationItem{ + datadogV2.ObservabilityPipelineConfigDestinationItem{ + ObservabilityPipelineDatadogLogsDestination: &datadogV2.ObservabilityPipelineDatadogLogsDestination{ + Id: "datadog-logs-destination", + Inputs: []string{ + "my-processor-group", + }, + Type: datadogV2.OBSERVABILITYPIPELINEDATADOGLOGSDESTINATIONTYPE_DATADOG_LOGS, + }}, + }, + ProcessorGroups: []datadogV2.ObservabilityPipelineConfigProcessorGroup{ + { + Enabled: true, + Id: "my-processor-group", + Include: "service:my-service", + Inputs: []string{ + "datadog-agent-source", + }, + Processors: []datadogV2.ObservabilityPipelineConfigProcessorItem{ + datadogV2.ObservabilityPipelineConfigProcessorItem{ + ObservabilityPipelineEnrichmentTableProcessor: &datadogV2.ObservabilityPipelineEnrichmentTableProcessor{ + Enabled: true, + Id: "enrichment-processor", + Include: "*", + Target: "enriched", + Type: datadogV2.OBSERVABILITYPIPELINEENRICHMENTTABLEPROCESSORTYPE_ENRICHMENT_TABLE, + File: &datadogV2.ObservabilityPipelineEnrichmentTableFile{ + Encoding: datadogV2.ObservabilityPipelineEnrichmentTableFileEncoding{ + Delimiter: ",", + Type: datadogV2.OBSERVABILITYPIPELINEENRICHMENTTABLEFILEENCODINGTYPE_CSV, + IncludesHeaders: true, + }, + Key: []datadogV2.ObservabilityPipelineEnrichmentTableFileKeyItems{ + { + Column: "user_id", + Comparison: datadogV2.OBSERVABILITYPIPELINEENRICHMENTTABLEFILEKEYITEMSCOMPARISON_EQUALS, + Field: datadogV2.ObservabilityPipelineEnrichmentTableFileKeyItemField{ + ObservabilityPipelineEnrichmentTableFieldSecretLookup: &datadogV2.ObservabilityPipelineEnrichmentTableFieldSecretLookup{ + Secret: "LOOKUP_KEY_SECRET", + }}, + }, + }, + Path: "/etc/enrichment/lookup.csv", + Schema: []datadogV2.ObservabilityPipelineEnrichmentTableFileSchemaItems{ + { + Column: "user_id", + Type: datadogV2.OBSERVABILITYPIPELINEENRICHMENTTABLEFILESCHEMAITEMSTYPE_STRING, + }, + }, + }, + }}, + }, + }, + }, + Sources: []datadogV2.ObservabilityPipelineConfigSourceItem{ + datadogV2.ObservabilityPipelineConfigSourceItem{ + ObservabilityPipelineDatadogAgentSource: &datadogV2.ObservabilityPipelineDatadogAgentSource{ + Id: "datadog-agent-source", + Type: datadogV2.OBSERVABILITYPIPELINEDATADOGAGENTSOURCETYPE_DATADOG_AGENT, + }}, + }, + }, + Name: "Pipeline with Enrichment Table Secret Field Lookup", + }, + Type: "pipelines", + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewObservabilityPipelinesApi(apiClient) + resp, r, err := api.ValidatePipeline(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ObservabilityPipelinesApi.ValidatePipeline`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ObservabilityPipelinesApi.ValidatePipeline`:\n%s\n", responseContent) +} diff --git a/examples/v2/test-optimization/GetFlakyTestsManagementPolicies.go b/examples/v2/test-optimization/GetFlakyTestsManagementPolicies.go new file mode 100644 index 00000000000..9351d70518f --- /dev/null +++ b/examples/v2/test-optimization/GetFlakyTestsManagementPolicies.go @@ -0,0 +1,38 @@ +// Get Flaky Tests Management policies returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.TestOptimizationFlakyTestsManagementPoliciesGetRequest{ + Data: datadogV2.TestOptimizationFlakyTestsManagementPoliciesGetRequestData{ + Attributes: datadogV2.TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes{ + RepositoryId: "github.com/datadog/shopist", + }, + Type: datadogV2.TESTOPTIMIZATIONGETFLAKYTESTSMANAGEMENTPOLICIESREQUESTDATATYPE_TEST_OPTIMIZATION_GET_FLAKY_TESTS_MANAGEMENT_POLICIES_REQUEST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetFlakyTestsManagementPolicies", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewTestOptimizationApi(apiClient) + resp, r, err := api.GetFlakyTestsManagementPolicies(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `TestOptimizationApi.GetFlakyTestsManagementPolicies`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `TestOptimizationApi.GetFlakyTestsManagementPolicies`:\n%s\n", responseContent) +} diff --git a/examples/v2/test-optimization/UpdateFlakyTestsManagementPolicies.go b/examples/v2/test-optimization/UpdateFlakyTestsManagementPolicies.go new file mode 100644 index 00000000000..a193a6758af --- /dev/null +++ b/examples/v2/test-optimization/UpdateFlakyTestsManagementPolicies.go @@ -0,0 +1,87 @@ +// Update Flaky Tests Management policies returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.TestOptimizationFlakyTestsManagementPoliciesUpdateRequest{ + Data: datadogV2.TestOptimizationFlakyTestsManagementPoliciesUpdateRequestData{ + Attributes: datadogV2.TestOptimizationFlakyTestsManagementPoliciesUpdateRequestAttributes{ + AttemptToFix: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesAttemptToFix{ + Retries: datadog.PtrInt64(3), + }, + Disabled: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesDisabled{ + AutoDisableRule: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule{ + Enabled: datadog.PtrBool(false), + Status: datadogV2.TESTOPTIMIZATIONFLAKYTESTSMANAGEMENTPOLICIESDISABLEDSTATUS_ACTIVE.Ptr(), + WindowSeconds: datadog.PtrInt64(3600), + }, + BranchRule: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesBranchRule{ + Branches: []string{ + "main", + }, + Enabled: datadog.PtrBool(true), + ExcludedBranches: []string{}, + ExcludedTestServices: []string{}, + }, + Enabled: datadog.PtrBool(false), + FailureRateRule: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule{ + Branches: []string{}, + Enabled: datadog.PtrBool(false), + MinRuns: datadog.PtrInt64(10), + Status: datadogV2.TESTOPTIMIZATIONFLAKYTESTSMANAGEMENTPOLICIESDISABLEDSTATUS_ACTIVE.Ptr(), + Threshold: datadog.PtrFloat64(0.5), + }, + }, + Quarantined: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesQuarantined{ + AutoQuarantineRule: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule{ + Enabled: datadog.PtrBool(true), + WindowSeconds: datadog.PtrInt64(3600), + }, + BranchRule: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesBranchRule{ + Branches: []string{ + "main", + }, + Enabled: datadog.PtrBool(true), + ExcludedBranches: []string{}, + ExcludedTestServices: []string{}, + }, + Enabled: datadog.PtrBool(true), + FailureRateRule: &datadogV2.TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule{ + Branches: []string{ + "main", + }, + Enabled: datadog.PtrBool(true), + MinRuns: datadog.PtrInt64(10), + Threshold: datadog.PtrFloat64(0.5), + }, + }, + RepositoryId: "github.com/datadog/shopist", + }, + Type: datadogV2.TESTOPTIMIZATIONUPDATEFLAKYTESTSMANAGEMENTPOLICIESREQUESTDATATYPE_TEST_OPTIMIZATION_UPDATE_FLAKY_TESTS_MANAGEMENT_POLICIES_REQUEST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateFlakyTestsManagementPolicies", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewTestOptimizationApi(apiClient) + resp, r, err := api.UpdateFlakyTestsManagementPolicies(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `TestOptimizationApi.UpdateFlakyTestsManagementPolicies`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `TestOptimizationApi.UpdateFlakyTestsManagementPolicies`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index a9dafc100af..e29711a1b4e 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -56,6 +56,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "AppBuilderApi": reflect.ValueOf(datadogV2.NewAppBuilderApi), "AuditApi": reflect.ValueOf(datadogV2.NewAuditApi), "AuthNMappingsApi": reflect.ValueOf(datadogV2.NewAuthNMappingsApi), + "BitsAIApi": reflect.ValueOf(datadogV2.NewBitsAIApi), "CaseManagementApi": reflect.ValueOf(datadogV2.NewCaseManagementApi), "CaseManagementTypeApi": reflect.ValueOf(datadogV2.NewCaseManagementTypeApi), "CaseManagementAttributeApi": reflect.ValueOf(datadogV2.NewCaseManagementAttributeApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_destination_token_strategy_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_destination_token_strategy_returns_OK_response.freeze new file mode 100644 index 00000000000..8aa26c0186a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_destination_token_strategy_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-08T15:11:59.762Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_destination_token_strategy_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_destination_token_strategy_returns_OK_response.yaml new file mode 100644 index 00000000000..8d3c9704ca3 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_destination_token_strategy_returns_OK_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"config":{"destinations":[{"id":"splunk-hec-destination","inputs":["my-processor-group"],"token_key":"SPLUNK_HEC_TOKEN","token_strategy":"custom","type":"splunk_hec"}],"processor_groups":[{"enabled":true,"id":"my-processor-group","include":"service:my-service","inputs":["datadog-agent-source"],"processors":[{"enabled":true,"id":"filter-processor","include":"status:error","type":"filter"}]}],"sources":[{"id":"datadog-agent-source","type":"datadog_agent"}]},"name":"Pipeline with Splunk HEC token_strategy"},"type":"pipelines"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/obs-pipelines/pipelines/validate + response: + body: '{"errors":[]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_source_store_hec_token_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_source_store_hec_token_returns_OK_response.freeze new file mode 100644 index 00000000000..9f348b438cf --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_source_store_hec_token_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-08T15:11:59.370Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_source_store_hec_token_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_source_store_hec_token_returns_OK_response.yaml new file mode 100644 index 00000000000..d6303a624ad --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_Splunk_HEC_source_store_hec_token_returns_OK_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"config":{"destinations":[{"id":"datadog-logs-destination","inputs":["my-processor-group"],"type":"datadog_logs"}],"processor_groups":[{"enabled":true,"id":"my-processor-group","include":"service:my-service","inputs":["splunk-hec-source"],"processors":[{"enabled":true,"id":"filter-processor","include":"status:error","type":"filter"}]}],"sources":[{"id":"splunk-hec-source","store_hec_token":true,"type":"splunk_hec"}]},"name":"Pipeline with Splunk HEC store_hec_token"},"type":"pipelines"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/obs-pipelines/pipelines/validate + response: + body: '{"errors":[]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_enrichment_table_secret_field_lookup_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_enrichment_table_secret_field_lookup_returns_OK_response.freeze new file mode 100644 index 00000000000..01da474ec31 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_enrichment_table_secret_field_lookup_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-09T11:54:29.220Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_enrichment_table_secret_field_lookup_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_enrichment_table_secret_field_lookup_returns_OK_response.yaml new file mode 100644 index 00000000000..fabbf74b2b0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Observability_Pipelines/Scenario_Validate_an_observability_pipeline_with_enrichment_table_secret_field_lookup_returns_OK_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"config":{"destinations":[{"id":"datadog-logs-destination","inputs":["my-processor-group"],"type":"datadog_logs"}],"processor_groups":[{"enabled":true,"id":"my-processor-group","include":"service:my-service","inputs":["datadog-agent-source"],"processors":[{"enabled":true,"file":{"encoding":{"delimiter":",","includes_headers":true,"type":"csv"},"key":[{"column":"user_id","comparison":"equals","field":{"secret":"LOOKUP_KEY_SECRET"}}],"path":"/etc/enrichment/lookup.csv","schema":[{"column":"user_id","type":"string"}]},"id":"enrichment-processor","include":"*","target":"enriched","type":"enrichment_table"}]}],"sources":[{"id":"datadog-agent-source","type":"datadog_agent"}]},"name":"Pipeline with Enrichment Table Secret Field Lookup"},"type":"pipelines"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/obs-pipelines/pipelines/validate + response: + body: '{"errors":[]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v2/bits_ai.feature b/tests/scenarios/features/v2/bits_ai.feature new file mode 100644 index 00000000000..bc5ec941d8f --- /dev/null +++ b/tests/scenarios/features/v2/bits_ai.feature @@ -0,0 +1,69 @@ +@endpoint(bits-ai) @endpoint(bits-ai-v2) +Feature: Bits AI + Use the Bits AI endpoints to retrieve AI-powered investigations. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "BitsAI" API + + @generated @skip @team:DataDog/bits-ai + Scenario: Get a Bits AI investigation returns "Bad Request" response + Given operation "GetInvestigation" enabled + And new "GetInvestigation" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/bits-ai + Scenario: Get a Bits AI investigation returns "Not Found" response + Given operation "GetInvestigation" enabled + And new "GetInvestigation" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/bits-ai + Scenario: Get a Bits AI investigation returns "OK" response + Given operation "GetInvestigation" enabled + And new "GetInvestigation" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/bits-ai + Scenario: List Bits AI investigations returns "Bad Request" response + Given operation "ListInvestigations" enabled + And new "ListInvestigations" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/bits-ai + Scenario: List Bits AI investigations returns "OK" response + Given operation "ListInvestigations" enabled + And new "ListInvestigations" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/bits-ai @with-pagination + Scenario: List Bits AI investigations returns "OK" response with pagination + Given operation "ListInvestigations" enabled + And new "ListInvestigations" request + When the request with pagination is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/bits-ai + Scenario: Trigger a Bits AI investigation returns "Bad Request" response + Given operation "TriggerInvestigation" enabled + And new "TriggerInvestigation" request + And body with value {"data": {"attributes": {"trigger": {"monitor_alert_trigger": {"event_id": "1234567890123456789", "event_ts": 1700000000000, "monitor_id": 12345678}, "type": "monitor_alert_trigger"}}, "type": "trigger_investigation_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/bits-ai + Scenario: Trigger a Bits AI investigation returns "OK" response + Given operation "TriggerInvestigation" enabled + And new "TriggerInvestigation" request + And body with value {"data": {"attributes": {"trigger": {"monitor_alert_trigger": {"event_id": "1234567890123456789", "event_ts": 1700000000000, "monitor_id": 12345678}, "type": "monitor_alert_trigger"}}, "type": "trigger_investigation_request"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/observability_pipelines.feature b/tests/scenarios/features/v2/observability_pipelines.feature index 96a0bbc6cba..887f147074d 100644 --- a/tests/scenarios/features/v2/observability_pipelines.feature +++ b/tests/scenarios/features/v2/observability_pipelines.feature @@ -207,6 +207,22 @@ Feature: Observability Pipelines Then the response status is 200 OK And the response "errors" has length 0 + @team:DataDog/observability-pipelines + Scenario: Validate an observability pipeline with Splunk HEC destination token_strategy returns "OK" response + Given new "ValidatePipeline" request + And body with value {"data": {"attributes": {"config": {"destinations": [{"id": "splunk-hec-destination", "inputs": ["my-processor-group"], "type": "splunk_hec", "token_key": "SPLUNK_HEC_TOKEN", "token_strategy": "custom"}], "processor_groups": [{"enabled": true, "id": "my-processor-group", "include": "service:my-service", "inputs": ["datadog-agent-source"], "processors": [{"enabled": true, "id": "filter-processor", "include": "status:error", "type": "filter"}]}], "sources": [{"id": "datadog-agent-source", "type": "datadog_agent"}]}, "name": "Pipeline with Splunk HEC token_strategy"}, "type": "pipelines"}} + When the request is sent + Then the response status is 200 OK + And the response "errors" has length 0 + + @team:DataDog/observability-pipelines + Scenario: Validate an observability pipeline with Splunk HEC source store_hec_token returns "OK" response + Given new "ValidatePipeline" request + And body with value {"data": {"attributes": {"config": {"destinations": [{"id": "datadog-logs-destination", "inputs": ["my-processor-group"], "type": "datadog_logs"}], "processor_groups": [{"enabled": true, "id": "my-processor-group", "include": "service:my-service", "inputs": ["splunk-hec-source"], "processors": [{"enabled": true, "id": "filter-processor", "include": "status:error", "type": "filter"}]}], "sources": [{"id": "splunk-hec-source", "type": "splunk_hec", "store_hec_token": true}]}, "name": "Pipeline with Splunk HEC store_hec_token"}, "type": "pipelines"}} + When the request is sent + Then the response status is 200 OK + And the response "errors" has length 0 + @team:DataDog/observability-pipelines Scenario: Validate an observability pipeline with amazon S3 source compression returns "OK" response Given new "ValidatePipeline" request @@ -223,6 +239,14 @@ Feature: Observability Pipelines Then the response status is 200 OK And the response "errors" has length 0 + @team:DataDog/observability-pipelines + Scenario: Validate an observability pipeline with enrichment table secret field lookup returns "OK" response + Given new "ValidatePipeline" request + And body with value {"data": {"attributes": {"config": {"destinations": [{"id": "datadog-logs-destination", "inputs": ["my-processor-group"], "type": "datadog_logs"}], "processor_groups": [{"enabled": true, "id": "my-processor-group", "include": "service:my-service", "inputs": ["datadog-agent-source"], "processors": [{"enabled": true, "id": "enrichment-processor", "include": "*", "target": "enriched", "type": "enrichment_table", "file": {"encoding": {"delimiter": ",", "type": "csv", "includes_headers": true}, "key": [{"column": "user_id", "comparison": "equals", "field": {"secret": "LOOKUP_KEY_SECRET"}}], "path": "/etc/enrichment/lookup.csv", "schema": [{"column": "user_id", "type": "string"}]}}]}], "sources": [{"id": "datadog-agent-source", "type": "datadog_agent"}]}, "name": "Pipeline with Enrichment Table Secret Field Lookup"}, "type": "pipelines"}} + When the request is sent + Then the response status is 200 OK + And the response "errors" has length 0 + @team:DataDog/observability-pipelines Scenario: Validate an observability pipeline with source secret key returns "OK" response Given new "ValidatePipeline" request diff --git a/tests/scenarios/features/v2/test_optimization.feature b/tests/scenarios/features/v2/test_optimization.feature index 427db05baf4..eeeec1dd340 100644 --- a/tests/scenarios/features/v2/test_optimization.feature +++ b/tests/scenarios/features/v2/test_optimization.feature @@ -33,6 +33,38 @@ Feature: Test Optimization When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get Flaky Tests Management policies returns "Bad Request" response + Given operation "GetFlakyTestsManagementPolicies" enabled + And new "GetFlakyTestsManagementPolicies" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist"}, "type": "test_optimization_get_flaky_tests_management_policies_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get Flaky Tests Management policies returns "Not Found" response + Given operation "GetFlakyTestsManagementPolicies" enabled + And new "GetFlakyTestsManagementPolicies" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist"}, "type": "test_optimization_get_flaky_tests_management_policies_request"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get Flaky Tests Management policies returns "OK" response + Given operation "GetFlakyTestsManagementPolicies" enabled + And new "GetFlakyTestsManagementPolicies" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist"}, "type": "test_optimization_get_flaky_tests_management_policies_request"}} + When the request is sent + Then the response status is 200 OK + + @skip @team:DataDog/ci-app-backend + Scenario: Get Flaky Tests Management policies with empty repository_id returns bad request + Given operation "GetFlakyTestsManagementPolicies" enabled + And new "GetFlakyTestsManagementPolicies" request + And body with value {"data": {"attributes": {"repository_id": ""}, "type": "test_optimization_get_flaky_tests_management_policies_request"}} + When the request is sent + Then the response status is 400 Bad Request + @generated @skip @team:DataDog/ci-app-backend Scenario: Get Test Optimization service settings returns "Bad Request" response Given operation "GetTestOptimizationServiceSettings" enabled @@ -133,6 +165,38 @@ Feature: Test Optimization When the request with pagination is sent Then the response status is 200 OK + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update Flaky Tests Management policies returns "Bad Request" response + Given operation "UpdateFlakyTestsManagementPolicies" enabled + And new "UpdateFlakyTestsManagementPolicies" request + And body with value {"data": {"attributes": {"attempt_to_fix": {"retries": 3}, "disabled": {"auto_disable_rule": {"enabled": false, "status": "active", "window_seconds": 3600}, "branch_rule": {"branches": ["main"], "enabled": true, "excluded_branches": [], "excluded_test_services": []}, "enabled": false, "failure_rate_rule": {"branches": [], "enabled": false, "min_runs": 10, "status": "active", "threshold": 0.5}}, "quarantined": {"auto_quarantine_rule": {"enabled": true, "window_seconds": 3600}, "branch_rule": {"branches": ["main"], "enabled": true, "excluded_branches": [], "excluded_test_services": []}, "enabled": true, "failure_rate_rule": {"branches": ["main"], "enabled": true, "min_runs": 10, "threshold": 0.5}}, "repository_id": "github.com/datadog/shopist"}, "type": "test_optimization_update_flaky_tests_management_policies_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update Flaky Tests Management policies returns "Not Found" response + Given operation "UpdateFlakyTestsManagementPolicies" enabled + And new "UpdateFlakyTestsManagementPolicies" request + And body with value {"data": {"attributes": {"attempt_to_fix": {"retries": 3}, "disabled": {"auto_disable_rule": {"enabled": false, "status": "active", "window_seconds": 3600}, "branch_rule": {"branches": ["main"], "enabled": true, "excluded_branches": [], "excluded_test_services": []}, "enabled": false, "failure_rate_rule": {"branches": [], "enabled": false, "min_runs": 10, "status": "active", "threshold": 0.5}}, "quarantined": {"auto_quarantine_rule": {"enabled": true, "window_seconds": 3600}, "branch_rule": {"branches": ["main"], "enabled": true, "excluded_branches": [], "excluded_test_services": []}, "enabled": true, "failure_rate_rule": {"branches": ["main"], "enabled": true, "min_runs": 10, "threshold": 0.5}}, "repository_id": "github.com/datadog/shopist"}, "type": "test_optimization_update_flaky_tests_management_policies_request"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update Flaky Tests Management policies returns "OK" response + Given operation "UpdateFlakyTestsManagementPolicies" enabled + And new "UpdateFlakyTestsManagementPolicies" request + And body with value {"data": {"attributes": {"attempt_to_fix": {"retries": 3}, "disabled": {"auto_disable_rule": {"enabled": false, "status": "active", "window_seconds": 3600}, "branch_rule": {"branches": ["main"], "enabled": true, "excluded_branches": [], "excluded_test_services": []}, "enabled": false, "failure_rate_rule": {"branches": [], "enabled": false, "min_runs": 10, "status": "active", "threshold": 0.5}}, "quarantined": {"auto_quarantine_rule": {"enabled": true, "window_seconds": 3600}, "branch_rule": {"branches": ["main"], "enabled": true, "excluded_branches": [], "excluded_test_services": []}, "enabled": true, "failure_rate_rule": {"branches": ["main"], "enabled": true, "min_runs": 10, "threshold": 0.5}}, "repository_id": "github.com/datadog/shopist"}, "type": "test_optimization_update_flaky_tests_management_policies_request"}} + When the request is sent + Then the response status is 200 OK + + @skip @team:DataDog/ci-app-backend + Scenario: Update Flaky Tests Management policies with empty repository_id returns bad request + Given operation "UpdateFlakyTestsManagementPolicies" enabled + And new "UpdateFlakyTestsManagementPolicies" request + And body with value {"data": {"attributes": {"repository_id": ""}, "type": "test_optimization_update_flaky_tests_management_policies_request"}} + When the request is sent + Then the response status is 400 Bad Request + @generated @skip @team:DataDog/ci-app-backend Scenario: Update Test Optimization service settings returns "Bad Request" response Given operation "UpdateTestOptimizationServiceSettings" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 078ced2bd84..19a52adbfc2 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -650,6 +650,24 @@ "type": "idempotent" } }, + "ListInvestigations": { + "tag": "Bits AI", + "undo": { + "type": "safe" + } + }, + "TriggerInvestigation": { + "tag": "Bits AI", + "undo": { + "type": "unsafe" + } + }, + "GetInvestigation": { + "tag": "Bits AI", + "undo": { + "type": "safe" + } + }, "SearchCases": { "tag": "Case Management", "undo": { @@ -1036,6 +1054,18 @@ "type": "safe" } }, + "UpdateFlakyTestsManagementPolicies": { + "tag": "Test Optimization", + "undo": { + "type": "unsafe" + } + }, + "GetFlakyTestsManagementPolicies": { + "tag": "Test Optimization", + "undo": { + "type": "safe" + } + }, "DeleteTestOptimizationServiceSettings": { "tag": "Test Optimization", "undo": {