-
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.
Merge pull request #175 from harness/del-ng-api
adding delegate resource
- Loading branch information
Showing
7 changed files
with
558 additions
and
29 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,261 @@ | ||
/* | ||
* 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 | ||
* | ||
* API version: 3.0 | ||
* Contact: [email protected] | ||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
*/ | ||
package nextgen | ||
|
||
import ( | ||
"context" | ||
"io/ioutil" | ||
"net/http" | ||
"net/url" | ||
"strings" | ||
|
||
"github.com/antihax/optional" | ||
) | ||
|
||
// Linger please | ||
var ( | ||
_ context.Context | ||
) | ||
|
||
type DelegateDownloadResourceApiService service | ||
|
||
/* | ||
DelegateDownloadResourceApiService Downloads a docker delegate yaml file. | ||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | ||
* @param body Parameters needed for downloading docker delegate yaml | ||
* @param accountIdentifier Account Identifier for the Entity. | ||
* @param optional nil or *DelegateDownloadResourceApiDownloadDockerDelegateYamlOpts - Optional Parameters: | ||
* @param "OrgIdentifier" (optional.String) - Organization Identifier for the Entity. | ||
* @param "ProjectIdentifier" (optional.String) - Project Identifier for the Entity. | ||
*/ | ||
|
||
type DelegateDownloadResourceApiDownloadDockerDelegateYamlOpts struct { | ||
OrgIdentifier optional.String | ||
ProjectIdentifier optional.String | ||
} | ||
|
||
func (a *DelegateDownloadResourceApiService) DownloadDockerDelegateYaml(ctx context.Context, body DelegateDownloadRequest, accountIdentifier string, localVarOptionals *DelegateDownloadResourceApiDownloadDockerDelegateYamlOpts) (*http.Response, error) { | ||
var ( | ||
localVarHttpMethod = strings.ToUpper("Post") | ||
localVarPostBody interface{} | ||
localVarFileName string | ||
localVarFileBytes []byte | ||
) | ||
|
||
// create path and map variables | ||
localVarPath := a.client.cfg.BasePath + "/ng/api/download-delegates/docker" | ||
|
||
localVarHeaderParams := make(map[string]string) | ||
localVarQueryParams := url.Values{} | ||
localVarFormParams := url.Values{} | ||
|
||
localVarQueryParams.Add("accountIdentifier", parameterToString(accountIdentifier, "")) | ||
if localVarOptionals != nil && localVarOptionals.OrgIdentifier.IsSet() { | ||
localVarQueryParams.Add("orgIdentifier", parameterToString(localVarOptionals.OrgIdentifier.Value(), "")) | ||
} | ||
if localVarOptionals != nil && localVarOptionals.ProjectIdentifier.IsSet() { | ||
localVarQueryParams.Add("projectIdentifier", parameterToString(localVarOptionals.ProjectIdentifier.Value(), "")) | ||
} | ||
// 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", "application/yaml"} | ||
|
||
// 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 nil, err | ||
} | ||
|
||
localVarHttpResponse, err := a.client.callAPI(r) | ||
if err != nil || localVarHttpResponse == nil { | ||
return localVarHttpResponse, err | ||
} | ||
|
||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) | ||
localVarHttpResponse.Body.Close() | ||
if err != nil { | ||
return localVarHttpResponse, err | ||
} | ||
|
||
if localVarHttpResponse.StatusCode >= 300 { | ||
newErr := GenericSwaggerError{ | ||
body: localVarBody, | ||
error: localVarHttpResponse.Status, | ||
} | ||
if localVarHttpResponse.StatusCode == 400 { | ||
var v Failure | ||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarHttpResponse, newErr | ||
} | ||
newErr.model = v | ||
return localVarHttpResponse, newErr | ||
} | ||
if localVarHttpResponse.StatusCode == 500 { | ||
var v ModelError | ||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarHttpResponse, newErr | ||
} | ||
newErr.model = v | ||
return localVarHttpResponse, newErr | ||
} | ||
return localVarHttpResponse, newErr | ||
} | ||
|
||
return localVarHttpResponse, nil | ||
} | ||
|
||
/* | ||
DelegateDownloadResourceApiService Downloads a kubernetes delegate yaml file. | ||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | ||
* @param body Parameters needed for downloading kubernetes delegate yaml | ||
* @param accountIdentifier Account Identifier for the Entity. | ||
* @param optional nil or *DelegateDownloadResourceApiDownloadKubernetesDelegateYamlOpts - Optional Parameters: | ||
* @param "OrgIdentifier" (optional.String) - Organization Identifier for the Entity. | ||
* @param "ProjectIdentifier" (optional.String) - Project Identifier for the Entity. | ||
*/ | ||
|
||
type DelegateDownloadResourceApiDownloadKubernetesDelegateYamlOpts struct { | ||
OrgIdentifier optional.String | ||
ProjectIdentifier optional.String | ||
} | ||
|
||
func (a *DelegateDownloadResourceApiService) DownloadKubernetesDelegateYaml(ctx context.Context, body DelegateDownloadRequest, accountIdentifier string, localVarOptionals *DelegateDownloadResourceApiDownloadKubernetesDelegateYamlOpts) (*http.Response, error) { | ||
var ( | ||
localVarHttpMethod = strings.ToUpper("Post") | ||
localVarPostBody interface{} | ||
localVarFileName string | ||
localVarFileBytes []byte | ||
) | ||
|
||
// create path and map variables | ||
localVarPath := a.client.cfg.BasePath + "/ng/api/download-delegates/kubernetes" | ||
|
||
localVarHeaderParams := make(map[string]string) | ||
localVarQueryParams := url.Values{} | ||
localVarFormParams := url.Values{} | ||
|
||
localVarQueryParams.Add("accountIdentifier", parameterToString(accountIdentifier, "")) | ||
if localVarOptionals != nil && localVarOptionals.OrgIdentifier.IsSet() { | ||
localVarQueryParams.Add("orgIdentifier", parameterToString(localVarOptionals.OrgIdentifier.Value(), "")) | ||
} | ||
if localVarOptionals != nil && localVarOptionals.ProjectIdentifier.IsSet() { | ||
localVarQueryParams.Add("projectIdentifier", parameterToString(localVarOptionals.ProjectIdentifier.Value(), "")) | ||
} | ||
// 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", "application/yaml"} | ||
|
||
// 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 nil, err | ||
} | ||
|
||
localVarHttpResponse, err := a.client.callAPI(r) | ||
if err != nil || localVarHttpResponse == nil { | ||
return localVarHttpResponse, err | ||
} | ||
|
||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) | ||
localVarHttpResponse.Body.Close() | ||
if err != nil { | ||
return localVarHttpResponse, err | ||
} | ||
|
||
if localVarHttpResponse.StatusCode >= 300 { | ||
newErr := GenericSwaggerError{ | ||
body: localVarBody, | ||
error: localVarHttpResponse.Status, | ||
} | ||
if localVarHttpResponse.StatusCode == 400 { | ||
var v Failure | ||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarHttpResponse, newErr | ||
} | ||
newErr.model = v | ||
return localVarHttpResponse, newErr | ||
} | ||
if localVarHttpResponse.StatusCode == 500 { | ||
var v ModelError | ||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarHttpResponse, newErr | ||
} | ||
newErr.model = v | ||
return localVarHttpResponse, newErr | ||
} | ||
return localVarHttpResponse, newErr | ||
} | ||
|
||
return localVarHttpResponse, nil | ||
} |
Oops, something went wrong.