Skip to content

Commit ff25c77

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add a new end point that allows the SPA recommendation to be called without the shard parameter (#3585)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 9cfdf1a commit ff25c77

9 files changed

Lines changed: 330 additions & 34 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42828,6 +42828,9 @@ components:
4282842828
description: Attributes of the SPA Recommendation resource. Contains recommendations
4282942829
for both driver and executor components.
4283042830
properties:
42831+
confidence_level:
42832+
format: double
42833+
type: number
4283142834
driver:
4283242835
$ref: '#/components/schemas/ComponentRecommendation'
4283342836
executor:
@@ -86626,13 +86629,79 @@ paths:
8662686629
x-unstable: '**Note**: This feature is in private beta. To request access, use
8662786630
the request access form in the [Service Level Objectives](https://docs.datadoghq.com/service_management/service_level_objectives/#slo-csv-export)
8662886631
docs.'
86629-
/api/v2/spa/recommendations/{service}/{shard}:
86632+
/api/v2/spa/recommendations/{service}:
8663086633
get:
86631-
description: Retrieve resource recommendations for a Spark job. The caller (Spark
86632-
Gateway or DJM UI) provides a service name and shard identifier, and SPA returns
86633-
structured recommendations for driver and executor resources.
86634+
description: This endpoint is currently experimental and restricted to Datadog
86635+
internal use only. Retrieve resource recommendations for a Spark job. The
86636+
caller (Spark Gateway or DJM UI) provides a service name and SPA returns structured
86637+
recommendations for driver and executor resources. The version with a shard
86638+
should be preferred, where possible, as it gives more accurate results.
8663486639
operationId: GetSPARecommendations
8663586640
parameters:
86641+
- description: The recommendation service should not use its metrics cache.
86642+
in: query
86643+
name: bypass_cache
86644+
schema:
86645+
type: string
86646+
- description: The service name for a spark job.
86647+
in: path
86648+
name: service
86649+
required: true
86650+
schema:
86651+
type: string
86652+
responses:
86653+
'200':
86654+
content:
86655+
application/json:
86656+
example:
86657+
data:
86658+
attributes:
86659+
driver:
86660+
estimation:
86661+
cpu:
86662+
max: 1500
86663+
p75: 1000
86664+
p95: 1200
86665+
ephemeral_storage: 896
86666+
heap: 6144
86667+
memory: 7168
86668+
overhead: 1024
86669+
executor:
86670+
estimation:
86671+
cpu:
86672+
max: 2000
86673+
p75: 1200
86674+
p95: 1500
86675+
ephemeral_storage: 512
86676+
heap: 3072
86677+
memory: 4096
86678+
overhead: 1024
86679+
id: dedupeactivecontexts:adp_dedupeactivecontexts_org2
86680+
type: recommendation
86681+
schema:
86682+
$ref: '#/components/schemas/RecommendationDocument'
86683+
description: OK
86684+
'400':
86685+
$ref: '#/components/responses/BadRequestResponse'
86686+
'403':
86687+
$ref: '#/components/responses/NotAuthorizedResponse'
86688+
'429':
86689+
$ref: '#/components/responses/TooManyRequestsResponse'
86690+
security:
86691+
- AuthZ: []
86692+
summary: Get SPA Recommendations
86693+
tags:
86694+
- Spa
86695+
x-unstable: '**Note**: This endpoint is in preview and may change in the future.
86696+
It is not yet recommended for production use.'
86697+
/api/v2/spa/recommendations/{service}/{shard}:
86698+
get:
86699+
description: This endpoint is currently experimental and restricted to Datadog
86700+
internal use only. Retrieve resource recommendations for a Spark job. The
86701+
caller (Spark Gateway or DJM UI) provides a service name and shard identifier,
86702+
and SPA returns structured recommendations for driver and executor resources.
86703+
operationId: GetSPARecommendationsWithShard
86704+
parameters:
8663686705
- description: The shard tag for a spark job, which differentiates jobs within
8663786706
the same service that have different resource needs
8663886707
in: path
@@ -86646,6 +86715,11 @@ paths:
8664686715
required: true
8664786716
schema:
8664886717
type: string
86718+
- description: The recommendation service should not use its metrics cache.
86719+
in: query
86720+
name: bypass_cache
86721+
schema:
86722+
type: string
8664986723
responses:
8665086724
'200':
8665186725
content:
@@ -86684,11 +86758,13 @@ paths:
8668486758
$ref: '#/components/responses/NotAuthorizedResponse'
8668586759
'429':
8668686760
$ref: '#/components/responses/TooManyRequestsResponse'
86687-
summary: Get SPA Recommendations
86761+
security:
86762+
- AuthZ: []
86763+
summary: Get SPA Recommendations with a shard parameter
8668886764
tags:
8668986765
- Spa
86690-
x-unstable: '**Note**: This endpoint is in public beta and may change in the
86691-
future. It is not yet recommended for production use.'
86766+
x-unstable: '**Note**: This endpoint is in preview and may change in the future.
86767+
It is not yet recommended for production use.'
8669286768
/api/v2/spans/analytics/aggregate:
8669386769
post:
8669486770
description: 'The API endpoint to aggregate spans into buckets and compute metrics

api/datadog/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ func NewConfiguration() *Configuration {
798798
"v2.GetSLOReport": false,
799799
"v2.GetSLOReportJobStatus": false,
800800
"v2.GetSPARecommendations": false,
801+
"v2.GetSPARecommendationsWithShard": false,
801802
"v2.CreateSCAResolveVulnerableSymbols": false,
802803
"v2.CreateSCAResult": false,
803804
"v2.AddMemberTeam": false,

api/datadogV2/api_spa.go

Lines changed: 142 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,40 @@ import (
1717
// SpaApi service type
1818
type SpaApi datadog.Service
1919

20+
// GetSPARecommendationsOptionalParameters holds optional parameters for GetSPARecommendations.
21+
type GetSPARecommendationsOptionalParameters struct {
22+
BypassCache *string
23+
}
24+
25+
// NewGetSPARecommendationsOptionalParameters creates an empty struct for parameters.
26+
func NewGetSPARecommendationsOptionalParameters() *GetSPARecommendationsOptionalParameters {
27+
this := GetSPARecommendationsOptionalParameters{}
28+
return &this
29+
}
30+
31+
// WithBypassCache sets the corresponding parameter name and returns the struct.
32+
func (r *GetSPARecommendationsOptionalParameters) WithBypassCache(bypassCache string) *GetSPARecommendationsOptionalParameters {
33+
r.BypassCache = &bypassCache
34+
return r
35+
}
36+
2037
// GetSPARecommendations Get SPA Recommendations.
21-
// Retrieve resource recommendations for a Spark job. The caller (Spark Gateway or DJM UI) provides a service name and shard identifier, and SPA returns structured recommendations for driver and executor resources.
22-
func (a *SpaApi) GetSPARecommendations(ctx _context.Context, shard string, service string) (RecommendationDocument, *_nethttp.Response, error) {
38+
// 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.
39+
func (a *SpaApi) GetSPARecommendations(ctx _context.Context, service string, o ...GetSPARecommendationsOptionalParameters) (RecommendationDocument, *_nethttp.Response, error) {
2340
var (
2441
localVarHTTPMethod = _nethttp.MethodGet
2542
localVarPostBody interface{}
2643
localVarReturnValue RecommendationDocument
44+
optionalParams GetSPARecommendationsOptionalParameters
2745
)
2846

47+
if len(o) > 1 {
48+
return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetSPARecommendationsOptionalParameters is allowed")
49+
}
50+
if len(o) == 1 {
51+
optionalParams = o[0]
52+
}
53+
2954
operationId := "v2.GetSPARecommendations"
3055
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
3156
if !isOperationEnabled {
@@ -40,28 +65,130 @@ func (a *SpaApi) GetSPARecommendations(ctx _context.Context, shard string, servi
4065
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
4166
}
4267

43-
localVarPath := localBasePath + "/api/v2/spa/recommendations/{service}/{shard}"
44-
localVarPath = datadog.ReplacePathParameter(localVarPath, "{shard}", _neturl.PathEscape(datadog.ParameterToString(shard, "")))
68+
localVarPath := localBasePath + "/api/v2/spa/recommendations/{service}"
4569
localVarPath = datadog.ReplacePathParameter(localVarPath, "{service}", _neturl.PathEscape(datadog.ParameterToString(service, "")))
4670

4771
localVarHeaderParams := make(map[string]string)
4872
localVarQueryParams := _neturl.Values{}
4973
localVarFormParams := _neturl.Values{}
74+
if optionalParams.BypassCache != nil {
75+
localVarQueryParams.Add("bypass_cache", datadog.ParameterToString(*optionalParams.BypassCache, ""))
76+
}
5077
localVarHeaderParams["Accept"] = "application/json"
5178

52-
if a.Client.Cfg.DelegatedTokenConfig != nil {
53-
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
54-
if err != nil {
55-
return localVarReturnValue, nil, err
79+
datadog.SetAuthKeys(
80+
ctx,
81+
&localVarHeaderParams,
82+
)
83+
84+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
85+
if err != nil {
86+
return localVarReturnValue, nil, err
87+
}
88+
89+
localVarHTTPResponse, err := a.Client.CallAPI(req)
90+
if err != nil || localVarHTTPResponse == nil {
91+
return localVarReturnValue, localVarHTTPResponse, err
92+
}
93+
94+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
95+
if err != nil {
96+
return localVarReturnValue, localVarHTTPResponse, err
97+
}
98+
99+
if localVarHTTPResponse.StatusCode >= 300 {
100+
newErr := datadog.GenericOpenAPIError{
101+
ErrorBody: localVarBody,
102+
ErrorMessage: localVarHTTPResponse.Status,
103+
}
104+
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 {
105+
var v APIErrorResponse
106+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
107+
if err != nil {
108+
return localVarReturnValue, localVarHTTPResponse, newErr
109+
}
110+
newErr.ErrorModel = v
111+
}
112+
return localVarReturnValue, localVarHTTPResponse, newErr
113+
}
114+
115+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
116+
if err != nil {
117+
newErr := datadog.GenericOpenAPIError{
118+
ErrorBody: localVarBody,
119+
ErrorMessage: err.Error(),
56120
}
57-
} else {
58-
datadog.SetAuthKeys(
59-
ctx,
60-
&localVarHeaderParams,
61-
[2]string{"apiKeyAuth", "DD-API-KEY"},
62-
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
63-
)
121+
return localVarReturnValue, localVarHTTPResponse, newErr
122+
}
123+
124+
return localVarReturnValue, localVarHTTPResponse, nil
125+
}
126+
127+
// GetSPARecommendationsWithShardOptionalParameters holds optional parameters for GetSPARecommendationsWithShard.
128+
type GetSPARecommendationsWithShardOptionalParameters struct {
129+
BypassCache *string
130+
}
131+
132+
// NewGetSPARecommendationsWithShardOptionalParameters creates an empty struct for parameters.
133+
func NewGetSPARecommendationsWithShardOptionalParameters() *GetSPARecommendationsWithShardOptionalParameters {
134+
this := GetSPARecommendationsWithShardOptionalParameters{}
135+
return &this
136+
}
137+
138+
// WithBypassCache sets the corresponding parameter name and returns the struct.
139+
func (r *GetSPARecommendationsWithShardOptionalParameters) WithBypassCache(bypassCache string) *GetSPARecommendationsWithShardOptionalParameters {
140+
r.BypassCache = &bypassCache
141+
return r
142+
}
143+
144+
// GetSPARecommendationsWithShard Get SPA Recommendations with a shard parameter.
145+
// 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 shard identifier, and SPA returns structured recommendations for driver and executor resources.
146+
func (a *SpaApi) GetSPARecommendationsWithShard(ctx _context.Context, shard string, service string, o ...GetSPARecommendationsWithShardOptionalParameters) (RecommendationDocument, *_nethttp.Response, error) {
147+
var (
148+
localVarHTTPMethod = _nethttp.MethodGet
149+
localVarPostBody interface{}
150+
localVarReturnValue RecommendationDocument
151+
optionalParams GetSPARecommendationsWithShardOptionalParameters
152+
)
153+
154+
if len(o) > 1 {
155+
return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetSPARecommendationsWithShardOptionalParameters is allowed")
64156
}
157+
if len(o) == 1 {
158+
optionalParams = o[0]
159+
}
160+
161+
operationId := "v2.GetSPARecommendationsWithShard"
162+
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
163+
if !isOperationEnabled {
164+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
165+
}
166+
if isOperationEnabled && a.Client.Cfg.Debug {
167+
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
168+
}
169+
170+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SpaApi.GetSPARecommendationsWithShard")
171+
if err != nil {
172+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
173+
}
174+
175+
localVarPath := localBasePath + "/api/v2/spa/recommendations/{service}/{shard}"
176+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{shard}", _neturl.PathEscape(datadog.ParameterToString(shard, "")))
177+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{service}", _neturl.PathEscape(datadog.ParameterToString(service, "")))
178+
179+
localVarHeaderParams := make(map[string]string)
180+
localVarQueryParams := _neturl.Values{}
181+
localVarFormParams := _neturl.Values{}
182+
if optionalParams.BypassCache != nil {
183+
localVarQueryParams.Add("bypass_cache", datadog.ParameterToString(*optionalParams.BypassCache, ""))
184+
}
185+
localVarHeaderParams["Accept"] = "application/json"
186+
187+
datadog.SetAuthKeys(
188+
ctx,
189+
&localVarHeaderParams,
190+
)
191+
65192
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
66193
if err != nil {
67194
return localVarReturnValue, nil, err

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@
649649
// - [SoftwareCatalogApi.UpsertCatalogEntity]
650650
// - [SoftwareCatalogApi.UpsertCatalogKind]
651651
// - [SpaApi.GetSPARecommendations]
652+
// - [SpaApi.GetSPARecommendationsWithShard]
652653
// - [SpansApi.AggregateSpans]
653654
// - [SpansApi.ListSpans]
654655
// - [SpansApi.ListSpansGet]

0 commit comments

Comments
 (0)