feat: port influx auth
command (#152)
This commit is contained in:
parent
ead44e4e83
commit
a058fe7e0b
920
api/api_authorizations.gen.go
Normal file
920
api/api_authorizations.gen.go
Normal file
@ -0,0 +1,920 @@
|
||||
/*
|
||||
* 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 AuthorizationsApi interface {
|
||||
|
||||
/*
|
||||
* DeleteAuthorizationsID Delete an authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to delete.
|
||||
* @return ApiDeleteAuthorizationsIDRequest
|
||||
*/
|
||||
DeleteAuthorizationsID(ctx _context.Context, authID string) ApiDeleteAuthorizationsIDRequest
|
||||
|
||||
/*
|
||||
* DeleteAuthorizationsIDExecute executes the request
|
||||
*/
|
||||
DeleteAuthorizationsIDExecute(r ApiDeleteAuthorizationsIDRequest) error
|
||||
|
||||
/*
|
||||
* GetAuthorizations List all authorizations
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiGetAuthorizationsRequest
|
||||
*/
|
||||
GetAuthorizations(ctx _context.Context) ApiGetAuthorizationsRequest
|
||||
|
||||
/*
|
||||
* GetAuthorizationsExecute executes the request
|
||||
* @return Authorizations
|
||||
*/
|
||||
GetAuthorizationsExecute(r ApiGetAuthorizationsRequest) (Authorizations, error)
|
||||
|
||||
/*
|
||||
* GetAuthorizationsID Retrieve an authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to get.
|
||||
* @return ApiGetAuthorizationsIDRequest
|
||||
*/
|
||||
GetAuthorizationsID(ctx _context.Context, authID string) ApiGetAuthorizationsIDRequest
|
||||
|
||||
/*
|
||||
* GetAuthorizationsIDExecute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
GetAuthorizationsIDExecute(r ApiGetAuthorizationsIDRequest) (Authorization, error)
|
||||
|
||||
/*
|
||||
* PatchAuthorizationsID Update an authorization to be active or inactive
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to update.
|
||||
* @return ApiPatchAuthorizationsIDRequest
|
||||
*/
|
||||
PatchAuthorizationsID(ctx _context.Context, authID string) ApiPatchAuthorizationsIDRequest
|
||||
|
||||
/*
|
||||
* PatchAuthorizationsIDExecute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
PatchAuthorizationsIDExecute(r ApiPatchAuthorizationsIDRequest) (Authorization, error)
|
||||
|
||||
/*
|
||||
* PostAuthorizations Create an authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiPostAuthorizationsRequest
|
||||
*/
|
||||
PostAuthorizations(ctx _context.Context) ApiPostAuthorizationsRequest
|
||||
|
||||
/*
|
||||
* PostAuthorizationsExecute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
PostAuthorizationsExecute(r ApiPostAuthorizationsRequest) (Authorization, 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() AuthorizationsApi
|
||||
|
||||
// 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() AuthorizationsApi
|
||||
}
|
||||
|
||||
// AuthorizationsApiService AuthorizationsApi service
|
||||
type AuthorizationsApiService service
|
||||
|
||||
func (a *AuthorizationsApiService) OnlyOSS() AuthorizationsApi {
|
||||
a.isOnlyOSS = true
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AuthorizationsApiService) OnlyCloud() AuthorizationsApi {
|
||||
a.isOnlyCloud = true
|
||||
return a
|
||||
}
|
||||
|
||||
type ApiDeleteAuthorizationsIDRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService AuthorizationsApi
|
||||
authID string
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiDeleteAuthorizationsIDRequest) AuthID(authID string) ApiDeleteAuthorizationsIDRequest {
|
||||
r.authID = authID
|
||||
return r
|
||||
}
|
||||
func (r ApiDeleteAuthorizationsIDRequest) GetAuthID() string {
|
||||
return r.authID
|
||||
}
|
||||
|
||||
func (r ApiDeleteAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiDeleteAuthorizationsIDRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiDeleteAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiDeleteAuthorizationsIDRequest) Execute() error {
|
||||
return r.ApiService.DeleteAuthorizationsIDExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* DeleteAuthorizationsID Delete an authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to delete.
|
||||
* @return ApiDeleteAuthorizationsIDRequest
|
||||
*/
|
||||
func (a *AuthorizationsApiService) DeleteAuthorizationsID(ctx _context.Context, authID string) ApiDeleteAuthorizationsIDRequest {
|
||||
return ApiDeleteAuthorizationsIDRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
authID: authID,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute executes the request
|
||||
*/
|
||||
func (a *AuthorizationsApiService) DeleteAuthorizationsIDExecute(r ApiDeleteAuthorizationsIDRequest) error {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodDelete
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsApiService.DeleteAuthorizationsID")
|
||||
if err != nil {
|
||||
return GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/authorizations/{authID}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"authID"+"}", _neturl.PathEscape(parameterToString(r.authID, "")), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := _neturl.Values{}
|
||||
localVarFormParams := _neturl.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"}
|
||||
|
||||
// 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),
|
||||
}
|
||||
var v Error
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, err.Error())
|
||||
return newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, v.Error())
|
||||
return newErr
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type ApiGetAuthorizationsRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService AuthorizationsApi
|
||||
zapTraceSpan *string
|
||||
userID *string
|
||||
user *string
|
||||
orgID *string
|
||||
org *string
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) ZapTraceSpan(zapTraceSpan string) ApiGetAuthorizationsRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) UserID(userID string) ApiGetAuthorizationsRequest {
|
||||
r.userID = &userID
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetUserID() *string {
|
||||
return r.userID
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) User(user string) ApiGetAuthorizationsRequest {
|
||||
r.user = &user
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetUser() *string {
|
||||
return r.user
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) OrgID(orgID string) ApiGetAuthorizationsRequest {
|
||||
r.orgID = &orgID
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetOrgID() *string {
|
||||
return r.orgID
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) Org(org string) ApiGetAuthorizationsRequest {
|
||||
r.org = &org
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetOrg() *string {
|
||||
return r.org
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) Execute() (Authorizations, error) {
|
||||
return r.ApiService.GetAuthorizationsExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* GetAuthorizations List all authorizations
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiGetAuthorizationsRequest
|
||||
*/
|
||||
func (a *AuthorizationsApiService) GetAuthorizations(ctx _context.Context) ApiGetAuthorizationsRequest {
|
||||
return ApiGetAuthorizationsRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute executes the request
|
||||
* @return Authorizations
|
||||
*/
|
||||
func (a *AuthorizationsApiService) GetAuthorizationsExecute(r ApiGetAuthorizationsRequest) (Authorizations, error) {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodGet
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue Authorizations
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsApiService.GetAuthorizations")
|
||||
if err != nil {
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/authorizations"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := _neturl.Values{}
|
||||
localVarFormParams := _neturl.Values{}
|
||||
|
||||
if r.userID != nil {
|
||||
localVarQueryParams.Add("userID", parameterToString(*r.userID, ""))
|
||||
}
|
||||
if r.user != nil {
|
||||
localVarQueryParams.Add("user", parameterToString(*r.user, ""))
|
||||
}
|
||||
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),
|
||||
}
|
||||
var v Error
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, err.Error())
|
||||
return localVarReturnValue, newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, v.Error())
|
||||
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 ApiGetAuthorizationsIDRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService AuthorizationsApi
|
||||
authID string
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsIDRequest) AuthID(authID string) ApiGetAuthorizationsIDRequest {
|
||||
r.authID = authID
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsIDRequest) GetAuthID() string {
|
||||
return r.authID
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiGetAuthorizationsIDRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsIDRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.GetAuthorizationsIDExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* GetAuthorizationsID Retrieve an authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to get.
|
||||
* @return ApiGetAuthorizationsIDRequest
|
||||
*/
|
||||
func (a *AuthorizationsApiService) GetAuthorizationsID(ctx _context.Context, authID string) ApiGetAuthorizationsIDRequest {
|
||||
return ApiGetAuthorizationsIDRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
authID: authID,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
func (a *AuthorizationsApiService) GetAuthorizationsIDExecute(r ApiGetAuthorizationsIDRequest) (Authorization, error) {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodGet
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue Authorization
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsApiService.GetAuthorizationsID")
|
||||
if err != nil {
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/authorizations/{authID}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"authID"+"}", _neturl.PathEscape(parameterToString(r.authID, "")), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := _neturl.Values{}
|
||||
localVarFormParams := _neturl.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"}
|
||||
|
||||
// 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),
|
||||
}
|
||||
var v Error
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, err.Error())
|
||||
return localVarReturnValue, newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, v.Error())
|
||||
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 ApiPatchAuthorizationsIDRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService AuthorizationsApi
|
||||
authID string
|
||||
authorizationUpdateRequest *AuthorizationUpdateRequest
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiPatchAuthorizationsIDRequest) AuthID(authID string) ApiPatchAuthorizationsIDRequest {
|
||||
r.authID = authID
|
||||
return r
|
||||
}
|
||||
func (r ApiPatchAuthorizationsIDRequest) GetAuthID() string {
|
||||
return r.authID
|
||||
}
|
||||
|
||||
func (r ApiPatchAuthorizationsIDRequest) AuthorizationUpdateRequest(authorizationUpdateRequest AuthorizationUpdateRequest) ApiPatchAuthorizationsIDRequest {
|
||||
r.authorizationUpdateRequest = &authorizationUpdateRequest
|
||||
return r
|
||||
}
|
||||
func (r ApiPatchAuthorizationsIDRequest) GetAuthorizationUpdateRequest() *AuthorizationUpdateRequest {
|
||||
return r.authorizationUpdateRequest
|
||||
}
|
||||
|
||||
func (r ApiPatchAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiPatchAuthorizationsIDRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiPatchAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiPatchAuthorizationsIDRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.PatchAuthorizationsIDExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* PatchAuthorizationsID Update an authorization to be active or inactive
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to update.
|
||||
* @return ApiPatchAuthorizationsIDRequest
|
||||
*/
|
||||
func (a *AuthorizationsApiService) PatchAuthorizationsID(ctx _context.Context, authID string) ApiPatchAuthorizationsIDRequest {
|
||||
return ApiPatchAuthorizationsIDRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
authID: authID,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
func (a *AuthorizationsApiService) PatchAuthorizationsIDExecute(r ApiPatchAuthorizationsIDRequest) (Authorization, error) {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodPatch
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue Authorization
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsApiService.PatchAuthorizationsID")
|
||||
if err != nil {
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/authorizations/{authID}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"authID"+"}", _neturl.PathEscape(parameterToString(r.authID, "")), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := _neturl.Values{}
|
||||
localVarFormParams := _neturl.Values{}
|
||||
if r.authorizationUpdateRequest == nil {
|
||||
return localVarReturnValue, reportError("authorizationUpdateRequest 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.authorizationUpdateRequest
|
||||
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),
|
||||
}
|
||||
var v Error
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, err.Error())
|
||||
return localVarReturnValue, newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, v.Error())
|
||||
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 ApiPostAuthorizationsRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService AuthorizationsApi
|
||||
authorizationPostRequest *AuthorizationPostRequest
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsRequest) AuthorizationPostRequest(authorizationPostRequest AuthorizationPostRequest) ApiPostAuthorizationsRequest {
|
||||
r.authorizationPostRequest = &authorizationPostRequest
|
||||
return r
|
||||
}
|
||||
func (r ApiPostAuthorizationsRequest) GetAuthorizationPostRequest() *AuthorizationPostRequest {
|
||||
return r.authorizationPostRequest
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsRequest) ZapTraceSpan(zapTraceSpan string) ApiPostAuthorizationsRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiPostAuthorizationsRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.PostAuthorizationsExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* PostAuthorizations Create an authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiPostAuthorizationsRequest
|
||||
*/
|
||||
func (a *AuthorizationsApiService) PostAuthorizations(ctx _context.Context) ApiPostAuthorizationsRequest {
|
||||
return ApiPostAuthorizationsRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
func (a *AuthorizationsApiService) PostAuthorizationsExecute(r ApiPostAuthorizationsRequest) (Authorization, error) {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodPost
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue Authorization
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsApiService.PostAuthorizations")
|
||||
if err != nil {
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/authorizations"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := _neturl.Values{}
|
||||
localVarFormParams := _neturl.Values{}
|
||||
if r.authorizationPostRequest == nil {
|
||||
return localVarReturnValue, reportError("authorizationPostRequest 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.authorizationPostRequest
|
||||
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%v", errorPrefix, err.Error())
|
||||
return localVarReturnValue, newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, v.Error())
|
||||
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%v", errorPrefix, err.Error())
|
||||
return localVarReturnValue, newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
newErr.error = _fmt.Sprintf("%s%v", errorPrefix, v.Error())
|
||||
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
|
||||
}
|
@ -27,84 +27,84 @@ var (
|
||||
type LegacyAuthorizationsApi interface {
|
||||
|
||||
/*
|
||||
* DeleteAuthorizationsID Delete an authorization
|
||||
* DeleteLegacyAuthorizationsID Delete a legacy authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to delete.
|
||||
* @return ApiDeleteAuthorizationsIDRequest
|
||||
* @param authID The ID of the legacy authorization to delete.
|
||||
* @return ApiDeleteLegacyAuthorizationsIDRequest
|
||||
*/
|
||||
DeleteAuthorizationsID(ctx _context.Context, authID string) ApiDeleteAuthorizationsIDRequest
|
||||
DeleteLegacyAuthorizationsID(ctx _context.Context, authID string) ApiDeleteLegacyAuthorizationsIDRequest
|
||||
|
||||
/*
|
||||
* DeleteAuthorizationsIDExecute executes the request
|
||||
* DeleteLegacyAuthorizationsIDExecute executes the request
|
||||
*/
|
||||
DeleteAuthorizationsIDExecute(r ApiDeleteAuthorizationsIDRequest) error
|
||||
DeleteLegacyAuthorizationsIDExecute(r ApiDeleteLegacyAuthorizationsIDRequest) error
|
||||
|
||||
/*
|
||||
* GetAuthorizations List all authorizations
|
||||
* GetLegacyAuthorizations List all legacy authorizations
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiGetAuthorizationsRequest
|
||||
* @return ApiGetLegacyAuthorizationsRequest
|
||||
*/
|
||||
GetAuthorizations(ctx _context.Context) ApiGetAuthorizationsRequest
|
||||
GetLegacyAuthorizations(ctx _context.Context) ApiGetLegacyAuthorizationsRequest
|
||||
|
||||
/*
|
||||
* GetAuthorizationsExecute executes the request
|
||||
* GetLegacyAuthorizationsExecute executes the request
|
||||
* @return Authorizations
|
||||
*/
|
||||
GetAuthorizationsExecute(r ApiGetAuthorizationsRequest) (Authorizations, error)
|
||||
GetLegacyAuthorizationsExecute(r ApiGetLegacyAuthorizationsRequest) (Authorizations, error)
|
||||
|
||||
/*
|
||||
* GetAuthorizationsID Retrieve an authorization
|
||||
* GetLegacyAuthorizationsID Retrieve a legacy authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to get.
|
||||
* @return ApiGetAuthorizationsIDRequest
|
||||
* @param authID The ID of the legacy authorization to get.
|
||||
* @return ApiGetLegacyAuthorizationsIDRequest
|
||||
*/
|
||||
GetAuthorizationsID(ctx _context.Context, authID string) ApiGetAuthorizationsIDRequest
|
||||
GetLegacyAuthorizationsID(ctx _context.Context, authID string) ApiGetLegacyAuthorizationsIDRequest
|
||||
|
||||
/*
|
||||
* GetAuthorizationsIDExecute executes the request
|
||||
* GetLegacyAuthorizationsIDExecute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
GetAuthorizationsIDExecute(r ApiGetAuthorizationsIDRequest) (Authorization, error)
|
||||
GetLegacyAuthorizationsIDExecute(r ApiGetLegacyAuthorizationsIDRequest) (Authorization, error)
|
||||
|
||||
/*
|
||||
* PatchAuthorizationsID Update an authorization to be active or inactive
|
||||
* PatchLegacyAuthorizationsID Update a legacy authorization to be active or inactive
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to update.
|
||||
* @return ApiPatchAuthorizationsIDRequest
|
||||
* @param authID The ID of the legacy authorization to update.
|
||||
* @return ApiPatchLegacyAuthorizationsIDRequest
|
||||
*/
|
||||
PatchAuthorizationsID(ctx _context.Context, authID string) ApiPatchAuthorizationsIDRequest
|
||||
PatchLegacyAuthorizationsID(ctx _context.Context, authID string) ApiPatchLegacyAuthorizationsIDRequest
|
||||
|
||||
/*
|
||||
* PatchAuthorizationsIDExecute executes the request
|
||||
* PatchLegacyAuthorizationsIDExecute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
PatchAuthorizationsIDExecute(r ApiPatchAuthorizationsIDRequest) (Authorization, error)
|
||||
PatchLegacyAuthorizationsIDExecute(r ApiPatchLegacyAuthorizationsIDRequest) (Authorization, error)
|
||||
|
||||
/*
|
||||
* PostAuthorizations Create an authorization
|
||||
* PostLegacyAuthorizations Create a legacy authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiPostAuthorizationsRequest
|
||||
* @return ApiPostLegacyAuthorizationsRequest
|
||||
*/
|
||||
PostAuthorizations(ctx _context.Context) ApiPostAuthorizationsRequest
|
||||
PostLegacyAuthorizations(ctx _context.Context) ApiPostLegacyAuthorizationsRequest
|
||||
|
||||
/*
|
||||
* PostAuthorizationsExecute executes the request
|
||||
* PostLegacyAuthorizationsExecute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
PostAuthorizationsExecute(r ApiPostAuthorizationsRequest) (Authorization, error)
|
||||
PostLegacyAuthorizationsExecute(r ApiPostLegacyAuthorizationsRequest) (Authorization, error)
|
||||
|
||||
/*
|
||||
* PostAuthorizationsIDPassword Set an authorization password
|
||||
* PostLegacyAuthorizationsIDPassword Set a legacy authorization password
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to update.
|
||||
* @return ApiPostAuthorizationsIDPasswordRequest
|
||||
* @param authID The ID of the legacy authorization to update.
|
||||
* @return ApiPostLegacyAuthorizationsIDPasswordRequest
|
||||
*/
|
||||
PostAuthorizationsIDPassword(ctx _context.Context, authID string) ApiPostAuthorizationsIDPasswordRequest
|
||||
PostLegacyAuthorizationsIDPassword(ctx _context.Context, authID string) ApiPostLegacyAuthorizationsIDPasswordRequest
|
||||
|
||||
/*
|
||||
* PostAuthorizationsIDPasswordExecute executes the request
|
||||
* PostLegacyAuthorizationsIDPasswordExecute executes the request
|
||||
*/
|
||||
PostAuthorizationsIDPasswordExecute(r ApiPostAuthorizationsIDPasswordRequest) error
|
||||
PostLegacyAuthorizationsIDPasswordExecute(r ApiPostLegacyAuthorizationsIDPasswordRequest) 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
|
||||
@ -130,41 +130,41 @@ func (a *LegacyAuthorizationsApiService) OnlyCloud() LegacyAuthorizationsApi {
|
||||
return a
|
||||
}
|
||||
|
||||
type ApiDeleteAuthorizationsIDRequest struct {
|
||||
type ApiDeleteLegacyAuthorizationsIDRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService LegacyAuthorizationsApi
|
||||
authID string
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiDeleteAuthorizationsIDRequest) AuthID(authID string) ApiDeleteAuthorizationsIDRequest {
|
||||
func (r ApiDeleteLegacyAuthorizationsIDRequest) AuthID(authID string) ApiDeleteLegacyAuthorizationsIDRequest {
|
||||
r.authID = authID
|
||||
return r
|
||||
}
|
||||
func (r ApiDeleteAuthorizationsIDRequest) GetAuthID() string {
|
||||
func (r ApiDeleteLegacyAuthorizationsIDRequest) GetAuthID() string {
|
||||
return r.authID
|
||||
}
|
||||
|
||||
func (r ApiDeleteAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiDeleteAuthorizationsIDRequest {
|
||||
func (r ApiDeleteLegacyAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiDeleteLegacyAuthorizationsIDRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiDeleteAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
func (r ApiDeleteLegacyAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiDeleteAuthorizationsIDRequest) Execute() error {
|
||||
return r.ApiService.DeleteAuthorizationsIDExecute(r)
|
||||
func (r ApiDeleteLegacyAuthorizationsIDRequest) Execute() error {
|
||||
return r.ApiService.DeleteLegacyAuthorizationsIDExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* DeleteAuthorizationsID Delete an authorization
|
||||
* DeleteLegacyAuthorizationsID Delete a legacy authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to delete.
|
||||
* @return ApiDeleteAuthorizationsIDRequest
|
||||
* @param authID The ID of the legacy authorization to delete.
|
||||
* @return ApiDeleteLegacyAuthorizationsIDRequest
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) DeleteAuthorizationsID(ctx _context.Context, authID string) ApiDeleteAuthorizationsIDRequest {
|
||||
return ApiDeleteAuthorizationsIDRequest{
|
||||
func (a *LegacyAuthorizationsApiService) DeleteLegacyAuthorizationsID(ctx _context.Context, authID string) ApiDeleteLegacyAuthorizationsIDRequest {
|
||||
return ApiDeleteLegacyAuthorizationsIDRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
authID: authID,
|
||||
@ -174,7 +174,7 @@ func (a *LegacyAuthorizationsApiService) DeleteAuthorizationsID(ctx _context.Con
|
||||
/*
|
||||
* Execute executes the request
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) DeleteAuthorizationsIDExecute(r ApiDeleteAuthorizationsIDRequest) error {
|
||||
func (a *LegacyAuthorizationsApiService) DeleteLegacyAuthorizationsIDExecute(r ApiDeleteLegacyAuthorizationsIDRequest) error {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodDelete
|
||||
localVarPostBody interface{}
|
||||
@ -183,7 +183,7 @@ func (a *LegacyAuthorizationsApiService) DeleteAuthorizationsIDExecute(r ApiDele
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.DeleteAuthorizationsID")
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.DeleteLegacyAuthorizationsID")
|
||||
if err != nil {
|
||||
return GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
@ -261,7 +261,7 @@ func (a *LegacyAuthorizationsApiService) DeleteAuthorizationsIDExecute(r ApiDele
|
||||
return nil
|
||||
}
|
||||
|
||||
type ApiGetAuthorizationsRequest struct {
|
||||
type ApiGetLegacyAuthorizationsRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService LegacyAuthorizationsApi
|
||||
zapTraceSpan *string
|
||||
@ -273,73 +273,73 @@ type ApiGetAuthorizationsRequest struct {
|
||||
authID *string
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) ZapTraceSpan(zapTraceSpan string) ApiGetAuthorizationsRequest {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) ZapTraceSpan(zapTraceSpan string) ApiGetLegacyAuthorizationsRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetZapTraceSpan() *string {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) UserID(userID string) ApiGetAuthorizationsRequest {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) UserID(userID string) ApiGetLegacyAuthorizationsRequest {
|
||||
r.userID = &userID
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetUserID() *string {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) GetUserID() *string {
|
||||
return r.userID
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) User(user string) ApiGetAuthorizationsRequest {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) User(user string) ApiGetLegacyAuthorizationsRequest {
|
||||
r.user = &user
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetUser() *string {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) GetUser() *string {
|
||||
return r.user
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) OrgID(orgID string) ApiGetAuthorizationsRequest {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) OrgID(orgID string) ApiGetLegacyAuthorizationsRequest {
|
||||
r.orgID = &orgID
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetOrgID() *string {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) GetOrgID() *string {
|
||||
return r.orgID
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) Org(org string) ApiGetAuthorizationsRequest {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) Org(org string) ApiGetLegacyAuthorizationsRequest {
|
||||
r.org = &org
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetOrg() *string {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) GetOrg() *string {
|
||||
return r.org
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) Token(token string) ApiGetAuthorizationsRequest {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) Token(token string) ApiGetLegacyAuthorizationsRequest {
|
||||
r.token = &token
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetToken() *string {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) GetToken() *string {
|
||||
return r.token
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) AuthID(authID string) ApiGetAuthorizationsRequest {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) AuthID(authID string) ApiGetLegacyAuthorizationsRequest {
|
||||
r.authID = &authID
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsRequest) GetAuthID() *string {
|
||||
func (r ApiGetLegacyAuthorizationsRequest) GetAuthID() *string {
|
||||
return r.authID
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsRequest) Execute() (Authorizations, error) {
|
||||
return r.ApiService.GetAuthorizationsExecute(r)
|
||||
func (r ApiGetLegacyAuthorizationsRequest) Execute() (Authorizations, error) {
|
||||
return r.ApiService.GetLegacyAuthorizationsExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* GetAuthorizations List all authorizations
|
||||
* GetLegacyAuthorizations List all legacy authorizations
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiGetAuthorizationsRequest
|
||||
* @return ApiGetLegacyAuthorizationsRequest
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) GetAuthorizations(ctx _context.Context) ApiGetAuthorizationsRequest {
|
||||
return ApiGetAuthorizationsRequest{
|
||||
func (a *LegacyAuthorizationsApiService) GetLegacyAuthorizations(ctx _context.Context) ApiGetLegacyAuthorizationsRequest {
|
||||
return ApiGetLegacyAuthorizationsRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
@ -349,7 +349,7 @@ func (a *LegacyAuthorizationsApiService) GetAuthorizations(ctx _context.Context)
|
||||
* Execute executes the request
|
||||
* @return Authorizations
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) GetAuthorizationsExecute(r ApiGetAuthorizationsRequest) (Authorizations, error) {
|
||||
func (a *LegacyAuthorizationsApiService) GetLegacyAuthorizationsExecute(r ApiGetLegacyAuthorizationsRequest) (Authorizations, error) {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodGet
|
||||
localVarPostBody interface{}
|
||||
@ -359,7 +359,7 @@ func (a *LegacyAuthorizationsApiService) GetAuthorizationsExecute(r ApiGetAuthor
|
||||
localVarReturnValue Authorizations
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.GetAuthorizations")
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.GetLegacyAuthorizations")
|
||||
if err != nil {
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
@ -473,41 +473,41 @@ func (a *LegacyAuthorizationsApiService) GetAuthorizationsExecute(r ApiGetAuthor
|
||||
return localVarReturnValue, nil
|
||||
}
|
||||
|
||||
type ApiGetAuthorizationsIDRequest struct {
|
||||
type ApiGetLegacyAuthorizationsIDRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService LegacyAuthorizationsApi
|
||||
authID string
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsIDRequest) AuthID(authID string) ApiGetAuthorizationsIDRequest {
|
||||
func (r ApiGetLegacyAuthorizationsIDRequest) AuthID(authID string) ApiGetLegacyAuthorizationsIDRequest {
|
||||
r.authID = authID
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsIDRequest) GetAuthID() string {
|
||||
func (r ApiGetLegacyAuthorizationsIDRequest) GetAuthID() string {
|
||||
return r.authID
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiGetAuthorizationsIDRequest {
|
||||
func (r ApiGetLegacyAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiGetLegacyAuthorizationsIDRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiGetAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
func (r ApiGetLegacyAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiGetAuthorizationsIDRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.GetAuthorizationsIDExecute(r)
|
||||
func (r ApiGetLegacyAuthorizationsIDRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.GetLegacyAuthorizationsIDExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* GetAuthorizationsID Retrieve an authorization
|
||||
* GetLegacyAuthorizationsID Retrieve a legacy authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to get.
|
||||
* @return ApiGetAuthorizationsIDRequest
|
||||
* @param authID The ID of the legacy authorization to get.
|
||||
* @return ApiGetLegacyAuthorizationsIDRequest
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) GetAuthorizationsID(ctx _context.Context, authID string) ApiGetAuthorizationsIDRequest {
|
||||
return ApiGetAuthorizationsIDRequest{
|
||||
func (a *LegacyAuthorizationsApiService) GetLegacyAuthorizationsID(ctx _context.Context, authID string) ApiGetLegacyAuthorizationsIDRequest {
|
||||
return ApiGetLegacyAuthorizationsIDRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
authID: authID,
|
||||
@ -518,7 +518,7 @@ func (a *LegacyAuthorizationsApiService) GetAuthorizationsID(ctx _context.Contex
|
||||
* Execute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) GetAuthorizationsIDExecute(r ApiGetAuthorizationsIDRequest) (Authorization, error) {
|
||||
func (a *LegacyAuthorizationsApiService) GetLegacyAuthorizationsIDExecute(r ApiGetLegacyAuthorizationsIDRequest) (Authorization, error) {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodGet
|
||||
localVarPostBody interface{}
|
||||
@ -528,7 +528,7 @@ func (a *LegacyAuthorizationsApiService) GetAuthorizationsIDExecute(r ApiGetAuth
|
||||
localVarReturnValue Authorization
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.GetAuthorizationsID")
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.GetLegacyAuthorizationsID")
|
||||
if err != nil {
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
@ -625,7 +625,7 @@ func (a *LegacyAuthorizationsApiService) GetAuthorizationsIDExecute(r ApiGetAuth
|
||||
return localVarReturnValue, nil
|
||||
}
|
||||
|
||||
type ApiPatchAuthorizationsIDRequest struct {
|
||||
type ApiPatchLegacyAuthorizationsIDRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService LegacyAuthorizationsApi
|
||||
authID string
|
||||
@ -633,42 +633,42 @@ type ApiPatchAuthorizationsIDRequest struct {
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiPatchAuthorizationsIDRequest) AuthID(authID string) ApiPatchAuthorizationsIDRequest {
|
||||
func (r ApiPatchLegacyAuthorizationsIDRequest) AuthID(authID string) ApiPatchLegacyAuthorizationsIDRequest {
|
||||
r.authID = authID
|
||||
return r
|
||||
}
|
||||
func (r ApiPatchAuthorizationsIDRequest) GetAuthID() string {
|
||||
func (r ApiPatchLegacyAuthorizationsIDRequest) GetAuthID() string {
|
||||
return r.authID
|
||||
}
|
||||
|
||||
func (r ApiPatchAuthorizationsIDRequest) AuthorizationUpdateRequest(authorizationUpdateRequest AuthorizationUpdateRequest) ApiPatchAuthorizationsIDRequest {
|
||||
func (r ApiPatchLegacyAuthorizationsIDRequest) AuthorizationUpdateRequest(authorizationUpdateRequest AuthorizationUpdateRequest) ApiPatchLegacyAuthorizationsIDRequest {
|
||||
r.authorizationUpdateRequest = &authorizationUpdateRequest
|
||||
return r
|
||||
}
|
||||
func (r ApiPatchAuthorizationsIDRequest) GetAuthorizationUpdateRequest() *AuthorizationUpdateRequest {
|
||||
func (r ApiPatchLegacyAuthorizationsIDRequest) GetAuthorizationUpdateRequest() *AuthorizationUpdateRequest {
|
||||
return r.authorizationUpdateRequest
|
||||
}
|
||||
|
||||
func (r ApiPatchAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiPatchAuthorizationsIDRequest {
|
||||
func (r ApiPatchLegacyAuthorizationsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiPatchLegacyAuthorizationsIDRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiPatchAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
func (r ApiPatchLegacyAuthorizationsIDRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiPatchAuthorizationsIDRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.PatchAuthorizationsIDExecute(r)
|
||||
func (r ApiPatchLegacyAuthorizationsIDRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.PatchLegacyAuthorizationsIDExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* PatchAuthorizationsID Update an authorization to be active or inactive
|
||||
* PatchLegacyAuthorizationsID Update a legacy authorization to be active or inactive
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to update.
|
||||
* @return ApiPatchAuthorizationsIDRequest
|
||||
* @param authID The ID of the legacy authorization to update.
|
||||
* @return ApiPatchLegacyAuthorizationsIDRequest
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) PatchAuthorizationsID(ctx _context.Context, authID string) ApiPatchAuthorizationsIDRequest {
|
||||
return ApiPatchAuthorizationsIDRequest{
|
||||
func (a *LegacyAuthorizationsApiService) PatchLegacyAuthorizationsID(ctx _context.Context, authID string) ApiPatchLegacyAuthorizationsIDRequest {
|
||||
return ApiPatchLegacyAuthorizationsIDRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
authID: authID,
|
||||
@ -679,7 +679,7 @@ func (a *LegacyAuthorizationsApiService) PatchAuthorizationsID(ctx _context.Cont
|
||||
* Execute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) PatchAuthorizationsIDExecute(r ApiPatchAuthorizationsIDRequest) (Authorization, error) {
|
||||
func (a *LegacyAuthorizationsApiService) PatchLegacyAuthorizationsIDExecute(r ApiPatchLegacyAuthorizationsIDRequest) (Authorization, error) {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodPatch
|
||||
localVarPostBody interface{}
|
||||
@ -689,7 +689,7 @@ func (a *LegacyAuthorizationsApiService) PatchAuthorizationsIDExecute(r ApiPatch
|
||||
localVarReturnValue Authorization
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.PatchAuthorizationsID")
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.PatchLegacyAuthorizationsID")
|
||||
if err != nil {
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
@ -791,40 +791,40 @@ func (a *LegacyAuthorizationsApiService) PatchAuthorizationsIDExecute(r ApiPatch
|
||||
return localVarReturnValue, nil
|
||||
}
|
||||
|
||||
type ApiPostAuthorizationsRequest struct {
|
||||
type ApiPostLegacyAuthorizationsRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService LegacyAuthorizationsApi
|
||||
legacyAuthorizationPostRequest *LegacyAuthorizationPostRequest
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsRequest) LegacyAuthorizationPostRequest(legacyAuthorizationPostRequest LegacyAuthorizationPostRequest) ApiPostAuthorizationsRequest {
|
||||
func (r ApiPostLegacyAuthorizationsRequest) LegacyAuthorizationPostRequest(legacyAuthorizationPostRequest LegacyAuthorizationPostRequest) ApiPostLegacyAuthorizationsRequest {
|
||||
r.legacyAuthorizationPostRequest = &legacyAuthorizationPostRequest
|
||||
return r
|
||||
}
|
||||
func (r ApiPostAuthorizationsRequest) GetLegacyAuthorizationPostRequest() *LegacyAuthorizationPostRequest {
|
||||
func (r ApiPostLegacyAuthorizationsRequest) GetLegacyAuthorizationPostRequest() *LegacyAuthorizationPostRequest {
|
||||
return r.legacyAuthorizationPostRequest
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsRequest) ZapTraceSpan(zapTraceSpan string) ApiPostAuthorizationsRequest {
|
||||
func (r ApiPostLegacyAuthorizationsRequest) ZapTraceSpan(zapTraceSpan string) ApiPostLegacyAuthorizationsRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiPostAuthorizationsRequest) GetZapTraceSpan() *string {
|
||||
func (r ApiPostLegacyAuthorizationsRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.PostAuthorizationsExecute(r)
|
||||
func (r ApiPostLegacyAuthorizationsRequest) Execute() (Authorization, error) {
|
||||
return r.ApiService.PostLegacyAuthorizationsExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* PostAuthorizations Create an authorization
|
||||
* PostLegacyAuthorizations Create a legacy authorization
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiPostAuthorizationsRequest
|
||||
* @return ApiPostLegacyAuthorizationsRequest
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) PostAuthorizations(ctx _context.Context) ApiPostAuthorizationsRequest {
|
||||
return ApiPostAuthorizationsRequest{
|
||||
func (a *LegacyAuthorizationsApiService) PostLegacyAuthorizations(ctx _context.Context) ApiPostLegacyAuthorizationsRequest {
|
||||
return ApiPostLegacyAuthorizationsRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
@ -834,7 +834,7 @@ func (a *LegacyAuthorizationsApiService) PostAuthorizations(ctx _context.Context
|
||||
* Execute executes the request
|
||||
* @return Authorization
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) PostAuthorizationsExecute(r ApiPostAuthorizationsRequest) (Authorization, error) {
|
||||
func (a *LegacyAuthorizationsApiService) PostLegacyAuthorizationsExecute(r ApiPostLegacyAuthorizationsRequest) (Authorization, error) {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodPost
|
||||
localVarPostBody interface{}
|
||||
@ -844,7 +844,7 @@ func (a *LegacyAuthorizationsApiService) PostAuthorizationsExecute(r ApiPostAuth
|
||||
localVarReturnValue Authorization
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.PostAuthorizations")
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.PostLegacyAuthorizations")
|
||||
if err != nil {
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
@ -956,7 +956,7 @@ func (a *LegacyAuthorizationsApiService) PostAuthorizationsExecute(r ApiPostAuth
|
||||
return localVarReturnValue, nil
|
||||
}
|
||||
|
||||
type ApiPostAuthorizationsIDPasswordRequest struct {
|
||||
type ApiPostLegacyAuthorizationsIDPasswordRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService LegacyAuthorizationsApi
|
||||
authID string
|
||||
@ -964,42 +964,42 @@ type ApiPostAuthorizationsIDPasswordRequest struct {
|
||||
zapTraceSpan *string
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsIDPasswordRequest) AuthID(authID string) ApiPostAuthorizationsIDPasswordRequest {
|
||||
func (r ApiPostLegacyAuthorizationsIDPasswordRequest) AuthID(authID string) ApiPostLegacyAuthorizationsIDPasswordRequest {
|
||||
r.authID = authID
|
||||
return r
|
||||
}
|
||||
func (r ApiPostAuthorizationsIDPasswordRequest) GetAuthID() string {
|
||||
func (r ApiPostLegacyAuthorizationsIDPasswordRequest) GetAuthID() string {
|
||||
return r.authID
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsIDPasswordRequest) PasswordResetBody(passwordResetBody PasswordResetBody) ApiPostAuthorizationsIDPasswordRequest {
|
||||
func (r ApiPostLegacyAuthorizationsIDPasswordRequest) PasswordResetBody(passwordResetBody PasswordResetBody) ApiPostLegacyAuthorizationsIDPasswordRequest {
|
||||
r.passwordResetBody = &passwordResetBody
|
||||
return r
|
||||
}
|
||||
func (r ApiPostAuthorizationsIDPasswordRequest) GetPasswordResetBody() *PasswordResetBody {
|
||||
func (r ApiPostLegacyAuthorizationsIDPasswordRequest) GetPasswordResetBody() *PasswordResetBody {
|
||||
return r.passwordResetBody
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsIDPasswordRequest) ZapTraceSpan(zapTraceSpan string) ApiPostAuthorizationsIDPasswordRequest {
|
||||
func (r ApiPostLegacyAuthorizationsIDPasswordRequest) ZapTraceSpan(zapTraceSpan string) ApiPostLegacyAuthorizationsIDPasswordRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiPostAuthorizationsIDPasswordRequest) GetZapTraceSpan() *string {
|
||||
func (r ApiPostLegacyAuthorizationsIDPasswordRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiPostAuthorizationsIDPasswordRequest) Execute() error {
|
||||
return r.ApiService.PostAuthorizationsIDPasswordExecute(r)
|
||||
func (r ApiPostLegacyAuthorizationsIDPasswordRequest) Execute() error {
|
||||
return r.ApiService.PostLegacyAuthorizationsIDPasswordExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* PostAuthorizationsIDPassword Set an authorization password
|
||||
* PostLegacyAuthorizationsIDPassword Set a legacy authorization password
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @param authID The ID of the authorization to update.
|
||||
* @return ApiPostAuthorizationsIDPasswordRequest
|
||||
* @param authID The ID of the legacy authorization to update.
|
||||
* @return ApiPostLegacyAuthorizationsIDPasswordRequest
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) PostAuthorizationsIDPassword(ctx _context.Context, authID string) ApiPostAuthorizationsIDPasswordRequest {
|
||||
return ApiPostAuthorizationsIDPasswordRequest{
|
||||
func (a *LegacyAuthorizationsApiService) PostLegacyAuthorizationsIDPassword(ctx _context.Context, authID string) ApiPostLegacyAuthorizationsIDPasswordRequest {
|
||||
return ApiPostLegacyAuthorizationsIDPasswordRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
authID: authID,
|
||||
@ -1009,7 +1009,7 @@ func (a *LegacyAuthorizationsApiService) PostAuthorizationsIDPassword(ctx _conte
|
||||
/*
|
||||
* Execute executes the request
|
||||
*/
|
||||
func (a *LegacyAuthorizationsApiService) PostAuthorizationsIDPasswordExecute(r ApiPostAuthorizationsIDPasswordRequest) error {
|
||||
func (a *LegacyAuthorizationsApiService) PostLegacyAuthorizationsIDPasswordExecute(r ApiPostLegacyAuthorizationsIDPasswordRequest) error {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodPost
|
||||
localVarPostBody interface{}
|
||||
@ -1018,7 +1018,7 @@ func (a *LegacyAuthorizationsApiService) PostAuthorizationsIDPasswordExecute(r A
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.PostAuthorizationsIDPassword")
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LegacyAuthorizationsApiService.PostLegacyAuthorizationsIDPassword")
|
||||
if err != nil {
|
||||
return GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ type APIClient struct {
|
||||
|
||||
// API Services
|
||||
|
||||
AuthorizationsApi AuthorizationsApi
|
||||
|
||||
BackupApi BackupApi
|
||||
|
||||
BucketSchemasApi BucketSchemasApi
|
||||
@ -102,6 +104,7 @@ func NewAPIClient(cfg *Configuration) *APIClient {
|
||||
c.common.client = c
|
||||
|
||||
// API Services
|
||||
c.AuthorizationsApi = (*AuthorizationsApiService)(&c.common)
|
||||
c.BackupApi = (*BackupApiService)(&c.common)
|
||||
c.BucketSchemasApi = (*BucketSchemasApiService)(&c.common)
|
||||
c.BucketsApi = (*BucketsApiService)(&c.common)
|
||||
|
@ -113,37 +113,37 @@ func NewConfiguration() *Configuration {
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"LegacyAuthorizationsApiService.DeleteAuthorizationsID": {
|
||||
"LegacyAuthorizationsApiService.DeleteLegacyAuthorizationsID": {
|
||||
{
|
||||
URL: "/private",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"LegacyAuthorizationsApiService.GetAuthorizations": {
|
||||
"LegacyAuthorizationsApiService.GetLegacyAuthorizations": {
|
||||
{
|
||||
URL: "/private",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"LegacyAuthorizationsApiService.GetAuthorizationsID": {
|
||||
"LegacyAuthorizationsApiService.GetLegacyAuthorizationsID": {
|
||||
{
|
||||
URL: "/private",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"LegacyAuthorizationsApiService.PatchAuthorizationsID": {
|
||||
"LegacyAuthorizationsApiService.PatchLegacyAuthorizationsID": {
|
||||
{
|
||||
URL: "/private",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"LegacyAuthorizationsApiService.PostAuthorizations": {
|
||||
"LegacyAuthorizationsApiService.PostLegacyAuthorizations": {
|
||||
{
|
||||
URL: "/private",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"LegacyAuthorizationsApiService.PostAuthorizationsIDPassword": {
|
||||
"LegacyAuthorizationsApiService.PostLegacyAuthorizationsIDPassword": {
|
||||
{
|
||||
URL: "/private",
|
||||
Description: "No description provided",
|
||||
|
@ -95,6 +95,10 @@ paths:
|
||||
servers:
|
||||
- url: "/private"
|
||||
$ref: "./openapi/src/oss/paths/legacy_authorizations_authID_password.yml"
|
||||
/authorizations:
|
||||
$ref: "./openapi/src/common/paths/authorizations.yml"
|
||||
/authorizations/{authID}:
|
||||
$ref: "./openapi/src/common/paths/authorizations_authID.yml"
|
||||
components:
|
||||
parameters:
|
||||
TraceSpan:
|
||||
@ -385,3 +389,5 @@ components:
|
||||
$ref: "./openapi/src/common/schemas/Authorizations.yml"
|
||||
LegacyAuthorizationPostRequest:
|
||||
$ref: "./openapi/src/oss/schemas/LegacyAuthorizationPostRequest.yml"
|
||||
AuthorizationPostRequest:
|
||||
$ref: "./openapi/src/common/schemas/AuthorizationPostRequest.yml"
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 6b464c86dde496960da2f68b45a3e21a7a6f0b58
|
||||
Subproject commit 99b90ac05ae3c57ac06e50fca5dca8608c9f6346
|
252
api/model_authorization_post_request.gen.go
Normal file
252
api/model_authorization_post_request.gen.go
Normal file
@ -0,0 +1,252 @@
|
||||
/*
|
||||
* 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 (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// AuthorizationPostRequest struct for AuthorizationPostRequest
|
||||
type AuthorizationPostRequest struct {
|
||||
// If inactive the token is inactive and requests using the token will be rejected.
|
||||
Status *string `json:"status,omitempty" yaml:"status,omitempty"`
|
||||
// A description of the token.
|
||||
Description *string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
// ID of org that authorization is scoped to.
|
||||
OrgID string `json:"orgID" yaml:"orgID"`
|
||||
// ID of user that authorization is scoped to.
|
||||
UserID *string `json:"userID,omitempty" yaml:"userID,omitempty"`
|
||||
// List of permissions for an auth. An auth must have at least one Permission.
|
||||
Permissions []Permission `json:"permissions" yaml:"permissions"`
|
||||
}
|
||||
|
||||
// NewAuthorizationPostRequest instantiates a new AuthorizationPostRequest object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewAuthorizationPostRequest(orgID string, permissions []Permission) *AuthorizationPostRequest {
|
||||
this := AuthorizationPostRequest{}
|
||||
var status string = "active"
|
||||
this.Status = &status
|
||||
this.OrgID = orgID
|
||||
this.Permissions = permissions
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewAuthorizationPostRequestWithDefaults instantiates a new AuthorizationPostRequest object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewAuthorizationPostRequestWithDefaults() *AuthorizationPostRequest {
|
||||
this := AuthorizationPostRequest{}
|
||||
var status string = "active"
|
||||
this.Status = &status
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetStatus returns the Status field value if set, zero value otherwise.
|
||||
func (o *AuthorizationPostRequest) GetStatus() string {
|
||||
if o == nil || o.Status == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Status
|
||||
}
|
||||
|
||||
// GetStatusOk returns a tuple with the Status field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *AuthorizationPostRequest) GetStatusOk() (*string, bool) {
|
||||
if o == nil || o.Status == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.Status, true
|
||||
}
|
||||
|
||||
// HasStatus returns a boolean if a field has been set.
|
||||
func (o *AuthorizationPostRequest) HasStatus() bool {
|
||||
if o != nil && o.Status != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetStatus gets a reference to the given string and assigns it to the Status field.
|
||||
func (o *AuthorizationPostRequest) SetStatus(v string) {
|
||||
o.Status = &v
|
||||
}
|
||||
|
||||
// GetDescription returns the Description field value if set, zero value otherwise.
|
||||
func (o *AuthorizationPostRequest) GetDescription() string {
|
||||
if o == nil || o.Description == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Description
|
||||
}
|
||||
|
||||
// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *AuthorizationPostRequest) GetDescriptionOk() (*string, bool) {
|
||||
if o == nil || o.Description == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.Description, true
|
||||
}
|
||||
|
||||
// HasDescription returns a boolean if a field has been set.
|
||||
func (o *AuthorizationPostRequest) HasDescription() bool {
|
||||
if o != nil && o.Description != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetDescription gets a reference to the given string and assigns it to the Description field.
|
||||
func (o *AuthorizationPostRequest) SetDescription(v string) {
|
||||
o.Description = &v
|
||||
}
|
||||
|
||||
// GetOrgID returns the OrgID field value
|
||||
func (o *AuthorizationPostRequest) GetOrgID() string {
|
||||
if o == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
|
||||
return o.OrgID
|
||||
}
|
||||
|
||||
// GetOrgIDOk returns a tuple with the OrgID field value
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *AuthorizationPostRequest) GetOrgIDOk() (*string, bool) {
|
||||
if o == nil {
|
||||
return nil, false
|
||||
}
|
||||
return &o.OrgID, true
|
||||
}
|
||||
|
||||
// SetOrgID sets field value
|
||||
func (o *AuthorizationPostRequest) SetOrgID(v string) {
|
||||
o.OrgID = v
|
||||
}
|
||||
|
||||
// GetUserID returns the UserID field value if set, zero value otherwise.
|
||||
func (o *AuthorizationPostRequest) GetUserID() string {
|
||||
if o == nil || o.UserID == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.UserID
|
||||
}
|
||||
|
||||
// GetUserIDOk returns a tuple with the UserID field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *AuthorizationPostRequest) GetUserIDOk() (*string, bool) {
|
||||
if o == nil || o.UserID == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.UserID, true
|
||||
}
|
||||
|
||||
// HasUserID returns a boolean if a field has been set.
|
||||
func (o *AuthorizationPostRequest) HasUserID() bool {
|
||||
if o != nil && o.UserID != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetUserID gets a reference to the given string and assigns it to the UserID field.
|
||||
func (o *AuthorizationPostRequest) SetUserID(v string) {
|
||||
o.UserID = &v
|
||||
}
|
||||
|
||||
// GetPermissions returns the Permissions field value
|
||||
func (o *AuthorizationPostRequest) GetPermissions() []Permission {
|
||||
if o == nil {
|
||||
var ret []Permission
|
||||
return ret
|
||||
}
|
||||
|
||||
return o.Permissions
|
||||
}
|
||||
|
||||
// GetPermissionsOk returns a tuple with the Permissions field value
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *AuthorizationPostRequest) GetPermissionsOk() (*[]Permission, bool) {
|
||||
if o == nil {
|
||||
return nil, false
|
||||
}
|
||||
return &o.Permissions, true
|
||||
}
|
||||
|
||||
// SetPermissions sets field value
|
||||
func (o *AuthorizationPostRequest) SetPermissions(v []Permission) {
|
||||
o.Permissions = v
|
||||
}
|
||||
|
||||
func (o AuthorizationPostRequest) MarshalJSON() ([]byte, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if o.Status != nil {
|
||||
toSerialize["status"] = o.Status
|
||||
}
|
||||
if o.Description != nil {
|
||||
toSerialize["description"] = o.Description
|
||||
}
|
||||
if true {
|
||||
toSerialize["orgID"] = o.OrgID
|
||||
}
|
||||
if o.UserID != nil {
|
||||
toSerialize["userID"] = o.UserID
|
||||
}
|
||||
if true {
|
||||
toSerialize["permissions"] = o.Permissions
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
type NullableAuthorizationPostRequest struct {
|
||||
value *AuthorizationPostRequest
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableAuthorizationPostRequest) Get() *AuthorizationPostRequest {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableAuthorizationPostRequest) Set(val *AuthorizationPostRequest) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableAuthorizationPostRequest) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableAuthorizationPostRequest) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableAuthorizationPostRequest(val *AuthorizationPostRequest) *NullableAuthorizationPostRequest {
|
||||
return &NullableAuthorizationPostRequest{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableAuthorizationPostRequest) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableAuthorizationPostRequest) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
188
api/model_authorization_post_request_all_of.gen.go
Normal file
188
api/model_authorization_post_request_all_of.gen.go
Normal file
@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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 (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// AuthorizationPostRequestAllOf struct for AuthorizationPostRequestAllOf
|
||||
type AuthorizationPostRequestAllOf struct {
|
||||
// ID of org that authorization is scoped to.
|
||||
OrgID *string `json:"orgID,omitempty" yaml:"orgID,omitempty"`
|
||||
// ID of user that authorization is scoped to.
|
||||
UserID *string `json:"userID,omitempty" yaml:"userID,omitempty"`
|
||||
// List of permissions for an auth. An auth must have at least one Permission.
|
||||
Permissions *[]Permission `json:"permissions,omitempty" yaml:"permissions,omitempty"`
|
||||
}
|
||||
|
||||
// NewAuthorizationPostRequestAllOf instantiates a new AuthorizationPostRequestAllOf object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewAuthorizationPostRequestAllOf() *AuthorizationPostRequestAllOf {
|
||||
this := AuthorizationPostRequestAllOf{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewAuthorizationPostRequestAllOfWithDefaults instantiates a new AuthorizationPostRequestAllOf object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewAuthorizationPostRequestAllOfWithDefaults() *AuthorizationPostRequestAllOf {
|
||||
this := AuthorizationPostRequestAllOf{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetOrgID returns the OrgID field value if set, zero value otherwise.
|
||||
func (o *AuthorizationPostRequestAllOf) GetOrgID() string {
|
||||
if o == nil || o.OrgID == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.OrgID
|
||||
}
|
||||
|
||||
// GetOrgIDOk returns a tuple with the OrgID field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *AuthorizationPostRequestAllOf) GetOrgIDOk() (*string, bool) {
|
||||
if o == nil || o.OrgID == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.OrgID, true
|
||||
}
|
||||
|
||||
// HasOrgID returns a boolean if a field has been set.
|
||||
func (o *AuthorizationPostRequestAllOf) HasOrgID() bool {
|
||||
if o != nil && o.OrgID != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetOrgID gets a reference to the given string and assigns it to the OrgID field.
|
||||
func (o *AuthorizationPostRequestAllOf) SetOrgID(v string) {
|
||||
o.OrgID = &v
|
||||
}
|
||||
|
||||
// GetUserID returns the UserID field value if set, zero value otherwise.
|
||||
func (o *AuthorizationPostRequestAllOf) GetUserID() string {
|
||||
if o == nil || o.UserID == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.UserID
|
||||
}
|
||||
|
||||
// GetUserIDOk returns a tuple with the UserID field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *AuthorizationPostRequestAllOf) GetUserIDOk() (*string, bool) {
|
||||
if o == nil || o.UserID == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.UserID, true
|
||||
}
|
||||
|
||||
// HasUserID returns a boolean if a field has been set.
|
||||
func (o *AuthorizationPostRequestAllOf) HasUserID() bool {
|
||||
if o != nil && o.UserID != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetUserID gets a reference to the given string and assigns it to the UserID field.
|
||||
func (o *AuthorizationPostRequestAllOf) SetUserID(v string) {
|
||||
o.UserID = &v
|
||||
}
|
||||
|
||||
// GetPermissions returns the Permissions field value if set, zero value otherwise.
|
||||
func (o *AuthorizationPostRequestAllOf) GetPermissions() []Permission {
|
||||
if o == nil || o.Permissions == nil {
|
||||
var ret []Permission
|
||||
return ret
|
||||
}
|
||||
return *o.Permissions
|
||||
}
|
||||
|
||||
// GetPermissionsOk returns a tuple with the Permissions field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *AuthorizationPostRequestAllOf) GetPermissionsOk() (*[]Permission, bool) {
|
||||
if o == nil || o.Permissions == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.Permissions, true
|
||||
}
|
||||
|
||||
// HasPermissions returns a boolean if a field has been set.
|
||||
func (o *AuthorizationPostRequestAllOf) HasPermissions() bool {
|
||||
if o != nil && o.Permissions != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetPermissions gets a reference to the given []Permission and assigns it to the Permissions field.
|
||||
func (o *AuthorizationPostRequestAllOf) SetPermissions(v []Permission) {
|
||||
o.Permissions = &v
|
||||
}
|
||||
|
||||
func (o AuthorizationPostRequestAllOf) MarshalJSON() ([]byte, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if o.OrgID != nil {
|
||||
toSerialize["orgID"] = o.OrgID
|
||||
}
|
||||
if o.UserID != nil {
|
||||
toSerialize["userID"] = o.UserID
|
||||
}
|
||||
if o.Permissions != nil {
|
||||
toSerialize["permissions"] = o.Permissions
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
type NullableAuthorizationPostRequestAllOf struct {
|
||||
value *AuthorizationPostRequestAllOf
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableAuthorizationPostRequestAllOf) Get() *AuthorizationPostRequestAllOf {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableAuthorizationPostRequestAllOf) Set(val *AuthorizationPostRequestAllOf) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableAuthorizationPostRequestAllOf) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableAuthorizationPostRequestAllOf) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableAuthorizationPostRequestAllOf(val *AuthorizationPostRequestAllOf) *NullableAuthorizationPostRequestAllOf {
|
||||
return &NullableAuthorizationPostRequestAllOf{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableAuthorizationPostRequestAllOf) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableAuthorizationPostRequestAllOf) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
15
api/permission_string.go
Normal file
15
api/permission_string.go
Normal file
@ -0,0 +1,15 @@
|
||||
package api
|
||||
|
||||
func (o Permission) String() string {
|
||||
ret := o.GetAction() + ":"
|
||||
r := o.GetResource()
|
||||
|
||||
if r.GetOrgID() != "" {
|
||||
ret += "orgs/" + r.GetOrgID()
|
||||
}
|
||||
ret += "/" + r.GetType()
|
||||
if r.GetId() != "" {
|
||||
ret += "/" + r.GetId()
|
||||
}
|
||||
return ret
|
||||
}
|
442
clients/auth/auth.go
Normal file
442
clients/auth/auth.go
Normal file
@ -0,0 +1,442 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/influxdata/influx-cli/v2/api"
|
||||
"github.com/influxdata/influx-cli/v2/clients"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/influxid"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
clients.CLI
|
||||
api.AuthorizationsApi
|
||||
api.UsersApi
|
||||
api.OrganizationsApi
|
||||
}
|
||||
|
||||
const (
|
||||
ReadAction = "read"
|
||||
WriteAction = "write"
|
||||
)
|
||||
|
||||
type token struct {
|
||||
ID string `json:"id"`
|
||||
Description string `json:"description"`
|
||||
Token string `json:"token"`
|
||||
Status string `json:"status"`
|
||||
UserName string `json:"userName"`
|
||||
UserID string `json:"userID"`
|
||||
Permissions []string `json:"permissions"`
|
||||
}
|
||||
|
||||
type printParams struct {
|
||||
deleted bool
|
||||
token *token
|
||||
tokens []token
|
||||
}
|
||||
|
||||
type CreateParams struct {
|
||||
clients.OrgParams
|
||||
User string
|
||||
Description string
|
||||
|
||||
WriteUserPermission bool
|
||||
ReadUserPermission bool
|
||||
|
||||
WriteBucketsPermission bool
|
||||
ReadBucketsPermission bool
|
||||
|
||||
WriteBucketIds []string
|
||||
ReadBucketIds []string
|
||||
|
||||
WriteTasksPermission bool
|
||||
ReadTasksPermission bool
|
||||
|
||||
WriteTelegrafsPermission bool
|
||||
ReadTelegrafsPermission bool
|
||||
|
||||
WriteOrganizationsPermission bool
|
||||
ReadOrganizationsPermission bool
|
||||
|
||||
WriteDashboardsPermission bool
|
||||
ReadDashboardsPermission bool
|
||||
|
||||
WriteCheckPermission bool
|
||||
ReadCheckPermission bool
|
||||
|
||||
WriteNotificationRulePermission bool
|
||||
ReadNotificationRulePermission bool
|
||||
|
||||
WriteNotificationEndpointPermission bool
|
||||
ReadNotificationEndpointPermission bool
|
||||
|
||||
WriteDBRPPermission bool
|
||||
ReadDBRPPermission bool
|
||||
}
|
||||
|
||||
func (c Client) Create(ctx context.Context, params *CreateParams) error {
|
||||
|
||||
orgID, err := c.getOrgID(ctx, params.OrgParams)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bucketPerms := []struct {
|
||||
action string
|
||||
perms []string
|
||||
}{
|
||||
{action: ReadAction, perms: params.ReadBucketIds},
|
||||
{action: WriteAction, perms: params.WriteBucketIds},
|
||||
}
|
||||
|
||||
var permissions []api.Permission
|
||||
for _, bp := range bucketPerms {
|
||||
for _, p := range bp.perms {
|
||||
// verify the input ID
|
||||
if _, err := influxid.IDFromString(p); err != nil {
|
||||
return fmt.Errorf("invalid bucket ID '%s': %w (did you pass a bucket name instead of an ID?)", p, err)
|
||||
}
|
||||
|
||||
newPerm := api.Permission{
|
||||
Action: bp.action,
|
||||
Resource: makePermResource("buckets", p, orgID),
|
||||
}
|
||||
permissions = append(permissions, newPerm)
|
||||
}
|
||||
}
|
||||
|
||||
providedPerm := []struct {
|
||||
readPerm, writePerm bool
|
||||
resourceType string
|
||||
}{
|
||||
{
|
||||
readPerm: params.ReadBucketsPermission,
|
||||
writePerm: params.WriteBucketsPermission,
|
||||
resourceType: "buckets",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadCheckPermission,
|
||||
writePerm: params.WriteCheckPermission,
|
||||
resourceType: "checks",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadDashboardsPermission,
|
||||
writePerm: params.WriteDashboardsPermission,
|
||||
resourceType: "dashboards",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadNotificationEndpointPermission,
|
||||
writePerm: params.WriteNotificationEndpointPermission,
|
||||
resourceType: "notificationEndpoints",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadNotificationRulePermission,
|
||||
writePerm: params.WriteNotificationRulePermission,
|
||||
resourceType: "notificationRules",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadOrganizationsPermission,
|
||||
writePerm: params.WriteOrganizationsPermission,
|
||||
resourceType: "orgs",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadTasksPermission,
|
||||
writePerm: params.WriteTasksPermission,
|
||||
resourceType: "tasks",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadTelegrafsPermission,
|
||||
writePerm: params.WriteTelegrafsPermission,
|
||||
resourceType: "telegrafs",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadUserPermission,
|
||||
writePerm: params.WriteUserPermission,
|
||||
resourceType: "users",
|
||||
},
|
||||
{
|
||||
readPerm: params.ReadDBRPPermission,
|
||||
writePerm: params.WriteDBRPPermission,
|
||||
resourceType: "dbrp",
|
||||
},
|
||||
}
|
||||
|
||||
for _, provided := range providedPerm {
|
||||
var actions []string
|
||||
if provided.readPerm {
|
||||
actions = append(actions, ReadAction)
|
||||
}
|
||||
if provided.writePerm {
|
||||
actions = append(actions, WriteAction)
|
||||
}
|
||||
|
||||
for _, action := range actions {
|
||||
p := api.Permission{
|
||||
Action: action,
|
||||
Resource: makePermResource(provided.resourceType, "", orgID),
|
||||
}
|
||||
permissions = append(permissions, p)
|
||||
}
|
||||
}
|
||||
|
||||
// Get the user ID because the command only takes a username, not ID
|
||||
users, err := c.UsersApi.GetUsers(ctx).Name(params.User).Execute()
|
||||
if err != nil || len(users.GetUsers()) == 0 {
|
||||
return fmt.Errorf("could not find user with name %q: %w", params.User, err)
|
||||
}
|
||||
userID := users.GetUsers()[0].GetId()
|
||||
|
||||
authReq := api.AuthorizationPostRequest{
|
||||
OrgID: orgID,
|
||||
UserID: &userID,
|
||||
Permissions: permissions,
|
||||
}
|
||||
if params.Description != "" {
|
||||
authReq.SetDescription(params.Description)
|
||||
}
|
||||
|
||||
auth, err := c.PostAuthorizations(ctx).AuthorizationPostRequest(authReq).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not write auth with provided arguments: %w", err)
|
||||
}
|
||||
|
||||
ps := make([]string, 0, len(auth.GetPermissions()))
|
||||
for _, p := range auth.GetPermissions() {
|
||||
ps = append(ps, p.String())
|
||||
}
|
||||
|
||||
return c.printAuth(printParams{
|
||||
token: &token{
|
||||
ID: auth.GetId(),
|
||||
Description: auth.GetDescription(),
|
||||
Token: auth.GetToken(),
|
||||
Status: auth.GetStatus(),
|
||||
UserName: auth.GetUser(),
|
||||
UserID: auth.GetUserID(),
|
||||
Permissions: ps,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (c Client) Remove(ctx context.Context, authID string) error {
|
||||
// check if auth exists first for better error logging, and to
|
||||
// acquire the auth that was deleted since the delete
|
||||
// request does not return the Authorization object.
|
||||
a, err := c.GetAuthorizationsID(ctx, authID).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not find auth with ID %q: %w", authID, err)
|
||||
}
|
||||
|
||||
if err := c.DeleteAuthorizationsID(ctx, authID).Execute(); err != nil {
|
||||
return fmt.Errorf("could not remove auth with ID %q: %w", authID, err)
|
||||
}
|
||||
|
||||
ps := make([]string, 0, len(a.Permissions))
|
||||
for _, p := range a.Permissions {
|
||||
ps = append(ps, p.String())
|
||||
}
|
||||
|
||||
return c.printAuth(printParams{
|
||||
deleted: true,
|
||||
token: &token{
|
||||
ID: a.GetId(),
|
||||
Description: a.GetDescription(),
|
||||
Token: a.GetToken(),
|
||||
Status: a.GetStatus(),
|
||||
UserName: a.GetUser(),
|
||||
UserID: a.GetUserID(),
|
||||
Permissions: ps,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type ListParams struct {
|
||||
clients.OrgParams
|
||||
Id string
|
||||
User string
|
||||
UserID string
|
||||
}
|
||||
|
||||
func (c Client) List(ctx context.Context, params *ListParams) error {
|
||||
|
||||
// If ID parameter is set, search by that over other filters
|
||||
if params.Id != "" {
|
||||
return c.findAuthorization(ctx, params.Id)
|
||||
}
|
||||
|
||||
req := c.GetAuthorizations(ctx)
|
||||
if params.User != "" {
|
||||
req.User(params.User)
|
||||
}
|
||||
if params.UserID != "" {
|
||||
req.UserID(params.UserID)
|
||||
}
|
||||
if params.OrgName != "" {
|
||||
req.Org(params.OrgName)
|
||||
}
|
||||
if params.OrgID.Valid() {
|
||||
req.OrgID(params.OrgID.String())
|
||||
}
|
||||
|
||||
auths, err := req.Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not find authorization with given parameters: %w", err)
|
||||
}
|
||||
|
||||
var tokens []token
|
||||
for _, a := range auths.GetAuthorizations() {
|
||||
var ps []string
|
||||
for _, p := range a.GetPermissions() {
|
||||
ps = append(ps, p.String())
|
||||
}
|
||||
|
||||
tokens = append(tokens, token{
|
||||
ID: a.GetId(),
|
||||
Description: a.GetDescription(),
|
||||
Token: a.GetToken(),
|
||||
Status: a.GetStatus(),
|
||||
UserName: a.GetUser(),
|
||||
UserID: a.GetUserID(),
|
||||
Permissions: ps,
|
||||
})
|
||||
}
|
||||
|
||||
return c.printAuth(printParams{tokens: tokens})
|
||||
}
|
||||
|
||||
func (c Client) findAuthorization(ctx context.Context, authID string) error {
|
||||
a, err := c.GetAuthorizationsID(ctx, authID).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not find authorization with ID %q: %w", authID, err)
|
||||
}
|
||||
|
||||
ps := make([]string, 0, len(a.GetPermissions()))
|
||||
for _, p := range a.GetPermissions() {
|
||||
ps = append(ps, p.String())
|
||||
}
|
||||
|
||||
return c.printAuth(printParams{
|
||||
token: &token{
|
||||
ID: a.GetId(),
|
||||
Description: a.GetDescription(),
|
||||
Token: a.GetToken(),
|
||||
Status: a.GetStatus(),
|
||||
UserName: a.GetUser(),
|
||||
UserID: a.GetUserID(),
|
||||
Permissions: ps,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (c Client) SetActive(ctx context.Context, authID string, active bool) error {
|
||||
|
||||
// check if auth exists first for better error logging
|
||||
if _, err := c.GetAuthorizationsID(ctx, authID).Execute(); err != nil {
|
||||
return fmt.Errorf("could not find auth with ID %q: %w", authID, err)
|
||||
}
|
||||
|
||||
var status string
|
||||
if active {
|
||||
status = "active"
|
||||
} else {
|
||||
status = "inactive"
|
||||
}
|
||||
a, err := c.PatchAuthorizationsID(ctx, authID).
|
||||
AuthorizationUpdateRequest(api.AuthorizationUpdateRequest{Status: &status}).
|
||||
Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not update status of auth with ID %q: %w", authID, err)
|
||||
}
|
||||
|
||||
ps := make([]string, 0, len(a.GetPermissions()))
|
||||
for _, p := range a.GetPermissions() {
|
||||
ps = append(ps, p.String())
|
||||
}
|
||||
|
||||
return c.printAuth(printParams{
|
||||
token: &token{
|
||||
ID: a.GetId(),
|
||||
Description: a.GetDescription(),
|
||||
Token: a.GetToken(),
|
||||
Status: a.GetStatus(),
|
||||
UserName: a.GetUser(),
|
||||
UserID: a.GetUserID(),
|
||||
Permissions: ps,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (c Client) printAuth(opts printParams) error {
|
||||
if c.PrintAsJSON {
|
||||
var v interface{}
|
||||
if opts.token != nil {
|
||||
v = opts.token
|
||||
} else {
|
||||
v = opts.tokens
|
||||
}
|
||||
return c.PrintJSON(v)
|
||||
}
|
||||
|
||||
headers := []string{
|
||||
"ID",
|
||||
"Description",
|
||||
"Token",
|
||||
"User Name",
|
||||
"User ID",
|
||||
"Permissions",
|
||||
}
|
||||
if opts.deleted {
|
||||
headers = append(headers, "Deleted")
|
||||
}
|
||||
|
||||
if opts.token != nil {
|
||||
opts.tokens = append(opts.tokens, *opts.token)
|
||||
}
|
||||
|
||||
var rows []map[string]interface{}
|
||||
for _, t := range opts.tokens {
|
||||
row := map[string]interface{}{
|
||||
"ID": t.ID,
|
||||
"Description": t.Description,
|
||||
"Token": t.Token,
|
||||
"User Name": t.UserName,
|
||||
"User ID": t.UserID,
|
||||
"Permissions": t.Permissions,
|
||||
}
|
||||
if opts.deleted {
|
||||
row["Deleted"] = true
|
||||
}
|
||||
rows = append(rows, row)
|
||||
}
|
||||
return c.PrintTable(headers, rows...)
|
||||
}
|
||||
|
||||
func makePermResource(permType string, id string, orgId string) api.PermissionResource {
|
||||
return api.PermissionResource{
|
||||
Type: permType,
|
||||
Id: &id,
|
||||
OrgID: &orgId,
|
||||
}
|
||||
}
|
||||
|
||||
func (c Client) getOrgID(ctx context.Context, params clients.OrgParams) (string, error) {
|
||||
if !params.OrgID.Valid() && params.OrgName == "" && c.ActiveConfig.Org == "" {
|
||||
return "", clients.ErrMustSpecifyOrg
|
||||
}
|
||||
if params.OrgID.Valid() {
|
||||
return params.OrgID.String(), nil
|
||||
}
|
||||
name := params.OrgName
|
||||
if name == "" {
|
||||
name = c.ActiveConfig.Org
|
||||
}
|
||||
org, err := c.GetOrgs(ctx).Org(name).Execute()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to lookup org with name %q: %w", name, err)
|
||||
}
|
||||
if len(org.GetOrgs()) == 0 {
|
||||
return "", fmt.Errorf("no organization with name %q: %w", name, err)
|
||||
}
|
||||
return org.GetOrgs()[0].GetId(), nil
|
||||
}
|
@ -71,7 +71,7 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
|
||||
}
|
||||
|
||||
// verify an existing token with the same username doesn't already exist
|
||||
auths, err := c.LegacyAuthorizationsApi.GetAuthorizations(ctx).Token(params.Username).Execute()
|
||||
auths, err := c.LegacyAuthorizationsApi.GetLegacyAuthorizations(ctx).Token(params.Username).Execute()
|
||||
if apiError, ok := err.(api.ApiError); ok {
|
||||
if apiError.ErrorCode() != api.ERRORCODE_NOT_FOUND {
|
||||
return fmt.Errorf("failed to verify username %q has no auth: %w", params.Username, err)
|
||||
@ -123,17 +123,17 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
|
||||
Token: ¶ms.Username,
|
||||
}
|
||||
|
||||
newAuth, err := c.LegacyAuthorizationsApi.PostAuthorizations(ctx).LegacyAuthorizationPostRequest(authReq).Execute()
|
||||
newAuth, err := c.LegacyAuthorizationsApi.PostLegacyAuthorizations(ctx).LegacyAuthorizationPostRequest(authReq).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create new authorization: %w", err)
|
||||
}
|
||||
|
||||
if password != "" {
|
||||
err := c.LegacyAuthorizationsApi.PostAuthorizationsIDPassword(ctx, newAuth.GetId()).
|
||||
err := c.LegacyAuthorizationsApi.PostLegacyAuthorizationsIDPassword(ctx, newAuth.GetId()).
|
||||
PasswordResetBody(api.PasswordResetBody{Password: password}).
|
||||
Execute()
|
||||
if err != nil {
|
||||
_ = c.LegacyAuthorizationsApi.DeleteAuthorizationsID(ctx, newAuth.GetId()).Execute()
|
||||
_ = c.LegacyAuthorizationsApi.DeleteLegacyAuthorizationsID(ctx, newAuth.GetId()).Execute()
|
||||
return fmt.Errorf("failed to set password for %q: %w", params.Username, err)
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
|
||||
|
||||
ps := make([]string, 0, len(newAuth.Permissions))
|
||||
for _, p := range newAuth.Permissions {
|
||||
ps = append(ps, permString(p))
|
||||
ps = append(ps, p.String())
|
||||
}
|
||||
|
||||
return c.printV1Tokens(&v1PrintOpts{
|
||||
@ -171,11 +171,11 @@ func (c Client) Remove(ctx context.Context, params *RemoveParams) error {
|
||||
return err
|
||||
}
|
||||
|
||||
auth, err := c.LegacyAuthorizationsApi.GetAuthorizationsID(ctx, id).Execute()
|
||||
auth, err := c.LegacyAuthorizationsApi.GetLegacyAuthorizationsID(ctx, id).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not find Authorization from ID %q: %w", id, err)
|
||||
}
|
||||
err = c.LegacyAuthorizationsApi.DeleteAuthorizationsID(ctx, id).Execute()
|
||||
err = c.LegacyAuthorizationsApi.DeleteLegacyAuthorizationsID(ctx, id).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not remove Authorization with ID %q: %w", id, err)
|
||||
}
|
||||
@ -187,7 +187,7 @@ func (c Client) Remove(ctx context.Context, params *RemoveParams) error {
|
||||
|
||||
ps := make([]string, 0, len(auth.GetPermissions()))
|
||||
for _, p := range auth.GetPermissions() {
|
||||
ps = append(ps, permString(p))
|
||||
ps = append(ps, p.String())
|
||||
}
|
||||
|
||||
return c.printV1Tokens(&v1PrintOpts{
|
||||
@ -212,7 +212,7 @@ type ListParams struct {
|
||||
}
|
||||
|
||||
func (c Client) List(ctx context.Context, params *ListParams) error {
|
||||
req := c.LegacyAuthorizationsApi.GetAuthorizations(ctx)
|
||||
req := c.LegacyAuthorizationsApi.GetLegacyAuthorizations(ctx)
|
||||
|
||||
if params.User != "" {
|
||||
req = req.User(params.User)
|
||||
@ -242,7 +242,7 @@ func (c Client) List(ctx context.Context, params *ListParams) error {
|
||||
for _, a := range auths.GetAuthorizations() {
|
||||
var permissions []string
|
||||
for _, p := range a.GetPermissions() {
|
||||
permissions = append(permissions, permString(p))
|
||||
permissions = append(permissions, p.String())
|
||||
}
|
||||
|
||||
usr, err := c.UsersApi.GetUsersID(ctx, a.GetUserID()).Execute()
|
||||
@ -274,7 +274,7 @@ func (c Client) SetActive(ctx context.Context, params *ActiveParams, active bool
|
||||
return err
|
||||
}
|
||||
|
||||
req := c.LegacyAuthorizationsApi.PatchAuthorizationsID(ctx, id)
|
||||
req := c.LegacyAuthorizationsApi.PatchLegacyAuthorizationsID(ctx, id)
|
||||
var status string
|
||||
if active {
|
||||
status = "active"
|
||||
@ -297,7 +297,7 @@ func (c Client) SetActive(ctx context.Context, params *ActiveParams, active bool
|
||||
|
||||
ps := make([]string, 0, len(auth.GetPermissions()))
|
||||
for _, p := range auth.GetPermissions() {
|
||||
ps = append(ps, permString(p))
|
||||
ps = append(ps, p.String())
|
||||
}
|
||||
|
||||
return c.printV1Tokens(&v1PrintOpts{
|
||||
@ -333,7 +333,7 @@ func (c Client) SetPassword(ctx context.Context, params *SetPasswordParams) erro
|
||||
password = pass
|
||||
}
|
||||
|
||||
err = c.LegacyAuthorizationsApi.PostAuthorizationsIDPassword(ctx, id).
|
||||
err = c.LegacyAuthorizationsApi.PostLegacyAuthorizationsIDPassword(ctx, id).
|
||||
PasswordResetBody(api.PasswordResetBody{Password: password}).
|
||||
Execute()
|
||||
if err != nil {
|
||||
@ -387,26 +387,12 @@ func (c Client) printV1Tokens(params *v1PrintOpts) error {
|
||||
return c.PrintTable(headers, rows...)
|
||||
}
|
||||
|
||||
func permString(p api.Permission) string {
|
||||
ret := p.GetAction() + ":"
|
||||
r := p.GetResource()
|
||||
|
||||
if r.GetOrgID() != "" {
|
||||
ret += "orgs/" + r.GetOrgID()
|
||||
}
|
||||
ret += "/" + r.GetType()
|
||||
if r.GetId() != "" {
|
||||
ret += "/" + r.GetId()
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c Client) getAuthReqID(ctx context.Context, params *AuthLookupParams) (id string, err error) {
|
||||
if params.ID.Valid() {
|
||||
id = params.ID.String()
|
||||
} else {
|
||||
var auths api.Authorizations
|
||||
auths, err = c.LegacyAuthorizationsApi.GetAuthorizations(ctx).Token(params.Username).Execute()
|
||||
auths, err = c.LegacyAuthorizationsApi.GetLegacyAuthorizations(ctx).Token(params.Username).Execute()
|
||||
if err != nil || len(auths.GetAuthorizations()) == 0 {
|
||||
err = fmt.Errorf("could not find v1 auth with token (username) %q: %w", params.Username, err)
|
||||
} else {
|
||||
|
282
cmd/influx/auth.go
Normal file
282
cmd/influx/auth.go
Normal file
@ -0,0 +1,282 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/influxdata/influx-cli/v2/clients/auth"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func newAuthCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "auth",
|
||||
Usage: "Authorization management commands",
|
||||
Aliases: []string{"authorization"},
|
||||
Subcommands: []cli.Command{
|
||||
newCreateCommand(),
|
||||
newDeleteCommand(),
|
||||
newListCommand(),
|
||||
newSetActiveCommand(),
|
||||
newSetInactiveCommand(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newCreateCommand() cli.Command {
|
||||
var params auth.CreateParams
|
||||
flags := append(commonFlags(), getOrgFlags(¶ms.OrgParams)...)
|
||||
flags = append(flags,
|
||||
&cli.StringFlag{
|
||||
Name: "user, u",
|
||||
Usage: "The user name",
|
||||
Destination: ¶ms.User,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "description, d",
|
||||
Usage: "Token description",
|
||||
Destination: ¶ms.Description,
|
||||
},
|
||||
|
||||
&cli.BoolFlag{
|
||||
Name: "write-user",
|
||||
Usage: "Grants the permission to perform mutative actions against organization users",
|
||||
Destination: ¶ms.WriteUserPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-user",
|
||||
Usage: "Grants the permission to perform read actions against organization users",
|
||||
Destination: ¶ms.ReadUserPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-buckets",
|
||||
Usage: "Grants the permission to perform mutative actions against organization buckets",
|
||||
Destination: ¶ms.WriteBucketsPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-buckets",
|
||||
Usage: "Grants the permission to perform read actions against organization buckets",
|
||||
Destination: ¶ms.ReadBucketsPermission,
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "write-bucket",
|
||||
Usage: "The bucket id",
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "read-bucket",
|
||||
Usage: "The bucket id",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-tasks",
|
||||
Usage: "Grants the permission to create tasks",
|
||||
Destination: ¶ms.WriteTasksPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-tasks",
|
||||
Usage: "Grants the permission to read tasks",
|
||||
Destination: ¶ms.ReadTasksPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-telegrafs",
|
||||
Usage: "Grants the permission to create telegraf configs",
|
||||
Destination: ¶ms.WriteTelegrafsPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-telegrafs",
|
||||
Usage: "Grants the permission to read telegraf configs",
|
||||
Destination: ¶ms.ReadTelegrafsPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-orgs",
|
||||
Usage: "Grants the permission to create organizations",
|
||||
Destination: ¶ms.WriteOrganizationsPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-orgs",
|
||||
Usage: "Grants the permission to read organizations",
|
||||
Destination: ¶ms.ReadOrganizationsPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-dashboards",
|
||||
Usage: "Grants the permission to create dashboards",
|
||||
Destination: ¶ms.WriteDashboardsPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-dashboards",
|
||||
Usage: "Grants the permission to read dashboards",
|
||||
Destination: ¶ms.ReadDashboardsPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-checks",
|
||||
Usage: "Grants the permission to create checks",
|
||||
Destination: ¶ms.WriteCheckPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-checks",
|
||||
Usage: "Grants the permission to read checks",
|
||||
Destination: ¶ms.ReadCheckPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-notificationRules",
|
||||
Usage: "Grants the permission to create notificationRules",
|
||||
Destination: ¶ms.WriteNotificationRulePermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-notificationRules",
|
||||
Usage: "Grants the permission to read notificationRules",
|
||||
Destination: ¶ms.ReadNotificationRulePermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-notificationEndpoints",
|
||||
Usage: "Grants the permission to create notificationEndpoints",
|
||||
Destination: ¶ms.WriteNotificationEndpointPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-notificationEndpoints",
|
||||
Usage: "Grants the permission to read notificationEndpoints",
|
||||
Destination: ¶ms.ReadNotificationEndpointPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "write-dbrps",
|
||||
Usage: "Grants the permission to create database retention policy mappings",
|
||||
Destination: ¶ms.WriteDBRPPermission,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "read-dbrps",
|
||||
Usage: "Grants the permission to read database retention policy mappings",
|
||||
Destination: ¶ms.ReadDBRPPermission,
|
||||
},
|
||||
)
|
||||
return cli.Command{
|
||||
Name: "create",
|
||||
Usage: "Create authorization",
|
||||
Flags: flags,
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
params.WriteBucketIds = ctx.StringSlice("write-bucket")
|
||||
params.ReadBucketIds = ctx.StringSlice("read-bucket")
|
||||
|
||||
api := getAPI(ctx)
|
||||
client := auth.Client{
|
||||
CLI: getCLI(ctx),
|
||||
AuthorizationsApi: api.AuthorizationsApi,
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.Create(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newDeleteCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "Delete authorization",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The authorization ID (required)",
|
||||
Required: true,
|
||||
},
|
||||
),
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
api := getAPI(ctx)
|
||||
client := auth.Client{
|
||||
CLI: getCLI(ctx),
|
||||
AuthorizationsApi: api.AuthorizationsApi,
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.Remove(getContext(ctx), ctx.String("id"))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newListCommand() cli.Command {
|
||||
var params auth.ListParams
|
||||
flags := append(commonFlags(), getOrgFlags(¶ms.OrgParams)...)
|
||||
flags = append(flags,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The authorization ID",
|
||||
Destination: ¶ms.Id,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user, u",
|
||||
Usage: "The user",
|
||||
Destination: ¶ms.User,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-id",
|
||||
Usage: "The user ID",
|
||||
Destination: ¶ms.UserID,
|
||||
},
|
||||
)
|
||||
return cli.Command{
|
||||
Name: "list",
|
||||
Usage: "List authorizations",
|
||||
Aliases: []string{"find", "ls"},
|
||||
Flags: flags,
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
api := getAPI(ctx)
|
||||
client := auth.Client{
|
||||
CLI: getCLI(ctx),
|
||||
AuthorizationsApi: api.AuthorizationsApi,
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.List(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newSetActiveCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "active",
|
||||
Usage: "Active authorization",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The authorization ID (required)",
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
api := getAPI(ctx)
|
||||
client := auth.Client{
|
||||
CLI: getCLI(ctx),
|
||||
AuthorizationsApi: api.AuthorizationsApi,
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.SetActive(getContext(ctx), ctx.String("id"), true)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newSetInactiveCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "inactive",
|
||||
Usage: "Inactive authorization",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The authorization ID (required)",
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
api := getAPI(ctx)
|
||||
client := auth.Client{
|
||||
CLI: getCLI(ctx),
|
||||
AuthorizationsApi: api.AuthorizationsApi,
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.SetActive(getContext(ctx), ctx.String("id"), false)
|
||||
},
|
||||
}
|
||||
}
|
@ -49,6 +49,7 @@ var app = cli.App{
|
||||
newExportCmd(),
|
||||
newSecretCommand(),
|
||||
newV1SubCommand(),
|
||||
newAuthCommand(),
|
||||
},
|
||||
Before: withContext(),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user