
* fix: cloud or oss only error msg for parsable responses * fix: add code text to error message * fix: keep the last part of the error msg * chore: make the error code a little more succinct * fix: corrected errors for non-server specific commands * chore: sync openapi submodule with main
1084 lines
32 KiB
Go
1084 lines
32 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 (
|
|
_context "context"
|
|
_fmt "fmt"
|
|
_ioutil "io/ioutil"
|
|
_nethttp "net/http"
|
|
_neturl "net/url"
|
|
"strings"
|
|
)
|
|
|
|
// Linger please
|
|
var (
|
|
_ _context.Context
|
|
)
|
|
|
|
type DBRPsApi interface {
|
|
|
|
/*
|
|
* DeleteDBRPID Delete a database retention policy
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param dbrpID The database retention policy mapping
|
|
* @return ApiDeleteDBRPIDRequest
|
|
*/
|
|
DeleteDBRPID(ctx _context.Context, dbrpID string) ApiDeleteDBRPIDRequest
|
|
|
|
/*
|
|
* DeleteDBRPIDExecute executes the request
|
|
*/
|
|
DeleteDBRPIDExecute(r ApiDeleteDBRPIDRequest) error
|
|
|
|
/*
|
|
* GetDBRPs List all database retention policy mappings
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiGetDBRPsRequest
|
|
*/
|
|
GetDBRPs(ctx _context.Context) ApiGetDBRPsRequest
|
|
|
|
/*
|
|
* GetDBRPsExecute executes the request
|
|
* @return DBRPs
|
|
*/
|
|
GetDBRPsExecute(r ApiGetDBRPsRequest) (DBRPs, error)
|
|
|
|
/*
|
|
* GetDBRPsID Retrieve a database retention policy mapping
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param dbrpID The database retention policy mapping ID
|
|
* @return ApiGetDBRPsIDRequest
|
|
*/
|
|
GetDBRPsID(ctx _context.Context, dbrpID string) ApiGetDBRPsIDRequest
|
|
|
|
/*
|
|
* GetDBRPsIDExecute executes the request
|
|
* @return DBRPGet
|
|
*/
|
|
GetDBRPsIDExecute(r ApiGetDBRPsIDRequest) (DBRPGet, error)
|
|
|
|
/*
|
|
* PatchDBRPID Update a database retention policy mapping
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param dbrpID The database retention policy mapping.
|
|
* @return ApiPatchDBRPIDRequest
|
|
*/
|
|
PatchDBRPID(ctx _context.Context, dbrpID string) ApiPatchDBRPIDRequest
|
|
|
|
/*
|
|
* PatchDBRPIDExecute executes the request
|
|
* @return DBRPGet
|
|
*/
|
|
PatchDBRPIDExecute(r ApiPatchDBRPIDRequest) (DBRPGet, error)
|
|
|
|
/*
|
|
* PostDBRP Add a database retention policy mapping
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiPostDBRPRequest
|
|
*/
|
|
PostDBRP(ctx _context.Context) ApiPostDBRPRequest
|
|
|
|
/*
|
|
* PostDBRPExecute executes the request
|
|
* @return DBRP
|
|
*/
|
|
PostDBRPExecute(r ApiPostDBRPRequest) (DBRP, error)
|
|
|
|
// Sets additional descriptive text in the error message if any request in
|
|
// this API fails, indicating that it is intended to be used only on OSS
|
|
// servers.
|
|
OnlyOSS() DBRPsApi
|
|
|
|
// Sets additional descriptive text in the error message if any request in
|
|
// this API fails, indicating that it is intended to be used only on cloud
|
|
// servers.
|
|
OnlyCloud() DBRPsApi
|
|
}
|
|
|
|
// DBRPsApiService DBRPsApi service
|
|
type DBRPsApiService service
|
|
|
|
func (a *DBRPsApiService) OnlyOSS() DBRPsApi {
|
|
a.isOnlyOSS = true
|
|
return a
|
|
}
|
|
|
|
func (a *DBRPsApiService) OnlyCloud() DBRPsApi {
|
|
a.isOnlyCloud = true
|
|
return a
|
|
}
|
|
|
|
type ApiDeleteDBRPIDRequest struct {
|
|
ctx _context.Context
|
|
ApiService DBRPsApi
|
|
dbrpID string
|
|
zapTraceSpan *string
|
|
orgID *string
|
|
org *string
|
|
}
|
|
|
|
func (r ApiDeleteDBRPIDRequest) DbrpID(dbrpID string) ApiDeleteDBRPIDRequest {
|
|
r.dbrpID = dbrpID
|
|
return r
|
|
}
|
|
func (r ApiDeleteDBRPIDRequest) GetDbrpID() string {
|
|
return r.dbrpID
|
|
}
|
|
|
|
func (r ApiDeleteDBRPIDRequest) ZapTraceSpan(zapTraceSpan string) ApiDeleteDBRPIDRequest {
|
|
r.zapTraceSpan = &zapTraceSpan
|
|
return r
|
|
}
|
|
func (r ApiDeleteDBRPIDRequest) GetZapTraceSpan() *string {
|
|
return r.zapTraceSpan
|
|
}
|
|
|
|
func (r ApiDeleteDBRPIDRequest) OrgID(orgID string) ApiDeleteDBRPIDRequest {
|
|
r.orgID = &orgID
|
|
return r
|
|
}
|
|
func (r ApiDeleteDBRPIDRequest) GetOrgID() *string {
|
|
return r.orgID
|
|
}
|
|
|
|
func (r ApiDeleteDBRPIDRequest) Org(org string) ApiDeleteDBRPIDRequest {
|
|
r.org = &org
|
|
return r
|
|
}
|
|
func (r ApiDeleteDBRPIDRequest) GetOrg() *string {
|
|
return r.org
|
|
}
|
|
|
|
func (r ApiDeleteDBRPIDRequest) Execute() error {
|
|
return r.ApiService.DeleteDBRPIDExecute(r)
|
|
}
|
|
|
|
/*
|
|
* DeleteDBRPID Delete a database retention policy
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param dbrpID The database retention policy mapping
|
|
* @return ApiDeleteDBRPIDRequest
|
|
*/
|
|
func (a *DBRPsApiService) DeleteDBRPID(ctx _context.Context, dbrpID string) ApiDeleteDBRPIDRequest {
|
|
return ApiDeleteDBRPIDRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
dbrpID: dbrpID,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
*/
|
|
func (a *DBRPsApiService) DeleteDBRPIDExecute(r ApiDeleteDBRPIDRequest) error {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodDelete
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DBRPsApiService.DeleteDBRPID")
|
|
if err != nil {
|
|
return GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/dbrps/{dbrpID}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"dbrpID"+"}", _neturl.PathEscape(parameterToString(r.dbrpID, "")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
|
|
if r.orgID != nil {
|
|
localVarQueryParams.Add("orgID", parameterToString(*r.orgID, ""))
|
|
}
|
|
if r.org != nil {
|
|
localVarQueryParams.Add("org", parameterToString(*r.org, ""))
|
|
}
|
|
// 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 err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return err
|
|
}
|
|
|
|
var errorPrefix string
|
|
if a.isOnlyOSS {
|
|
errorPrefix = "InfluxDB OSS-only command failed: "
|
|
} else if a.isOnlyCloud {
|
|
errorPrefix = "InfluxDB Cloud-only command failed: "
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status),
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return newErr
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type ApiGetDBRPsRequest struct {
|
|
ctx _context.Context
|
|
ApiService DBRPsApi
|
|
zapTraceSpan *string
|
|
orgID *string
|
|
org *string
|
|
id *string
|
|
bucketID *string
|
|
default_ *bool
|
|
db *string
|
|
rp *string
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) ZapTraceSpan(zapTraceSpan string) ApiGetDBRPsRequest {
|
|
r.zapTraceSpan = &zapTraceSpan
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsRequest) GetZapTraceSpan() *string {
|
|
return r.zapTraceSpan
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) OrgID(orgID string) ApiGetDBRPsRequest {
|
|
r.orgID = &orgID
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsRequest) GetOrgID() *string {
|
|
return r.orgID
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) Org(org string) ApiGetDBRPsRequest {
|
|
r.org = &org
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsRequest) GetOrg() *string {
|
|
return r.org
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) Id(id string) ApiGetDBRPsRequest {
|
|
r.id = &id
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsRequest) GetId() *string {
|
|
return r.id
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) BucketID(bucketID string) ApiGetDBRPsRequest {
|
|
r.bucketID = &bucketID
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsRequest) GetBucketID() *string {
|
|
return r.bucketID
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) Default_(default_ bool) ApiGetDBRPsRequest {
|
|
r.default_ = &default_
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsRequest) GetDefault_() *bool {
|
|
return r.default_
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) Db(db string) ApiGetDBRPsRequest {
|
|
r.db = &db
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsRequest) GetDb() *string {
|
|
return r.db
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) Rp(rp string) ApiGetDBRPsRequest {
|
|
r.rp = &rp
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsRequest) GetRp() *string {
|
|
return r.rp
|
|
}
|
|
|
|
func (r ApiGetDBRPsRequest) Execute() (DBRPs, error) {
|
|
return r.ApiService.GetDBRPsExecute(r)
|
|
}
|
|
|
|
/*
|
|
* GetDBRPs List all database retention policy mappings
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiGetDBRPsRequest
|
|
*/
|
|
func (a *DBRPsApiService) GetDBRPs(ctx _context.Context) ApiGetDBRPsRequest {
|
|
return ApiGetDBRPsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return DBRPs
|
|
*/
|
|
func (a *DBRPsApiService) GetDBRPsExecute(r ApiGetDBRPsRequest) (DBRPs, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodGet
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue DBRPs
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DBRPsApiService.GetDBRPs")
|
|
if err != nil {
|
|
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/dbrps"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
|
|
if r.orgID != nil {
|
|
localVarQueryParams.Add("orgID", parameterToString(*r.orgID, ""))
|
|
}
|
|
if r.org != nil {
|
|
localVarQueryParams.Add("org", parameterToString(*r.org, ""))
|
|
}
|
|
if r.id != nil {
|
|
localVarQueryParams.Add("id", parameterToString(*r.id, ""))
|
|
}
|
|
if r.bucketID != nil {
|
|
localVarQueryParams.Add("bucketID", parameterToString(*r.bucketID, ""))
|
|
}
|
|
if r.default_ != nil {
|
|
localVarQueryParams.Add("default", parameterToString(*r.default_, ""))
|
|
}
|
|
if r.db != nil {
|
|
localVarQueryParams.Add("db", parameterToString(*r.db, ""))
|
|
}
|
|
if r.rp != nil {
|
|
localVarQueryParams.Add("rp", parameterToString(*r.rp, ""))
|
|
}
|
|
// 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 errorPrefix string
|
|
if a.isOnlyOSS {
|
|
errorPrefix = "InfluxDB OSS-only command failed: "
|
|
} else if a.isOnlyCloud {
|
|
errorPrefix = "InfluxDB Cloud-only command failed: "
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status),
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, err.Error()),
|
|
}
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
return localVarReturnValue, nil
|
|
}
|
|
|
|
type ApiGetDBRPsIDRequest struct {
|
|
ctx _context.Context
|
|
ApiService DBRPsApi
|
|
dbrpID string
|
|
zapTraceSpan *string
|
|
orgID *string
|
|
org *string
|
|
}
|
|
|
|
func (r ApiGetDBRPsIDRequest) DbrpID(dbrpID string) ApiGetDBRPsIDRequest {
|
|
r.dbrpID = dbrpID
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsIDRequest) GetDbrpID() string {
|
|
return r.dbrpID
|
|
}
|
|
|
|
func (r ApiGetDBRPsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiGetDBRPsIDRequest {
|
|
r.zapTraceSpan = &zapTraceSpan
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsIDRequest) GetZapTraceSpan() *string {
|
|
return r.zapTraceSpan
|
|
}
|
|
|
|
func (r ApiGetDBRPsIDRequest) OrgID(orgID string) ApiGetDBRPsIDRequest {
|
|
r.orgID = &orgID
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsIDRequest) GetOrgID() *string {
|
|
return r.orgID
|
|
}
|
|
|
|
func (r ApiGetDBRPsIDRequest) Org(org string) ApiGetDBRPsIDRequest {
|
|
r.org = &org
|
|
return r
|
|
}
|
|
func (r ApiGetDBRPsIDRequest) GetOrg() *string {
|
|
return r.org
|
|
}
|
|
|
|
func (r ApiGetDBRPsIDRequest) Execute() (DBRPGet, error) {
|
|
return r.ApiService.GetDBRPsIDExecute(r)
|
|
}
|
|
|
|
/*
|
|
* GetDBRPsID Retrieve a database retention policy mapping
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param dbrpID The database retention policy mapping ID
|
|
* @return ApiGetDBRPsIDRequest
|
|
*/
|
|
func (a *DBRPsApiService) GetDBRPsID(ctx _context.Context, dbrpID string) ApiGetDBRPsIDRequest {
|
|
return ApiGetDBRPsIDRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
dbrpID: dbrpID,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return DBRPGet
|
|
*/
|
|
func (a *DBRPsApiService) GetDBRPsIDExecute(r ApiGetDBRPsIDRequest) (DBRPGet, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodGet
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue DBRPGet
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DBRPsApiService.GetDBRPsID")
|
|
if err != nil {
|
|
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/dbrps/{dbrpID}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"dbrpID"+"}", _neturl.PathEscape(parameterToString(r.dbrpID, "")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
|
|
if r.orgID != nil {
|
|
localVarQueryParams.Add("orgID", parameterToString(*r.orgID, ""))
|
|
}
|
|
if r.org != nil {
|
|
localVarQueryParams.Add("org", parameterToString(*r.org, ""))
|
|
}
|
|
// 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 errorPrefix string
|
|
if a.isOnlyOSS {
|
|
errorPrefix = "InfluxDB OSS-only command failed: "
|
|
} else if a.isOnlyCloud {
|
|
errorPrefix = "InfluxDB Cloud-only command failed: "
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status),
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, err.Error()),
|
|
}
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
return localVarReturnValue, nil
|
|
}
|
|
|
|
type ApiPatchDBRPIDRequest struct {
|
|
ctx _context.Context
|
|
ApiService DBRPsApi
|
|
dbrpID string
|
|
dBRPUpdate *DBRPUpdate
|
|
zapTraceSpan *string
|
|
orgID *string
|
|
org *string
|
|
}
|
|
|
|
func (r ApiPatchDBRPIDRequest) DbrpID(dbrpID string) ApiPatchDBRPIDRequest {
|
|
r.dbrpID = dbrpID
|
|
return r
|
|
}
|
|
func (r ApiPatchDBRPIDRequest) GetDbrpID() string {
|
|
return r.dbrpID
|
|
}
|
|
|
|
func (r ApiPatchDBRPIDRequest) DBRPUpdate(dBRPUpdate DBRPUpdate) ApiPatchDBRPIDRequest {
|
|
r.dBRPUpdate = &dBRPUpdate
|
|
return r
|
|
}
|
|
func (r ApiPatchDBRPIDRequest) GetDBRPUpdate() *DBRPUpdate {
|
|
return r.dBRPUpdate
|
|
}
|
|
|
|
func (r ApiPatchDBRPIDRequest) ZapTraceSpan(zapTraceSpan string) ApiPatchDBRPIDRequest {
|
|
r.zapTraceSpan = &zapTraceSpan
|
|
return r
|
|
}
|
|
func (r ApiPatchDBRPIDRequest) GetZapTraceSpan() *string {
|
|
return r.zapTraceSpan
|
|
}
|
|
|
|
func (r ApiPatchDBRPIDRequest) OrgID(orgID string) ApiPatchDBRPIDRequest {
|
|
r.orgID = &orgID
|
|
return r
|
|
}
|
|
func (r ApiPatchDBRPIDRequest) GetOrgID() *string {
|
|
return r.orgID
|
|
}
|
|
|
|
func (r ApiPatchDBRPIDRequest) Org(org string) ApiPatchDBRPIDRequest {
|
|
r.org = &org
|
|
return r
|
|
}
|
|
func (r ApiPatchDBRPIDRequest) GetOrg() *string {
|
|
return r.org
|
|
}
|
|
|
|
func (r ApiPatchDBRPIDRequest) Execute() (DBRPGet, error) {
|
|
return r.ApiService.PatchDBRPIDExecute(r)
|
|
}
|
|
|
|
/*
|
|
* PatchDBRPID Update a database retention policy mapping
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param dbrpID The database retention policy mapping.
|
|
* @return ApiPatchDBRPIDRequest
|
|
*/
|
|
func (a *DBRPsApiService) PatchDBRPID(ctx _context.Context, dbrpID string) ApiPatchDBRPIDRequest {
|
|
return ApiPatchDBRPIDRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
dbrpID: dbrpID,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return DBRPGet
|
|
*/
|
|
func (a *DBRPsApiService) PatchDBRPIDExecute(r ApiPatchDBRPIDRequest) (DBRPGet, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodPatch
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue DBRPGet
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DBRPsApiService.PatchDBRPID")
|
|
if err != nil {
|
|
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/dbrps/{dbrpID}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"dbrpID"+"}", _neturl.PathEscape(parameterToString(r.dbrpID, "")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
if r.dBRPUpdate == nil {
|
|
return localVarReturnValue, reportError("dBRPUpdate is required and must be specified")
|
|
}
|
|
|
|
if r.orgID != nil {
|
|
localVarQueryParams.Add("orgID", parameterToString(*r.orgID, ""))
|
|
}
|
|
if r.org != nil {
|
|
localVarQueryParams.Add("org", parameterToString(*r.org, ""))
|
|
}
|
|
// 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.dBRPUpdate
|
|
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 errorPrefix string
|
|
if a.isOnlyOSS {
|
|
errorPrefix = "InfluxDB OSS-only command failed: "
|
|
} else if a.isOnlyCloud {
|
|
errorPrefix = "InfluxDB Cloud-only command failed: "
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status),
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, err.Error()),
|
|
}
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
return localVarReturnValue, nil
|
|
}
|
|
|
|
type ApiPostDBRPRequest struct {
|
|
ctx _context.Context
|
|
ApiService DBRPsApi
|
|
dBRPCreate *DBRPCreate
|
|
zapTraceSpan *string
|
|
}
|
|
|
|
func (r ApiPostDBRPRequest) DBRPCreate(dBRPCreate DBRPCreate) ApiPostDBRPRequest {
|
|
r.dBRPCreate = &dBRPCreate
|
|
return r
|
|
}
|
|
func (r ApiPostDBRPRequest) GetDBRPCreate() *DBRPCreate {
|
|
return r.dBRPCreate
|
|
}
|
|
|
|
func (r ApiPostDBRPRequest) ZapTraceSpan(zapTraceSpan string) ApiPostDBRPRequest {
|
|
r.zapTraceSpan = &zapTraceSpan
|
|
return r
|
|
}
|
|
func (r ApiPostDBRPRequest) GetZapTraceSpan() *string {
|
|
return r.zapTraceSpan
|
|
}
|
|
|
|
func (r ApiPostDBRPRequest) Execute() (DBRP, error) {
|
|
return r.ApiService.PostDBRPExecute(r)
|
|
}
|
|
|
|
/*
|
|
* PostDBRP Add a database retention policy mapping
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @return ApiPostDBRPRequest
|
|
*/
|
|
func (a *DBRPsApiService) PostDBRP(ctx _context.Context) ApiPostDBRPRequest {
|
|
return ApiPostDBRPRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return DBRP
|
|
*/
|
|
func (a *DBRPsApiService) PostDBRPExecute(r ApiPostDBRPRequest) (DBRP, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodPost
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue DBRP
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DBRPsApiService.PostDBRP")
|
|
if err != nil {
|
|
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/dbrps"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
if r.dBRPCreate == nil {
|
|
return localVarReturnValue, reportError("dBRPCreate 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.dBRPCreate
|
|
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 errorPrefix string
|
|
if a.isOnlyOSS {
|
|
errorPrefix = "InfluxDB OSS-only command failed: "
|
|
} else if a.isOnlyCloud {
|
|
errorPrefix = "InfluxDB Cloud-only command failed: "
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status),
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
localVarBody, err := _ioutil.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err)
|
|
}
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: _fmt.Sprintf("%s%s", errorPrefix, err.Error()),
|
|
}
|
|
return localVarReturnValue, newErr
|
|
}
|
|
|
|
return localVarReturnValue, nil
|
|
}
|