mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
737 lines
26 KiB
Go
737 lines
26 KiB
Go
/*
|
|
Hanzo Cloud API
|
|
|
|
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
|
|
|
|
API version: v1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package hanzoai
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// EnvironmentAPIService EnvironmentAPI service
|
|
type EnvironmentAPIService service
|
|
|
|
type EnvironmentAPIDeleteEnvironmentByRepoRequest struct {
|
|
ctx context.Context
|
|
ApiService *EnvironmentAPIService
|
|
repo string
|
|
}
|
|
|
|
func (r EnvironmentAPIDeleteEnvironmentByRepoRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.DeleteEnvironmentByRepoExecute(r)
|
|
}
|
|
|
|
/*
|
|
DeleteEnvironmentByRepo Forgets one codebase's environment, and its secrets with it.
|
|
|
|
Forgets one codebase's environment, and its secrets with it.
|
|
|
|
Later runs on the codebase start bare. Each secret's value is removed from KMS
|
|
first; one that will not go stops the forget, so no value outlives the record
|
|
that names it. Org admin only.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param repo Repo is the repository's name in the caller's org — a name, never owner/name.
|
|
@return EnvironmentAPIDeleteEnvironmentByRepoRequest
|
|
*/
|
|
func (a *EnvironmentAPIService) DeleteEnvironmentByRepo(ctx context.Context, repo string) EnvironmentAPIDeleteEnvironmentByRepoRequest {
|
|
return EnvironmentAPIDeleteEnvironmentByRepoRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
repo: repo,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *EnvironmentAPIService) DeleteEnvironmentByRepoExecute(r EnvironmentAPIDeleteEnvironmentByRepoRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EnvironmentAPIService.DeleteEnvironmentByRepo")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/environment/{repo}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"repo"+"}", url.PathEscape(parameterValueToString(r.repo, "repo")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// 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/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EnvironmentAPIDeleteEnvironmentByRepoSecretsByNameRequest struct {
|
|
ctx context.Context
|
|
ApiService *EnvironmentAPIService
|
|
repo string
|
|
name string
|
|
}
|
|
|
|
func (r EnvironmentAPIDeleteEnvironmentByRepoSecretsByNameRequest) Execute() (*EnvironmentEnvironment, *http.Response, error) {
|
|
return r.ApiService.DeleteEnvironmentByRepoSecretsByNameExecute(r)
|
|
}
|
|
|
|
/*
|
|
DeleteEnvironmentByRepoSecretsByName Removes one secret from a codebase.
|
|
|
|
Removes one secret from a codebase.
|
|
|
|
The value is removed from KMS, then the name from the environment; later runs
|
|
no longer export it. Removing a name that is not set is a 404. Org admin only.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param repo Repo is the repository's name in the caller's org.
|
|
@param name Name is the secret's environment variable name.
|
|
@return EnvironmentAPIDeleteEnvironmentByRepoSecretsByNameRequest
|
|
*/
|
|
func (a *EnvironmentAPIService) DeleteEnvironmentByRepoSecretsByName(ctx context.Context, repo string, name string) EnvironmentAPIDeleteEnvironmentByRepoSecretsByNameRequest {
|
|
return EnvironmentAPIDeleteEnvironmentByRepoSecretsByNameRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
repo: repo,
|
|
name: name,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EnvironmentEnvironment
|
|
func (a *EnvironmentAPIService) DeleteEnvironmentByRepoSecretsByNameExecute(r EnvironmentAPIDeleteEnvironmentByRepoSecretsByNameRequest) (*EnvironmentEnvironment, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EnvironmentEnvironment
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EnvironmentAPIService.DeleteEnvironmentByRepoSecretsByName")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/environment/{repo}/secrets/{name}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"repo"+"}", url.PathEscape(parameterValueToString(r.repo, "repo")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// 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", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EnvironmentAPIGetEnvironmentRequest struct {
|
|
ctx context.Context
|
|
ApiService *EnvironmentAPIService
|
|
}
|
|
|
|
func (r EnvironmentAPIGetEnvironmentRequest) Execute() (*EnvironmentEnvList, *http.Response, error) {
|
|
return r.ApiService.GetEnvironmentExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEnvironment Lists every codebase in your org that has an environment.
|
|
|
|
Lists every codebase in your org that has an environment.
|
|
|
|
An environment is what a coding run does to its checkout before its agent
|
|
starts: the install script, the start command and the secrets it exports.
|
|
Secret values are never answered — only which names are set. A codebase with
|
|
nothing saved and nothing proposed is not listed.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EnvironmentAPIGetEnvironmentRequest
|
|
*/
|
|
func (a *EnvironmentAPIService) GetEnvironment(ctx context.Context) EnvironmentAPIGetEnvironmentRequest {
|
|
return EnvironmentAPIGetEnvironmentRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EnvironmentEnvList
|
|
func (a *EnvironmentAPIService) GetEnvironmentExecute(r EnvironmentAPIGetEnvironmentRequest) (*EnvironmentEnvList, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EnvironmentEnvList
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EnvironmentAPIService.GetEnvironment")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/environment"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// 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", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EnvironmentAPIGetEnvironmentByRepoRequest struct {
|
|
ctx context.Context
|
|
ApiService *EnvironmentAPIService
|
|
repo string
|
|
}
|
|
|
|
func (r EnvironmentAPIGetEnvironmentByRepoRequest) Execute() (*EnvironmentEnvironment, *http.Response, error) {
|
|
return r.ApiService.GetEnvironmentByRepoExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEnvironmentByRepo Reads one codebase's environment.
|
|
|
|
Reads one codebase's environment.
|
|
|
|
A codebase with none answers 200 with state `none` and empty scripts, so a
|
|
surface can always draw the editor. `proposed` means a setup run's answer is
|
|
waiting in `proposal`; nothing in it runs until it is saved.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param repo Repo is the repository's name in the caller's org — a name, never owner/name.
|
|
@return EnvironmentAPIGetEnvironmentByRepoRequest
|
|
*/
|
|
func (a *EnvironmentAPIService) GetEnvironmentByRepo(ctx context.Context, repo string) EnvironmentAPIGetEnvironmentByRepoRequest {
|
|
return EnvironmentAPIGetEnvironmentByRepoRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
repo: repo,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EnvironmentEnvironment
|
|
func (a *EnvironmentAPIService) GetEnvironmentByRepoExecute(r EnvironmentAPIGetEnvironmentByRepoRequest) (*EnvironmentEnvironment, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EnvironmentEnvironment
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EnvironmentAPIService.GetEnvironmentByRepo")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/environment/{repo}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"repo"+"}", url.PathEscape(parameterValueToString(r.repo, "repo")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// 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", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EnvironmentAPIPutEnvironmentByRepoRequest struct {
|
|
ctx context.Context
|
|
ApiService *EnvironmentAPIService
|
|
repo string
|
|
environmentEnvSave *EnvironmentEnvSave
|
|
}
|
|
|
|
func (r EnvironmentAPIPutEnvironmentByRepoRequest) EnvironmentEnvSave(environmentEnvSave EnvironmentEnvSave) EnvironmentAPIPutEnvironmentByRepoRequest {
|
|
r.environmentEnvSave = &environmentEnvSave
|
|
return r
|
|
}
|
|
|
|
func (r EnvironmentAPIPutEnvironmentByRepoRequest) Execute() (*EnvironmentEnvironment, *http.Response, error) {
|
|
return r.ApiService.PutEnvironmentByRepoExecute(r)
|
|
}
|
|
|
|
/*
|
|
PutEnvironmentByRepo Saves one codebase's install and start scripts.
|
|
|
|
Saves one codebase's install and start scripts.
|
|
|
|
Every later sandbox run on this codebase runs the install script in its fresh
|
|
checkout before the agent starts, and leaves the start command running in the
|
|
background. Saving clears any pending proposal: saving is the review. Secrets
|
|
are set one at a time on their own address and are left as they are. Org admin
|
|
only.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param repo Repo is the repository's name in the caller's org.
|
|
@return EnvironmentAPIPutEnvironmentByRepoRequest
|
|
*/
|
|
func (a *EnvironmentAPIService) PutEnvironmentByRepo(ctx context.Context, repo string) EnvironmentAPIPutEnvironmentByRepoRequest {
|
|
return EnvironmentAPIPutEnvironmentByRepoRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
repo: repo,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EnvironmentEnvironment
|
|
func (a *EnvironmentAPIService) PutEnvironmentByRepoExecute(r EnvironmentAPIPutEnvironmentByRepoRequest) (*EnvironmentEnvironment, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EnvironmentEnvironment
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EnvironmentAPIService.PutEnvironmentByRepo")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/environment/{repo}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"repo"+"}", url.PathEscape(parameterValueToString(r.repo, "repo")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.environmentEnvSave == nil {
|
|
return localVarReturnValue, nil, reportError("environmentEnvSave is required and must be specified")
|
|
}
|
|
|
|
// 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/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.environmentEnvSave
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EnvironmentAPIPutEnvironmentByRepoSecretsByNameRequest struct {
|
|
ctx context.Context
|
|
ApiService *EnvironmentAPIService
|
|
repo string
|
|
name string
|
|
environmentEnvSecret *EnvironmentEnvSecret
|
|
}
|
|
|
|
func (r EnvironmentAPIPutEnvironmentByRepoSecretsByNameRequest) EnvironmentEnvSecret(environmentEnvSecret EnvironmentEnvSecret) EnvironmentAPIPutEnvironmentByRepoSecretsByNameRequest {
|
|
r.environmentEnvSecret = &environmentEnvSecret
|
|
return r
|
|
}
|
|
|
|
func (r EnvironmentAPIPutEnvironmentByRepoSecretsByNameRequest) Execute() (*EnvironmentEnvironment, *http.Response, error) {
|
|
return r.ApiService.PutEnvironmentByRepoSecretsByNameExecute(r)
|
|
}
|
|
|
|
/*
|
|
PutEnvironmentByRepoSecretsByName Sets one secret on a codebase.
|
|
|
|
Sets one secret on a codebase.
|
|
|
|
The value is sealed in KMS and exported to every later sandbox run on this
|
|
codebase under its name, a setup run included. It is blinded out of every
|
|
stream the run publishes, and no route answers it back. Setting a name that is
|
|
already set replaces its value. Org admin only.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param repo Repo is the repository's name in the caller's org.
|
|
@param name Name is the environment variable the run exports the value under.
|
|
@return EnvironmentAPIPutEnvironmentByRepoSecretsByNameRequest
|
|
*/
|
|
func (a *EnvironmentAPIService) PutEnvironmentByRepoSecretsByName(ctx context.Context, repo string, name string) EnvironmentAPIPutEnvironmentByRepoSecretsByNameRequest {
|
|
return EnvironmentAPIPutEnvironmentByRepoSecretsByNameRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
repo: repo,
|
|
name: name,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EnvironmentEnvironment
|
|
func (a *EnvironmentAPIService) PutEnvironmentByRepoSecretsByNameExecute(r EnvironmentAPIPutEnvironmentByRepoSecretsByNameRequest) (*EnvironmentEnvironment, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EnvironmentEnvironment
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EnvironmentAPIService.PutEnvironmentByRepoSecretsByName")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/environment/{repo}/secrets/{name}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"repo"+"}", url.PathEscape(parameterValueToString(r.repo, "repo")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.environmentEnvSecret == nil {
|
|
return localVarReturnValue, nil, reportError("environmentEnvSecret is required and must be specified")
|
|
}
|
|
|
|
// 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/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.environmentEnvSecret
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|