2906 lines
100 KiB
Go
2906 lines
100 KiB
Go
/*
|
|
STACKIT VPN API
|
|
|
|
The STACKIT VPN API provides endpoints to provision and manage VPN instances in your STACKIT project.
|
|
|
|
API version: 1alpha1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package vpnalpha
|
|
|
|
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 {
|
|
/*
|
|
CreateGatewayConnection Create a connection for an existing VPN gateway.
|
|
Create a connection for an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiCreateGatewayConnectionRequest
|
|
*/
|
|
CreateGatewayConnection(ctx context.Context, projectId string, region Region, gatewayName string) ApiCreateGatewayConnectionRequest
|
|
/*
|
|
CreateGatewayConnectionExecute 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 gatewayName
|
|
@return Connection
|
|
|
|
*/
|
|
CreateGatewayConnectionExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*Connection, error)
|
|
/*
|
|
CreateVPNGateway Create a VPN gateway in a project.
|
|
Create a VPN gateway in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@return ApiCreateVPNGatewayRequest
|
|
*/
|
|
CreateVPNGateway(ctx context.Context, projectId string, region Region) ApiCreateVPNGatewayRequest
|
|
/*
|
|
CreateVPNGatewayExecute 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 Gateway
|
|
|
|
*/
|
|
CreateVPNGatewayExecute(ctx context.Context, projectId string, region Region) (*Gateway, error)
|
|
/*
|
|
DeleteGatewayConnection Delete a certain connection from an existing VPN gateway.
|
|
Delete a certain connection from an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@param connectionName
|
|
@return ApiDeleteGatewayConnectionRequest
|
|
*/
|
|
DeleteGatewayConnection(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) ApiDeleteGatewayConnectionRequest
|
|
/*
|
|
DeleteGatewayConnectionExecute executes the request
|
|
|
|
*/
|
|
DeleteGatewayConnectionExecute(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) error
|
|
/*
|
|
DeleteVPNGateway Delete a existing VPN gateway in a project.
|
|
Delete a existing VPN gateway and all it's connections in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiDeleteVPNGatewayRequest
|
|
*/
|
|
DeleteVPNGateway(ctx context.Context, projectId string, region Region, gatewayName string) ApiDeleteVPNGatewayRequest
|
|
/*
|
|
DeleteVPNGatewayExecute executes the request
|
|
|
|
*/
|
|
DeleteVPNGatewayExecute(ctx context.Context, projectId string, region Region, gatewayName string) error
|
|
/*
|
|
GetGatewayConnection Get a certain connection for an existing VPN gateway.
|
|
Get a certain connection for an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@param connectionName
|
|
@return ApiGetGatewayConnectionRequest
|
|
*/
|
|
GetGatewayConnection(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) ApiGetGatewayConnectionRequest
|
|
/*
|
|
GetGatewayConnectionExecute 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 gatewayName
|
|
@param connectionName
|
|
@return Connection
|
|
|
|
*/
|
|
GetGatewayConnectionExecute(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) (*Connection, error)
|
|
/*
|
|
GetGatewayConnectionStatus Gets the status for a specific connection in an existing VPN gateway.
|
|
Gets the status for a specific connection in an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@param connectionName
|
|
@return ApiGetGatewayConnectionStatusRequest
|
|
*/
|
|
GetGatewayConnectionStatus(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) ApiGetGatewayConnectionStatusRequest
|
|
/*
|
|
GetGatewayConnectionStatusExecute 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 gatewayName
|
|
@param connectionName
|
|
@return ConnectionStatusResponse
|
|
|
|
*/
|
|
GetGatewayConnectionStatusExecute(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) (*ConnectionStatusResponse, error)
|
|
/*
|
|
GetVPNGateway Get details of a VPN Gateway in a project.
|
|
Get details of a VPN Gateway in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiGetVPNGatewayRequest
|
|
*/
|
|
GetVPNGateway(ctx context.Context, projectId string, region Region, gatewayName string) ApiGetVPNGatewayRequest
|
|
/*
|
|
GetVPNGatewayExecute 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 gatewayName
|
|
@return Gateway
|
|
|
|
*/
|
|
GetVPNGatewayExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*Gateway, error)
|
|
/*
|
|
GetVPNGatewayStatus Get the status of a VPN gateway in a project.
|
|
Get the status of a VPN gateway in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiGetVPNGatewayStatusRequest
|
|
*/
|
|
GetVPNGatewayStatus(ctx context.Context, projectId string, region Region, gatewayName string) ApiGetVPNGatewayStatusRequest
|
|
/*
|
|
GetVPNGatewayStatusExecute 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 gatewayName
|
|
@return GatewayStatusResponse
|
|
|
|
*/
|
|
GetVPNGatewayStatusExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*GatewayStatusResponse, error)
|
|
/*
|
|
ListGatewayConnections List connections for an existing VPN gateway.
|
|
List connections for an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiListGatewayConnectionsRequest
|
|
*/
|
|
ListGatewayConnections(ctx context.Context, projectId string, region Region, gatewayName string) ApiListGatewayConnectionsRequest
|
|
/*
|
|
ListGatewayConnectionsExecute 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 gatewayName
|
|
@return ConnectionList
|
|
|
|
*/
|
|
ListGatewayConnectionsExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*ConnectionList, error)
|
|
/*
|
|
ListPlans List available service plans for a project.
|
|
List available 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 Region) 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 PlanList
|
|
|
|
*/
|
|
ListPlansExecute(ctx context.Context, region Region) (*PlanList, error)
|
|
/*
|
|
ListQuotas List project quotas.
|
|
List project quotas.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@return ApiListQuotasRequest
|
|
*/
|
|
ListQuotas(ctx context.Context, projectId string, region Region) ApiListQuotasRequest
|
|
/*
|
|
ListQuotasExecute 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 QuotaListResponse
|
|
|
|
*/
|
|
ListQuotasExecute(ctx context.Context, projectId string, region Region) (*QuotaListResponse, error)
|
|
/*
|
|
ListVPNGateways List VPN gateways in a project with label filtering
|
|
Retrieve VPN gateways in a project filtered by a custom label selector format.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@return ApiListVPNGatewaysRequest
|
|
*/
|
|
ListVPNGateways(ctx context.Context, projectId string, region Region) ApiListVPNGatewaysRequest
|
|
/*
|
|
ListVPNGatewaysExecute 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 GatewayList
|
|
|
|
*/
|
|
ListVPNGatewaysExecute(ctx context.Context, projectId string, region Region) (*GatewayList, error)
|
|
/*
|
|
UpdateGatewayConnection Update a connection for an existing VPN gateway.
|
|
Update a connection for an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@param connectionName
|
|
@return ApiUpdateGatewayConnectionRequest
|
|
*/
|
|
UpdateGatewayConnection(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) ApiUpdateGatewayConnectionRequest
|
|
/*
|
|
UpdateGatewayConnectionExecute 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 gatewayName
|
|
@param connectionName
|
|
@return Connection
|
|
|
|
*/
|
|
UpdateGatewayConnectionExecute(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) (*Connection, error)
|
|
/*
|
|
UpdateVPNGateway Update a VPN gateway in a project.
|
|
Update a VPN gateway in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiUpdateVPNGatewayRequest
|
|
*/
|
|
UpdateVPNGateway(ctx context.Context, projectId string, region Region, gatewayName string) ApiUpdateVPNGatewayRequest
|
|
/*
|
|
UpdateVPNGatewayExecute 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 gatewayName
|
|
@return Gateway
|
|
|
|
*/
|
|
UpdateVPNGatewayExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*Gateway, error)
|
|
}
|
|
|
|
type ApiCreateGatewayConnectionRequest interface {
|
|
CreateGatewayConnectionPayload(createGatewayConnectionPayload CreateGatewayConnectionPayload) ApiCreateGatewayConnectionRequest
|
|
Execute() (*Connection, error)
|
|
}
|
|
|
|
type ApiCreateVPNGatewayRequest interface {
|
|
CreateVPNGatewayPayload(createVPNGatewayPayload CreateVPNGatewayPayload) ApiCreateVPNGatewayRequest
|
|
Execute() (*Gateway, error)
|
|
}
|
|
|
|
type ApiDeleteGatewayConnectionRequest interface {
|
|
Execute() error
|
|
}
|
|
|
|
type ApiDeleteVPNGatewayRequest interface {
|
|
Execute() error
|
|
}
|
|
|
|
type ApiGetGatewayConnectionRequest interface {
|
|
Execute() (*Connection, error)
|
|
}
|
|
|
|
type ApiGetGatewayConnectionStatusRequest interface {
|
|
Execute() (*ConnectionStatusResponse, error)
|
|
}
|
|
|
|
type ApiGetVPNGatewayRequest interface {
|
|
Execute() (*Gateway, error)
|
|
}
|
|
|
|
type ApiGetVPNGatewayStatusRequest interface {
|
|
Execute() (*GatewayStatusResponse, error)
|
|
}
|
|
|
|
type ApiListGatewayConnectionsRequest interface {
|
|
Execute() (*ConnectionList, error)
|
|
}
|
|
|
|
type ApiListPlansRequest interface {
|
|
Execute() (*PlanList, error)
|
|
}
|
|
|
|
type ApiListQuotasRequest interface {
|
|
Execute() (*QuotaListResponse, error)
|
|
}
|
|
|
|
type ApiListVPNGatewaysRequest interface {
|
|
LabelSelector(labelSelector map[string]string) ApiListVPNGatewaysRequest
|
|
Execute() (*GatewayList, error)
|
|
}
|
|
|
|
type ApiUpdateGatewayConnectionRequest interface {
|
|
UpdateGatewayConnectionPayload(updateGatewayConnectionPayload UpdateGatewayConnectionPayload) ApiUpdateGatewayConnectionRequest
|
|
Execute() (*Connection, error)
|
|
}
|
|
|
|
type ApiUpdateVPNGatewayRequest interface {
|
|
UpdateVPNGatewayPayload(updateVPNGatewayPayload UpdateVPNGatewayPayload) ApiUpdateVPNGatewayRequest
|
|
Execute() (*Gateway, error)
|
|
}
|
|
|
|
// DefaultApiService DefaultApi service
|
|
type DefaultApiService service
|
|
|
|
type CreateGatewayConnectionRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
createGatewayConnectionPayload *CreateGatewayConnectionPayload
|
|
}
|
|
|
|
func (r CreateGatewayConnectionRequest) CreateGatewayConnectionPayload(createGatewayConnectionPayload CreateGatewayConnectionPayload) ApiCreateGatewayConnectionRequest {
|
|
r.createGatewayConnectionPayload = &createGatewayConnectionPayload
|
|
return r
|
|
}
|
|
|
|
func (r CreateGatewayConnectionRequest) Execute() (*Connection, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *Connection
|
|
)
|
|
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.CreateGatewayConnection")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}/connections"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// 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.createGatewayConnectionPayload
|
|
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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
CreateGatewayConnection: Create a connection for an existing VPN gateway.
|
|
|
|
Create a connection for an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiCreateGatewayConnectionRequest
|
|
*/
|
|
func (a *APIClient) CreateGatewayConnection(ctx context.Context, projectId string, region Region, gatewayName string) ApiCreateGatewayConnectionRequest {
|
|
return CreateGatewayConnectionRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) CreateGatewayConnectionExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*Connection, error) {
|
|
r := CreateGatewayConnectionRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type CreateVPNGatewayRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
createVPNGatewayPayload *CreateVPNGatewayPayload
|
|
}
|
|
|
|
func (r CreateVPNGatewayRequest) CreateVPNGatewayPayload(createVPNGatewayPayload CreateVPNGatewayPayload) ApiCreateVPNGatewayRequest {
|
|
r.createVPNGatewayPayload = &createVPNGatewayPayload
|
|
return r
|
|
}
|
|
|
|
func (r CreateVPNGatewayRequest) Execute() (*Gateway, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *Gateway
|
|
)
|
|
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.CreateVPNGateway")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways"
|
|
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.createVPNGatewayPayload == nil {
|
|
return localVarReturnValue, fmt.Errorf("createVPNGatewayPayload 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.createVPNGatewayPayload
|
|
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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 409 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
CreateVPNGateway: Create a VPN gateway in a project.
|
|
|
|
Create a VPN gateway in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@return ApiCreateVPNGatewayRequest
|
|
*/
|
|
func (a *APIClient) CreateVPNGateway(ctx context.Context, projectId string, region Region) ApiCreateVPNGatewayRequest {
|
|
return CreateVPNGatewayRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) CreateVPNGatewayExecute(ctx context.Context, projectId string, region Region) (*Gateway, error) {
|
|
r := CreateVPNGatewayRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type DeleteGatewayConnectionRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
connectionName string
|
|
}
|
|
|
|
func (r DeleteGatewayConnectionRequest) Execute() error {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
a := r.apiService
|
|
client, ok := a.client.(*APIClient)
|
|
if !ok {
|
|
return fmt.Errorf("could not parse client to type APIClient")
|
|
}
|
|
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteGatewayConnection")
|
|
if err != nil {
|
|
return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}/connections/{connectionName}"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"connectionName"+"}", url.PathEscape(ParameterValueToString(r.connectionName, "connectionName")), -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 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 err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &oapierror.GenericOpenAPIError{
|
|
StatusCode: localVarHTTPResponse.StatusCode,
|
|
Body: localVarBody,
|
|
ErrorMessage: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
return newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
return newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
return newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
return newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
}
|
|
return newErr
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
/*
|
|
DeleteGatewayConnection: Delete a certain connection from an existing VPN gateway.
|
|
|
|
Delete a certain connection from an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@param connectionName
|
|
@return ApiDeleteGatewayConnectionRequest
|
|
*/
|
|
func (a *APIClient) DeleteGatewayConnection(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) ApiDeleteGatewayConnectionRequest {
|
|
return DeleteGatewayConnectionRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
connectionName: connectionName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) DeleteGatewayConnectionExecute(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) error {
|
|
r := DeleteGatewayConnectionRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
connectionName: connectionName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type DeleteVPNGatewayRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
}
|
|
|
|
func (r DeleteVPNGatewayRequest) Execute() error {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
a := r.apiService
|
|
client, ok := a.client.(*APIClient)
|
|
if !ok {
|
|
return fmt.Errorf("could not parse client to type APIClient")
|
|
}
|
|
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteVPNGateway")
|
|
if err != nil {
|
|
return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -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 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 err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &oapierror.GenericOpenAPIError{
|
|
StatusCode: localVarHTTPResponse.StatusCode,
|
|
Body: localVarBody,
|
|
ErrorMessage: localVarHTTPResponse.Status,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
return newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
return newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
return newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.ErrorMessage = err.Error()
|
|
return newErr
|
|
}
|
|
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.Model = v
|
|
}
|
|
return newErr
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
/*
|
|
DeleteVPNGateway: Delete a existing VPN gateway in a project.
|
|
|
|
Delete a existing VPN gateway and all it's connections in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiDeleteVPNGatewayRequest
|
|
*/
|
|
func (a *APIClient) DeleteVPNGateway(ctx context.Context, projectId string, region Region, gatewayName string) ApiDeleteVPNGatewayRequest {
|
|
return DeleteVPNGatewayRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) DeleteVPNGatewayExecute(ctx context.Context, projectId string, region Region, gatewayName string) error {
|
|
r := DeleteVPNGatewayRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type GetGatewayConnectionRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
connectionName string
|
|
}
|
|
|
|
func (r GetGatewayConnectionRequest) Execute() (*Connection, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *Connection
|
|
)
|
|
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.GetGatewayConnection")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}/connections/{connectionName}"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"connectionName"+"}", url.PathEscape(ParameterValueToString(r.connectionName, "connectionName")), -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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
GetGatewayConnection: Get a certain connection for an existing VPN gateway.
|
|
|
|
Get a certain connection for an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@param connectionName
|
|
@return ApiGetGatewayConnectionRequest
|
|
*/
|
|
func (a *APIClient) GetGatewayConnection(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) ApiGetGatewayConnectionRequest {
|
|
return GetGatewayConnectionRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
connectionName: connectionName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) GetGatewayConnectionExecute(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) (*Connection, error) {
|
|
r := GetGatewayConnectionRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
connectionName: connectionName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type GetGatewayConnectionStatusRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
connectionName string
|
|
}
|
|
|
|
func (r GetGatewayConnectionStatusRequest) Execute() (*ConnectionStatusResponse, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *ConnectionStatusResponse
|
|
)
|
|
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.GetGatewayConnectionStatus")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}/connections/{connectionName}/status"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"connectionName"+"}", url.PathEscape(ParameterValueToString(r.connectionName, "connectionName")), -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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
GetGatewayConnectionStatus: Gets the status for a specific connection in an existing VPN gateway.
|
|
|
|
Gets the status for a specific connection in an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@param connectionName
|
|
@return ApiGetGatewayConnectionStatusRequest
|
|
*/
|
|
func (a *APIClient) GetGatewayConnectionStatus(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) ApiGetGatewayConnectionStatusRequest {
|
|
return GetGatewayConnectionStatusRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
connectionName: connectionName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) GetGatewayConnectionStatusExecute(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) (*ConnectionStatusResponse, error) {
|
|
r := GetGatewayConnectionStatusRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
connectionName: connectionName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type GetVPNGatewayRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
}
|
|
|
|
func (r GetVPNGatewayRequest) Execute() (*Gateway, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *Gateway
|
|
)
|
|
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.GetVPNGateway")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
GetVPNGateway: Get details of a VPN Gateway in a project.
|
|
|
|
Get details of a VPN Gateway in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiGetVPNGatewayRequest
|
|
*/
|
|
func (a *APIClient) GetVPNGateway(ctx context.Context, projectId string, region Region, gatewayName string) ApiGetVPNGatewayRequest {
|
|
return GetVPNGatewayRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) GetVPNGatewayExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*Gateway, error) {
|
|
r := GetVPNGatewayRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type GetVPNGatewayStatusRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
}
|
|
|
|
func (r GetVPNGatewayStatusRequest) Execute() (*GatewayStatusResponse, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *GatewayStatusResponse
|
|
)
|
|
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.GetVPNGatewayStatus")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}/status"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
GetVPNGatewayStatus: Get the status of a VPN gateway in a project.
|
|
|
|
Get the status of a VPN gateway in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiGetVPNGatewayStatusRequest
|
|
*/
|
|
func (a *APIClient) GetVPNGatewayStatus(ctx context.Context, projectId string, region Region, gatewayName string) ApiGetVPNGatewayStatusRequest {
|
|
return GetVPNGatewayStatusRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) GetVPNGatewayStatusExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*GatewayStatusResponse, error) {
|
|
r := GetVPNGatewayStatusRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type ListGatewayConnectionsRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
}
|
|
|
|
func (r ListGatewayConnectionsRequest) Execute() (*ConnectionList, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *ConnectionList
|
|
)
|
|
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.ListGatewayConnections")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}/connections"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
ListGatewayConnections: List connections for an existing VPN gateway.
|
|
|
|
List connections for an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiListGatewayConnectionsRequest
|
|
*/
|
|
func (a *APIClient) ListGatewayConnections(ctx context.Context, projectId string, region Region, gatewayName string) ApiListGatewayConnectionsRequest {
|
|
return ListGatewayConnectionsRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) ListGatewayConnectionsExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*ConnectionList, error) {
|
|
r := ListGatewayConnectionsRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type ListPlansRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
region Region
|
|
}
|
|
|
|
func (r ListPlansRequest) Execute() (*PlanList, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *PlanList
|
|
)
|
|
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 + "/v1alpha1/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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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 for a project.
|
|
|
|
List available 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 Region) ApiListPlansRequest {
|
|
return ListPlansRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
region: region,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) ListPlansExecute(ctx context.Context, region Region) (*PlanList, error) {
|
|
r := ListPlansRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
region: region,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type ListQuotasRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
}
|
|
|
|
func (r ListQuotasRequest) Execute() (*QuotaListResponse, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *QuotaListResponse
|
|
)
|
|
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.ListQuotas")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/quotas"
|
|
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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
ListQuotas: List project quotas.
|
|
|
|
List project quotas.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@return ApiListQuotasRequest
|
|
*/
|
|
func (a *APIClient) ListQuotas(ctx context.Context, projectId string, region Region) ApiListQuotasRequest {
|
|
return ListQuotasRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) ListQuotasExecute(ctx context.Context, projectId string, region Region) (*QuotaListResponse, error) {
|
|
r := ListQuotasRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type ListVPNGatewaysRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
labelSelector *map[string]string
|
|
}
|
|
|
|
func (r ListVPNGatewaysRequest) LabelSelector(labelSelector map[string]string) ApiListVPNGatewaysRequest {
|
|
r.labelSelector = &labelSelector
|
|
return r
|
|
}
|
|
|
|
func (r ListVPNGatewaysRequest) Execute() (*GatewayList, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *GatewayList
|
|
)
|
|
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.ListVPNGateways")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways"
|
|
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.labelSelector != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "label_selector", r.labelSelector, "")
|
|
}
|
|
// 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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
ListVPNGateways: List VPN gateways in a project with label filtering
|
|
|
|
Retrieve VPN gateways in a project filtered by a custom label selector format.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@return ApiListVPNGatewaysRequest
|
|
*/
|
|
func (a *APIClient) ListVPNGateways(ctx context.Context, projectId string, region Region) ApiListVPNGatewaysRequest {
|
|
return ListVPNGatewaysRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) ListVPNGatewaysExecute(ctx context.Context, projectId string, region Region) (*GatewayList, error) {
|
|
r := ListVPNGatewaysRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type UpdateGatewayConnectionRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
connectionName string
|
|
updateGatewayConnectionPayload *UpdateGatewayConnectionPayload
|
|
}
|
|
|
|
func (r UpdateGatewayConnectionRequest) UpdateGatewayConnectionPayload(updateGatewayConnectionPayload UpdateGatewayConnectionPayload) ApiUpdateGatewayConnectionRequest {
|
|
r.updateGatewayConnectionPayload = &updateGatewayConnectionPayload
|
|
return r
|
|
}
|
|
|
|
func (r UpdateGatewayConnectionRequest) Execute() (*Connection, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *Connection
|
|
)
|
|
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.UpdateGatewayConnection")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}/connections/{connectionName}"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"connectionName"+"}", url.PathEscape(ParameterValueToString(r.connectionName, "connectionName")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// 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.updateGatewayConnectionPayload
|
|
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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
UpdateGatewayConnection: Update a connection for an existing VPN gateway.
|
|
|
|
Update a connection for an existing VPN gateway.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@param connectionName
|
|
@return ApiUpdateGatewayConnectionRequest
|
|
*/
|
|
func (a *APIClient) UpdateGatewayConnection(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) ApiUpdateGatewayConnectionRequest {
|
|
return UpdateGatewayConnectionRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
connectionName: connectionName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) UpdateGatewayConnectionExecute(ctx context.Context, projectId string, region Region, gatewayName string, connectionName string) (*Connection, error) {
|
|
r := UpdateGatewayConnectionRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
connectionName: connectionName,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type UpdateVPNGatewayRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region Region
|
|
gatewayName string
|
|
updateVPNGatewayPayload *UpdateVPNGatewayPayload
|
|
}
|
|
|
|
func (r UpdateVPNGatewayRequest) UpdateVPNGatewayPayload(updateVPNGatewayPayload UpdateVPNGatewayPayload) ApiUpdateVPNGatewayRequest {
|
|
r.updateVPNGatewayPayload = &updateVPNGatewayPayload
|
|
return r
|
|
}
|
|
|
|
func (r UpdateVPNGatewayRequest) Execute() (*Gateway, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *Gateway
|
|
)
|
|
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.UpdateVPNGateway")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1alpha1/projects/{projectId}/regions/{region}/gateways/{gatewayName}"
|
|
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, "{"+"gatewayName"+"}", url.PathEscape(ParameterValueToString(r.gatewayName, "gatewayName")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.updateVPNGatewayPayload == nil {
|
|
return localVarReturnValue, fmt.Errorf("updateVPNGatewayPayload 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.updateVPNGatewayPayload
|
|
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 == 400 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 403 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 409 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 500 {
|
|
var v APIErrorResponse
|
|
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
|
|
}
|
|
|
|
/*
|
|
UpdateVPNGateway: Update a VPN gateway in a project.
|
|
|
|
Update a VPN gateway in a project.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId
|
|
@param region
|
|
@param gatewayName
|
|
@return ApiUpdateVPNGatewayRequest
|
|
*/
|
|
func (a *APIClient) UpdateVPNGateway(ctx context.Context, projectId string, region Region, gatewayName string) ApiUpdateVPNGatewayRequest {
|
|
return UpdateVPNGatewayRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) UpdateVPNGatewayExecute(ctx context.Context, projectId string, region Region, gatewayName string) (*Gateway, error) {
|
|
r := UpdateVPNGatewayRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
gatewayName: gatewayName,
|
|
}
|
|
return r.Execute()
|
|
}
|