Skip to content

Commit 61aa5f7

Browse files
authored
feat:[CCM-21658]: Added Support for Updating Cluster orchestrator Config (#659)
1 parent 48f81db commit 61aa5f7

File tree

3 files changed

+159
-6
lines changed

3 files changed

+159
-6
lines changed

harness/nextgen/api_cloud_cost_cluster_orchestrator.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,88 @@ func (a *CloudCostClusterOrchestratorApiService) ClusterOrchestratorDetails(ctx
182182

183183
return localVarReturnValue, localVarHttpResponse, nil
184184
}
185+
func (a *CloudCostClusterOrchestratorApiService) UpdateClusterOrchestratorConfig(ctx context.Context, accountIdentifier string, orchID string, body ClusterOrchConfig) (UpdateClusterOrchestratorConfigResponse, *http.Response, error) {
186+
var (
187+
localVarHttpMethod = strings.ToUpper("Put")
188+
localVarPostBody interface{}
189+
localVarFileName string
190+
localVarFileBytes []byte
191+
localVarReturnValue UpdateClusterOrchestratorConfigResponse
192+
)
193+
194+
localVarPath := fmt.Sprintf("%s/lw/api/accounts/%s/clusters/orchestrator/%s/config", a.client.cfg.BasePath, accountIdentifier, orchID)
195+
196+
localVarHeaderParams := make(map[string]string)
197+
localVarQueryParams := url.Values{}
198+
localVarFormParams := url.Values{}
199+
200+
localVarQueryParams.Add("accountIdentifier", parameterToString(accountIdentifier, ""))
201+
// to determine the Content-Type header
202+
localVarHttpContentTypes := []string{"application/json"}
203+
204+
// set Content-Type header
205+
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
206+
if localVarHttpContentType != "" {
207+
localVarHeaderParams["Content-Type"] = localVarHttpContentType
208+
}
209+
210+
// to determine the Accept header
211+
localVarHttpHeaderAccepts := []string{"application/json"}
212+
213+
// set Accept header
214+
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
215+
if localVarHttpHeaderAccept != "" {
216+
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
217+
}
218+
// body params
219+
localVarPostBody = &body
220+
if ctx != nil {
221+
// API Key Authentication
222+
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
223+
var key string
224+
if auth.Prefix != "" {
225+
key = auth.Prefix + " " + auth.Key
226+
} else {
227+
key = auth.Key
228+
}
229+
localVarHeaderParams["x-api-key"] = key
230+
231+
}
232+
}
233+
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
234+
if err != nil {
235+
return localVarReturnValue, nil, err
236+
}
237+
238+
localVarHttpResponse, err := a.client.callAPI(r)
239+
if err != nil || localVarHttpResponse == nil {
240+
return localVarReturnValue, localVarHttpResponse, err
241+
}
242+
243+
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
244+
localVarHttpResponse.Body.Close()
245+
if err != nil {
246+
return localVarReturnValue, localVarHttpResponse, err
247+
}
248+
249+
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
250+
if localVarHttpResponse.StatusCode < 300 {
251+
// If we succeed, return the data, otherwise pass on to decode error.
252+
return localVarReturnValue, localVarHttpResponse, err
253+
}
254+
255+
if localVarHttpResponse.StatusCode >= 300 {
256+
newErr := GenericSwaggerError{
257+
body: localVarBody,
258+
error: localVarHttpResponse.Status,
259+
}
260+
if err != nil {
261+
newErr.error = err.Error()
262+
return localVarReturnValue, localVarHttpResponse, newErr
263+
}
264+
newErr.error = strings.Join(localVarReturnValue.Errors, ", ")
265+
return localVarReturnValue, localVarHttpResponse, newErr
266+
}
267+
268+
return localVarReturnValue, localVarHttpResponse, nil
269+
}

harness/nextgen/model_cluster_orchestrator.go

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,68 @@
99
*/
1010
package nextgen
1111

12+
import "time"
13+
1214
type ClusterOrchDistributionSelector string
1315
type ClusterOrchNodeDistributionStrategy string
16+
type ConsolidationPolicy string
17+
type replacementWindowType string
18+
type podEvictor struct {
19+
Enabled bool `json:"enabled"`
20+
EvictSingleReplicas bool `json:"evict_single_replicas"`
21+
MinCPU float64 `json:"minimum_cpu"`
22+
MinMem float64 `json:"minimum_memory"`
23+
}
1424

25+
type DisruptionBudget struct {
26+
Reasons []string `json:"reasons,omitempty"`
27+
Nodes string `json:"nodes" hash:"ignore"`
28+
Schedule *string `json:"schedule,omitempty" hash:"ignore"`
29+
Duration string `json:"duration,omitempty" hash:"ignore"`
30+
}
31+
32+
type consolidation struct {
33+
ConsolidationPolicy ConsolidationPolicy `json:"policy"`
34+
ConsolidateAfter string `json:"after"`
35+
Budgets []DisruptionBudget `json:"budgets"`
36+
NodeExpiry *string `json:"node_expiry"`
37+
EnableSpotToSpot bool `json:"enable_spot_to_spot"`
38+
PodEvictor podEvictor `json:"pod_evictor"`
39+
}
40+
type ReverseFallback struct {
41+
Enabled bool `json:"enabled"`
42+
RetryInterval string `json:"retry_interval"`
43+
}
44+
type commitmentIntegration struct {
45+
Enabled bool `json:"enabled"`
46+
CloudAccountID string `json:"cloud_account_id"`
47+
}
48+
type windowAppliesTo struct {
49+
HarnessPodEviction bool `json:"harness_pod_eviction"`
50+
}
51+
type windowDetails struct {
52+
Days []time.Weekday `json:"days"`
53+
AllDay bool `json:"all_day"`
54+
StartTime *TimeInDay `json:"start_time"`
55+
EndTime *TimeInDay `json:"end_time"`
56+
TimeZone string `json:"time_zone"`
57+
}
58+
type replacementWindow struct {
59+
AppliesTo *windowAppliesTo `json:"applies_to"`
60+
ReplacementWindowType replacementWindowType `json:"replacement_window_type"`
61+
WindowDetails *windowDetails `json:"window_details,omitempty"`
62+
}
1563
type ClusterOrchConfig struct {
16-
SpotDistribution ClusterOrchDistributionSelector `json:"spot_distribution"`
17-
NodeDeletionDelay int `json:"node_deletion_delay"`
18-
DistributionStrategy ClusterOrchNodeDistributionStrategy `json:"distribution_strategy"`
19-
BaseOnDemandCapacity int `json:"base_on_demand_capacity"`
20-
SpotSplit int `json:"spot_split"`
21-
OnDemandSplit int `json:"on_demand_split"`
64+
SpotDistribution ClusterOrchDistributionSelector `json:"spot_distribution"`
65+
NodeDeletionDelay int `json:"node_deletion_delay"`
66+
DistributionStrategy ClusterOrchNodeDistributionStrategy `json:"distribution_strategy"`
67+
BaseOnDemandCapacity int `json:"base_on_demand_capacity"`
68+
SpotSplit int `json:"spot_split"`
69+
OnDemandSplit int `json:"on_demand_split"`
70+
Consolidation consolidation `json:"consolidation"`
71+
ReverseFallback *ReverseFallback `json:"reverse_fallback"`
72+
CommitmentIntegration *commitmentIntegration `json:"commitment_integration"`
73+
ReplacementWindow *replacementWindow `json:"replacement_window"`
2274
}
2375

2476
type ClusterOrchestratorUserConfig struct {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Harness NextGen Software Delivery Platform API Reference
3+
*
4+
* This is the Open Api Spec 3 for the NextGen Manager. This is under active development. Beware of the breaking change with respect to the generated code stub # Authentication <!-- ReDoc-Inject: <security-definitions> -->
5+
*
6+
* API version: 3.0
7+
* Contact: [email protected]
8+
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
9+
*/
10+
package nextgen
11+
12+
type UpdateClusterOrchestratorConfigResponse struct {
13+
Success bool `json:"success"`
14+
Errors []string `json:"errors"`
15+
Response string `json:"response"`
16+
}

0 commit comments

Comments
 (0)