@@ -17,15 +17,40 @@ import (
1717// SpaApi service type
1818type 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
0 commit comments