
* chore: update openapi * feat: update replication field names to match influx changes * feat: add new field to show replication queue sync progress * chore: update to master openapi
1269 lines
45 KiB
Go
1269 lines
45 KiB
Go
/*
|
|
* Subset of Influx API covered by Influx CLI
|
|
*
|
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
*
|
|
* API version: 2.0.0
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
_context "context"
|
|
_fmt "fmt"
|
|
_io "io"
|
|
_nethttp "net/http"
|
|
_neturl "net/url"
|
|
"strings"
|
|
)
|
|
|
|
// Linger please
|
|
var (
|
|
_ _context.Context
|
|
)
|
|
|
|
type AuthorizationsAPITokensApi interface {
|
|
|
|
/*
|
|
* DeleteAuthorizationsID Delete an authorization
|
|
* Deletes an authorization.
|
|
|
|
Use the endpoint to delete an API token.
|
|
|
|
If you want to disable an API token instead of delete it,
|
|
[update the authorization's status to `inactive`](#operation/PatchAuthorizationsID).
|
|
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param authID An authorization ID. Specifies the authorization to delete.
|
|
* @return ApiDeleteAuthorizationsIDRequest
|
|
*/
|
|
DeleteAuthorizationsID(ctx _context.Context, authID string) ApiDeleteAuthorizationsIDRequest
|
|
|
|
/*
|
|
* DeleteAuthorizationsIDExecute executes the request
|
|
*/
|
|
DeleteAuthorizationsIDExecute(r ApiDeleteAuthorizationsIDRequest) error
|
|
|
|
/*
|
|
* DeleteAuthorizationsIDExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not
|
|
* available on the returned HTTP response as it will have already been read and closed; access to the response body
|
|
* content should be achieved through the returned response model if applicable.
|
|
*/
|
|
DeleteAuthorizationsIDExecuteWithHttpInfo(r ApiDeleteAuthorizationsIDRequest) (*_nethttp.Response, error)
|
|
|
|
/*
|
|
* GetAuthorizations List authorizations
|
|
* Lists authorizations.
|
|
|
|
To limit which authorizations are returned, pass query parameters in your request.
|
|
If no query parameters are passed, InfluxDB returns all authorizations.
|
|
|
|
#### InfluxDB Cloud
|
|
|
|
- InfluxDB Cloud doesn't expose [API token]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#token)
|
|
values in `GET /api/v2/authorizations` responses;
|
|
returns `token: redacted` for all authorizations.
|
|
|
|
#### Required permissions
|
|
|
|
To retrieve an authorization, the request must use an API token that has the
|
|
following permissions:
|
|
|
|
- `read-authorizations`
|
|
- `read-user` for the user that the authorization is scoped to
|
|
|
|
#### Related guides
|
|
|
|
- [View tokens]({{% INFLUXDB_DOCS_URL %}}/security/tokens/view-tokens/)
|
|
|
|
* @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)
|
|
|
|
/*
|
|
* GetAuthorizationsExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not
|
|
* available on the returned HTTP response as it will have already been read and closed; access to the response body
|
|
* content should be achieved through the returned response model if applicable.
|
|
* @return Authorizations
|
|
*/
|
|
GetAuthorizationsExecuteWithHttpInfo(r ApiGetAuthorizationsRequest) (Authorizations, *_nethttp.Response, error)
|
|
|
|
/*
|
|
* GetAuthorizationsID Retrieve an authorization
|
|
* Retrieves an authorization.
|
|
|
|
Use this endpoint to retrieve information about an API token, including
|
|
the token's permissions and the user that the token is scoped to.
|
|
|
|
#### InfluxDB OSS
|
|
|
|
- InfluxDB OSS returns
|
|
[API token]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#token) values in authorizations.
|
|
- If the request uses an _[operator token](https://docs.influxdata.com/influxdb/latest/security/tokens/#operator-token)_,
|
|
InfluxDB OSS returns authorizations for all organizations in the instance.
|
|
|
|
#### Related guides
|
|
|
|
- [View tokens]({{% INFLUXDB_DOCS_URL %}}/security/tokens/view-tokens/)
|
|
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param authID An authorization ID. Specifies the authorization to retrieve.
|
|
* @return ApiGetAuthorizationsIDRequest
|
|
*/
|
|
GetAuthorizationsID(ctx _context.Context, authID string) ApiGetAuthorizationsIDRequest
|
|
|
|
/*
|
|
* GetAuthorizationsIDExecute executes the request
|
|
* @return Authorization
|
|
*/
|
|
GetAuthorizationsIDExecute(r ApiGetAuthorizationsIDRequest) (Authorization, error)
|
|
|
|
/*
|
|
* GetAuthorizationsIDExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not
|
|
* available on the returned HTTP response as it will have already been read and closed; access to the response body
|
|
* content should be achieved through the returned response model if applicable.
|
|
* @return Authorization
|
|
*/
|
|
GetAuthorizationsIDExecuteWithHttpInfo(r ApiGetAuthorizationsIDRequest) (Authorization, *_nethttp.Response, error)
|
|
|
|
/*
|
|
* PatchAuthorizationsID Update an API token to be active or inactive
|
|
* Updates an authorization.
|
|
|
|
Use this endpoint to set an API token's status to be _active_ or _inactive_.
|
|
InfluxDB rejects requests that use inactive API tokens.
|
|
|
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param authID An authorization ID. Specifies the authorization to update.
|
|
* @return ApiPatchAuthorizationsIDRequest
|
|
*/
|
|
PatchAuthorizationsID(ctx _context.Context, authID string) ApiPatchAuthorizationsIDRequest
|
|
|
|
/*
|
|
* PatchAuthorizationsIDExecute executes the request
|
|
* @return Authorization
|
|
*/
|
|
PatchAuthorizationsIDExecute(r ApiPatchAuthorizationsIDRequest) (Authorization, error)
|
|
|
|
/*
|
|
* PatchAuthorizationsIDExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not
|
|
* available on the returned HTTP response as it will have already been read and closed; access to the response body
|
|
* content should be achieved through the returned response model if applicable.
|
|
* @return Authorization
|
|
*/
|
|
PatchAuthorizationsIDExecuteWithHttpInfo(r ApiPatchAuthorizationsIDRequest) (Authorization, *_nethttp.Response, error)
|
|
|
|
/*
|
|
* PostAuthorizations Create an authorization
|
|
* Creates an authorization and returns the authorization with the
|
|
generated API [token]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#token).
|
|
|
|
Use this endpoint to create an authorization, which generates an API token
|
|
with permissions to `read` or `write` to a specific resource or `type` of resource.
|
|
The API token is the authorization's `token` property value.
|
|
|
|
To follow best practices for secure API token generation and retrieval,
|
|
InfluxDB enforces access restrictions on API tokens.
|
|
|
|
- InfluxDB allows access to the API token value immediately after the authorization is created.
|
|
- You can’t change access (read/write) permissions for an API token after it’s created.
|
|
- Tokens stop working when the user who created the token is deleted.
|
|
|
|
We recommend the following for managing your tokens:
|
|
|
|
- Create a generic user to create and manage tokens for writing data.
|
|
- Store your tokens in a secure password vault for future access.
|
|
|
|
#### Required permissions
|
|
|
|
- `write-authorizations`
|
|
- `write-user` for the user that the authorization is scoped to
|
|
|
|
#### Related guides
|
|
|
|
- [Create a token]({{% INFLUXDB_DOCS_URL %}}/security/tokens/create-token/)
|
|
|
|
* @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)
|
|
|
|
/*
|
|
* PostAuthorizationsExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not
|
|
* available on the returned HTTP response as it will have already been read and closed; access to the response body
|
|
* content should be achieved through the returned response model if applicable.
|
|
* @return Authorization
|
|
*/
|
|
PostAuthorizationsExecuteWithHttpInfo(r ApiPostAuthorizationsRequest) (Authorization, *_nethttp.Response, error)
|
|
}
|
|
|
|
// AuthorizationsAPITokensApiService AuthorizationsAPITokensApi service
|
|
type AuthorizationsAPITokensApiService service
|
|
|
|
type ApiDeleteAuthorizationsIDRequest struct {
|
|
ctx _context.Context
|
|
ApiService AuthorizationsAPITokensApi
|
|
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)
|
|
}
|
|
|
|
func (r ApiDeleteAuthorizationsIDRequest) ExecuteWithHttpInfo() (*_nethttp.Response, error) {
|
|
return r.ApiService.DeleteAuthorizationsIDExecuteWithHttpInfo(r)
|
|
}
|
|
|
|
/*
|
|
- DeleteAuthorizationsID Delete an authorization
|
|
- Deletes an authorization.
|
|
|
|
Use the endpoint to delete an API token.
|
|
|
|
If you want to disable an API token instead of delete it,
|
|
[update the authorization's status to `inactive`](#operation/PatchAuthorizationsID).
|
|
|
|
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
- @param authID An authorization ID. Specifies the authorization to delete.
|
|
- @return ApiDeleteAuthorizationsIDRequest
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) DeleteAuthorizationsID(ctx _context.Context, authID string) ApiDeleteAuthorizationsIDRequest {
|
|
return ApiDeleteAuthorizationsIDRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
authID: authID,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) DeleteAuthorizationsIDExecute(r ApiDeleteAuthorizationsIDRequest) error {
|
|
_, err := a.DeleteAuthorizationsIDExecuteWithHttpInfo(r)
|
|
return err
|
|
}
|
|
|
|
/*
|
|
* ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the
|
|
* returned HTTP response as it will have already been read and closed; access to the response body content should be
|
|
* achieved through the returned response model if applicable.
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) DeleteAuthorizationsIDExecuteWithHttpInfo(r ApiDeleteAuthorizationsIDRequest) (*_nethttp.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodDelete
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsAPITokensApiService.DeleteAuthorizationsID")
|
|
if err != nil {
|
|
return nil, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v2/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 nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
newErr := GenericOpenAPIError{
|
|
buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"),
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
newErr.error = localVarHTTPResponse.Status
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v UnauthorizedRequestError
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiGetAuthorizationsRequest struct {
|
|
ctx _context.Context
|
|
ApiService AuthorizationsAPITokensApi
|
|
zapTraceSpan *string
|
|
userID *string
|
|
user *string
|
|
orgID *string
|
|
org *string
|
|
token *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) Token(token string) ApiGetAuthorizationsRequest {
|
|
r.token = &token
|
|
return r
|
|
}
|
|
func (r ApiGetAuthorizationsRequest) GetToken() *string {
|
|
return r.token
|
|
}
|
|
|
|
func (r ApiGetAuthorizationsRequest) Execute() (Authorizations, error) {
|
|
return r.ApiService.GetAuthorizationsExecute(r)
|
|
}
|
|
|
|
func (r ApiGetAuthorizationsRequest) ExecuteWithHttpInfo() (Authorizations, *_nethttp.Response, error) {
|
|
return r.ApiService.GetAuthorizationsExecuteWithHttpInfo(r)
|
|
}
|
|
|
|
/*
|
|
- GetAuthorizations List authorizations
|
|
- Lists authorizations.
|
|
|
|
To limit which authorizations are returned, pass query parameters in your request.
|
|
If no query parameters are passed, InfluxDB returns all authorizations.
|
|
|
|
#### InfluxDB Cloud
|
|
|
|
- InfluxDB Cloud doesn't expose [API token]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#token)
|
|
values in `GET /api/v2/authorizations` responses;
|
|
returns `token: redacted` for all authorizations.
|
|
|
|
#### Required permissions
|
|
|
|
To retrieve an authorization, the request must use an API token that has the
|
|
following permissions:
|
|
|
|
- `read-authorizations`
|
|
- `read-user` for the user that the authorization is scoped to
|
|
|
|
#### Related guides
|
|
|
|
- [View tokens]({{% INFLUXDB_DOCS_URL %}}/security/tokens/view-tokens/)
|
|
|
|
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
- @return ApiGetAuthorizationsRequest
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) GetAuthorizations(ctx _context.Context) ApiGetAuthorizationsRequest {
|
|
return ApiGetAuthorizationsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return Authorizations
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) GetAuthorizationsExecute(r ApiGetAuthorizationsRequest) (Authorizations, error) {
|
|
returnVal, _, err := a.GetAuthorizationsExecuteWithHttpInfo(r)
|
|
return returnVal, err
|
|
}
|
|
|
|
/*
|
|
* ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the
|
|
* returned HTTP response as it will have already been read and closed; access to the response body content should be
|
|
* achieved through the returned response model if applicable.
|
|
* @return Authorizations
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) GetAuthorizationsExecuteWithHttpInfo(r ApiGetAuthorizationsRequest) (Authorizations, *_nethttp.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodGet
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue Authorizations
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsAPITokensApiService.GetAuthorizations")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v2/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, ""))
|
|
}
|
|
if r.token != nil {
|
|
localVarQueryParams.Add("token", parameterToString(*r.token, ""))
|
|
}
|
|
// 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, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
newErr := GenericOpenAPIError{
|
|
buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"),
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
newErr.error = localVarHTTPResponse.Status
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v UnauthorizedRequestError
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiGetAuthorizationsIDRequest struct {
|
|
ctx _context.Context
|
|
ApiService AuthorizationsAPITokensApi
|
|
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)
|
|
}
|
|
|
|
func (r ApiGetAuthorizationsIDRequest) ExecuteWithHttpInfo() (Authorization, *_nethttp.Response, error) {
|
|
return r.ApiService.GetAuthorizationsIDExecuteWithHttpInfo(r)
|
|
}
|
|
|
|
/*
|
|
- GetAuthorizationsID Retrieve an authorization
|
|
- Retrieves an authorization.
|
|
|
|
Use this endpoint to retrieve information about an API token, including
|
|
the token's permissions and the user that the token is scoped to.
|
|
|
|
#### InfluxDB OSS
|
|
|
|
- InfluxDB OSS returns
|
|
[API token]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#token) values in authorizations.
|
|
- If the request uses an _[operator token](https://docs.influxdata.com/influxdb/latest/security/tokens/#operator-token)_,
|
|
InfluxDB OSS returns authorizations for all organizations in the instance.
|
|
|
|
#### Related guides
|
|
|
|
- [View tokens]({{% INFLUXDB_DOCS_URL %}}/security/tokens/view-tokens/)
|
|
|
|
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
- @param authID An authorization ID. Specifies the authorization to retrieve.
|
|
- @return ApiGetAuthorizationsIDRequest
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) GetAuthorizationsID(ctx _context.Context, authID string) ApiGetAuthorizationsIDRequest {
|
|
return ApiGetAuthorizationsIDRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
authID: authID,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return Authorization
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) GetAuthorizationsIDExecute(r ApiGetAuthorizationsIDRequest) (Authorization, error) {
|
|
returnVal, _, err := a.GetAuthorizationsIDExecuteWithHttpInfo(r)
|
|
return returnVal, err
|
|
}
|
|
|
|
/*
|
|
* ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the
|
|
* returned HTTP response as it will have already been read and closed; access to the response body content should be
|
|
* achieved through the returned response model if applicable.
|
|
* @return Authorization
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) GetAuthorizationsIDExecuteWithHttpInfo(r ApiGetAuthorizationsIDRequest) (Authorization, *_nethttp.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodGet
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue Authorization
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsAPITokensApiService.GetAuthorizationsID")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v2/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, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
newErr := GenericOpenAPIError{
|
|
buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"),
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
newErr.error = localVarHTTPResponse.Status
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v UnauthorizedRequestError
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiPatchAuthorizationsIDRequest struct {
|
|
ctx _context.Context
|
|
ApiService AuthorizationsAPITokensApi
|
|
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)
|
|
}
|
|
|
|
func (r ApiPatchAuthorizationsIDRequest) ExecuteWithHttpInfo() (Authorization, *_nethttp.Response, error) {
|
|
return r.ApiService.PatchAuthorizationsIDExecuteWithHttpInfo(r)
|
|
}
|
|
|
|
/*
|
|
- PatchAuthorizationsID Update an API token to be active or inactive
|
|
- Updates an authorization.
|
|
|
|
Use this endpoint to set an API token's status to be _active_ or _inactive_.
|
|
InfluxDB rejects requests that use inactive API tokens.
|
|
|
|
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
- @param authID An authorization ID. Specifies the authorization to update.
|
|
- @return ApiPatchAuthorizationsIDRequest
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) PatchAuthorizationsID(ctx _context.Context, authID string) ApiPatchAuthorizationsIDRequest {
|
|
return ApiPatchAuthorizationsIDRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
authID: authID,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return Authorization
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) PatchAuthorizationsIDExecute(r ApiPatchAuthorizationsIDRequest) (Authorization, error) {
|
|
returnVal, _, err := a.PatchAuthorizationsIDExecuteWithHttpInfo(r)
|
|
return returnVal, err
|
|
}
|
|
|
|
/*
|
|
* ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the
|
|
* returned HTTP response as it will have already been read and closed; access to the response body content should be
|
|
* achieved through the returned response model if applicable.
|
|
* @return Authorization
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) PatchAuthorizationsIDExecuteWithHttpInfo(r ApiPatchAuthorizationsIDRequest) (Authorization, *_nethttp.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodPatch
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue Authorization
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsAPITokensApiService.PatchAuthorizationsID")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v2/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, nil, 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, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
newErr := GenericOpenAPIError{
|
|
buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"),
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
newErr.error = localVarHTTPResponse.Status
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type ApiPostAuthorizationsRequest struct {
|
|
ctx _context.Context
|
|
ApiService AuthorizationsAPITokensApi
|
|
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)
|
|
}
|
|
|
|
func (r ApiPostAuthorizationsRequest) ExecuteWithHttpInfo() (Authorization, *_nethttp.Response, error) {
|
|
return r.ApiService.PostAuthorizationsExecuteWithHttpInfo(r)
|
|
}
|
|
|
|
/*
|
|
- PostAuthorizations Create an authorization
|
|
- Creates an authorization and returns the authorization with the
|
|
|
|
generated API [token]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#token).
|
|
|
|
Use this endpoint to create an authorization, which generates an API token
|
|
with permissions to `read` or `write` to a specific resource or `type` of resource.
|
|
The API token is the authorization's `token` property value.
|
|
|
|
To follow best practices for secure API token generation and retrieval,
|
|
InfluxDB enforces access restrictions on API tokens.
|
|
|
|
- InfluxDB allows access to the API token value immediately after the authorization is created.
|
|
- You can’t change access (read/write) permissions for an API token after it’s created.
|
|
- Tokens stop working when the user who created the token is deleted.
|
|
|
|
We recommend the following for managing your tokens:
|
|
|
|
- Create a generic user to create and manage tokens for writing data.
|
|
- Store your tokens in a secure password vault for future access.
|
|
|
|
#### Required permissions
|
|
|
|
- `write-authorizations`
|
|
- `write-user` for the user that the authorization is scoped to
|
|
|
|
#### Related guides
|
|
|
|
- [Create a token]({{% INFLUXDB_DOCS_URL %}}/security/tokens/create-token/)
|
|
|
|
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
- @return ApiPostAuthorizationsRequest
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) PostAuthorizations(ctx _context.Context) ApiPostAuthorizationsRequest {
|
|
return ApiPostAuthorizationsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Execute executes the request
|
|
* @return Authorization
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) PostAuthorizationsExecute(r ApiPostAuthorizationsRequest) (Authorization, error) {
|
|
returnVal, _, err := a.PostAuthorizationsExecuteWithHttpInfo(r)
|
|
return returnVal, err
|
|
}
|
|
|
|
/*
|
|
* ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the
|
|
* returned HTTP response as it will have already been read and closed; access to the response body content should be
|
|
* achieved through the returned response model if applicable.
|
|
* @return Authorization
|
|
*/
|
|
func (a *AuthorizationsAPITokensApiService) PostAuthorizationsExecuteWithHttpInfo(r ApiPostAuthorizationsRequest) (Authorization, *_nethttp.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = _nethttp.MethodPost
|
|
localVarPostBody interface{}
|
|
localVarFormFileName string
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue Authorization
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuthorizationsAPITokensApiService.PostAuthorizations")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/api/v2/authorizations"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := _neturl.Values{}
|
|
localVarFormParams := _neturl.Values{}
|
|
if r.authorizationPostRequest == nil {
|
|
return localVarReturnValue, nil, 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, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
newErr := GenericOpenAPIError{
|
|
buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"),
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
newErr.error = localVarHTTPResponse.Status
|
|
if localVarHTTPResponse.StatusCode == 400 {
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v UnauthorizedRequestError
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
var v Error
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
|
|
newErr.model = &v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
body, err := GunzipIfNeeded(localVarHTTPResponse)
|
|
if err != nil {
|
|
body.Close()
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
localVarBody, err := _io.ReadAll(body)
|
|
body.Close()
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.body = localVarBody
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|