-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CCM-19455]: Added Cluster Orchestrator Models and Create API (#580)
* [CCM-19455]: Added Cluster Orchestrator Models and Create API * added CloudCostClusterOrchestratorApiService to Client * added ClusterOrchestratorDetails method * changed response of cluster orch details api * Added K8sConnID to CreateClusterOrchestratorDto * Added application/json content type
- Loading branch information
Showing
5 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
package nextgen | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io/ioutil" | ||
"net/http" | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
type CloudCostClusterOrchestratorApiService service | ||
|
||
func (a *CloudCostClusterOrchestratorApiService) CreateClusterOrchestrator(ctx context.Context, accountIdentifier string, body CreateClusterOrchestratorDto) (ClusterOrchestratorResponse, *http.Response, error) { | ||
var ( | ||
localVarHttpMethod = strings.ToUpper("Post") | ||
localVarPostBody interface{} | ||
localVarFileName string | ||
localVarFileBytes []byte | ||
localVarReturnValue ClusterOrchestratorResponse | ||
) | ||
|
||
localVarPath := a.client.cfg.BasePath + "/lw/api/accounts/{account_id}/clusters/orchestrator" | ||
localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", fmt.Sprintf("%v", accountIdentifier), -1) | ||
|
||
localVarHeaderParams := make(map[string]string) | ||
localVarQueryParams := url.Values{} | ||
localVarFormParams := url.Values{} | ||
|
||
localVarQueryParams.Add("accountIdentifier", parameterToString(accountIdentifier, "")) | ||
// to determine the Content-Type header | ||
localVarHttpContentTypes := []string{"application/json"} | ||
|
||
// set Content-Type header | ||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) | ||
if localVarHttpContentType != "" { | ||
localVarHeaderParams["Content-Type"] = localVarHttpContentType | ||
} | ||
|
||
// to determine the Accept header | ||
localVarHttpHeaderAccepts := []string{"application/json"} | ||
|
||
// set Accept header | ||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) | ||
if localVarHttpHeaderAccept != "" { | ||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept | ||
} | ||
// body params | ||
localVarPostBody = &body | ||
if ctx != nil { | ||
// API Key Authentication | ||
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { | ||
var key string | ||
if auth.Prefix != "" { | ||
key = auth.Prefix + " " + auth.Key | ||
} else { | ||
key = auth.Key | ||
} | ||
localVarHeaderParams["x-api-key"] = key | ||
|
||
} | ||
} | ||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) | ||
if err != nil { | ||
return localVarReturnValue, nil, err | ||
} | ||
|
||
localVarHttpResponse, err := a.client.callAPI(r) | ||
if err != nil || localVarHttpResponse == nil { | ||
return localVarReturnValue, localVarHttpResponse, err | ||
} | ||
|
||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) | ||
localVarHttpResponse.Body.Close() | ||
if err != nil { | ||
return localVarReturnValue, localVarHttpResponse, err | ||
} | ||
|
||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) | ||
if localVarHttpResponse.StatusCode < 300 { | ||
// If we succeed, return the data, otherwise pass on to decode error. | ||
return localVarReturnValue, localVarHttpResponse, err | ||
} | ||
|
||
if localVarHttpResponse.StatusCode >= 300 { | ||
newErr := GenericSwaggerError{ | ||
body: localVarBody, | ||
error: localVarHttpResponse.Status, | ||
} | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHttpResponse, newErr | ||
} | ||
newErr.error = strings.Join(localVarReturnValue.Errors, ", ") | ||
return localVarReturnValue, localVarHttpResponse, newErr | ||
} | ||
|
||
return localVarReturnValue, localVarHttpResponse, nil | ||
} | ||
func (a *CloudCostClusterOrchestratorApiService) ClusterOrchestratorDetails(ctx context.Context, accountIdentifier string, Identifier string) (ClusterOrchestratorResponse, *http.Response, error) { | ||
var ( | ||
localVarHttpMethod = strings.ToUpper("Get") | ||
localVarPostBody interface{} | ||
localVarFileName string | ||
localVarFileBytes []byte | ||
localVarReturnValue ClusterOrchestratorResponse | ||
) | ||
|
||
// create path and map variables | ||
localVarPath := a.client.cfg.BasePath + "/lw/api/accounts/{account_id}/clusters/orchestrator/{cluster_id}" | ||
localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", fmt.Sprintf("%v", accountIdentifier), -1) | ||
localVarPath = strings.Replace(localVarPath, "{"+"cluster_id"+"}", fmt.Sprintf("%v", Identifier), -1) | ||
|
||
localVarHeaderParams := make(map[string]string) | ||
localVarQueryParams := url.Values{} | ||
localVarFormParams := url.Values{} | ||
|
||
localVarQueryParams.Add("accountIdentifier", parameterToString(accountIdentifier, "")) | ||
// to determine the Content-Type header | ||
localVarHttpContentTypes := []string{} | ||
|
||
// set Content-Type header | ||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) | ||
if localVarHttpContentType != "" { | ||
localVarHeaderParams["Content-Type"] = localVarHttpContentType | ||
} | ||
|
||
// to determine the Accept header | ||
localVarHttpHeaderAccepts := []string{"application/json"} | ||
|
||
// set Accept header | ||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) | ||
if localVarHttpHeaderAccept != "" { | ||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept | ||
} | ||
if ctx != nil { | ||
// API Key Authentication | ||
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { | ||
var key string | ||
if auth.Prefix != "" { | ||
key = auth.Prefix + " " + auth.Key | ||
} else { | ||
key = auth.Key | ||
} | ||
localVarHeaderParams["x-api-key"] = key | ||
} | ||
} | ||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) | ||
if err != nil { | ||
return localVarReturnValue, nil, err | ||
} | ||
|
||
localVarHttpResponse, err := a.client.callAPI(r) | ||
if err != nil || localVarHttpResponse == nil { | ||
return localVarReturnValue, localVarHttpResponse, err | ||
} | ||
|
||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) | ||
localVarHttpResponse.Body.Close() | ||
if err != nil { | ||
return localVarReturnValue, localVarHttpResponse, err | ||
} | ||
|
||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) | ||
if localVarHttpResponse.StatusCode < 300 { | ||
// If we succeed, return the data, otherwise pass on to decode error. | ||
return localVarReturnValue, localVarHttpResponse, err | ||
} | ||
|
||
if localVarHttpResponse.StatusCode >= 300 { | ||
newErr := GenericSwaggerError{ | ||
body: localVarBody, | ||
error: localVarHttpResponse.Status, | ||
} | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHttpResponse, newErr | ||
} | ||
newErr.error = strings.Join(localVarReturnValue.Errors, ", ") | ||
return localVarReturnValue, localVarHttpResponse, newErr | ||
} | ||
|
||
return localVarReturnValue, localVarHttpResponse, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Harness NextGen Software Delivery Platform API Reference | ||
* | ||
* 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> --> | ||
* | ||
* API version: 3.0 | ||
* Contact: [email protected] | ||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
*/ | ||
package nextgen | ||
|
||
type ClusterOrchDistributionSelector string | ||
type ClusterOrchNodeDistributionStrategy string | ||
|
||
type ClusterOrchConfig struct { | ||
SpotDistribution ClusterOrchDistributionSelector `json:"spot_distribution"` | ||
NodeDeletionDelay int `json:"node_deletion_delay"` | ||
DistributionStrategy ClusterOrchNodeDistributionStrategy `json:"distribution_strategy"` | ||
BaseOnDemandCapacity int `json:"base_on_demand_capacity"` | ||
SpotSplit int `json:"spot_split"` | ||
OnDemandSplit int `json:"on_demand_split"` | ||
} | ||
|
||
type ClusterOrchestratorUserConfig struct { | ||
ClusterEndPoint string `json:"cluster_endpoint"` | ||
} | ||
|
||
type ClusterOrchestrator struct { | ||
ID string `json:"id" db:"id"` | ||
AccountID string `json:"account_id" db:"account_id"` | ||
K8sConnectorID string `json:"k8s_connector_id" db:"k8s_connector_id"` | ||
CloudAccID string `json:"cloud_account_id" db:"cloud_account_id"` | ||
Name string `json:"name" db:"name"` | ||
Config *ClusterOrchConfig `json:"config" db:"config"` | ||
UserConfig *ClusterOrchestratorUserConfig `json:"user_config,omitempty" db:"user_config"` | ||
OptimizationEnabled bool `json:"optimization_enabled" db:"optimization_enabled"` | ||
Disabled bool `json:"-" db:"disabled"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Harness NextGen Software Delivery Platform API Reference | ||
* | ||
* 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> --> | ||
* | ||
* API version: 3.0 | ||
* Contact: [email protected] | ||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
*/ | ||
package nextgen | ||
|
||
type CreateClusterOrchestratorDto struct { | ||
Name string `json:"name"` | ||
K8sConnID string `json:"k8s_connector_id"` | ||
UserConfig ClusterOrchestratorUserConfig `json:"user_config"` | ||
} |
16 changes: 16 additions & 0 deletions
16
harness/nextgen/model_create_cluster_orchestrator_response.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Harness NextGen Software Delivery Platform API Reference | ||
* | ||
* 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> --> | ||
* | ||
* API version: 3.0 | ||
* Contact: [email protected] | ||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
*/ | ||
package nextgen | ||
|
||
type ClusterOrchestratorResponse struct { | ||
Response *ClusterOrchestrator `json:"response,omitempty"` | ||
Errors []string `json:"errors,omitempty"` | ||
Success bool `json:"success"` | ||
} |