mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
386 lines
14 KiB
Go
386 lines
14 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"
|
|
)
|
|
|
|
// EntitlementAPIService EntitlementAPI service
|
|
type EntitlementAPIService service
|
|
|
|
type EntitlementAPIGetEntitlementRequest struct {
|
|
ctx context.Context
|
|
ApiService *EntitlementAPIService
|
|
}
|
|
|
|
func (r EntitlementAPIGetEntitlementRequest) Execute() (*EntitlementProjectionView, *http.Response, error) {
|
|
return r.ApiService.GetEntitlementExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEntitlement Reports which console apps the CALLER's org may open, and the plan slug that decides it.
|
|
|
|
Reports which console apps the CALLER's org may open, and the plan slug
|
|
that decides it. It is the READ side of the unified paywall: the org's plan tier
|
|
resolved from commerce, which is a different authority from the enablement store
|
|
behind GET /v1/entitlement/orgs/{org} (that one is the org's own on/off intent).
|
|
|
|
It never answers 500: an unvalidated principal is a 403, and an app whose plan
|
|
cannot be confirmed is reported locked at 200, so the shell always renders. The
|
|
paywall applies the same rule when it enforces: access follows a confirmed
|
|
standing.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EntitlementAPIGetEntitlementRequest
|
|
*/
|
|
func (a *EntitlementAPIService) GetEntitlement(ctx context.Context) EntitlementAPIGetEntitlementRequest {
|
|
return EntitlementAPIGetEntitlementRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EntitlementProjectionView
|
|
func (a *EntitlementAPIService) GetEntitlementExecute(r EntitlementAPIGetEntitlementRequest) (*EntitlementProjectionView, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EntitlementProjectionView
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EntitlementAPIService.GetEntitlement")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/entitlement"
|
|
|
|
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 EntitlementAPIGetEntitlementOrgsByOrgRequest struct {
|
|
ctx context.Context
|
|
ApiService *EntitlementAPIService
|
|
org string
|
|
}
|
|
|
|
func (r EntitlementAPIGetEntitlementOrgsByOrgRequest) Execute() (*EntitlementEntitlementsView, *http.Response, error) {
|
|
return r.ApiService.GetEntitlementOrgsByOrgExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEntitlementOrgsByOrg Lists the products an org has ENABLED — its own intent, which the console's paid-product sidebar reads to decide what to show.
|
|
|
|
Lists the products an org has ENABLED — its own intent, which the console's
|
|
paid-product sidebar reads to decide what to show. It is distinct from what the
|
|
org's plan ENTITLES it to (that is GET /v1/entitlement, resolved from commerce).
|
|
|
|
A caller may only read its OWN org's row; a platform super admin may read any.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param org
|
|
@return EntitlementAPIGetEntitlementOrgsByOrgRequest
|
|
*/
|
|
func (a *EntitlementAPIService) GetEntitlementOrgsByOrg(ctx context.Context, org string) EntitlementAPIGetEntitlementOrgsByOrgRequest {
|
|
return EntitlementAPIGetEntitlementOrgsByOrgRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
org: org,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EntitlementEntitlementsView
|
|
func (a *EntitlementAPIService) GetEntitlementOrgsByOrgExecute(r EntitlementAPIGetEntitlementOrgsByOrgRequest) (*EntitlementEntitlementsView, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EntitlementEntitlementsView
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EntitlementAPIService.GetEntitlementOrgsByOrg")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/entitlement/orgs/{org}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterValueToString(r.org, "org")), -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 EntitlementAPIPostEntitlementOrgsByOrgRequest struct {
|
|
ctx context.Context
|
|
ApiService *EntitlementAPIService
|
|
org string
|
|
entitlementMutateReq *EntitlementMutateReq
|
|
}
|
|
|
|
func (r EntitlementAPIPostEntitlementOrgsByOrgRequest) EntitlementMutateReq(entitlementMutateReq EntitlementMutateReq) EntitlementAPIPostEntitlementOrgsByOrgRequest {
|
|
r.entitlementMutateReq = &entitlementMutateReq
|
|
return r
|
|
}
|
|
|
|
func (r EntitlementAPIPostEntitlementOrgsByOrgRequest) Execute() (*EntitlementEntitlementsView, *http.Response, error) {
|
|
return r.ApiService.PostEntitlementOrgsByOrgExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostEntitlementOrgsByOrg Turns products on or off for an org and returns the enabled set afterwards.
|
|
|
|
Turns products on or off for an org and returns the enabled set afterwards.
|
|
|
|
A product may only be ENABLED if the org's plan already ENTITLES it, so enabling
|
|
never spends new money — a product the plan does not grant answers 402 and the
|
|
console routes that to an upgrade prompt. DISABLING is never gated. A platform
|
|
super admin bypasses the plan check (operator comp/grant) and may target any org;
|
|
everyone else may only change their own. Commerce unreachable is a 503, never an
|
|
implicit yes.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param org
|
|
@return EntitlementAPIPostEntitlementOrgsByOrgRequest
|
|
*/
|
|
func (a *EntitlementAPIService) PostEntitlementOrgsByOrg(ctx context.Context, org string) EntitlementAPIPostEntitlementOrgsByOrgRequest {
|
|
return EntitlementAPIPostEntitlementOrgsByOrgRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
org: org,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EntitlementEntitlementsView
|
|
func (a *EntitlementAPIService) PostEntitlementOrgsByOrgExecute(r EntitlementAPIPostEntitlementOrgsByOrgRequest) (*EntitlementEntitlementsView, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EntitlementEntitlementsView
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EntitlementAPIService.PostEntitlementOrgsByOrg")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/entitlement/orgs/{org}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterValueToString(r.org, "org")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.entitlementMutateReq == nil {
|
|
return localVarReturnValue, nil, reportError("entitlementMutateReq 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.entitlementMutateReq
|
|
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
|
|
}
|