mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
817 lines
30 KiB
Go
817 lines
30 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"
|
|
)
|
|
|
|
// ContentAPIService ContentAPI service
|
|
type ContentAPIService service
|
|
|
|
type ContentAPIGetContentBoardRequest struct {
|
|
ctx context.Context
|
|
ApiService *ContentAPIService
|
|
status *string
|
|
project *string
|
|
doctype *string
|
|
limit *int64
|
|
}
|
|
|
|
// Status keeps only items in one lifecycle state (draft, in_review, approved, queued, published, archived). An undefined state is refused.
|
|
func (r ContentAPIGetContentBoardRequest) Status(status string) ContentAPIGetContentBoardRequest {
|
|
r.status = &status
|
|
return r
|
|
}
|
|
|
|
// Project keeps only items in one brand/site sub-scope.
|
|
func (r ContentAPIGetContentBoardRequest) Project(project string) ContentAPIGetContentBoardRequest {
|
|
r.project = &project
|
|
return r
|
|
}
|
|
|
|
// DocType keeps only one content type; omitted, the board spans every publishable type. An unknown type is refused.
|
|
func (r ContentAPIGetContentBoardRequest) Doctype(doctype string) ContentAPIGetContentBoardRequest {
|
|
r.doctype = &doctype
|
|
return r
|
|
}
|
|
|
|
// Limit caps the rows returned, clamped to 1000. Defaults to 200, which is also what a non-positive or unparseable value takes.
|
|
func (r ContentAPIGetContentBoardRequest) Limit(limit int64) ContentAPIGetContentBoardRequest {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
|
|
func (r ContentAPIGetContentBoardRequest) Execute() (*ContentBoardPage, *http.Response, error) {
|
|
return r.ApiService.GetContentBoardExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetContentBoard Aggregates the caller org's marketing content across every publishable content type into ONE queue board — the cross-type read the framework's per-DocType list cannot give.
|
|
|
|
Aggregates the caller org's marketing content across every publishable
|
|
content type into ONE queue board — the cross-type read the framework's
|
|
per-DocType list cannot give. It never fails on a partial outage: a content type
|
|
the org has not installed, or one whose search errors, is skipped and logged
|
|
rather than failing the whole board.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ContentAPIGetContentBoardRequest
|
|
*/
|
|
func (a *ContentAPIService) GetContentBoard(ctx context.Context) ContentAPIGetContentBoardRequest {
|
|
return ContentAPIGetContentBoardRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return ContentBoardPage
|
|
func (a *ContentAPIService) GetContentBoardExecute(r ContentAPIGetContentBoardRequest) (*ContentBoardPage, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *ContentBoardPage
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ContentAPIService.GetContentBoard")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/content/board"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.status != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "")
|
|
}
|
|
if r.project != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "project", r.project, "form", "")
|
|
}
|
|
if r.doctype != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "doctype", r.doctype, "form", "")
|
|
}
|
|
if r.limit != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
|
|
}
|
|
// 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 ContentAPIGetContentChannelsRequest struct {
|
|
ctx context.Context
|
|
ApiService *ContentAPIService
|
|
}
|
|
|
|
func (r ContentAPIGetContentChannelsRequest) Execute() (*ContentChannelList, *http.Response, error) {
|
|
return r.ApiService.GetContentChannelsExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetContentChannels Lists the distribution channels the caller's org has connected — the social integrations a publish can target.
|
|
|
|
Lists the distribution channels the caller's org has connected — the
|
|
social integrations a publish can target. A deployment with no distribution edge
|
|
wired answers 503 rather than an empty list that would read as "no channels".
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ContentAPIGetContentChannelsRequest
|
|
*/
|
|
func (a *ContentAPIService) GetContentChannels(ctx context.Context) ContentAPIGetContentChannelsRequest {
|
|
return ContentAPIGetContentChannelsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return ContentChannelList
|
|
func (a *ContentAPIService) GetContentChannelsExecute(r ContentAPIGetContentChannelsRequest) (*ContentChannelList, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *ContentChannelList
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ContentAPIService.GetContentChannels")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/content/channels"
|
|
|
|
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 ContentAPIGetContentLifecycleRequest struct {
|
|
ctx context.Context
|
|
ApiService *ContentAPIService
|
|
}
|
|
|
|
func (r ContentAPIGetContentLifecycleRequest) Execute() (*ContentStateGraph, *http.Response, error) {
|
|
return r.ApiService.GetContentLifecycleExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetContentLifecycle Returns the ONE marketing-content state machine: the ordered lifecycle states, which state a fresh document starts in, which one is publicly live, and the legal successors of every state.
|
|
|
|
Returns the ONE marketing-content state machine: the ordered
|
|
lifecycle states, which state a fresh document starts in, which one is publicly
|
|
live, and the legal successors of every state. The console builds its board
|
|
columns and its per-item action buttons from this single answer, so the UI and
|
|
the write-time enforcement hook can never disagree about what is legal.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ContentAPIGetContentLifecycleRequest
|
|
*/
|
|
func (a *ContentAPIService) GetContentLifecycle(ctx context.Context) ContentAPIGetContentLifecycleRequest {
|
|
return ContentAPIGetContentLifecycleRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return ContentStateGraph
|
|
func (a *ContentAPIService) GetContentLifecycleExecute(r ContentAPIGetContentLifecycleRequest) (*ContentStateGraph, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *ContentStateGraph
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ContentAPIService.GetContentLifecycle")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/content/lifecycle"
|
|
|
|
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 ContentAPIPostContentByDoctypeByNameTransitionRequest struct {
|
|
ctx context.Context
|
|
ApiService *ContentAPIService
|
|
doctype string
|
|
name string
|
|
contentTransitionIn *ContentTransitionIn
|
|
}
|
|
|
|
func (r ContentAPIPostContentByDoctypeByNameTransitionRequest) ContentTransitionIn(contentTransitionIn ContentTransitionIn) ContentAPIPostContentByDoctypeByNameTransitionRequest {
|
|
r.contentTransitionIn = &contentTransitionIn
|
|
return r
|
|
}
|
|
|
|
func (r ContentAPIPostContentByDoctypeByNameTransitionRequest) Execute() (*ContentTransitionResult, *http.Response, error) {
|
|
return r.ApiService.PostContentByDoctypeByNameTransitionExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostContentByDoctypeByNameTransition Moves one content item to a new lifecycle state and, on the move to published, fans it out to the item's channels.
|
|
|
|
Moves one content item to a new lifecycle state and, on the move to
|
|
published, fans it out to the item's channels. The edge must be legal for the
|
|
item's current state — an illegal move is refused with 409 — and the status write
|
|
re-validates it at the storage boundary. Distribution is best effort: its honest
|
|
state is reported on the result and a distribution failure never rolls the status
|
|
change back.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param doctype DocType is the content type to act on, from the path.
|
|
@param name Name is the document to act on, from the path.
|
|
@return ContentAPIPostContentByDoctypeByNameTransitionRequest
|
|
*/
|
|
func (a *ContentAPIService) PostContentByDoctypeByNameTransition(ctx context.Context, doctype string, name string) ContentAPIPostContentByDoctypeByNameTransitionRequest {
|
|
return ContentAPIPostContentByDoctypeByNameTransitionRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
doctype: doctype,
|
|
name: name,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return ContentTransitionResult
|
|
func (a *ContentAPIService) PostContentByDoctypeByNameTransitionExecute(r ContentAPIPostContentByDoctypeByNameTransitionRequest) (*ContentTransitionResult, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *ContentTransitionResult
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ContentAPIService.PostContentByDoctypeByNameTransition")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/content/{doctype}/{name}/transition"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"doctype"+"}", url.PathEscape(parameterValueToString(r.doctype, "doctype")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.contentTransitionIn == nil {
|
|
return localVarReturnValue, nil, reportError("contentTransitionIn 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.contentTransitionIn
|
|
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 ContentAPIPostContentGenerateRequest struct {
|
|
ctx context.Context
|
|
ApiService *ContentAPIService
|
|
contentGenerateInput *ContentGenerateInput
|
|
}
|
|
|
|
func (r ContentAPIPostContentGenerateRequest) ContentGenerateInput(contentGenerateInput ContentGenerateInput) ContentAPIPostContentGenerateRequest {
|
|
r.contentGenerateInput = &contentGenerateInput
|
|
return r
|
|
}
|
|
|
|
func (r ContentAPIPostContentGenerateRequest) Execute() (*ContentGenerateResult, *http.Response, error) {
|
|
return r.ApiService.PostContentGenerateExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostContentGenerate Draft a provider of marketing content and file it in the CMS as a draft.
|
|
|
|
Draft a provider of marketing content and file it in the CMS as a draft.
|
|
|
|
Answers 201 with the created draft's identity — {doctype, name, status} — and the
|
|
document itself lands in the CMS through the SAME validate and lifecycle-hook
|
|
pipeline an ordinary create runs. This is a WRITE, not a preview: there is no
|
|
dry-run, and every call that succeeds leaves a document behind.
|
|
|
|
`doctype` picks which of two generation planes runs, and they are the only two.
|
|
Campaign and SocialPost are drafted as brand COPY on the platform AI plane (zen5 by
|
|
default, overridable per request with `model` or per deployment); Asset is a studio
|
|
image render the AI plane never sees. Everything else about the call is identical.
|
|
|
|
MONEY, metered in exactly one place per mode and never both. Copy rides the
|
|
platform's own inference meter — the org's balance is authorised before the model
|
|
call and debited at the exact token cost after — so content never re-bills it. A
|
|
studio render is invisible to that meter, so content is the sole meter for it: the
|
|
org is gated BEFORE the GPU compute and refused 402 when out of funds or over its
|
|
spend cap, and the debit is recorded only once the render actually returns, because
|
|
the billable event is the consumed compute and not the CMS row. `project` rides the
|
|
BODY rather than a server-minted identity claim, so it attributes spend but a
|
|
project-scoped cap stays soft on it — the org is the value that is enforced.
|
|
|
|
The org is the caller's own, resolved once from the validated principal and never
|
|
read from the body; a caller without one is refused 401. Status is not the
|
|
generator's to choose: a generated item is ALWAYS a draft, and the storage-boundary
|
|
hook enforces that a second time.
|
|
|
|
It fails closed rather than inventing anything. An unknown content type is 404 and a
|
|
deployment whose marketing module is not installed is 409 naming the install call.
|
|
An AI plane or studio that is unconfigured or unreachable, a graph the studio
|
|
rejects, and a render that does not return in time all degrade to 503 — never
|
|
fabricated copy, never a fake render. A `source_media` that fails the SSRF and
|
|
traversal validator is 400 raised before the billing gate and before the studio is
|
|
contacted, so a hostile source never costs the caller anything.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ContentAPIPostContentGenerateRequest
|
|
*/
|
|
func (a *ContentAPIService) PostContentGenerate(ctx context.Context) ContentAPIPostContentGenerateRequest {
|
|
return ContentAPIPostContentGenerateRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return ContentGenerateResult
|
|
func (a *ContentAPIService) PostContentGenerateExecute(r ContentAPIPostContentGenerateRequest) (*ContentGenerateResult, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *ContentGenerateResult
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ContentAPIService.PostContentGenerate")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/content/generate"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.contentGenerateInput == nil {
|
|
return localVarReturnValue, nil, reportError("contentGenerateInput 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.contentGenerateInput
|
|
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,
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 402 {
|
|
var v ContentGenerateResult
|
|
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
|
|
}
|
|
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 ContentAPIPostContentPublishRequest struct {
|
|
ctx context.Context
|
|
ApiService *ContentAPIService
|
|
contentPublishInput *ContentPublishInput
|
|
}
|
|
|
|
func (r ContentAPIPostContentPublishRequest) ContentPublishInput(contentPublishInput ContentPublishInput) ContentAPIPostContentPublishRequest {
|
|
r.contentPublishInput = &contentPublishInput
|
|
return r
|
|
}
|
|
|
|
func (r ContentAPIPostContentPublishRequest) Execute() (*ContentPublishResult, *http.Response, error) {
|
|
return r.ApiService.PostContentPublishExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostContentPublish Publish distributes one CMS content item to the channels recorded on it and returns the honest per-channel outcome.
|
|
|
|
Publish distributes one CMS content item to the channels recorded on it and
|
|
returns the honest per-channel outcome. The item names itself — its caption,
|
|
media and channel list are read from the stored document, not from this request.
|
|
It is idempotent per channel (a channel already posted for this item is skipped),
|
|
and a publish that loses the per-item lease to a live publisher answers status
|
|
"in_progress" having posted nothing.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ContentAPIPostContentPublishRequest
|
|
*/
|
|
func (a *ContentAPIService) PostContentPublish(ctx context.Context) ContentAPIPostContentPublishRequest {
|
|
return ContentAPIPostContentPublishRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return ContentPublishResult
|
|
func (a *ContentAPIService) PostContentPublishExecute(r ContentAPIPostContentPublishRequest) (*ContentPublishResult, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *ContentPublishResult
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ContentAPIService.PostContentPublish")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/content/publish"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.contentPublishInput == nil {
|
|
return localVarReturnValue, nil, reportError("contentPublishInput 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.contentPublishInput
|
|
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
|
|
}
|