terraform-provider-stackitp.../pkg/albbeta/api_default.go
Marcel S. Henselin 9f41c4da7f
Some checks failed
Publish / Check GoReleaser config (push) Successful in 4s
Release / goreleaser (push) Failing after 29s
Publish / Publish provider (push) Failing after 4m24s
feat: auto generated files and new structure (#4)
## Description

<!-- **Please link some issue here describing what you are trying to achieve.**

In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->

relates to #1234

## Checklist

- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)

Reviewed-on: #4
Reviewed-by: Andre_Harms <andre.harms@stackit.cloud>
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
2026-01-29 14:10:25 +00:00

2409 lines
84 KiB
Go

/*
STACKIT Application Load Balancer API
### DEPRECATED! This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each application load balancer provided, two VMs are deployed in your OpenStack project subject to a fee.
API version: 2beta2.0.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package albbeta
import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"github.com/stackitcloud/stackit-sdk-go/core/config"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
)
type DefaultApi interface {
/*
CreateCredentials Create credentials for observability of the application load balancer
Created credentials can be stored and used for the load balancer observability. For example, when using STACKIT
Observability, credentials first must be created for that STACKIT Observability instance (by using their API or the
STACKIT Portal) and then can be provided to the load balancer by storing them with this endpoint.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiCreateCredentialsRequest
*/
CreateCredentials(ctx context.Context, projectId string, region string) ApiCreateCredentialsRequest
/*
CreateCredentialsExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return CreateCredentialsResponse
*/
CreateCredentialsExecute(ctx context.Context, projectId string, region string) (*CreateCredentialsResponse, error)
/*
CreateLoadBalancer Create an application load balancer in a project
Creates an Application Load Balancer.
The default load balancing algorithm is Maglev, and selecting a different algorithm is currently not supported.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiCreateLoadBalancerRequest
*/
CreateLoadBalancer(ctx context.Context, projectId string, region string) ApiCreateLoadBalancerRequest
/*
CreateLoadBalancerExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return LoadBalancer
*/
CreateLoadBalancerExecute(ctx context.Context, projectId string, region string) (*LoadBalancer, error)
/*
DeleteCredentials Delete a single credential in a project.
Deletes the stored Observability credentials.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return ApiDeleteCredentialsRequest
*/
DeleteCredentials(ctx context.Context, projectId string, region string, credentialsRef string) ApiDeleteCredentialsRequest
/*
DeleteCredentialsExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return map[string]interface{}
*/
DeleteCredentialsExecute(ctx context.Context, projectId string, region string, credentialsRef string) (map[string]interface{}, error)
/*
DeleteLoadBalancer Delete a given load balancer in a project.
Deletes the specified Application Load Balancer.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return ApiDeleteLoadBalancerRequest
*/
DeleteLoadBalancer(ctx context.Context, projectId string, region string, name string) ApiDeleteLoadBalancerRequest
/*
DeleteLoadBalancerExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return map[string]interface{}
*/
DeleteLoadBalancerExecute(ctx context.Context, projectId string, region string, name string) (map[string]interface{}, error)
/*
GetCredentials Get a single credential reference in a project.
Gets the stored Observability credentials.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return ApiGetCredentialsRequest
*/
GetCredentials(ctx context.Context, projectId string, region string, credentialsRef string) ApiGetCredentialsRequest
/*
GetCredentialsExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return GetCredentialsResponse
*/
GetCredentialsExecute(ctx context.Context, projectId string, region string, credentialsRef string) (*GetCredentialsResponse, error)
/*
GetLoadBalancer Get a single application load balancer in a project.
Retrieves details of a specific Application Load Balancer in a project.
Includes creation and update information, current status, and any error descriptions.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return ApiGetLoadBalancerRequest
*/
GetLoadBalancer(ctx context.Context, projectId string, region string, name string) ApiGetLoadBalancerRequest
/*
GetLoadBalancerExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return LoadBalancer
*/
GetLoadBalancerExecute(ctx context.Context, projectId string, region string, name string) (*LoadBalancer, error)
/*
GetQuota Get the quota of Application Load Balancers in a project.
Retrieves the configured Application Load Balancer quota for the project. Limit can be changed via service request.
There can be 3 times as many TLS certificates and observability credentials as Load Balancers.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiGetQuotaRequest
*/
GetQuota(ctx context.Context, projectId string, region string) ApiGetQuotaRequest
/*
GetQuotaExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return GetQuotaResponse
*/
GetQuotaExecute(ctx context.Context, projectId string, region string) (*GetQuotaResponse, error)
/*
ListCredentials List all credentials in a project.
Lists the stored Observability credentials.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiListCredentialsRequest
*/
ListCredentials(ctx context.Context, projectId string, region string) ApiListCredentialsRequest
/*
ListCredentialsExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ListCredentialsResponse
*/
ListCredentialsExecute(ctx context.Context, projectId string, region string) (*ListCredentialsResponse, error)
/*
ListLoadBalancers List load balancers in a project.
Lists all Application Load Balancers in a project.
Includes details from creation or updates, along with their status and any error descriptions.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiListLoadBalancersRequest
*/
ListLoadBalancers(ctx context.Context, projectId string, region string) ApiListLoadBalancersRequest
/*
ListLoadBalancersExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ListLoadBalancersResponse
*/
ListLoadBalancersExecute(ctx context.Context, projectId string, region string) (*ListLoadBalancersResponse, error)
/*
ListPlans List available service plans.
Lists the configured service plans for a project.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param region
@return ApiListPlansRequest
*/
ListPlans(ctx context.Context, region string) ApiListPlansRequest
/*
ListPlansExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param region
@return ListPlansResponse
*/
ListPlansExecute(ctx context.Context, region string) (*ListPlansResponse, error)
/*
UpdateCredentials Update credentials for observability in a project.
Updates the stored Observability credentials.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return ApiUpdateCredentialsRequest
*/
UpdateCredentials(ctx context.Context, projectId string, region string, credentialsRef string) ApiUpdateCredentialsRequest
/*
UpdateCredentialsExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return UpdateCredentialsResponse
*/
UpdateCredentialsExecute(ctx context.Context, projectId string, region string, credentialsRef string) (*UpdateCredentialsResponse, error)
/*
UpdateLoadBalancer Update a load balancer in a project.
Updates an existing Application Load Balancer by modifying its listeners and target pools.
Ensure the resource version is current to maintain concurrency safety.
The default load balancing algorithm is Maglev, and selecting a different algorithm is currently not supported.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return ApiUpdateLoadBalancerRequest
*/
UpdateLoadBalancer(ctx context.Context, projectId string, region string, name string) ApiUpdateLoadBalancerRequest
/*
UpdateLoadBalancerExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return LoadBalancer
*/
UpdateLoadBalancerExecute(ctx context.Context, projectId string, region string, name string) (*LoadBalancer, error)
/*
UpdateTargetPool Update a single target pool of a load balancer in a project.
Replaces the content of a specific target pool in the Application Load Balancer (useful for adding or removing target servers).
Only updates the specified target pool, leaving others unchanged.
Cannot be used to create or rename target pools.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@param targetPoolName
@return ApiUpdateTargetPoolRequest
*/
UpdateTargetPool(ctx context.Context, projectId string, region string, name string, targetPoolName string) ApiUpdateTargetPoolRequest
/*
UpdateTargetPoolExecute executes the request
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@param targetPoolName
@return TargetPool
*/
UpdateTargetPoolExecute(ctx context.Context, projectId string, region string, name string, targetPoolName string) (*TargetPool, error)
}
type ApiCreateCredentialsRequest interface {
CreateCredentialsPayload(createCredentialsPayload CreateCredentialsPayload) ApiCreateCredentialsRequest
XRequestID(xRequestID string) ApiCreateCredentialsRequest
Execute() (*CreateCredentialsResponse, error)
}
type ApiCreateLoadBalancerRequest interface {
CreateLoadBalancerPayload(createLoadBalancerPayload CreateLoadBalancerPayload) ApiCreateLoadBalancerRequest
XRequestID(xRequestID string) ApiCreateLoadBalancerRequest
Execute() (*LoadBalancer, error)
}
type ApiDeleteCredentialsRequest interface {
Execute() (map[string]interface{}, error)
}
type ApiDeleteLoadBalancerRequest interface {
Execute() (map[string]interface{}, error)
}
type ApiGetCredentialsRequest interface {
Execute() (*GetCredentialsResponse, error)
}
type ApiGetLoadBalancerRequest interface {
Execute() (*LoadBalancer, error)
}
type ApiGetQuotaRequest interface {
Execute() (*GetQuotaResponse, error)
}
type ApiListCredentialsRequest interface {
Execute() (*ListCredentialsResponse, error)
}
type ApiListLoadBalancersRequest interface {
// page_size specifies how many load balancers should be returned on this page. Must be a positive number &lt;&#x3D; 1000
PageSize(pageSize string) ApiListLoadBalancersRequest
// page_id is a page identifier returned by the previous response and is used to request the next page
PageId(pageId string) ApiListLoadBalancersRequest
Execute() (*ListLoadBalancersResponse, error)
}
type ApiListPlansRequest interface {
Execute() (*ListPlansResponse, error)
}
type ApiUpdateCredentialsRequest interface {
UpdateCredentialsPayload(updateCredentialsPayload UpdateCredentialsPayload) ApiUpdateCredentialsRequest
Execute() (*UpdateCredentialsResponse, error)
}
type ApiUpdateLoadBalancerRequest interface {
UpdateLoadBalancerPayload(updateLoadBalancerPayload UpdateLoadBalancerPayload) ApiUpdateLoadBalancerRequest
Execute() (*LoadBalancer, error)
}
type ApiUpdateTargetPoolRequest interface {
UpdateTargetPoolPayload(updateTargetPoolPayload UpdateTargetPoolPayload) ApiUpdateTargetPoolRequest
Execute() (*TargetPool, error)
}
// DefaultApiService DefaultApi service
type DefaultApiService service
type CreateCredentialsRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
createCredentialsPayload *CreateCredentialsPayload
xRequestID *string
}
func (r CreateCredentialsRequest) CreateCredentialsPayload(createCredentialsPayload CreateCredentialsPayload) ApiCreateCredentialsRequest {
r.createCredentialsPayload = &createCredentialsPayload
return r
}
func (r CreateCredentialsRequest) XRequestID(xRequestID string) ApiCreateCredentialsRequest {
r.xRequestID = &xRequestID
return r
}
func (r CreateCredentialsRequest) Execute() (*CreateCredentialsResponse, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *CreateCredentialsResponse
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateCredentials")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/credentials"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.createCredentialsPayload == nil {
return localVarReturnValue, fmt.Errorf("createCredentialsPayload 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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.xRequestID != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Request-ID", r.xRequestID, "")
}
// body params
localVarPostBody = r.createCredentialsPayload
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
CreateCredentials: Create credentials for observability of the application load balancer
Created credentials can be stored and used for the load balancer observability. For example, when using STACKIT
Observability, credentials first must be created for that STACKIT Observability instance (by using their API or the
STACKIT Portal) and then can be provided to the load balancer by storing them with this endpoint.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiCreateCredentialsRequest
*/
func (a *APIClient) CreateCredentials(ctx context.Context, projectId string, region string) ApiCreateCredentialsRequest {
return CreateCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
}
func (a *APIClient) CreateCredentialsExecute(ctx context.Context, projectId string, region string) (*CreateCredentialsResponse, error) {
r := CreateCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
return r.Execute()
}
type CreateLoadBalancerRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
createLoadBalancerPayload *CreateLoadBalancerPayload
xRequestID *string
}
func (r CreateLoadBalancerRequest) CreateLoadBalancerPayload(createLoadBalancerPayload CreateLoadBalancerPayload) ApiCreateLoadBalancerRequest {
r.createLoadBalancerPayload = &createLoadBalancerPayload
return r
}
func (r CreateLoadBalancerRequest) XRequestID(xRequestID string) ApiCreateLoadBalancerRequest {
r.xRequestID = &xRequestID
return r
}
func (r CreateLoadBalancerRequest) Execute() (*LoadBalancer, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LoadBalancer
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateLoadBalancer")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/load-balancers"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.createLoadBalancerPayload == nil {
return localVarReturnValue, fmt.Errorf("createLoadBalancerPayload 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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.xRequestID != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Request-ID", r.xRequestID, "")
}
// body params
localVarPostBody = r.createLoadBalancerPayload
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
CreateLoadBalancer: Create an application load balancer in a project
Creates an Application Load Balancer.
The default load balancing algorithm is Maglev, and selecting a different algorithm is currently not supported.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiCreateLoadBalancerRequest
*/
func (a *APIClient) CreateLoadBalancer(ctx context.Context, projectId string, region string) ApiCreateLoadBalancerRequest {
return CreateLoadBalancerRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
}
func (a *APIClient) CreateLoadBalancerExecute(ctx context.Context, projectId string, region string) (*LoadBalancer, error) {
r := CreateLoadBalancerRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
return r.Execute()
}
type DeleteCredentialsRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
credentialsRef string
}
func (r DeleteCredentialsRequest) Execute() (map[string]interface{}, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue map[string]interface{}
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteCredentials")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/credentials/{credentialsRef}"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"credentialsRef"+"}", url.PathEscape(ParameterValueToString(r.credentialsRef, "credentialsRef")), -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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
DeleteCredentials: Delete a single credential in a project.
Deletes the stored Observability credentials.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return ApiDeleteCredentialsRequest
*/
func (a *APIClient) DeleteCredentials(ctx context.Context, projectId string, region string, credentialsRef string) ApiDeleteCredentialsRequest {
return DeleteCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
credentialsRef: credentialsRef,
}
}
func (a *APIClient) DeleteCredentialsExecute(ctx context.Context, projectId string, region string, credentialsRef string) (map[string]interface{}, error) {
r := DeleteCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
credentialsRef: credentialsRef,
}
return r.Execute()
}
type DeleteLoadBalancerRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
name string
}
func (r DeleteLoadBalancerRequest) Execute() (map[string]interface{}, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue map[string]interface{}
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteLoadBalancer")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/load-balancers/{name}"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
DeleteLoadBalancer: Delete a given load balancer in a project.
Deletes the specified Application Load Balancer.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return ApiDeleteLoadBalancerRequest
*/
func (a *APIClient) DeleteLoadBalancer(ctx context.Context, projectId string, region string, name string) ApiDeleteLoadBalancerRequest {
return DeleteLoadBalancerRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
name: name,
}
}
func (a *APIClient) DeleteLoadBalancerExecute(ctx context.Context, projectId string, region string, name string) (map[string]interface{}, error) {
r := DeleteLoadBalancerRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
name: name,
}
return r.Execute()
}
type GetCredentialsRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
credentialsRef string
}
func (r GetCredentialsRequest) Execute() (*GetCredentialsResponse, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *GetCredentialsResponse
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCredentials")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/credentials/{credentialsRef}"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"credentialsRef"+"}", url.PathEscape(ParameterValueToString(r.credentialsRef, "credentialsRef")), -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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
GetCredentials: Get a single credential reference in a project.
Gets the stored Observability credentials.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return ApiGetCredentialsRequest
*/
func (a *APIClient) GetCredentials(ctx context.Context, projectId string, region string, credentialsRef string) ApiGetCredentialsRequest {
return GetCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
credentialsRef: credentialsRef,
}
}
func (a *APIClient) GetCredentialsExecute(ctx context.Context, projectId string, region string, credentialsRef string) (*GetCredentialsResponse, error) {
r := GetCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
credentialsRef: credentialsRef,
}
return r.Execute()
}
type GetLoadBalancerRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
name string
}
func (r GetLoadBalancerRequest) Execute() (*LoadBalancer, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LoadBalancer
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetLoadBalancer")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/load-balancers/{name}"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
GetLoadBalancer: Get a single application load balancer in a project.
Retrieves details of a specific Application Load Balancer in a project.
Includes creation and update information, current status, and any error descriptions.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return ApiGetLoadBalancerRequest
*/
func (a *APIClient) GetLoadBalancer(ctx context.Context, projectId string, region string, name string) ApiGetLoadBalancerRequest {
return GetLoadBalancerRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
name: name,
}
}
func (a *APIClient) GetLoadBalancerExecute(ctx context.Context, projectId string, region string, name string) (*LoadBalancer, error) {
r := GetLoadBalancerRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
name: name,
}
return r.Execute()
}
type GetQuotaRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
}
func (r GetQuotaRequest) Execute() (*GetQuotaResponse, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *GetQuotaResponse
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetQuota")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/quota"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
GetQuota: Get the quota of Application Load Balancers in a project.
Retrieves the configured Application Load Balancer quota for the project. Limit can be changed via service request.
There can be 3 times as many TLS certificates and observability credentials as Load Balancers.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiGetQuotaRequest
*/
func (a *APIClient) GetQuota(ctx context.Context, projectId string, region string) ApiGetQuotaRequest {
return GetQuotaRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
}
func (a *APIClient) GetQuotaExecute(ctx context.Context, projectId string, region string) (*GetQuotaResponse, error) {
r := GetQuotaRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
return r.Execute()
}
type ListCredentialsRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
}
func (r ListCredentialsRequest) Execute() (*ListCredentialsResponse, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *ListCredentialsResponse
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCredentials")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/credentials"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
ListCredentials: List all credentials in a project.
Lists the stored Observability credentials.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiListCredentialsRequest
*/
func (a *APIClient) ListCredentials(ctx context.Context, projectId string, region string) ApiListCredentialsRequest {
return ListCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
}
func (a *APIClient) ListCredentialsExecute(ctx context.Context, projectId string, region string) (*ListCredentialsResponse, error) {
r := ListCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
return r.Execute()
}
type ListLoadBalancersRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
pageSize *string
pageId *string
}
// page_size specifies how many load balancers should be returned on this page. Must be a positive number &lt;&#x3D; 1000
func (r ListLoadBalancersRequest) PageSize(pageSize string) ApiListLoadBalancersRequest {
r.pageSize = &pageSize
return r
}
// page_id is a page identifier returned by the previous response and is used to request the next page
func (r ListLoadBalancersRequest) PageId(pageId string) ApiListLoadBalancersRequest {
r.pageId = &pageId
return r
}
func (r ListLoadBalancersRequest) Execute() (*ListLoadBalancersResponse, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *ListLoadBalancersResponse
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListLoadBalancers")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/load-balancers"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.pageSize != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "")
}
if r.pageId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "pageId", r.pageId, "")
}
// 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
}
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
ListLoadBalancers: List load balancers in a project.
Lists all Application Load Balancers in a project.
Includes details from creation or updates, along with their status and any error descriptions.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@return ApiListLoadBalancersRequest
*/
func (a *APIClient) ListLoadBalancers(ctx context.Context, projectId string, region string) ApiListLoadBalancersRequest {
return ListLoadBalancersRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
}
func (a *APIClient) ListLoadBalancersExecute(ctx context.Context, projectId string, region string) (*ListLoadBalancersResponse, error) {
r := ListLoadBalancersRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
}
return r.Execute()
}
type ListPlansRequest struct {
ctx context.Context
apiService *DefaultApiService
region string
}
func (r ListPlansRequest) Execute() (*ListPlansResponse, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *ListPlansResponse
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListPlans")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/regions/{region}/plans"
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
ListPlans: List available service plans.
Lists the configured service plans for a project.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param region
@return ApiListPlansRequest
*/
func (a *APIClient) ListPlans(ctx context.Context, region string) ApiListPlansRequest {
return ListPlansRequest{
apiService: a.defaultApi,
ctx: ctx,
region: region,
}
}
func (a *APIClient) ListPlansExecute(ctx context.Context, region string) (*ListPlansResponse, error) {
r := ListPlansRequest{
apiService: a.defaultApi,
ctx: ctx,
region: region,
}
return r.Execute()
}
type UpdateCredentialsRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
credentialsRef string
updateCredentialsPayload *UpdateCredentialsPayload
}
func (r UpdateCredentialsRequest) UpdateCredentialsPayload(updateCredentialsPayload UpdateCredentialsPayload) ApiUpdateCredentialsRequest {
r.updateCredentialsPayload = &updateCredentialsPayload
return r
}
func (r UpdateCredentialsRequest) Execute() (*UpdateCredentialsResponse, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *UpdateCredentialsResponse
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateCredentials")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/credentials/{credentialsRef}"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"credentialsRef"+"}", url.PathEscape(ParameterValueToString(r.credentialsRef, "credentialsRef")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.updateCredentialsPayload == nil {
return localVarReturnValue, fmt.Errorf("updateCredentialsPayload 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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.updateCredentialsPayload
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
UpdateCredentials: Update credentials for observability in a project.
Updates the stored Observability credentials.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param credentialsRef
@return ApiUpdateCredentialsRequest
*/
func (a *APIClient) UpdateCredentials(ctx context.Context, projectId string, region string, credentialsRef string) ApiUpdateCredentialsRequest {
return UpdateCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
credentialsRef: credentialsRef,
}
}
func (a *APIClient) UpdateCredentialsExecute(ctx context.Context, projectId string, region string, credentialsRef string) (*UpdateCredentialsResponse, error) {
r := UpdateCredentialsRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
credentialsRef: credentialsRef,
}
return r.Execute()
}
type UpdateLoadBalancerRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
name string
updateLoadBalancerPayload *UpdateLoadBalancerPayload
}
func (r UpdateLoadBalancerRequest) UpdateLoadBalancerPayload(updateLoadBalancerPayload UpdateLoadBalancerPayload) ApiUpdateLoadBalancerRequest {
r.updateLoadBalancerPayload = &updateLoadBalancerPayload
return r
}
func (r UpdateLoadBalancerRequest) Execute() (*LoadBalancer, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LoadBalancer
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateLoadBalancer")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/load-balancers/{name}"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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.updateLoadBalancerPayload == nil {
return localVarReturnValue, fmt.Errorf("updateLoadBalancerPayload 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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.updateLoadBalancerPayload
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
UpdateLoadBalancer: Update a load balancer in a project.
Updates an existing Application Load Balancer by modifying its listeners and target pools.
Ensure the resource version is current to maintain concurrency safety.
The default load balancing algorithm is Maglev, and selecting a different algorithm is currently not supported.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@return ApiUpdateLoadBalancerRequest
*/
func (a *APIClient) UpdateLoadBalancer(ctx context.Context, projectId string, region string, name string) ApiUpdateLoadBalancerRequest {
return UpdateLoadBalancerRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
name: name,
}
}
func (a *APIClient) UpdateLoadBalancerExecute(ctx context.Context, projectId string, region string, name string) (*LoadBalancer, error) {
r := UpdateLoadBalancerRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
name: name,
}
return r.Execute()
}
type UpdateTargetPoolRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
name string
targetPoolName string
updateTargetPoolPayload *UpdateTargetPoolPayload
}
func (r UpdateTargetPoolRequest) UpdateTargetPoolPayload(updateTargetPoolPayload UpdateTargetPoolPayload) ApiUpdateTargetPoolRequest {
r.updateTargetPoolPayload = &updateTargetPoolPayload
return r
}
func (r UpdateTargetPoolRequest) Execute() (*TargetPool, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *TargetPool
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateTargetPool")
if err != nil {
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v2beta2/projects/{projectId}/regions/{region}/load-balancers/{name}/target-pools/{targetPoolName}"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(ParameterValueToString(r.name, "name")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"targetPoolName"+"}", url.PathEscape(ParameterValueToString(r.targetPoolName, "targetPoolName")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.updateTargetPoolPayload == nil {
return localVarReturnValue, fmt.Errorf("updateTargetPoolPayload 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", "*/*"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.updateTargetPoolPayload
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
var v Status
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return localVarReturnValue, newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return localVarReturnValue, newErr
}
err = client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
/*
UpdateTargetPool: Update a single target pool of a load balancer in a project.
Replaces the content of a specific target pool in the Application Load Balancer (useful for adding or removing target servers).
Only updates the specified target pool, leaving others unchanged.
Cannot be used to create or rename target pools.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId
@param region
@param name
@param targetPoolName
@return ApiUpdateTargetPoolRequest
*/
func (a *APIClient) UpdateTargetPool(ctx context.Context, projectId string, region string, name string, targetPoolName string) ApiUpdateTargetPoolRequest {
return UpdateTargetPoolRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
name: name,
targetPoolName: targetPoolName,
}
}
func (a *APIClient) UpdateTargetPoolExecute(ctx context.Context, projectId string, region string, name string, targetPoolName string) (*TargetPool, error) {
r := UpdateTargetPoolRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
name: name,
targetPoolName: targetPoolName,
}
return r.Execute()
}