Files
sdk/api_library.go

818 lines
27 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"
)
// LibraryAPIService LibraryAPI service
type LibraryAPIService service
type LibraryAPIDeleteLibraryByIdRequest struct {
ctx context.Context
ApiService *LibraryAPIService
id string
}
func (r LibraryAPIDeleteLibraryByIdRequest) Execute() (*http.Response, error) {
return r.ApiService.DeleteLibraryByIdExecute(r)
}
/*
DeleteLibraryById Deletes one of your items and its bytes.
Deletes one of your items and its bytes. Only its owner deletes an
item.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the item, from the path.
@return LibraryAPIDeleteLibraryByIdRequest
*/
func (a *LibraryAPIService) DeleteLibraryById(ctx context.Context, id string) LibraryAPIDeleteLibraryByIdRequest {
return LibraryAPIDeleteLibraryByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
func (a *LibraryAPIService) DeleteLibraryByIdExecute(r LibraryAPIDeleteLibraryByIdRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryAPIService.DeleteLibraryById")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/library/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -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/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 nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return 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 localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type LibraryAPIGetLibraryRequest struct {
ctx context.Context
ApiService *LibraryAPIService
kind *string
source *string
ref *string
project *string
q *string
since *string
until *string
scope *string
limit *int64
cursor *string
}
// Kind keeps one kind: image, video, audio, document, slides, type, model, code or file.
func (r LibraryAPIGetLibraryRequest) Kind(kind string) LibraryAPIGetLibraryRequest {
r.kind = &kind
return r
}
// Source keeps what one product made: chat, dev, studio or workflow.
func (r LibraryAPIGetLibraryRequest) Source(source string) LibraryAPIGetLibraryRequest {
r.source = &source
return r
}
// Ref keeps what one conversation, run or Studio run made.
func (r LibraryAPIGetLibraryRequest) Ref(ref string) LibraryAPIGetLibraryRequest {
r.ref = &ref
return r
}
// Project keeps one project's items.
func (r LibraryAPIGetLibraryRequest) Project(project string) LibraryAPIGetLibraryRequest {
r.project = &project
return r
}
// Q keeps the items whose name contains it, ignoring case.
func (r LibraryAPIGetLibraryRequest) Q(q string) LibraryAPIGetLibraryRequest {
r.q = &q
return r
}
// Since and Until bound when it was made: RFC 3339, or a date (YYYY-MM-DD).
func (r LibraryAPIGetLibraryRequest) Since(since string) LibraryAPIGetLibraryRequest {
r.since = &since
return r
}
func (r LibraryAPIGetLibraryRequest) Until(until string) LibraryAPIGetLibraryRequest {
r.until = &until
return r
}
// Scope is all (yours and what your org shared, the default), mine, or shared.
func (r LibraryAPIGetLibraryRequest) Scope(scope string) LibraryAPIGetLibraryRequest {
r.scope = &scope
return r
}
// Limit bounds the page: default 60, at most 200.
func (r LibraryAPIGetLibraryRequest) Limit(limit int64) LibraryAPIGetLibraryRequest {
r.limit = &limit
return r
}
// Cursor continues a list from the page before's `next`.
func (r LibraryAPIGetLibraryRequest) Cursor(cursor string) LibraryAPIGetLibraryRequest {
r.cursor = &cursor
return r
}
func (r LibraryAPIGetLibraryRequest) Execute() (*LibraryItemPage, *http.Response, error) {
return r.ApiService.GetLibraryExecute(r)
}
/*
GetLibrary Lists what you made and what members of your organization shared with you, newest first.
Lists what you made and what members of your organization shared
with you, newest first. Narrow it by kind, source, ref, project, a name search
and a time range; `scope` mine keeps only yours and shared only what others
shared. Each item carries signed URLs that work for an hour.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return LibraryAPIGetLibraryRequest
*/
func (a *LibraryAPIService) GetLibrary(ctx context.Context) LibraryAPIGetLibraryRequest {
return LibraryAPIGetLibraryRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return LibraryItemPage
func (a *LibraryAPIService) GetLibraryExecute(r LibraryAPIGetLibraryRequest) (*LibraryItemPage, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LibraryItemPage
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryAPIService.GetLibrary")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/library"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.kind != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "kind", r.kind, "form", "")
}
if r.source != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "source", r.source, "form", "")
}
if r.ref != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "ref", r.ref, "form", "")
}
if r.project != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "project", r.project, "form", "")
}
if r.q != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "q", r.q, "form", "")
}
if r.since != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "since", r.since, "form", "")
}
if r.until != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "until", r.until, "form", "")
}
if r.scope != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "scope", r.scope, "form", "")
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
if r.cursor != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "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 LibraryAPIGetLibraryByIdRequest struct {
ctx context.Context
ApiService *LibraryAPIService
id string
}
func (r LibraryAPIGetLibraryByIdRequest) Execute() (*LibraryLibraryItem, *http.Response, error) {
return r.ApiService.GetLibraryByIdExecute(r)
}
/*
GetLibraryById Reads one item with fresh signed URLs.
Reads one item with fresh signed URLs. An item that is not yours and
was not shared with your organization answers 404, as one that does not exist.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the item, from the path.
@return LibraryAPIGetLibraryByIdRequest
*/
func (a *LibraryAPIService) GetLibraryById(ctx context.Context, id string) LibraryAPIGetLibraryByIdRequest {
return LibraryAPIGetLibraryByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return LibraryLibraryItem
func (a *LibraryAPIService) GetLibraryByIdExecute(r LibraryAPIGetLibraryByIdRequest) (*LibraryLibraryItem, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LibraryLibraryItem
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryAPIService.GetLibraryById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/library/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -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 LibraryAPIGetLibraryUnownedRequest struct {
ctx context.Context
ApiService *LibraryAPIService
limit *int64
}
// Limit bounds the page: default 60, at most 200.
func (r LibraryAPIGetLibraryUnownedRequest) Limit(limit int64) LibraryAPIGetLibraryUnownedRequest {
r.limit = &limit
return r
}
func (r LibraryAPIGetLibraryUnownedRequest) Execute() (*LibraryItemPage, *http.Response, error) {
return r.ApiService.GetLibraryUnownedExecute(r)
}
/*
GetLibraryUnowned ListUnowned reads, for a SuperAdmin alone, the organization's items that record no owner.
ListUnowned reads, for a SuperAdmin alone, the organization's items that record
no owner. Such an item is nobody's: no member lists it, reads it
or changes it, and this view neither changes it nor signs its bytes. Every
read of it is written to the audit trail.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return LibraryAPIGetLibraryUnownedRequest
*/
func (a *LibraryAPIService) GetLibraryUnowned(ctx context.Context) LibraryAPIGetLibraryUnownedRequest {
return LibraryAPIGetLibraryUnownedRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return LibraryItemPage
func (a *LibraryAPIService) GetLibraryUnownedExecute(r LibraryAPIGetLibraryUnownedRequest) (*LibraryItemPage, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LibraryItemPage
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryAPIService.GetLibraryUnowned")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/library/unowned"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
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 LibraryAPIPatchLibraryByIdRequest struct {
ctx context.Context
ApiService *LibraryAPIService
id string
libraryItemPatch *LibraryItemPatch
}
func (r LibraryAPIPatchLibraryByIdRequest) LibraryItemPatch(libraryItemPatch LibraryItemPatch) LibraryAPIPatchLibraryByIdRequest {
r.libraryItemPatch = &libraryItemPatch
return r
}
func (r LibraryAPIPatchLibraryByIdRequest) Execute() (*LibraryLibraryItem, *http.Response, error) {
return r.ApiService.PatchLibraryByIdExecute(r)
}
/*
PatchLibraryById Renames one of your items, shares it with your organization or stops sharing it, moves it to a project, or commits a reserved upload.
Renames one of your items, shares it with your organization or
stops sharing it, moves it to a project, or commits a reserved upload. Only
its owner changes an item; a member's shared item answers 404 here as one
that does not exist.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the item, from the path.
@return LibraryAPIPatchLibraryByIdRequest
*/
func (a *LibraryAPIService) PatchLibraryById(ctx context.Context, id string) LibraryAPIPatchLibraryByIdRequest {
return LibraryAPIPatchLibraryByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return LibraryLibraryItem
func (a *LibraryAPIService) PatchLibraryByIdExecute(r LibraryAPIPatchLibraryByIdRequest) (*LibraryLibraryItem, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPatch
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LibraryLibraryItem
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryAPIService.PatchLibraryById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/library/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.libraryItemPatch == nil {
return localVarReturnValue, nil, reportError("libraryItemPatch 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.libraryItemPatch
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 LibraryAPIPostLibraryRequest struct {
ctx context.Context
ApiService *LibraryAPIService
libraryKeepIn *LibraryKeepIn
}
func (r LibraryAPIPostLibraryRequest) LibraryKeepIn(libraryKeepIn LibraryKeepIn) LibraryAPIPostLibraryRequest {
r.libraryKeepIn = &libraryKeepIn
return r
}
func (r LibraryAPIPostLibraryRequest) Execute() (*LibraryLibraryItem, *http.Response, error) {
return r.ApiService.PostLibraryExecute(r)
}
/*
PostLibrary Keeps one thing you made in your Library: its bytes go to your own prefix of the Library's store, and it is listed to you alone until you share it.
Keeps one thing you made in your Library: its bytes go to your own
prefix of the Library's store, and it is listed to you alone until you share
it. Send `data` up to 10 MiB inline, or send `bytes` up to 2 GiB to reserve
a signed `upload` PUT and finish it with `PATCH /v1/library/:id` `{"commit": true}`.
A save with the `key` of one already kept answers that item.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return LibraryAPIPostLibraryRequest
*/
func (a *LibraryAPIService) PostLibrary(ctx context.Context) LibraryAPIPostLibraryRequest {
return LibraryAPIPostLibraryRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return LibraryLibraryItem
func (a *LibraryAPIService) PostLibraryExecute(r LibraryAPIPostLibraryRequest) (*LibraryLibraryItem, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LibraryLibraryItem
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LibraryAPIService.PostLibrary")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/library"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.libraryKeepIn == nil {
return localVarReturnValue, nil, reportError("libraryKeepIn 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.libraryKeepIn
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
}