Files
sdk/api_settings.go

268 lines
9.6 KiB
Go

/*
Hanzo Cloud API
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
API version: v1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hanzoai
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
)
// SettingsAPIService SettingsAPI service
type SettingsAPIService service
type SettingsAPIGetSettingsByProductRequest struct {
ctx context.Context
ApiService *SettingsAPIService
product string
}
func (r SettingsAPIGetSettingsByProductRequest) Execute() (*SettingsView, *http.Response, error) {
return r.ApiService.GetSettingsByProductExecute(r)
}
/*
GetSettingsByProduct Reads the caller org's configuration for one product, with every secret field MASKED — only the names of the set secrets come back, never their values, which live in KMS.
Reads the caller org's configuration for one product, with every
secret field MASKED — only the names of the set secrets come back, never their
values, which live in KMS. A product the org has never configured is not a 404:
it answers 200 with an empty config object, so the console's Settings tab always
renders and merges its own display defaults on top.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param product Product is the catalog slug, from the path. Must match ^[a-z0-9][a-z0-9._-]{0,62}$.
@return SettingsAPIGetSettingsByProductRequest
*/
func (a *SettingsAPIService) GetSettingsByProduct(ctx context.Context, product string) SettingsAPIGetSettingsByProductRequest {
return SettingsAPIGetSettingsByProductRequest{
ApiService: a,
ctx: ctx,
product: product,
}
}
// Execute executes the request
//
// @return SettingsView
func (a *SettingsAPIService) GetSettingsByProductExecute(r SettingsAPIGetSettingsByProductRequest) (*SettingsView, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *SettingsView
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SettingsAPIService.GetSettingsByProduct")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/settings/{product}"
localVarPath = strings.Replace(localVarPath, "{"+"product"+"}", url.PathEscape(parameterValueToString(r.product, "product")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type SettingsAPIPutSettingsByProductRequest struct {
ctx context.Context
ApiService *SettingsAPIService
product string
settingsSettingsReq *SettingsSettingsReq
}
func (r SettingsAPIPutSettingsByProductRequest) SettingsSettingsReq(settingsSettingsReq SettingsSettingsReq) SettingsAPIPutSettingsByProductRequest {
r.settingsSettingsReq = &settingsSettingsReq
return r
}
func (r SettingsAPIPutSettingsByProductRequest) Execute() (*SettingsView, *http.Response, error) {
return r.ApiService.PutSettingsByProductExecute(r)
}
/*
PutSettingsByProduct Writes the caller org's configuration for one product and answers the stored result, secrets masked.
Writes the caller org's configuration for one product and answers the
stored result, secrets masked. Secret VALUES are sealed into KMS under
orgs/{org}/settings/{product}/{key} and never touch this deployment's database;
with no KMS configured a write that carries any secret is refused whole (503)
rather than dropping it or persisting it in the clear. A secret the body omits
keeps its stored value, so a partial write never silently clears one.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param product Product is the catalog slug, from the PATH. zip binds the path last, so the URL names the product being written whatever a body field claims.
@return SettingsAPIPutSettingsByProductRequest
*/
func (a *SettingsAPIService) PutSettingsByProduct(ctx context.Context, product string) SettingsAPIPutSettingsByProductRequest {
return SettingsAPIPutSettingsByProductRequest{
ApiService: a,
ctx: ctx,
product: product,
}
}
// Execute executes the request
//
// @return SettingsView
func (a *SettingsAPIService) PutSettingsByProductExecute(r SettingsAPIPutSettingsByProductRequest) (*SettingsView, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *SettingsView
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SettingsAPIService.PutSettingsByProduct")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/settings/{product}"
localVarPath = strings.Replace(localVarPath, "{"+"product"+"}", url.PathEscape(parameterValueToString(r.product, "product")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.settingsSettingsReq == nil {
return localVarReturnValue, nil, reportError("settingsSettingsReq is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.settingsSettingsReq
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}