From 6bf785c8f243d3e507a0e7529f17b5ed2da51674 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 2 Oct 2026 15:40:01 +0000 Subject: [PATCH] Regenerate client from commit c7c1fad of spec repo --- .generator/schemas/v2/openapi.yaml | 105 ++++++++++++ api/datadog/configuration.go | 1 + api/datadogV2/api_spa.go | 85 ++++++++++ api/datadogV2/doc.go | 1 + ...el_recommendation_v2_request_attributes.go | 103 ++++++++++++ .../model_recommendation_v2_request_body.go | 111 +++++++++++++ .../model_recommendation_v2_request_data.go | 149 ++++++++++++++++++ .../model_recommendation_v2_request_type.go | 64 ++++++++ examples/v2/spa/GetSPARecommendationsV2.go | 41 +++++ tests/scenarios/features/v2/spa.feature | 27 ++++ tests/scenarios/features/v2/undo.json | 6 + 11 files changed, 693 insertions(+) create mode 100644 api/datadogV2/model_recommendation_v2_request_attributes.go create mode 100644 api/datadogV2/model_recommendation_v2_request_body.go create mode 100644 api/datadogV2/model_recommendation_v2_request_data.go create mode 100644 api/datadogV2/model_recommendation_v2_request_type.go create mode 100644 examples/v2/spa/GetSPARecommendationsV2.go diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9dd8e972ab6..62da8be0f94 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -92998,6 +92998,49 @@ components: type: string x-enum-varnames: - RECOMMENDATION + RecommendationV2RequestAttributes: + description: |- + Attributes for requesting SPA recommendations by forwarding a Spark job's raw arguments + instead of a precomputed shard. + properties: + arguments: + description: |- + Raw, unfiltered Spark job arguments as submitted (for example, `--org_id=2`). + SPA determines which arguments are relevant for the given service. + example: + - "" + items: + type: string + type: array + required: [arguments] + type: object + RecommendationV2RequestBody: + description: |- + Request body for retrieving SPA recommendations by forwarding a Spark job's raw arguments + instead of a precomputed shard. + properties: + data: + $ref: "#/components/schemas/RecommendationV2RequestData" + required: [data] + type: object + RecommendationV2RequestData: + description: JSON:API resource object for the SPA v2 recommendation request. + properties: + attributes: + $ref: "#/components/schemas/RecommendationV2RequestAttributes" + type: + $ref: "#/components/schemas/RecommendationV2RequestType" + required: [type, attributes] + type: object + RecommendationV2RequestType: + default: recommendation_v2_request + description: JSON:API resource type for the SPA v2 recommendation request. + enum: + - recommendation_v2_request + example: recommendation_v2_request + type: string + x-enum-varnames: + - RECOMMENDATION_V2_REQUEST RecommendationsFilterRequest: description: JSON:API request body for filtering cost recommendations. example: @@ -218752,6 +218795,68 @@ paths: 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/spa/recommendations-v2/{service}: + post: + description: |- + This endpoint is experimental and restricted to Datadog internal use only. + Retrieve resource recommendations for a Spark job. The caller (Spark Gateway) provides + a service name and the job's raw arguments. SPA determines which arguments are relevant + for the service and returns structured recommendations for driver and executor resources. + operationId: GetSPARecommendationsV2 + parameters: + - description: The service name for a Spark job + in: path + name: service + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RecommendationV2RequestBody" + required: true + responses: + "200": + content: + application/json: + example: + data: + attributes: + driver: + estimation: + cpu: {max: 1500, p75: 1000, p95: 1200} + ephemeral_storage: 896 + heap: 6144 + memory: 7168 + overhead: 1024 + executor: + estimation: + cpu: {max: 2000, p75: 1200, p95: 1500} + ephemeral_storage: 512 + heap: 3072 + memory: 4096 + overhead: 1024 + id: "dedupeactivecontexts:adp_dedupeactivecontexts_org2" + type: recommendation + schema: + $ref: "#/components/schemas/RecommendationDocument" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - AuthZ: [] + summary: Get SPA recommendations v2 + tags: + - Spa + x-unstable: |- + **Note**: This endpoint is in preview and may change in the future. It is not yet recommended for production use. /api/v2/spa/recommendations/{service}: get: description: This endpoint is currently experimental and restricted to Datadog internal use only. Retrieve resource recommendations for a Spark job. The caller (Spark Gateway or DJM UI) provides a service name and SPA returns structured recommendations for driver and executor resources. The version with a shard should be preferred, where possible, as it gives more accurate results. diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 107959d535e..5494ef05d4d 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -1391,6 +1391,7 @@ func NewConfiguration() *Configuration { "v2.GetSloStatus": false, "v2.CreateSnapshot": false, "v2.GetSPARecommendations": false, + "v2.GetSPARecommendationsV2": false, "v2.GetSPARecommendationsWithShard": false, "v2.CreateAiCustomRule": false, "v2.CreateAiCustomRuleRevision": false, diff --git a/api/datadogV2/api_spa.go b/api/datadogV2/api_spa.go index fc6f9439222..5e42e31dc2a 100644 --- a/api/datadogV2/api_spa.go +++ b/api/datadogV2/api_spa.go @@ -124,6 +124,91 @@ func (a *SpaApi) GetSPARecommendations(ctx _context.Context, service string, o . return localVarReturnValue, localVarHTTPResponse, nil } +// GetSPARecommendationsV2 Get SPA recommendations v2. +// This endpoint is experimental and restricted to Datadog internal use only. +// Retrieve resource recommendations for a Spark job. The caller (Spark Gateway) provides +// a service name and the job's raw arguments. SPA determines which arguments are relevant +// for the service and returns structured recommendations for driver and executor resources. +func (a *SpaApi) GetSPARecommendationsV2(ctx _context.Context, service string, body RecommendationV2RequestBody) (RecommendationDocument, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue RecommendationDocument + ) + + operationId := "v2.GetSPARecommendationsV2" + 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.SpaApi.GetSPARecommendationsV2") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/spa/recommendations-v2/{service}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{service}", _neturl.PathEscape(datadog.ParameterToString(service, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + ) + + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // GetSPARecommendationsWithShardOptionalParameters holds optional parameters for GetSPARecommendationsWithShard. type GetSPARecommendationsWithShardOptionalParameters struct { BypassCache *string diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 049bb6b2c9f..75c046fe6e1 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -1364,6 +1364,7 @@ // - [SoftwareCatalogApi.UpsertCatalogEntity] // - [SoftwareCatalogApi.UpsertCatalogKind] // - [SpaApi.GetSPARecommendations] +// - [SpaApi.GetSPARecommendationsV2] // - [SpaApi.GetSPARecommendationsWithShard] // - [SpansApi.AggregateSpans] // - [SpansApi.ListSpans] diff --git a/api/datadogV2/model_recommendation_v2_request_attributes.go b/api/datadogV2/model_recommendation_v2_request_attributes.go new file mode 100644 index 00000000000..ab96b37528e --- /dev/null +++ b/api/datadogV2/model_recommendation_v2_request_attributes.go @@ -0,0 +1,103 @@ +// 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" +) + +// RecommendationV2RequestAttributes Attributes for requesting SPA recommendations by forwarding a Spark job's raw arguments +// instead of a precomputed shard. +type RecommendationV2RequestAttributes struct { + // Raw, unfiltered Spark job arguments as submitted (for example, `--org_id=2`). + // SPA determines which arguments are relevant for the given service. + Arguments []string `json:"arguments"` + // 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:"-"` +} + +// NewRecommendationV2RequestAttributes instantiates a new RecommendationV2RequestAttributes 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 NewRecommendationV2RequestAttributes(arguments []string) *RecommendationV2RequestAttributes { + this := RecommendationV2RequestAttributes{} + this.Arguments = arguments + return &this +} + +// NewRecommendationV2RequestAttributesWithDefaults instantiates a new RecommendationV2RequestAttributes 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 NewRecommendationV2RequestAttributesWithDefaults() *RecommendationV2RequestAttributes { + this := RecommendationV2RequestAttributes{} + return &this +} + +// GetArguments returns the Arguments field value. +func (o *RecommendationV2RequestAttributes) GetArguments() []string { + if o == nil { + var ret []string + return ret + } + return o.Arguments +} + +// GetArgumentsOk returns a tuple with the Arguments field value +// and a boolean to check if the value has been set. +func (o *RecommendationV2RequestAttributes) GetArgumentsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Arguments, true +} + +// SetArguments sets field value. +func (o *RecommendationV2RequestAttributes) SetArguments(v []string) { + o.Arguments = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RecommendationV2RequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["arguments"] = o.Arguments + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RecommendationV2RequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Arguments *[]string `json:"arguments"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Arguments == nil { + return fmt.Errorf("required field arguments missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"arguments"}) + } else { + return err + } + o.Arguments = *all.Arguments + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_recommendation_v2_request_body.go b/api/datadogV2/model_recommendation_v2_request_body.go new file mode 100644 index 00000000000..0309498896d --- /dev/null +++ b/api/datadogV2/model_recommendation_v2_request_body.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RecommendationV2RequestBody Request body for retrieving SPA recommendations by forwarding a Spark job's raw arguments +// instead of a precomputed shard. +type RecommendationV2RequestBody struct { + // JSON:API resource object for the SPA v2 recommendation request. + Data RecommendationV2RequestData `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:"-"` +} + +// NewRecommendationV2RequestBody instantiates a new RecommendationV2RequestBody 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 NewRecommendationV2RequestBody(data RecommendationV2RequestData) *RecommendationV2RequestBody { + this := RecommendationV2RequestBody{} + this.Data = data + return &this +} + +// NewRecommendationV2RequestBodyWithDefaults instantiates a new RecommendationV2RequestBody 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 NewRecommendationV2RequestBodyWithDefaults() *RecommendationV2RequestBody { + this := RecommendationV2RequestBody{} + return &this +} + +// GetData returns the Data field value. +func (o *RecommendationV2RequestBody) GetData() RecommendationV2RequestData { + if o == nil { + var ret RecommendationV2RequestData + 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 *RecommendationV2RequestBody) GetDataOk() (*RecommendationV2RequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *RecommendationV2RequestBody) SetData(v RecommendationV2RequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RecommendationV2RequestBody) 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 *RecommendationV2RequestBody) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *RecommendationV2RequestData `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_recommendation_v2_request_data.go b/api/datadogV2/model_recommendation_v2_request_data.go new file mode 100644 index 00000000000..6437c93d559 --- /dev/null +++ b/api/datadogV2/model_recommendation_v2_request_data.go @@ -0,0 +1,149 @@ +// 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" +) + +// RecommendationV2RequestData JSON:API resource object for the SPA v2 recommendation request. +type RecommendationV2RequestData struct { + // Attributes for requesting SPA recommendations by forwarding a Spark job's raw arguments + // instead of a precomputed shard. + Attributes RecommendationV2RequestAttributes `json:"attributes"` + // JSON:API resource type for the SPA v2 recommendation request. + Type RecommendationV2RequestType `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:"-"` +} + +// NewRecommendationV2RequestData instantiates a new RecommendationV2RequestData 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 NewRecommendationV2RequestData(attributes RecommendationV2RequestAttributes, typeVar RecommendationV2RequestType) *RecommendationV2RequestData { + this := RecommendationV2RequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewRecommendationV2RequestDataWithDefaults instantiates a new RecommendationV2RequestData 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 NewRecommendationV2RequestDataWithDefaults() *RecommendationV2RequestData { + this := RecommendationV2RequestData{} + var typeVar RecommendationV2RequestType = RECOMMENDATIONV2REQUESTTYPE_RECOMMENDATION_V2_REQUEST + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *RecommendationV2RequestData) GetAttributes() RecommendationV2RequestAttributes { + if o == nil { + var ret RecommendationV2RequestAttributes + 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 *RecommendationV2RequestData) GetAttributesOk() (*RecommendationV2RequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *RecommendationV2RequestData) SetAttributes(v RecommendationV2RequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *RecommendationV2RequestData) GetType() RecommendationV2RequestType { + if o == nil { + var ret RecommendationV2RequestType + 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 *RecommendationV2RequestData) GetTypeOk() (*RecommendationV2RequestType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *RecommendationV2RequestData) SetType(v RecommendationV2RequestType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RecommendationV2RequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RecommendationV2RequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RecommendationV2RequestAttributes `json:"attributes"` + Type *RecommendationV2RequestType `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", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_recommendation_v2_request_type.go b/api/datadogV2/model_recommendation_v2_request_type.go new file mode 100644 index 00000000000..2581d5afffd --- /dev/null +++ b/api/datadogV2/model_recommendation_v2_request_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RecommendationV2RequestType JSON:API resource type for the SPA v2 recommendation request. +type RecommendationV2RequestType string + +// List of RecommendationV2RequestType. +const ( + RECOMMENDATIONV2REQUESTTYPE_RECOMMENDATION_V2_REQUEST RecommendationV2RequestType = "recommendation_v2_request" +) + +var allowedRecommendationV2RequestTypeEnumValues = []RecommendationV2RequestType{ + RECOMMENDATIONV2REQUESTTYPE_RECOMMENDATION_V2_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RecommendationV2RequestType) GetAllowedValues() []RecommendationV2RequestType { + return allowedRecommendationV2RequestTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RecommendationV2RequestType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RecommendationV2RequestType(value) + return nil +} + +// NewRecommendationV2RequestTypeFromValue returns a pointer to a valid RecommendationV2RequestType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRecommendationV2RequestTypeFromValue(v string) (*RecommendationV2RequestType, error) { + ev := RecommendationV2RequestType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RecommendationV2RequestType: valid values are %v", v, allowedRecommendationV2RequestTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RecommendationV2RequestType) IsValid() bool { + for _, existing := range allowedRecommendationV2RequestTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RecommendationV2RequestType value. +func (v RecommendationV2RequestType) Ptr() *RecommendationV2RequestType { + return &v +} diff --git a/examples/v2/spa/GetSPARecommendationsV2.go b/examples/v2/spa/GetSPARecommendationsV2.go new file mode 100644 index 00000000000..83aa3d298ae --- /dev/null +++ b/examples/v2/spa/GetSPARecommendationsV2.go @@ -0,0 +1,41 @@ +// Get SPA recommendations v2 returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.RecommendationV2RequestBody{ + Data: datadogV2.RecommendationV2RequestData{ + Attributes: datadogV2.RecommendationV2RequestAttributes{ + Arguments: []string{ + "", + }, + }, + Type: datadogV2.RECOMMENDATIONV2REQUESTTYPE_RECOMMENDATION_V2_REQUEST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN")) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetSPARecommendationsV2", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSpaApi(apiClient) + resp, r, err := api.GetSPARecommendationsV2(ctx, "service", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SpaApi.GetSPARecommendationsV2`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SpaApi.GetSPARecommendationsV2`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/spa.feature b/tests/scenarios/features/v2/spa.feature index 0e6ac6b3a76..b3d5d0fec0c 100644 --- a/tests/scenarios/features/v2/spa.feature +++ b/tests/scenarios/features/v2/spa.feature @@ -40,6 +40,33 @@ Feature: Spa When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/data-and-analytics-processing + Scenario: Get SPA recommendations v2 returns "Bad Request" response + Given operation "GetSPARecommendationsV2" enabled + And new "GetSPARecommendationsV2" request + And request contains "service" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"arguments": [""]}, "type": "recommendation_v2_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/data-and-analytics-processing + Scenario: Get SPA recommendations v2 returns "Not Found" response + Given operation "GetSPARecommendationsV2" enabled + And new "GetSPARecommendationsV2" request + And request contains "service" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"arguments": [""]}, "type": "recommendation_v2_request"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/data-and-analytics-processing + Scenario: Get SPA recommendations v2 returns "OK" response + Given operation "GetSPARecommendationsV2" enabled + And new "GetSPARecommendationsV2" request + And request contains "service" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"arguments": [""]}, "type": "recommendation_v2_request"}} + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/data-and-analytics-processing Scenario: GetSPARecommendations returns a JSON:API Recommendation with driver and executor estimations Given new "GetSPARecommendations" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 8ad9cc9418f..0f86041e11e 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -9323,6 +9323,12 @@ "type": "unsafe" } }, + "GetSPARecommendationsV2": { + "tag": "Spa", + "undo": { + "type": "safe" + } + }, "GetSPARecommendations": { "tag": "Spa", "undo": {