
* build: add goimports to fmt target to remove unused imports * feat: update codegen template to support returning raw response body * feat: add support for gunzip-ing response bodies * refactor: remove unused piece from codegen return values
424 lines
12 KiB
Go
424 lines
12 KiB
Go
/*
|
|
* Subset of Influx API covered by Influx CLI
|
|
*
|
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
*
|
|
* API version: 2.0.0
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
_gzip "compress/gzip"
|
|
_context "context"
|
|
_io "io"
|
|
_ioutil "io/ioutil"
|
|
_nethttp "net/http"
|
|
_neturl "net/url"
|
|
)
|
|
|
|
// Linger please
|
|
var (
|
|
_ _context.Context
|
|
)
|
|
|
|
type OrganizationsApi interface {
|
|
|
|
/*
|
|
* GetOrgs List all organizations
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiGetOrgsRequest
|
|
*/
|
|
GetOrgs(ctx _context.Context) ApiGetOrgsRequest
|
|
|
|
/*
|
|
* GetOrgsExecute executes the request
|
|
* @return Organizations
|
|
*/
|
|
GetOrgsExecute(r ApiGetOrgsRequest) (Organizations, error)
|
|
|
|
/*
|
|
* PostOrgs Create an organization
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiPostOrgsRequest
|
|
*/
|
|
PostOrgs(ctx _context.Context) ApiPostOrgsRequest
|
|
|
|
/*
|
|
* PostOrgsExecute executes the request
|
|
* @return Organization
|
|
*/
|
|
PostOrgsExecute(r ApiPostOrgsRequest) (Organization, error)
|
|
}
|
|
|
|
// organizationsApiGzipReadCloser supports streaming gzip response-bodies directly from the server.
|
|
type organizationsApiGzipReadCloser struct {
|
|
underlying _io.ReadCloser
|
|
gzip _io.ReadCloser
|
|
}
|
|
|
|
func (gzrc *organizationsApiGzipReadCloser) Read(p []byte) (int, error) {
|
|
return gzrc.gzip.Read(p)
|
|
}
|
|
func (gzrc *organizationsApiGzipReadCloser) Close() error {
|
|
if err := gzrc.gzip.Close(); err != nil {
|
|
return err
|
|
}
|
|
return gzrc.underlying.Close()
|
|
}
|
|
|
|
// OrganizationsApiService OrganizationsApi service
|
|
type OrganizationsApiService service
|
|
|
|
type ApiGetOrgsRequest struct {
|
|
ctx _context.Context
|
|
ApiService OrganizationsApi
|
|
zapTraceSpan *string
|
|
offset *int32
|
|
limit *int32
|
|
descending *bool
|
|
org *string
|
|
orgID *string
|
|
userID *string
|
|
}
|
|
|
|
func (r ApiGetOrgsRequest) ZapTraceSpan(zapTraceSpan string) ApiGetOrgsRequest {
|
|
r.zapTraceSpan = &zapTraceSpan
|
|
return r
|
|
}
|
|
func (r ApiGetOrgsRequest) GetZapTraceSpan() *string {
|
|
return r.zapTraceSpan
|
|
}
|
|
|
|
func (r ApiGetOrgsRequest) Offset(offset int32) ApiGetOrgsRequest {
|
|
r.offset = &offset
|
|
return r
|
|
}
|
|
func (r ApiGetOrgsRequest) GetOffset() *int32 {
|
|
return r.offset
|
|
}
|
|
|
|
func (r ApiGetOrgsRequest) Limit(limit int32) ApiGetOrgsRequest {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
func (r ApiGetOrgsRequest) GetLimit() *int32 {
|
|
return r.limit
|
|
}
|
|
|
|
func (r ApiGetOrgsRequest) Descending(descending bool) ApiGetOrgsRequest {
|
|
r.descending = &descending
|
|
return r
|
|
}
|
|
func (r ApiGetOrgsRequest) GetDescending() *bool {
|
|
return r.descending
|
|
}
|
|
|
|
func (r ApiGetOrgsRequest) Org(org string) ApiGetOrgsRequest {
|
|
r.org = &org
|
|
return r
|
|
}
|
|
func (r ApiGetOrgsRequest) GetOrg() *string {
|
|
return r.org
|
|
}
|
|
|
|
func (r ApiGetOrgsRequest) OrgID(orgID string) ApiGetOrgsRequest {
|
|
r.orgID = &orgID
|
|
return r
|
|
}
|
|
func (r ApiGetOrgsRequest) GetOrgID() *string {
|
|
return r.orgID
|
|
}
|
|
|
|
func (r ApiGetOrgsRequest) UserID(userID string) ApiGetOrgsRequest {
|
|
r.userID = &userID
|
|
return r
|
|
}
|
|
func (r ApiGetOrgsRequest) GetUserID() *string {
|
|
return r.userID
|
|
}
|
|
|
|
func (r ApiGetOrgsRequest) Execute() (Organizations, error) {
|
|
return r.ApiService.GetOrgsExecute(r)
|
|
}
|
|
|
|
/*
|
|
* GetOrgs List all organizations
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiGetOrgsRequest
|
|
*/
|
|
func (a *OrganizationsApiService) GetOrgs(ctx _context.Context) ApiGetOrgsRequest {
|
|
return ApiGetOrgsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return Organizations
|
|
*/
|
|
func (a *OrganizationsApiService) GetOrgsExecute(r ApiGetOrgsRequest) (Organizations, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodGet
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue Organizations
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OrganizationsApiService.GetOrgs")
|
|
if err != nil {
|
|
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/orgs"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
|
|
if r.offset != nil {
|
|
localVarQueryParams.Add("offset", parameterToString(*r.offset, ""))
|
|
}
|
|
if r.limit != nil {
|
|
localVarQueryParams.Add("limit", parameterToString(*r.limit, ""))
|
|
}
|
|
if r.descending != nil {
|
|
localVarQueryParams.Add("descending", parameterToString(*r.descending, ""))
|
|
}
|
|
if r.org != nil {
|
|
localVarQueryParams.Add("org", parameterToString(*r.org, ""))
|
|
}
|
|
if r.orgID != nil {
|
|
localVarQueryParams.Add("orgID", parameterToString(*r.orgID, ""))
|
|
}
|
|
if r.userID != nil {
|
|
localVarQueryParams.Add("userID", parameterToString(*r.userID, ""))
|
|
}
|
|
// 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"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.zapTraceSpan != nil {
|
|
localVarHeaderParams["Zap-Trace-Span"] = parameterToString(*r.zapTraceSpan, "")
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
|
if err != nil {
|
|
return localVarReturnValue, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, err
|
|
}
|
|
|
|
var body _io.ReadCloser = localVarHTTPResponse.Body
|
|
if localVarHTTPResponse.Header.Get("Content-Encoding") == "gzip" {
|
|
gzr, err := _gzip.NewReader(body)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, err
|
|
}
|
|
body = &organizationsApiGzipReadCloser{underlying: body, gzip: gzr}
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, err
|
|
}
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, newErr
|
|
}
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, err
|
|
}
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
return localVarReturnValue, nil
|
|
}
|
|
|
|
type ApiPostOrgsRequest struct {
|
|
ctx _context.Context
|
|
ApiService OrganizationsApi
|
|
organization *Organization
|
|
zapTraceSpan *string
|
|
}
|
|
|
|
func (r ApiPostOrgsRequest) Organization(organization Organization) ApiPostOrgsRequest {
|
|
r.organization = &organization
|
|
return r
|
|
}
|
|
func (r ApiPostOrgsRequest) GetOrganization() *Organization {
|
|
return r.organization
|
|
}
|
|
|
|
func (r ApiPostOrgsRequest) ZapTraceSpan(zapTraceSpan string) ApiPostOrgsRequest {
|
|
r.zapTraceSpan = &zapTraceSpan
|
|
return r
|
|
}
|
|
func (r ApiPostOrgsRequest) GetZapTraceSpan() *string {
|
|
return r.zapTraceSpan
|
|
}
|
|
|
|
func (r ApiPostOrgsRequest) Execute() (Organization, error) {
|
|
return r.ApiService.PostOrgsExecute(r)
|
|
}
|
|
|
|
/*
|
|
* PostOrgs Create an organization
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiPostOrgsRequest
|
|
*/
|
|
func (a *OrganizationsApiService) PostOrgs(ctx _context.Context) ApiPostOrgsRequest {
|
|
return ApiPostOrgsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return Organization
|
|
*/
|
|
func (a *OrganizationsApiService) PostOrgsExecute(r ApiPostOrgsRequest) (Organization, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodPost
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue Organization
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OrganizationsApiService.PostOrgs")
|
|
if err != nil {
|
|
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/orgs"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
if r.organization == nil {
|
|
return localVarReturnValue, reportError("organization 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"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.zapTraceSpan != nil {
|
|
localVarHeaderParams["Zap-Trace-Span"] = parameterToString(*r.zapTraceSpan, "")
|
|
}
|
|
// body params
|
|
localVarPostBody = r.organization
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
|
if err != nil {
|
|
return localVarReturnValue, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, err
|
|
}
|
|
|
|
var body _io.ReadCloser = localVarHTTPResponse.Body
|
|
if localVarHTTPResponse.Header.Get("Content-Encoding") == "gzip" {
|
|
gzr, err := _gzip.NewReader(body)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, err
|
|
}
|
|
body = &organizationsApiGzipReadCloser{underlying: body, gzip: gzr}
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, err
|
|
}
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, newErr
|
|
}
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, err
|
|
}
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
return localVarReturnValue, nil
|
|
}
|