mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
244 lines
8.1 KiB
Go
244 lines
8.1 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"
|
|
)
|
|
|
|
// CatalogAPIService CatalogAPI service
|
|
type CatalogAPIService service
|
|
|
|
type CatalogAPIGetCatalogRequest struct {
|
|
ctx context.Context
|
|
ApiService *CatalogAPIService
|
|
q *string
|
|
org *string
|
|
kind *string
|
|
origin *string
|
|
archetype *string
|
|
language *string
|
|
template *string
|
|
forkable *string
|
|
limit *string
|
|
offset *string
|
|
}
|
|
|
|
// Q is the free-text query the lexical index scores relevance on. Empty is a browse rather than a search — the same request either way.
|
|
func (r CatalogAPIGetCatalogRequest) Q(q string) CatalogAPIGetCatalogRequest {
|
|
r.q = &q
|
|
return r
|
|
}
|
|
|
|
// Org narrows to one builder org: hanzo | lux | zoo. Case-insensitive.
|
|
func (r CatalogAPIGetCatalogRequest) Org(org string) CatalogAPIGetCatalogRequest {
|
|
r.org = &org
|
|
return r
|
|
}
|
|
|
|
// Kind narrows to repo | site. Case-insensitive.
|
|
func (r CatalogAPIGetCatalogRequest) Kind(kind string) CatalogAPIGetCatalogRequest {
|
|
r.kind = &kind
|
|
return r
|
|
}
|
|
|
|
// Origin narrows to what a row IS to you: template | community | third-party | product. This is the axis the two hanzo.app lanes are cut on.
|
|
func (r CatalogAPIGetCatalogRequest) Origin(origin string) CatalogAPIGetCatalogRequest {
|
|
r.origin = &origin
|
|
return r
|
|
}
|
|
|
|
// Archetype narrows to one project archetype. Case-insensitive.
|
|
func (r CatalogAPIGetCatalogRequest) Archetype(archetype string) CatalogAPIGetCatalogRequest {
|
|
r.archetype = &archetype
|
|
return r
|
|
}
|
|
|
|
// Language narrows to one implementation language. Case-insensitive.
|
|
func (r CatalogAPIGetCatalogRequest) Language(language string) CatalogAPIGetCatalogRequest {
|
|
r.language = &language
|
|
return r
|
|
}
|
|
|
|
// Template narrows a lane to ONE lineage: the id of the parent everything returned was forked from.
|
|
func (r CatalogAPIGetCatalogRequest) Template(template string) CatalogAPIGetCatalogRequest {
|
|
r.template = &template
|
|
return r
|
|
}
|
|
|
|
// Forkable is tri-state: \"true\" selects the forkable rows, \"false\" selects the rest, and anything else — including absent — applies no filter at all.
|
|
func (r CatalogAPIGetCatalogRequest) Forkable(forkable string) CatalogAPIGetCatalogRequest {
|
|
r.forkable = &forkable
|
|
return r
|
|
}
|
|
|
|
// Limit caps the page at 200, default 50. A value that is not a non-negative integer falls back to the default.
|
|
func (r CatalogAPIGetCatalogRequest) Limit(limit string) CatalogAPIGetCatalogRequest {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
|
|
// Offset is where the page starts, default 0, with the same tolerance.
|
|
func (r CatalogAPIGetCatalogRequest) Offset(offset string) CatalogAPIGetCatalogRequest {
|
|
r.offset = &offset
|
|
return r
|
|
}
|
|
|
|
func (r CatalogAPIGetCatalogRequest) Execute() (*CatalogCatalogPage, *http.Response, error) {
|
|
return r.ApiService.GetCatalogExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetCatalog Searches AND browses the cross-org catalog: every project, app and site the fleet has built, whichever org built it.
|
|
|
|
Searches AND browses the cross-org catalog: every project, app and site
|
|
the fleet has built, whichever org built it.
|
|
|
|
It reads TWO corpora and returns them as one page — the published,
|
|
world-readable catalog that every caller sees, plus the caller's OWN org's
|
|
private entries when the request carries a validated principal. Each row says
|
|
which it came from in `scope`, so a client can warn before sharing a link. An
|
|
anonymous caller simply gets the published one; no filter can ever widen a
|
|
caller into another tenant's corpus, because the query that would return it is
|
|
never run for them.
|
|
|
|
A request with no q is a browse rather than a search, and both answer the same
|
|
shape: the page, the total before paging, and the facet counts over the whole
|
|
matching set.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CatalogAPIGetCatalogRequest
|
|
*/
|
|
func (a *CatalogAPIService) GetCatalog(ctx context.Context) CatalogAPIGetCatalogRequest {
|
|
return CatalogAPIGetCatalogRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return CatalogCatalogPage
|
|
func (a *CatalogAPIService) GetCatalogExecute(r CatalogAPIGetCatalogRequest) (*CatalogCatalogPage, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CatalogCatalogPage
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CatalogAPIService.GetCatalog")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/catalog"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.q != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "q", r.q, "form", "")
|
|
}
|
|
if r.org != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "org", r.org, "form", "")
|
|
}
|
|
if r.kind != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "kind", r.kind, "form", "")
|
|
}
|
|
if r.origin != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "origin", r.origin, "form", "")
|
|
}
|
|
if r.archetype != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "archetype", r.archetype, "form", "")
|
|
}
|
|
if r.language != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "language", r.language, "form", "")
|
|
}
|
|
if r.template != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "template", r.template, "form", "")
|
|
}
|
|
if r.forkable != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "forkable", r.forkable, "form", "")
|
|
}
|
|
if r.limit != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
|
|
}
|
|
if r.offset != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "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
|
|
}
|