diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 62fbf9422f2..c26a927e835 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -50318,6 +50318,72 @@ components: required: - name type: object + LicensesListResponse: + description: The top-level response object returned by the licenses list endpoint, containing the array of supported SPDX licenses. + properties: + data: + $ref: "#/components/schemas/LicensesListResponseData" + required: + - data + type: object + LicensesListResponseData: + description: The data object in a licenses list response, containing the list of SPDX licenses. + properties: + attributes: + $ref: "#/components/schemas/LicensesListResponseDataAttributes" + id: + description: The unique identifier for this licenses list response. + example: 0190a3d4-1234-7000-8000-000000000000 + type: string + type: + $ref: "#/components/schemas/LicensesListResponseDataType" + required: + - id + - type + - attributes + type: object + LicensesListResponseDataAttributes: + description: The attributes of the licenses list response, containing the array of SPDX licenses. + properties: + licenses: + $ref: "#/components/schemas/LicensesListResponseDataAttributesLicenses" + required: + - licenses + type: object + LicensesListResponseDataAttributesLicenses: + description: The list of SPDX licenses returned by the API. + items: + $ref: "#/components/schemas/LicensesListResponseDataAttributesLicensesItems" + type: array + LicensesListResponseDataAttributesLicensesItems: + description: An SPDX license entry returned by the licenses list endpoint. + properties: + display_name: + description: The human-readable name of the license. + example: MIT License + type: string + identifier: + description: The SPDX identifier of the license. + example: MIT + type: string + short_name: + description: The short name of the license, typically matching the SPDX identifier. + example: MIT + type: string + required: + - display_name + - identifier + - short_name + type: object + LicensesListResponseDataType: + default: licenserequest + description: The type identifier for license list responses. + enum: + - licenserequest + example: licenserequest + type: string + x-enum-varnames: + - LICENSEREQUEST Links: description: The JSON:API links related to pagination. properties: @@ -53122,6 +53188,144 @@ components: type: string x-enum-varnames: - MANAGED_ORGS + McpScanRequest: + description: The top-level request object for submitting an MCP SCA dependency scan. + properties: + data: + $ref: "#/components/schemas/McpScanRequestData" + required: + - data + type: object + McpScanRequestData: + description: The data object in an MCP SCA scan request, containing the scan attributes and request type. + properties: + attributes: + $ref: "#/components/schemas/McpScanRequestDataAttributes" + id: + description: An optional identifier for this scan request. + type: string + type: + $ref: "#/components/schemas/McpScanRequestDataType" + required: + - type + - attributes + type: object + McpScanRequestDataAttributes: + description: The attributes of an MCP SCA scan request, describing the libraries to scan and their context. + properties: + commit_hash: + description: The commit hash of the source code being scanned. + example: 0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc + type: string + libraries: + $ref: "#/components/schemas/McpScanRequestDataAttributesLibraries" + resource_name: + description: The name of the resource (typically the repository or project name) being scanned. + example: my-org/my-repo + type: string + required: + - resource_name + - commit_hash + - libraries + type: object + McpScanRequestDataAttributesLibraries: + description: The list of libraries to scan for vulnerabilities. + items: + $ref: "#/components/schemas/McpScanRequestDataAttributesLibrariesItems" + type: array + McpScanRequestDataAttributesLibrariesItems: + description: A library declaration to include in the dependency scan. + properties: + exclusions: + $ref: "#/components/schemas/McpScanRequestDataAttributesLibrariesItemsExclusions" + is_dev: + description: Whether this library is a development-only dependency. + example: false + type: boolean + is_direct: + description: Whether this library is a direct (rather than transitive) dependency. + example: true + type: boolean + package_manager: + description: The package manager that produced this library entry (for example, `npm`, `pip`, `nuget`). + example: nuget + type: string + purl: + description: The Package URL (PURL) uniquely identifying the library and its version. + example: pkg:nuget/Newtonsoft.Json@13.0.1 + type: string + target_frameworks: + $ref: "#/components/schemas/McpScanRequestDataAttributesLibrariesItemsTargetFrameworks" + required: + - purl + - is_dev + - is_direct + - package_manager + type: object + McpScanRequestDataAttributesLibrariesItemsExclusions: + description: The list of dependency PURLs to exclude when resolving transitive dependencies for this library. + items: + description: A dependency PURL to exclude. + type: string + type: array + McpScanRequestDataAttributesLibrariesItemsTargetFrameworks: + description: The list of target framework identifiers associated with the library. + items: + description: A target framework identifier (for example, `net8.0`). + type: string + type: array + McpScanRequestDataType: + default: mcpscanrequest + description: The type identifier for MCP SCA scan requests. + enum: + - mcpscanrequest + example: mcpscanrequest + type: string + x-enum-varnames: + - MCPSCANREQUEST + McpScanRequestResponse: + description: The top-level response object returned when an MCP SCA dependency scan request has been accepted. + properties: + data: + $ref: "#/components/schemas/McpScanRequestResponseData" + required: + - data + type: object + McpScanRequestResponseData: + description: The data object returned when a scan request has been accepted. + properties: + attributes: + $ref: "#/components/schemas/McpScanRequestResponseDataAttributes" + id: + description: The job identifier assigned to the scan. + example: 0190a3d4-1234-7000-8000-000000000000 + type: string + type: + $ref: "#/components/schemas/McpScanRequestResponseDataType" + required: + - id + - type + - attributes + type: object + McpScanRequestResponseDataAttributes: + description: The attributes returned when a scan request has been accepted, containing the job identifier used to poll for results. + properties: + job_id: + description: The job identifier assigned to the scan, used to retrieve the scan result. + example: 0190a3d4-1234-7000-8000-000000000000 + type: string + required: + - job_id + type: object + McpScanRequestResponseDataType: + default: mcpscanrequestresponse + description: The type identifier for MCP SCA scan request responses. + enum: + - mcpscanrequestresponse + example: mcpscanrequestresponse + type: string + x-enum-varnames: + - MCPSCANREQUESTRESPONSE MemberTeam: description: A member team properties: @@ -74996,6 +75200,13 @@ components: type: $ref: "#/components/schemas/ScalarFormulaResponseType" type: object + ScanResultResponse: + description: |- + The raw scan result document produced by the SCA processor. + The contents reflect the vulnerabilities and metadata produced for the libraries + submitted in the original scan request. + oneOf: + - $ref: "#/components/schemas/AnyValueObject" ScannedAssetMetadata: description: The metadata of a scanned asset. properties: @@ -164165,6 +164376,138 @@ paths: tags: - Static Analysis x-unstable: "**Note**: This endpoint may be subject to changes." + /api/v2/static-analysis-sca/dependencies/scan: + post: + operationId: CreateSCAScan + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + commit_hash: 0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc + libraries: + - exclusions: [] + is_dev: false + is_direct: true + package_manager: nuget + purl: pkg:nuget/Newtonsoft.Json@13.0.1 + target_frameworks: + - net8.0 + resource_name: my-org/my-repo + type: mcpscanrequest + schema: + $ref: "#/components/schemas/McpScanRequest" + required: true + responses: + "202": + content: + application/json: + examples: + default: + value: + data: + attributes: + job_id: 0190a3d4-1234-7000-8000-000000000000 + id: 0190a3d4-1234-7000-8000-000000000000 + type: mcpscanrequestresponse + schema: + $ref: "#/components/schemas/McpScanRequestResponse" + description: Accepted + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - code_analysis_read + summary: Submit libraries for vulnerability scanning + tags: + - Static Analysis + 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/static-analysis-sca/dependencies/scan/{job_id}: + get: + operationId: GetSCAScan + parameters: + - description: The job identifier returned when the scan was submitted. + in: path + name: job_id + required: true + schema: + example: 0190a3d4-1234-7000-8000-000000000000 + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + vulnerabilities: [] + schema: + $ref: "#/components/schemas/ScanResultResponse" + description: OK + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - code_analysis_read + summary: Retrieve a dependency scan result + tags: + - Static Analysis + 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/static-analysis-sca/licenses/list: + get: + operationId: ListSCALicenses + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + licenses: + - display_name: MIT License + identifier: MIT + short_name: MIT + id: 0190a3d4-1234-7000-8000-000000000000 + type: licenserequest + schema: + $ref: "#/components/schemas/LicensesListResponse" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get the list of SPDX licenses + tags: + - Static Analysis + 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/static-analysis-sca/vulnerabilities/resolve-vulnerable-symbols: post: operationId: CreateSCAResolveVulnerableSymbols diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 24a4de54d85..8cc541b49e8 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -1061,6 +1061,7 @@ func NewConfiguration() *Configuration { "v2.CreateCustomRuleset": false, "v2.CreateSCAResolveVulnerableSymbols": false, "v2.CreateSCAResult": false, + "v2.CreateSCAScan": false, "v2.DeleteAiCustomRule": false, "v2.DeleteAiCustomRuleset": false, "v2.DeleteAiMemoryViolationResult": false, @@ -1072,12 +1073,14 @@ func NewConfiguration() *Configuration { "v2.GetCustomRule": false, "v2.GetCustomRuleRevision": false, "v2.GetCustomRuleset": false, + "v2.GetSCAScan": false, "v2.ListAiCustomRuleRevisions": false, "v2.ListAiCustomRulesets": false, "v2.ListAiMemoryViolationResults": false, "v2.ListAiPrompts": false, "v2.ListCustomRuleRevisions": false, "v2.ListCustomRulesets": false, + "v2.ListSCALicenses": false, "v2.RevertCustomRuleRevision": false, "v2.UpdateAiCustomRuleset": false, "v2.UpdateCustomRuleset": false, diff --git a/api/datadogV2/api_static_analysis.go b/api/datadogV2/api_static_analysis.go index d8b9f1ca370..8d07b0abd57 100644 --- a/api/datadogV2/api_static_analysis.go +++ b/api/datadogV2/api_static_analysis.go @@ -847,6 +847,104 @@ func (a *StaticAnalysisApi) CreateSCAResult(ctx _context.Context, body ScaReques return localVarHTTPResponse, nil } +// CreateSCAScan Submit libraries for vulnerability scanning. + +func (a *StaticAnalysisApi) CreateSCAScan(ctx _context.Context, body McpScanRequest) (McpScanRequestResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue McpScanRequestResponse + ) + + operationId := "v2.CreateSCAScan" + 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.StaticAnalysisApi.CreateSCAScan") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/static-analysis-sca/dependencies/scan" + + 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 +} + // DeleteAiCustomRule Delete an AI custom rule. // Delete an AI custom rule by name within a ruleset. func (a *StaticAnalysisApi) DeleteAiCustomRule(ctx _context.Context, rulesetName string, ruleName string) (*_nethttp.Response, error) { @@ -1861,6 +1959,102 @@ func (a *StaticAnalysisApi) GetCustomRuleset(ctx _context.Context, rulesetName s return localVarReturnValue, localVarHTTPResponse, nil } +// GetSCAScan Retrieve a dependency scan result. + +func (a *StaticAnalysisApi) GetSCAScan(ctx _context.Context, jobId string) (ScanResultResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ScanResultResponse + ) + + operationId := "v2.GetSCAScan" + 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.StaticAnalysisApi.GetSCAScan") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/static-analysis-sca/dependencies/scan/{job_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{job_id}", _neturl.PathEscape(datadog.ParameterToString(jobId, ""))) + + 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 == 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 +} + // ListAiCustomRuleRevisionsOptionalParameters holds optional parameters for ListAiCustomRuleRevisions. type ListAiCustomRuleRevisionsOptionalParameters struct { PageOffset *int64 @@ -2640,6 +2834,92 @@ func (a *StaticAnalysisApi) ListCustomRulesets(ctx _context.Context) (CustomRule return localVarReturnValue, localVarHTTPResponse, nil } +// ListSCALicenses Get the list of SPDX licenses. + +func (a *StaticAnalysisApi) ListSCALicenses(ctx _context.Context) (LicensesListResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue LicensesListResponse + ) + + operationId := "v2.ListSCALicenses" + 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.StaticAnalysisApi.ListSCALicenses") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/static-analysis-sca/licenses/list" + + 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 == 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 +} + // RevertCustomRuleRevision Revert Custom Rule Revision. // Revert a custom rule to a previous revision func (a *StaticAnalysisApi) RevertCustomRuleRevision(ctx _context.Context, rulesetName string, ruleName string, body RevertCustomRuleRevisionRequest) (*_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 1eb9f563eef..f826bbb517d 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -1084,6 +1084,7 @@ // - [StaticAnalysisApi.CreateCustomRuleset] // - [StaticAnalysisApi.CreateSCAResolveVulnerableSymbols] // - [StaticAnalysisApi.CreateSCAResult] +// - [StaticAnalysisApi.CreateSCAScan] // - [StaticAnalysisApi.DeleteAiCustomRule] // - [StaticAnalysisApi.DeleteAiCustomRuleset] // - [StaticAnalysisApi.DeleteAiMemoryViolationResult] @@ -1095,12 +1096,14 @@ // - [StaticAnalysisApi.GetCustomRule] // - [StaticAnalysisApi.GetCustomRuleRevision] // - [StaticAnalysisApi.GetCustomRuleset] +// - [StaticAnalysisApi.GetSCAScan] // - [StaticAnalysisApi.ListAiCustomRuleRevisions] // - [StaticAnalysisApi.ListAiCustomRulesets] // - [StaticAnalysisApi.ListAiMemoryViolationResults] // - [StaticAnalysisApi.ListAiPrompts] // - [StaticAnalysisApi.ListCustomRuleRevisions] // - [StaticAnalysisApi.ListCustomRulesets] +// - [StaticAnalysisApi.ListSCALicenses] // - [StaticAnalysisApi.RevertCustomRuleRevision] // - [StaticAnalysisApi.UpdateAiCustomRuleset] // - [StaticAnalysisApi.UpdateCustomRuleset] diff --git a/api/datadogV2/model_licenses_list_response.go b/api/datadogV2/model_licenses_list_response.go new file mode 100644 index 00000000000..86dfbe92c28 --- /dev/null +++ b/api/datadogV2/model_licenses_list_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" +) + +// LicensesListResponse The top-level response object returned by the licenses list endpoint, containing the array of supported SPDX licenses. +type LicensesListResponse struct { + // The data object in a licenses list response, containing the list of SPDX licenses. + Data LicensesListResponseData `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:"-"` +} + +// NewLicensesListResponse instantiates a new LicensesListResponse 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 NewLicensesListResponse(data LicensesListResponseData) *LicensesListResponse { + this := LicensesListResponse{} + this.Data = data + return &this +} + +// NewLicensesListResponseWithDefaults instantiates a new LicensesListResponse 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 NewLicensesListResponseWithDefaults() *LicensesListResponse { + this := LicensesListResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *LicensesListResponse) GetData() LicensesListResponseData { + if o == nil { + var ret LicensesListResponseData + 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 *LicensesListResponse) GetDataOk() (*LicensesListResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *LicensesListResponse) SetData(v LicensesListResponseData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o LicensesListResponse) 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 *LicensesListResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *LicensesListResponseData `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.UnmarshalUseNumber(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_licenses_list_response_data.go b/api/datadogV2/model_licenses_list_response_data.go new file mode 100644 index 00000000000..4e7d427377b --- /dev/null +++ b/api/datadogV2/model_licenses_list_response_data.go @@ -0,0 +1,180 @@ +// 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" +) + +// LicensesListResponseData The data object in a licenses list response, containing the list of SPDX licenses. +type LicensesListResponseData struct { + // The attributes of the licenses list response, containing the array of SPDX licenses. + Attributes LicensesListResponseDataAttributes `json:"attributes"` + // The unique identifier for this licenses list response. + Id string `json:"id"` + // The type identifier for license list responses. + Type LicensesListResponseDataType `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:"-"` +} + +// NewLicensesListResponseData instantiates a new LicensesListResponseData 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 NewLicensesListResponseData(attributes LicensesListResponseDataAttributes, id string, typeVar LicensesListResponseDataType) *LicensesListResponseData { + this := LicensesListResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewLicensesListResponseDataWithDefaults instantiates a new LicensesListResponseData 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 NewLicensesListResponseDataWithDefaults() *LicensesListResponseData { + this := LicensesListResponseData{} + var typeVar LicensesListResponseDataType = LICENSESLISTRESPONSEDATATYPE_LICENSEREQUEST + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *LicensesListResponseData) GetAttributes() LicensesListResponseDataAttributes { + if o == nil { + var ret LicensesListResponseDataAttributes + 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 *LicensesListResponseData) GetAttributesOk() (*LicensesListResponseDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *LicensesListResponseData) SetAttributes(v LicensesListResponseDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *LicensesListResponseData) 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 *LicensesListResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *LicensesListResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *LicensesListResponseData) GetType() LicensesListResponseDataType { + if o == nil { + var ret LicensesListResponseDataType + 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 *LicensesListResponseData) GetTypeOk() (*LicensesListResponseDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *LicensesListResponseData) SetType(v LicensesListResponseDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o LicensesListResponseData) 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 *LicensesListResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *LicensesListResponseDataAttributes `json:"attributes"` + Id *string `json:"id"` + Type *LicensesListResponseDataType `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.UnmarshalUseNumber(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_licenses_list_response_data_attributes.go b/api/datadogV2/model_licenses_list_response_data_attributes.go new file mode 100644 index 00000000000..cf6bc09d948 --- /dev/null +++ b/api/datadogV2/model_licenses_list_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" +) + +// LicensesListResponseDataAttributes The attributes of the licenses list response, containing the array of SPDX licenses. +type LicensesListResponseDataAttributes struct { + // The list of SPDX licenses returned by the API. + Licenses []LicensesListResponseDataAttributesLicensesItems `json:"licenses"` + // 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:"-"` +} + +// NewLicensesListResponseDataAttributes instantiates a new LicensesListResponseDataAttributes 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 NewLicensesListResponseDataAttributes(licenses []LicensesListResponseDataAttributesLicensesItems) *LicensesListResponseDataAttributes { + this := LicensesListResponseDataAttributes{} + this.Licenses = licenses + return &this +} + +// NewLicensesListResponseDataAttributesWithDefaults instantiates a new LicensesListResponseDataAttributes 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 NewLicensesListResponseDataAttributesWithDefaults() *LicensesListResponseDataAttributes { + this := LicensesListResponseDataAttributes{} + return &this +} + +// GetLicenses returns the Licenses field value. +func (o *LicensesListResponseDataAttributes) GetLicenses() []LicensesListResponseDataAttributesLicensesItems { + if o == nil { + var ret []LicensesListResponseDataAttributesLicensesItems + return ret + } + return o.Licenses +} + +// GetLicensesOk returns a tuple with the Licenses field value +// and a boolean to check if the value has been set. +func (o *LicensesListResponseDataAttributes) GetLicensesOk() (*[]LicensesListResponseDataAttributesLicensesItems, bool) { + if o == nil { + return nil, false + } + return &o.Licenses, true +} + +// SetLicenses sets field value. +func (o *LicensesListResponseDataAttributes) SetLicenses(v []LicensesListResponseDataAttributesLicensesItems) { + o.Licenses = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o LicensesListResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["licenses"] = o.Licenses + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *LicensesListResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Licenses *[]LicensesListResponseDataAttributesLicensesItems `json:"licenses"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Licenses == nil { + return fmt.Errorf("required field licenses missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"licenses"}) + } else { + return err + } + o.Licenses = *all.Licenses + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_licenses_list_response_data_attributes_licenses_items.go b/api/datadogV2/model_licenses_list_response_data_attributes_licenses_items.go new file mode 100644 index 00000000000..4f802c55311 --- /dev/null +++ b/api/datadogV2/model_licenses_list_response_data_attributes_licenses_items.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" +) + +// LicensesListResponseDataAttributesLicensesItems An SPDX license entry returned by the licenses list endpoint. +type LicensesListResponseDataAttributesLicensesItems struct { + // The human-readable name of the license. + DisplayName string `json:"display_name"` + // The SPDX identifier of the license. + Identifier string `json:"identifier"` + // The short name of the license, typically matching the SPDX identifier. + ShortName string `json:"short_name"` + // 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:"-"` +} + +// NewLicensesListResponseDataAttributesLicensesItems instantiates a new LicensesListResponseDataAttributesLicensesItems 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 NewLicensesListResponseDataAttributesLicensesItems(displayName string, identifier string, shortName string) *LicensesListResponseDataAttributesLicensesItems { + this := LicensesListResponseDataAttributesLicensesItems{} + this.DisplayName = displayName + this.Identifier = identifier + this.ShortName = shortName + return &this +} + +// NewLicensesListResponseDataAttributesLicensesItemsWithDefaults instantiates a new LicensesListResponseDataAttributesLicensesItems 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 NewLicensesListResponseDataAttributesLicensesItemsWithDefaults() *LicensesListResponseDataAttributesLicensesItems { + this := LicensesListResponseDataAttributesLicensesItems{} + return &this +} + +// GetDisplayName returns the DisplayName field value. +func (o *LicensesListResponseDataAttributesLicensesItems) GetDisplayName() string { + if o == nil { + var ret string + return ret + } + return o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *LicensesListResponseDataAttributesLicensesItems) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DisplayName, true +} + +// SetDisplayName sets field value. +func (o *LicensesListResponseDataAttributesLicensesItems) SetDisplayName(v string) { + o.DisplayName = v +} + +// GetIdentifier returns the Identifier field value. +func (o *LicensesListResponseDataAttributesLicensesItems) GetIdentifier() string { + if o == nil { + var ret string + return ret + } + return o.Identifier +} + +// GetIdentifierOk returns a tuple with the Identifier field value +// and a boolean to check if the value has been set. +func (o *LicensesListResponseDataAttributesLicensesItems) GetIdentifierOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Identifier, true +} + +// SetIdentifier sets field value. +func (o *LicensesListResponseDataAttributesLicensesItems) SetIdentifier(v string) { + o.Identifier = v +} + +// GetShortName returns the ShortName field value. +func (o *LicensesListResponseDataAttributesLicensesItems) GetShortName() string { + if o == nil { + var ret string + return ret + } + return o.ShortName +} + +// GetShortNameOk returns a tuple with the ShortName field value +// and a boolean to check if the value has been set. +func (o *LicensesListResponseDataAttributesLicensesItems) GetShortNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ShortName, true +} + +// SetShortName sets field value. +func (o *LicensesListResponseDataAttributesLicensesItems) SetShortName(v string) { + o.ShortName = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o LicensesListResponseDataAttributesLicensesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["display_name"] = o.DisplayName + toSerialize["identifier"] = o.Identifier + toSerialize["short_name"] = o.ShortName + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *LicensesListResponseDataAttributesLicensesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DisplayName *string `json:"display_name"` + Identifier *string `json:"identifier"` + ShortName *string `json:"short_name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.DisplayName == nil { + return fmt.Errorf("required field display_name missing") + } + if all.Identifier == nil { + return fmt.Errorf("required field identifier missing") + } + if all.ShortName == nil { + return fmt.Errorf("required field short_name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"display_name", "identifier", "short_name"}) + } else { + return err + } + o.DisplayName = *all.DisplayName + o.Identifier = *all.Identifier + o.ShortName = *all.ShortName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_licenses_list_response_data_type.go b/api/datadogV2/model_licenses_list_response_data_type.go new file mode 100644 index 00000000000..33f71afee14 --- /dev/null +++ b/api/datadogV2/model_licenses_list_response_data_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" +) + +// LicensesListResponseDataType The type identifier for license list responses. +type LicensesListResponseDataType string + +// List of LicensesListResponseDataType. +const ( + LICENSESLISTRESPONSEDATATYPE_LICENSEREQUEST LicensesListResponseDataType = "licenserequest" +) + +var allowedLicensesListResponseDataTypeEnumValues = []LicensesListResponseDataType{ + LICENSESLISTRESPONSEDATATYPE_LICENSEREQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *LicensesListResponseDataType) GetAllowedValues() []LicensesListResponseDataType { + return allowedLicensesListResponseDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *LicensesListResponseDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = LicensesListResponseDataType(value) + return nil +} + +// NewLicensesListResponseDataTypeFromValue returns a pointer to a valid LicensesListResponseDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewLicensesListResponseDataTypeFromValue(v string) (*LicensesListResponseDataType, error) { + ev := LicensesListResponseDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for LicensesListResponseDataType: valid values are %v", v, allowedLicensesListResponseDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v LicensesListResponseDataType) IsValid() bool { + for _, existing := range allowedLicensesListResponseDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to LicensesListResponseDataType value. +func (v LicensesListResponseDataType) Ptr() *LicensesListResponseDataType { + return &v +} diff --git a/api/datadogV2/model_mcp_scan_request.go b/api/datadogV2/model_mcp_scan_request.go new file mode 100644 index 00000000000..a478bfd5740 --- /dev/null +++ b/api/datadogV2/model_mcp_scan_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" +) + +// McpScanRequest The top-level request object for submitting an MCP SCA dependency scan. +type McpScanRequest struct { + // The data object in an MCP SCA scan request, containing the scan attributes and request type. + Data McpScanRequestData `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:"-"` +} + +// NewMcpScanRequest instantiates a new McpScanRequest 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 NewMcpScanRequest(data McpScanRequestData) *McpScanRequest { + this := McpScanRequest{} + this.Data = data + return &this +} + +// NewMcpScanRequestWithDefaults instantiates a new McpScanRequest 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 NewMcpScanRequestWithDefaults() *McpScanRequest { + this := McpScanRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *McpScanRequest) GetData() McpScanRequestData { + if o == nil { + var ret McpScanRequestData + 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 *McpScanRequest) GetDataOk() (*McpScanRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *McpScanRequest) SetData(v McpScanRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o McpScanRequest) 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 *McpScanRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *McpScanRequestData `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.UnmarshalUseNumber(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_mcp_scan_request_data.go b/api/datadogV2/model_mcp_scan_request_data.go new file mode 100644 index 00000000000..a96c44f592c --- /dev/null +++ b/api/datadogV2/model_mcp_scan_request_data.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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// McpScanRequestData The data object in an MCP SCA scan request, containing the scan attributes and request type. +type McpScanRequestData struct { + // The attributes of an MCP SCA scan request, describing the libraries to scan and their context. + Attributes McpScanRequestDataAttributes `json:"attributes"` + // An optional identifier for this scan request. + Id *string `json:"id,omitempty"` + // The type identifier for MCP SCA scan requests. + Type McpScanRequestDataType `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:"-"` +} + +// NewMcpScanRequestData instantiates a new McpScanRequestData 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 NewMcpScanRequestData(attributes McpScanRequestDataAttributes, typeVar McpScanRequestDataType) *McpScanRequestData { + this := McpScanRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewMcpScanRequestDataWithDefaults instantiates a new McpScanRequestData 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 NewMcpScanRequestDataWithDefaults() *McpScanRequestData { + this := McpScanRequestData{} + var typeVar McpScanRequestDataType = MCPSCANREQUESTDATATYPE_MCPSCANREQUEST + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *McpScanRequestData) GetAttributes() McpScanRequestDataAttributes { + if o == nil { + var ret McpScanRequestDataAttributes + 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 *McpScanRequestData) GetAttributesOk() (*McpScanRequestDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *McpScanRequestData) SetAttributes(v McpScanRequestDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *McpScanRequestData) 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 *McpScanRequestData) 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 *McpScanRequestData) 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 *McpScanRequestData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value. +func (o *McpScanRequestData) GetType() McpScanRequestDataType { + if o == nil { + var ret McpScanRequestDataType + 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 *McpScanRequestData) GetTypeOk() (*McpScanRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *McpScanRequestData) SetType(v McpScanRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o McpScanRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + if o.Id != nil { + 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 *McpScanRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *McpScanRequestDataAttributes `json:"attributes"` + Id *string `json:"id,omitempty"` + Type *McpScanRequestDataType `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.UnmarshalUseNumber(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_mcp_scan_request_data_attributes.go b/api/datadogV2/model_mcp_scan_request_data_attributes.go new file mode 100644 index 00000000000..cf7a6de544d --- /dev/null +++ b/api/datadogV2/model_mcp_scan_request_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" +) + +// McpScanRequestDataAttributes The attributes of an MCP SCA scan request, describing the libraries to scan and their context. +type McpScanRequestDataAttributes struct { + // The commit hash of the source code being scanned. + CommitHash string `json:"commit_hash"` + // The list of libraries to scan for vulnerabilities. + Libraries []McpScanRequestDataAttributesLibrariesItems `json:"libraries"` + // The name of the resource (typically the repository or project name) being scanned. + ResourceName string `json:"resource_name"` + // 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:"-"` +} + +// NewMcpScanRequestDataAttributes instantiates a new McpScanRequestDataAttributes 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 NewMcpScanRequestDataAttributes(commitHash string, libraries []McpScanRequestDataAttributesLibrariesItems, resourceName string) *McpScanRequestDataAttributes { + this := McpScanRequestDataAttributes{} + this.CommitHash = commitHash + this.Libraries = libraries + this.ResourceName = resourceName + return &this +} + +// NewMcpScanRequestDataAttributesWithDefaults instantiates a new McpScanRequestDataAttributes 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 NewMcpScanRequestDataAttributesWithDefaults() *McpScanRequestDataAttributes { + this := McpScanRequestDataAttributes{} + return &this +} + +// GetCommitHash returns the CommitHash field value. +func (o *McpScanRequestDataAttributes) GetCommitHash() string { + if o == nil { + var ret string + return ret + } + return o.CommitHash +} + +// GetCommitHashOk returns a tuple with the CommitHash field value +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributes) GetCommitHashOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.CommitHash, true +} + +// SetCommitHash sets field value. +func (o *McpScanRequestDataAttributes) SetCommitHash(v string) { + o.CommitHash = v +} + +// GetLibraries returns the Libraries field value. +func (o *McpScanRequestDataAttributes) GetLibraries() []McpScanRequestDataAttributesLibrariesItems { + if o == nil { + var ret []McpScanRequestDataAttributesLibrariesItems + return ret + } + return o.Libraries +} + +// GetLibrariesOk returns a tuple with the Libraries field value +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributes) GetLibrariesOk() (*[]McpScanRequestDataAttributesLibrariesItems, bool) { + if o == nil { + return nil, false + } + return &o.Libraries, true +} + +// SetLibraries sets field value. +func (o *McpScanRequestDataAttributes) SetLibraries(v []McpScanRequestDataAttributesLibrariesItems) { + o.Libraries = v +} + +// GetResourceName returns the ResourceName field value. +func (o *McpScanRequestDataAttributes) GetResourceName() string { + if o == nil { + var ret string + return ret + } + return o.ResourceName +} + +// GetResourceNameOk returns a tuple with the ResourceName field value +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributes) GetResourceNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ResourceName, true +} + +// SetResourceName sets field value. +func (o *McpScanRequestDataAttributes) SetResourceName(v string) { + o.ResourceName = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o McpScanRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["commit_hash"] = o.CommitHash + toSerialize["libraries"] = o.Libraries + toSerialize["resource_name"] = o.ResourceName + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *McpScanRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CommitHash *string `json:"commit_hash"` + Libraries *[]McpScanRequestDataAttributesLibrariesItems `json:"libraries"` + ResourceName *string `json:"resource_name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CommitHash == nil { + return fmt.Errorf("required field commit_hash missing") + } + if all.Libraries == nil { + return fmt.Errorf("required field libraries missing") + } + if all.ResourceName == nil { + return fmt.Errorf("required field resource_name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"commit_hash", "libraries", "resource_name"}) + } else { + return err + } + o.CommitHash = *all.CommitHash + o.Libraries = *all.Libraries + o.ResourceName = *all.ResourceName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_mcp_scan_request_data_attributes_libraries_items.go b/api/datadogV2/model_mcp_scan_request_data_attributes_libraries_items.go new file mode 100644 index 00000000000..14d510f5acb --- /dev/null +++ b/api/datadogV2/model_mcp_scan_request_data_attributes_libraries_items.go @@ -0,0 +1,267 @@ +// 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" +) + +// McpScanRequestDataAttributesLibrariesItems A library declaration to include in the dependency scan. +type McpScanRequestDataAttributesLibrariesItems struct { + // The list of dependency PURLs to exclude when resolving transitive dependencies for this library. + Exclusions []string `json:"exclusions,omitempty"` + // Whether this library is a development-only dependency. + IsDev bool `json:"is_dev"` + // Whether this library is a direct (rather than transitive) dependency. + IsDirect bool `json:"is_direct"` + // The package manager that produced this library entry (for example, `npm`, `pip`, `nuget`). + PackageManager string `json:"package_manager"` + // The Package URL (PURL) uniquely identifying the library and its version. + Purl string `json:"purl"` + // The list of target framework identifiers associated with the library. + TargetFrameworks []string `json:"target_frameworks,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:"-"` +} + +// NewMcpScanRequestDataAttributesLibrariesItems instantiates a new McpScanRequestDataAttributesLibrariesItems 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 NewMcpScanRequestDataAttributesLibrariesItems(isDev bool, isDirect bool, packageManager string, purl string) *McpScanRequestDataAttributesLibrariesItems { + this := McpScanRequestDataAttributesLibrariesItems{} + this.IsDev = isDev + this.IsDirect = isDirect + this.PackageManager = packageManager + this.Purl = purl + return &this +} + +// NewMcpScanRequestDataAttributesLibrariesItemsWithDefaults instantiates a new McpScanRequestDataAttributesLibrariesItems 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 NewMcpScanRequestDataAttributesLibrariesItemsWithDefaults() *McpScanRequestDataAttributesLibrariesItems { + this := McpScanRequestDataAttributesLibrariesItems{} + return &this +} + +// GetExclusions returns the Exclusions field value if set, zero value otherwise. +func (o *McpScanRequestDataAttributesLibrariesItems) GetExclusions() []string { + if o == nil || o.Exclusions == nil { + var ret []string + return ret + } + return o.Exclusions +} + +// GetExclusionsOk returns a tuple with the Exclusions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributesLibrariesItems) GetExclusionsOk() (*[]string, bool) { + if o == nil || o.Exclusions == nil { + return nil, false + } + return &o.Exclusions, true +} + +// HasExclusions returns a boolean if a field has been set. +func (o *McpScanRequestDataAttributesLibrariesItems) HasExclusions() bool { + return o != nil && o.Exclusions != nil +} + +// SetExclusions gets a reference to the given []string and assigns it to the Exclusions field. +func (o *McpScanRequestDataAttributesLibrariesItems) SetExclusions(v []string) { + o.Exclusions = v +} + +// GetIsDev returns the IsDev field value. +func (o *McpScanRequestDataAttributesLibrariesItems) GetIsDev() bool { + if o == nil { + var ret bool + return ret + } + return o.IsDev +} + +// GetIsDevOk returns a tuple with the IsDev field value +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributesLibrariesItems) GetIsDevOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.IsDev, true +} + +// SetIsDev sets field value. +func (o *McpScanRequestDataAttributesLibrariesItems) SetIsDev(v bool) { + o.IsDev = v +} + +// GetIsDirect returns the IsDirect field value. +func (o *McpScanRequestDataAttributesLibrariesItems) GetIsDirect() bool { + if o == nil { + var ret bool + return ret + } + return o.IsDirect +} + +// GetIsDirectOk returns a tuple with the IsDirect field value +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributesLibrariesItems) GetIsDirectOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.IsDirect, true +} + +// SetIsDirect sets field value. +func (o *McpScanRequestDataAttributesLibrariesItems) SetIsDirect(v bool) { + o.IsDirect = v +} + +// GetPackageManager returns the PackageManager field value. +func (o *McpScanRequestDataAttributesLibrariesItems) GetPackageManager() string { + if o == nil { + var ret string + return ret + } + return o.PackageManager +} + +// GetPackageManagerOk returns a tuple with the PackageManager field value +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributesLibrariesItems) GetPackageManagerOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PackageManager, true +} + +// SetPackageManager sets field value. +func (o *McpScanRequestDataAttributesLibrariesItems) SetPackageManager(v string) { + o.PackageManager = v +} + +// GetPurl returns the Purl field value. +func (o *McpScanRequestDataAttributesLibrariesItems) GetPurl() string { + if o == nil { + var ret string + return ret + } + return o.Purl +} + +// GetPurlOk returns a tuple with the Purl field value +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributesLibrariesItems) GetPurlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Purl, true +} + +// SetPurl sets field value. +func (o *McpScanRequestDataAttributesLibrariesItems) SetPurl(v string) { + o.Purl = v +} + +// GetTargetFrameworks returns the TargetFrameworks field value if set, zero value otherwise. +func (o *McpScanRequestDataAttributesLibrariesItems) GetTargetFrameworks() []string { + if o == nil || o.TargetFrameworks == nil { + var ret []string + return ret + } + return o.TargetFrameworks +} + +// GetTargetFrameworksOk returns a tuple with the TargetFrameworks field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *McpScanRequestDataAttributesLibrariesItems) GetTargetFrameworksOk() (*[]string, bool) { + if o == nil || o.TargetFrameworks == nil { + return nil, false + } + return &o.TargetFrameworks, true +} + +// HasTargetFrameworks returns a boolean if a field has been set. +func (o *McpScanRequestDataAttributesLibrariesItems) HasTargetFrameworks() bool { + return o != nil && o.TargetFrameworks != nil +} + +// SetTargetFrameworks gets a reference to the given []string and assigns it to the TargetFrameworks field. +func (o *McpScanRequestDataAttributesLibrariesItems) SetTargetFrameworks(v []string) { + o.TargetFrameworks = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o McpScanRequestDataAttributesLibrariesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Exclusions != nil { + toSerialize["exclusions"] = o.Exclusions + } + toSerialize["is_dev"] = o.IsDev + toSerialize["is_direct"] = o.IsDirect + toSerialize["package_manager"] = o.PackageManager + toSerialize["purl"] = o.Purl + if o.TargetFrameworks != nil { + toSerialize["target_frameworks"] = o.TargetFrameworks + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *McpScanRequestDataAttributesLibrariesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Exclusions []string `json:"exclusions,omitempty"` + IsDev *bool `json:"is_dev"` + IsDirect *bool `json:"is_direct"` + PackageManager *string `json:"package_manager"` + Purl *string `json:"purl"` + TargetFrameworks []string `json:"target_frameworks,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.IsDev == nil { + return fmt.Errorf("required field is_dev missing") + } + if all.IsDirect == nil { + return fmt.Errorf("required field is_direct missing") + } + if all.PackageManager == nil { + return fmt.Errorf("required field package_manager missing") + } + if all.Purl == nil { + return fmt.Errorf("required field purl missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"exclusions", "is_dev", "is_direct", "package_manager", "purl", "target_frameworks"}) + } else { + return err + } + o.Exclusions = all.Exclusions + o.IsDev = *all.IsDev + o.IsDirect = *all.IsDirect + o.PackageManager = *all.PackageManager + o.Purl = *all.Purl + o.TargetFrameworks = all.TargetFrameworks + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_mcp_scan_request_data_type.go b/api/datadogV2/model_mcp_scan_request_data_type.go new file mode 100644 index 00000000000..65d5e2ace0b --- /dev/null +++ b/api/datadogV2/model_mcp_scan_request_data_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" +) + +// McpScanRequestDataType The type identifier for MCP SCA scan requests. +type McpScanRequestDataType string + +// List of McpScanRequestDataType. +const ( + MCPSCANREQUESTDATATYPE_MCPSCANREQUEST McpScanRequestDataType = "mcpscanrequest" +) + +var allowedMcpScanRequestDataTypeEnumValues = []McpScanRequestDataType{ + MCPSCANREQUESTDATATYPE_MCPSCANREQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *McpScanRequestDataType) GetAllowedValues() []McpScanRequestDataType { + return allowedMcpScanRequestDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *McpScanRequestDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = McpScanRequestDataType(value) + return nil +} + +// NewMcpScanRequestDataTypeFromValue returns a pointer to a valid McpScanRequestDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewMcpScanRequestDataTypeFromValue(v string) (*McpScanRequestDataType, error) { + ev := McpScanRequestDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for McpScanRequestDataType: valid values are %v", v, allowedMcpScanRequestDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v McpScanRequestDataType) IsValid() bool { + for _, existing := range allowedMcpScanRequestDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to McpScanRequestDataType value. +func (v McpScanRequestDataType) Ptr() *McpScanRequestDataType { + return &v +} diff --git a/api/datadogV2/model_mcp_scan_request_response.go b/api/datadogV2/model_mcp_scan_request_response.go new file mode 100644 index 00000000000..b80cb304faa --- /dev/null +++ b/api/datadogV2/model_mcp_scan_request_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" +) + +// McpScanRequestResponse The top-level response object returned when an MCP SCA dependency scan request has been accepted. +type McpScanRequestResponse struct { + // The data object returned when a scan request has been accepted. + Data McpScanRequestResponseData `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:"-"` +} + +// NewMcpScanRequestResponse instantiates a new McpScanRequestResponse 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 NewMcpScanRequestResponse(data McpScanRequestResponseData) *McpScanRequestResponse { + this := McpScanRequestResponse{} + this.Data = data + return &this +} + +// NewMcpScanRequestResponseWithDefaults instantiates a new McpScanRequestResponse 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 NewMcpScanRequestResponseWithDefaults() *McpScanRequestResponse { + this := McpScanRequestResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *McpScanRequestResponse) GetData() McpScanRequestResponseData { + if o == nil { + var ret McpScanRequestResponseData + 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 *McpScanRequestResponse) GetDataOk() (*McpScanRequestResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *McpScanRequestResponse) SetData(v McpScanRequestResponseData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o McpScanRequestResponse) 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 *McpScanRequestResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *McpScanRequestResponseData `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.UnmarshalUseNumber(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_mcp_scan_request_response_data.go b/api/datadogV2/model_mcp_scan_request_response_data.go new file mode 100644 index 00000000000..62eb02c08fd --- /dev/null +++ b/api/datadogV2/model_mcp_scan_request_response_data.go @@ -0,0 +1,180 @@ +// 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" +) + +// McpScanRequestResponseData The data object returned when a scan request has been accepted. +type McpScanRequestResponseData struct { + // The attributes returned when a scan request has been accepted, containing the job identifier used to poll for results. + Attributes McpScanRequestResponseDataAttributes `json:"attributes"` + // The job identifier assigned to the scan. + Id string `json:"id"` + // The type identifier for MCP SCA scan request responses. + Type McpScanRequestResponseDataType `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:"-"` +} + +// NewMcpScanRequestResponseData instantiates a new McpScanRequestResponseData 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 NewMcpScanRequestResponseData(attributes McpScanRequestResponseDataAttributes, id string, typeVar McpScanRequestResponseDataType) *McpScanRequestResponseData { + this := McpScanRequestResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewMcpScanRequestResponseDataWithDefaults instantiates a new McpScanRequestResponseData 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 NewMcpScanRequestResponseDataWithDefaults() *McpScanRequestResponseData { + this := McpScanRequestResponseData{} + var typeVar McpScanRequestResponseDataType = MCPSCANREQUESTRESPONSEDATATYPE_MCPSCANREQUESTRESPONSE + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *McpScanRequestResponseData) GetAttributes() McpScanRequestResponseDataAttributes { + if o == nil { + var ret McpScanRequestResponseDataAttributes + 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 *McpScanRequestResponseData) GetAttributesOk() (*McpScanRequestResponseDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *McpScanRequestResponseData) SetAttributes(v McpScanRequestResponseDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *McpScanRequestResponseData) 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 *McpScanRequestResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *McpScanRequestResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *McpScanRequestResponseData) GetType() McpScanRequestResponseDataType { + if o == nil { + var ret McpScanRequestResponseDataType + 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 *McpScanRequestResponseData) GetTypeOk() (*McpScanRequestResponseDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *McpScanRequestResponseData) SetType(v McpScanRequestResponseDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o McpScanRequestResponseData) 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 *McpScanRequestResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *McpScanRequestResponseDataAttributes `json:"attributes"` + Id *string `json:"id"` + Type *McpScanRequestResponseDataType `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.UnmarshalUseNumber(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_mcp_scan_request_response_data_attributes.go b/api/datadogV2/model_mcp_scan_request_response_data_attributes.go new file mode 100644 index 00000000000..1d635f0dc3d --- /dev/null +++ b/api/datadogV2/model_mcp_scan_request_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" +) + +// McpScanRequestResponseDataAttributes The attributes returned when a scan request has been accepted, containing the job identifier used to poll for results. +type McpScanRequestResponseDataAttributes struct { + // The job identifier assigned to the scan, used to retrieve the scan result. + JobId string `json:"job_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:"-"` +} + +// NewMcpScanRequestResponseDataAttributes instantiates a new McpScanRequestResponseDataAttributes 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 NewMcpScanRequestResponseDataAttributes(jobId string) *McpScanRequestResponseDataAttributes { + this := McpScanRequestResponseDataAttributes{} + this.JobId = jobId + return &this +} + +// NewMcpScanRequestResponseDataAttributesWithDefaults instantiates a new McpScanRequestResponseDataAttributes 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 NewMcpScanRequestResponseDataAttributesWithDefaults() *McpScanRequestResponseDataAttributes { + this := McpScanRequestResponseDataAttributes{} + return &this +} + +// GetJobId returns the JobId field value. +func (o *McpScanRequestResponseDataAttributes) GetJobId() string { + if o == nil { + var ret string + return ret + } + return o.JobId +} + +// GetJobIdOk returns a tuple with the JobId field value +// and a boolean to check if the value has been set. +func (o *McpScanRequestResponseDataAttributes) GetJobIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.JobId, true +} + +// SetJobId sets field value. +func (o *McpScanRequestResponseDataAttributes) SetJobId(v string) { + o.JobId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o McpScanRequestResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["job_id"] = o.JobId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *McpScanRequestResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + JobId *string `json:"job_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.JobId == nil { + return fmt.Errorf("required field job_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"job_id"}) + } else { + return err + } + o.JobId = *all.JobId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_mcp_scan_request_response_data_type.go b/api/datadogV2/model_mcp_scan_request_response_data_type.go new file mode 100644 index 00000000000..d852361fbcb --- /dev/null +++ b/api/datadogV2/model_mcp_scan_request_response_data_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" +) + +// McpScanRequestResponseDataType The type identifier for MCP SCA scan request responses. +type McpScanRequestResponseDataType string + +// List of McpScanRequestResponseDataType. +const ( + MCPSCANREQUESTRESPONSEDATATYPE_MCPSCANREQUESTRESPONSE McpScanRequestResponseDataType = "mcpscanrequestresponse" +) + +var allowedMcpScanRequestResponseDataTypeEnumValues = []McpScanRequestResponseDataType{ + MCPSCANREQUESTRESPONSEDATATYPE_MCPSCANREQUESTRESPONSE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *McpScanRequestResponseDataType) GetAllowedValues() []McpScanRequestResponseDataType { + return allowedMcpScanRequestResponseDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *McpScanRequestResponseDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = McpScanRequestResponseDataType(value) + return nil +} + +// NewMcpScanRequestResponseDataTypeFromValue returns a pointer to a valid McpScanRequestResponseDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewMcpScanRequestResponseDataTypeFromValue(v string) (*McpScanRequestResponseDataType, error) { + ev := McpScanRequestResponseDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for McpScanRequestResponseDataType: valid values are %v", v, allowedMcpScanRequestResponseDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v McpScanRequestResponseDataType) IsValid() bool { + for _, existing := range allowedMcpScanRequestResponseDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to McpScanRequestResponseDataType value. +func (v McpScanRequestResponseDataType) Ptr() *McpScanRequestResponseDataType { + return &v +} diff --git a/api/datadogV2/model_scan_result_response.go b/api/datadogV2/model_scan_result_response.go new file mode 100644 index 00000000000..4d0bb745112 --- /dev/null +++ b/api/datadogV2/model_scan_result_response.go @@ -0,0 +1,75 @@ +// 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" +) + +// ScanResultResponse - The raw scan result document produced by the SCA processor. +// The contents reflect the vulnerabilities and metadata produced for the libraries +// submitted in the original scan request. +type ScanResultResponse struct { + AnyValueObject map[string]interface{} + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// AnyValueObjectAsScanResultResponse is a convenience function that returns map[string]interface{} wrapped in ScanResultResponse. +func AnyValueObjectAsScanResultResponse(v map[string]interface{}) ScanResultResponse { + return ScanResultResponse{AnyValueObject: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *ScanResultResponse) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into AnyValueObject + err = datadog.Unmarshal(data, &obj.AnyValueObject) + if err == nil { + if obj.AnyValueObject != nil { + jsonAnyValueObject, _ := datadog.Marshal(obj.AnyValueObject) + if string(jsonAnyValueObject) == "{}" && string(data) != "{}" { // empty struct + obj.AnyValueObject = nil + } else { + match++ + } + } else { + obj.AnyValueObject = nil + } + } else { + obj.AnyValueObject = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.AnyValueObject = 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 ScanResultResponse) MarshalJSON() ([]byte, error) { + if obj.AnyValueObject != nil { + return datadog.Marshal(&obj.AnyValueObject) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *ScanResultResponse) GetActualInstance() interface{} { + if obj.AnyValueObject != nil { + return obj.AnyValueObject + } + + // all schemas are nil + return nil +} diff --git a/examples/v2/static-analysis/CreateSCAScan.go b/examples/v2/static-analysis/CreateSCAScan.go new file mode 100644 index 00000000000..8174bd145b2 --- /dev/null +++ b/examples/v2/static-analysis/CreateSCAScan.go @@ -0,0 +1,49 @@ +// Submit libraries for vulnerability scanning returns "Accepted" 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.McpScanRequest{ + Data: datadogV2.McpScanRequestData{ + Attributes: datadogV2.McpScanRequestDataAttributes{ + CommitHash: "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc", + Libraries: []datadogV2.McpScanRequestDataAttributesLibrariesItems{ + { + Exclusions: []string{}, + IsDev: false, + IsDirect: true, + PackageManager: "nuget", + Purl: "pkg:nuget/Newtonsoft.Json@13.0.1", + TargetFrameworks: []string{}, + }, + }, + ResourceName: "my-org/my-repo", + }, + Type: datadogV2.MCPSCANREQUESTDATATYPE_MCPSCANREQUEST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateSCAScan", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStaticAnalysisApi(apiClient) + resp, r, err := api.CreateSCAScan(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StaticAnalysisApi.CreateSCAScan`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StaticAnalysisApi.CreateSCAScan`:\n%s\n", responseContent) +} diff --git a/examples/v2/static-analysis/GetSCAScan.go b/examples/v2/static-analysis/GetSCAScan.go new file mode 100644 index 00000000000..8ebde3ea386 --- /dev/null +++ b/examples/v2/static-analysis/GetSCAScan.go @@ -0,0 +1,30 @@ +// Retrieve a dependency scan result 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.GetSCAScan", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStaticAnalysisApi(apiClient) + resp, r, err := api.GetSCAScan(ctx, "0190a3d4-1234-7000-8000-000000000000") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StaticAnalysisApi.GetSCAScan`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StaticAnalysisApi.GetSCAScan`:\n%s\n", responseContent) +} diff --git a/examples/v2/static-analysis/ListSCALicenses.go b/examples/v2/static-analysis/ListSCALicenses.go new file mode 100644 index 00000000000..c5018e76eae --- /dev/null +++ b/examples/v2/static-analysis/ListSCALicenses.go @@ -0,0 +1,30 @@ +// Get the list of SPDX licenses 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.ListSCALicenses", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStaticAnalysisApi(apiClient) + resp, r, err := api.ListSCALicenses(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StaticAnalysisApi.ListSCALicenses`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StaticAnalysisApi.ListSCALicenses`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/static_analysis.feature b/tests/scenarios/features/v2/static_analysis.feature index 3d690035c18..5a662bc9c32 100644 --- a/tests/scenarios/features/v2/static_analysis.feature +++ b/tests/scenarios/features/v2/static_analysis.feature @@ -434,6 +434,13 @@ Feature: Static Analysis When the request is sent Then the response status is 200 Successful response + @generated @skip @team:DataDog/k9-vm-sca + Scenario: Get the list of SPDX licenses returns "OK" response + Given operation "ListSCALicenses" enabled + And new "ListSCALicenses" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-vm-ast Scenario: List AI custom rule revisions returns "Bad Request" response Given operation "ListAiCustomRuleRevisions" enabled @@ -578,6 +585,22 @@ Feature: Static Analysis When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/k9-vm-sca + Scenario: Retrieve a dependency scan result returns "Not Found" response + Given operation "GetSCAScan" enabled + And new "GetSCAScan" request + And request contains "job_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-vm-sca + Scenario: Retrieve a dependency scan result returns "OK" response + Given operation "GetSCAScan" enabled + And new "GetSCAScan" request + And request contains "job_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-vm-ast Scenario: Revert Custom Rule Revision returns "Bad request" response Given operation "RevertCustomRuleRevision" enabled @@ -679,6 +702,22 @@ Feature: Static Analysis When the request is sent Then the response status is 200 Successful response + @generated @skip @team:DataDog/k9-vm-sca + Scenario: Submit libraries for vulnerability scanning returns "Accepted" response + Given operation "CreateSCAScan" enabled + And new "CreateSCAScan" request + And body with value {"data": {"attributes": {"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc", "libraries": [{"exclusions": [], "is_dev": false, "is_direct": true, "package_manager": "nuget", "purl": "pkg:nuget/Newtonsoft.Json@13.0.1", "target_frameworks": []}], "resource_name": "my-org/my-repo"}, "type": "mcpscanrequest"}} + When the request is sent + Then the response status is 202 Accepted + + @generated @skip @team:DataDog/k9-vm-sca + Scenario: Submit libraries for vulnerability scanning returns "Bad Request" response + Given operation "CreateSCAScan" enabled + And new "CreateSCAScan" request + And body with value {"data": {"attributes": {"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc", "libraries": [{"exclusions": [], "is_dev": false, "is_direct": true, "package_manager": "nuget", "purl": "pkg:nuget/Newtonsoft.Json@13.0.1", "target_frameworks": []}], "resource_name": "my-org/my-repo"}, "type": "mcpscanrequest"}} + When the request is sent + Then the response status is 400 Bad Request + @generated @skip @team:DataDog/k9-vm-ast Scenario: Update Custom Ruleset returns "Bad request" response Given operation "UpdateCustomRuleset" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 417de3d9c81..211637b2390 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -7525,6 +7525,24 @@ "type": "safe" } }, + "CreateSCAScan": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, + "GetSCAScan": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, + "ListSCALicenses": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, "CreateSCAResolveVulnerableSymbols": { "tag": "Static Analysis", "undo": {