feat: port influx v1 auth
command (#138)
This commit is contained in:
1032
api/api_legacy_authorizations.gen.go
Normal file
1032
api/api_legacy_authorizations.gen.go
Normal file
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,8 @@ type APIClient struct {
|
|||||||
|
|
||||||
HealthApi HealthApi
|
HealthApi HealthApi
|
||||||
|
|
||||||
|
LegacyAuthorizationsApi LegacyAuthorizationsApi
|
||||||
|
|
||||||
OrganizationsApi OrganizationsApi
|
OrganizationsApi OrganizationsApi
|
||||||
|
|
||||||
QueryApi QueryApi
|
QueryApi QueryApi
|
||||||
@ -107,6 +109,7 @@ func NewAPIClient(cfg *Configuration) *APIClient {
|
|||||||
c.DashboardsApi = (*DashboardsApiService)(&c.common)
|
c.DashboardsApi = (*DashboardsApiService)(&c.common)
|
||||||
c.DeleteApi = (*DeleteApiService)(&c.common)
|
c.DeleteApi = (*DeleteApiService)(&c.common)
|
||||||
c.HealthApi = (*HealthApiService)(&c.common)
|
c.HealthApi = (*HealthApiService)(&c.common)
|
||||||
|
c.LegacyAuthorizationsApi = (*LegacyAuthorizationsApiService)(&c.common)
|
||||||
c.OrganizationsApi = (*OrganizationsApiService)(&c.common)
|
c.OrganizationsApi = (*OrganizationsApiService)(&c.common)
|
||||||
c.QueryApi = (*QueryApiService)(&c.common)
|
c.QueryApi = (*QueryApiService)(&c.common)
|
||||||
c.RestoreApi = (*RestoreApiService)(&c.common)
|
c.RestoreApi = (*RestoreApiService)(&c.common)
|
||||||
|
@ -113,6 +113,42 @@ func NewConfiguration() *Configuration {
|
|||||||
Description: "No description provided",
|
Description: "No description provided",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"LegacyAuthorizationsApiService.DeleteAuthorizationsID": {
|
||||||
|
{
|
||||||
|
URL: "/private",
|
||||||
|
Description: "No description provided",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"LegacyAuthorizationsApiService.GetAuthorizations": {
|
||||||
|
{
|
||||||
|
URL: "/private",
|
||||||
|
Description: "No description provided",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"LegacyAuthorizationsApiService.GetAuthorizationsID": {
|
||||||
|
{
|
||||||
|
URL: "/private",
|
||||||
|
Description: "No description provided",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"LegacyAuthorizationsApiService.PatchAuthorizationsID": {
|
||||||
|
{
|
||||||
|
URL: "/private",
|
||||||
|
Description: "No description provided",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"LegacyAuthorizationsApiService.PostAuthorizations": {
|
||||||
|
{
|
||||||
|
URL: "/private",
|
||||||
|
Description: "No description provided",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"LegacyAuthorizationsApiService.PostAuthorizationsIDPassword": {
|
||||||
|
{
|
||||||
|
URL: "/private",
|
||||||
|
Description: "No description provided",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return cfg
|
return cfg
|
||||||
|
@ -83,6 +83,18 @@ paths:
|
|||||||
$ref: "./openapi/src/common/paths/dbrps.yml"
|
$ref: "./openapi/src/common/paths/dbrps.yml"
|
||||||
"/dbrps/{dbrpID}":
|
"/dbrps/{dbrpID}":
|
||||||
$ref: "./openapi/src/common/paths/dbrps_dbrpID.yml"
|
$ref: "./openapi/src/common/paths/dbrps_dbrpID.yml"
|
||||||
|
/legacy/authorizations:
|
||||||
|
servers:
|
||||||
|
- url: "/private"
|
||||||
|
$ref: "./openapi/src/oss/paths/legacy_authorizations.yml"
|
||||||
|
/legacy/authorizations/{authID}:
|
||||||
|
servers:
|
||||||
|
- url: "/private"
|
||||||
|
$ref: "./openapi/src/oss/paths/legacy_authorizations_authID.yml"
|
||||||
|
/legacy/authorizations/{authID}/password:
|
||||||
|
servers:
|
||||||
|
- url: "/private"
|
||||||
|
$ref: "./openapi/src/oss/paths/legacy_authorizations_authID_password.yml"
|
||||||
components:
|
components:
|
||||||
parameters:
|
parameters:
|
||||||
TraceSpan:
|
TraceSpan:
|
||||||
@ -369,3 +381,7 @@ components:
|
|||||||
$ref: "./openapi/src/common/schemas/DBRPUpdate.yml"
|
$ref: "./openapi/src/common/schemas/DBRPUpdate.yml"
|
||||||
DBRPGet:
|
DBRPGet:
|
||||||
$ref: "./openapi/src/common/schemas/DBRPGet.yml"
|
$ref: "./openapi/src/common/schemas/DBRPGet.yml"
|
||||||
|
Authorizations:
|
||||||
|
$ref: "./openapi/src/common/schemas/Authorizations.yml"
|
||||||
|
LegacyAuthorizationPostRequest:
|
||||||
|
$ref: "./openapi/src/oss/schemas/LegacyAuthorizationPostRequest.yml"
|
||||||
|
Submodule api/contract/openapi updated: 8a47036bed...6b464c86dd
149
api/model_authorizations.gen.go
Normal file
149
api/model_authorizations.gen.go
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Authorizations struct for Authorizations
|
||||||
|
type Authorizations struct {
|
||||||
|
Links *Links `json:"links,omitempty"`
|
||||||
|
Authorizations *[]Authorization `json:"authorizations,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAuthorizations instantiates a new Authorizations 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 NewAuthorizations() *Authorizations {
|
||||||
|
this := Authorizations{}
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAuthorizationsWithDefaults instantiates a new Authorizations 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 NewAuthorizationsWithDefaults() *Authorizations {
|
||||||
|
this := Authorizations{}
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLinks returns the Links field value if set, zero value otherwise.
|
||||||
|
func (o *Authorizations) GetLinks() Links {
|
||||||
|
if o == nil || o.Links == nil {
|
||||||
|
var ret Links
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return *o.Links
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLinksOk returns a tuple with the Links field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *Authorizations) GetLinksOk() (*Links, bool) {
|
||||||
|
if o == nil || o.Links == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return o.Links, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasLinks returns a boolean if a field has been set.
|
||||||
|
func (o *Authorizations) HasLinks() bool {
|
||||||
|
if o != nil && o.Links != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLinks gets a reference to the given Links and assigns it to the Links field.
|
||||||
|
func (o *Authorizations) SetLinks(v Links) {
|
||||||
|
o.Links = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAuthorizations returns the Authorizations field value if set, zero value otherwise.
|
||||||
|
func (o *Authorizations) GetAuthorizations() []Authorization {
|
||||||
|
if o == nil || o.Authorizations == nil {
|
||||||
|
var ret []Authorization
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return *o.Authorizations
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAuthorizationsOk returns a tuple with the Authorizations field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *Authorizations) GetAuthorizationsOk() (*[]Authorization, bool) {
|
||||||
|
if o == nil || o.Authorizations == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return o.Authorizations, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasAuthorizations returns a boolean if a field has been set.
|
||||||
|
func (o *Authorizations) HasAuthorizations() bool {
|
||||||
|
if o != nil && o.Authorizations != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAuthorizations gets a reference to the given []Authorization and assigns it to the Authorizations field.
|
||||||
|
func (o *Authorizations) SetAuthorizations(v []Authorization) {
|
||||||
|
o.Authorizations = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o Authorizations) MarshalJSON() ([]byte, error) {
|
||||||
|
toSerialize := map[string]interface{}{}
|
||||||
|
if o.Links != nil {
|
||||||
|
toSerialize["links"] = o.Links
|
||||||
|
}
|
||||||
|
if o.Authorizations != nil {
|
||||||
|
toSerialize["authorizations"] = o.Authorizations
|
||||||
|
}
|
||||||
|
return json.Marshal(toSerialize)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableAuthorizations struct {
|
||||||
|
value *Authorizations
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableAuthorizations) Get() *Authorizations {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableAuthorizations) Set(val *Authorizations) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableAuthorizations) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableAuthorizations) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableAuthorizations(val *Authorizations) *NullableAuthorizations {
|
||||||
|
return &NullableAuthorizations{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableAuthorizations) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableAuthorizations) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
289
api/model_legacy_authorization_post_request.gen.go
Normal file
289
api/model_legacy_authorization_post_request.gen.go
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LegacyAuthorizationPostRequest struct for LegacyAuthorizationPostRequest
|
||||||
|
type LegacyAuthorizationPostRequest struct {
|
||||||
|
// If inactive the token is inactive and requests using the token will be rejected.
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
// A description of the token.
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
// ID of org that authorization is scoped to.
|
||||||
|
OrgID string `json:"orgID"`
|
||||||
|
// ID of user that authorization is scoped to.
|
||||||
|
UserID *string `json:"userID,omitempty"`
|
||||||
|
// Token (name) of the authorization
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
// List of permissions for an auth. An auth must have at least one Permission.
|
||||||
|
Permissions []Permission `json:"permissions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLegacyAuthorizationPostRequest instantiates a new LegacyAuthorizationPostRequest 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 NewLegacyAuthorizationPostRequest(orgID string, permissions []Permission) *LegacyAuthorizationPostRequest {
|
||||||
|
this := LegacyAuthorizationPostRequest{}
|
||||||
|
var status string = "active"
|
||||||
|
this.Status = &status
|
||||||
|
this.OrgID = orgID
|
||||||
|
this.Permissions = permissions
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLegacyAuthorizationPostRequestWithDefaults instantiates a new LegacyAuthorizationPostRequest 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 NewLegacyAuthorizationPostRequestWithDefaults() *LegacyAuthorizationPostRequest {
|
||||||
|
this := LegacyAuthorizationPostRequest{}
|
||||||
|
var status string = "active"
|
||||||
|
this.Status = &status
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStatus returns the Status field value if set, zero value otherwise.
|
||||||
|
func (o *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) SetStatus(v string) {
|
||||||
|
o.Status = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDescription returns the Description field value if set, zero value otherwise.
|
||||||
|
func (o *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) SetDescription(v string) {
|
||||||
|
o.Description = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrgID returns the OrgID field value
|
||||||
|
func (o *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) GetOrgIDOk() (*string, bool) {
|
||||||
|
if o == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return &o.OrgID, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOrgID sets field value
|
||||||
|
func (o *LegacyAuthorizationPostRequest) SetOrgID(v string) {
|
||||||
|
o.OrgID = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserID returns the UserID field value if set, zero value otherwise.
|
||||||
|
func (o *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) SetUserID(v string) {
|
||||||
|
o.UserID = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetToken returns the Token field value if set, zero value otherwise.
|
||||||
|
func (o *LegacyAuthorizationPostRequest) GetToken() string {
|
||||||
|
if o == nil || o.Token == nil {
|
||||||
|
var ret string
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return *o.Token
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTokenOk returns a tuple with the Token field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *LegacyAuthorizationPostRequest) GetTokenOk() (*string, bool) {
|
||||||
|
if o == nil || o.Token == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return o.Token, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasToken returns a boolean if a field has been set.
|
||||||
|
func (o *LegacyAuthorizationPostRequest) HasToken() bool {
|
||||||
|
if o != nil && o.Token != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetToken gets a reference to the given string and assigns it to the Token field.
|
||||||
|
func (o *LegacyAuthorizationPostRequest) SetToken(v string) {
|
||||||
|
o.Token = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPermissions returns the Permissions field value
|
||||||
|
func (o *LegacyAuthorizationPostRequest) 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 *LegacyAuthorizationPostRequest) GetPermissionsOk() (*[]Permission, bool) {
|
||||||
|
if o == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return &o.Permissions, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPermissions sets field value
|
||||||
|
func (o *LegacyAuthorizationPostRequest) SetPermissions(v []Permission) {
|
||||||
|
o.Permissions = v
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o LegacyAuthorizationPostRequest) 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 o.Token != nil {
|
||||||
|
toSerialize["token"] = o.Token
|
||||||
|
}
|
||||||
|
if true {
|
||||||
|
toSerialize["permissions"] = o.Permissions
|
||||||
|
}
|
||||||
|
return json.Marshal(toSerialize)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableLegacyAuthorizationPostRequest struct {
|
||||||
|
value *LegacyAuthorizationPostRequest
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableLegacyAuthorizationPostRequest) Get() *LegacyAuthorizationPostRequest {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableLegacyAuthorizationPostRequest) Set(val *LegacyAuthorizationPostRequest) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableLegacyAuthorizationPostRequest) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableLegacyAuthorizationPostRequest) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableLegacyAuthorizationPostRequest(val *LegacyAuthorizationPostRequest) *NullableLegacyAuthorizationPostRequest {
|
||||||
|
return &NullableLegacyAuthorizationPostRequest{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableLegacyAuthorizationPostRequest) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableLegacyAuthorizationPostRequest) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
225
api/model_legacy_authorization_post_request_all_of.gen.go
Normal file
225
api/model_legacy_authorization_post_request_all_of.gen.go
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LegacyAuthorizationPostRequestAllOf struct for LegacyAuthorizationPostRequestAllOf
|
||||||
|
type LegacyAuthorizationPostRequestAllOf struct {
|
||||||
|
// ID of org that authorization is scoped to.
|
||||||
|
OrgID *string `json:"orgID,omitempty"`
|
||||||
|
// ID of user that authorization is scoped to.
|
||||||
|
UserID *string `json:"userID,omitempty"`
|
||||||
|
// Token (name) of the authorization
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
// List of permissions for an auth. An auth must have at least one Permission.
|
||||||
|
Permissions *[]Permission `json:"permissions,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLegacyAuthorizationPostRequestAllOf instantiates a new LegacyAuthorizationPostRequestAllOf 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 NewLegacyAuthorizationPostRequestAllOf() *LegacyAuthorizationPostRequestAllOf {
|
||||||
|
this := LegacyAuthorizationPostRequestAllOf{}
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLegacyAuthorizationPostRequestAllOfWithDefaults instantiates a new LegacyAuthorizationPostRequestAllOf 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 NewLegacyAuthorizationPostRequestAllOfWithDefaults() *LegacyAuthorizationPostRequestAllOf {
|
||||||
|
this := LegacyAuthorizationPostRequestAllOf{}
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrgID returns the OrgID field value if set, zero value otherwise.
|
||||||
|
func (o *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) SetOrgID(v string) {
|
||||||
|
o.OrgID = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserID returns the UserID field value if set, zero value otherwise.
|
||||||
|
func (o *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) SetUserID(v string) {
|
||||||
|
o.UserID = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetToken returns the Token field value if set, zero value otherwise.
|
||||||
|
func (o *LegacyAuthorizationPostRequestAllOf) GetToken() string {
|
||||||
|
if o == nil || o.Token == nil {
|
||||||
|
var ret string
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return *o.Token
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTokenOk returns a tuple with the Token field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *LegacyAuthorizationPostRequestAllOf) GetTokenOk() (*string, bool) {
|
||||||
|
if o == nil || o.Token == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return o.Token, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasToken returns a boolean if a field has been set.
|
||||||
|
func (o *LegacyAuthorizationPostRequestAllOf) HasToken() bool {
|
||||||
|
if o != nil && o.Token != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetToken gets a reference to the given string and assigns it to the Token field.
|
||||||
|
func (o *LegacyAuthorizationPostRequestAllOf) SetToken(v string) {
|
||||||
|
o.Token = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPermissions returns the Permissions field value if set, zero value otherwise.
|
||||||
|
func (o *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) 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 *LegacyAuthorizationPostRequestAllOf) SetPermissions(v []Permission) {
|
||||||
|
o.Permissions = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o LegacyAuthorizationPostRequestAllOf) 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.Token != nil {
|
||||||
|
toSerialize["token"] = o.Token
|
||||||
|
}
|
||||||
|
if o.Permissions != nil {
|
||||||
|
toSerialize["permissions"] = o.Permissions
|
||||||
|
}
|
||||||
|
return json.Marshal(toSerialize)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableLegacyAuthorizationPostRequestAllOf struct {
|
||||||
|
value *LegacyAuthorizationPostRequestAllOf
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableLegacyAuthorizationPostRequestAllOf) Get() *LegacyAuthorizationPostRequestAllOf {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableLegacyAuthorizationPostRequestAllOf) Set(val *LegacyAuthorizationPostRequestAllOf) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableLegacyAuthorizationPostRequestAllOf) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableLegacyAuthorizationPostRequestAllOf) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableLegacyAuthorizationPostRequestAllOf(val *LegacyAuthorizationPostRequestAllOf) *NullableLegacyAuthorizationPostRequestAllOf {
|
||||||
|
return &NullableLegacyAuthorizationPostRequestAllOf{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableLegacyAuthorizationPostRequestAllOf) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableLegacyAuthorizationPostRequestAllOf) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
@ -18,13 +18,13 @@ import (
|
|||||||
type PermissionResource struct {
|
type PermissionResource struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
// If ID is set that is a permission for a specific resource. if it is not set it is a permission for all resources of that resource type.
|
// If ID is set that is a permission for a specific resource. if it is not set it is a permission for all resources of that resource type.
|
||||||
Id NullableString `json:"id,omitempty"`
|
Id *string `json:"id,omitempty"`
|
||||||
// Optional name of the resource if the resource has a name field.
|
// Optional name of the resource if the resource has a name field.
|
||||||
Name NullableString `json:"name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
// If orgID is set that is a permission for all resources owned my that org. if it is not set it is a permission for all resources of that resource type.
|
// If orgID is set that is a permission for all resources owned my that org. if it is not set it is a permission for all resources of that resource type.
|
||||||
OrgID NullableString `json:"orgID,omitempty"`
|
OrgID *string `json:"orgID,omitempty"`
|
||||||
// Optional name of the organization of the organization with orgID.
|
// Optional name of the organization of the organization with orgID.
|
||||||
Org NullableString `json:"org,omitempty"`
|
Org *string `json:"org,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPermissionResource instantiates a new PermissionResource object
|
// NewPermissionResource instantiates a new PermissionResource object
|
||||||
@ -69,176 +69,132 @@ func (o *PermissionResource) SetType(v string) {
|
|||||||
o.Type = v
|
o.Type = v
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetId returns the Id field value if set, zero value otherwise (both if not set or set to explicit null).
|
// GetId returns the Id field value if set, zero value otherwise.
|
||||||
func (o *PermissionResource) GetId() string {
|
func (o *PermissionResource) GetId() string {
|
||||||
if o == nil || o.Id.Get() == nil {
|
if o == nil || o.Id == nil {
|
||||||
var ret string
|
var ret string
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.Id.Get()
|
return *o.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
|
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
|
||||||
func (o *PermissionResource) GetIdOk() (*string, bool) {
|
func (o *PermissionResource) GetIdOk() (*string, bool) {
|
||||||
if o == nil {
|
if o == nil || o.Id == nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
return o.Id.Get(), o.Id.IsSet()
|
return o.Id, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasId returns a boolean if a field has been set.
|
// HasId returns a boolean if a field has been set.
|
||||||
func (o *PermissionResource) HasId() bool {
|
func (o *PermissionResource) HasId() bool {
|
||||||
if o != nil && o.Id.IsSet() {
|
if o != nil && o.Id != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetId gets a reference to the given NullableString and assigns it to the Id field.
|
// SetId gets a reference to the given string and assigns it to the Id field.
|
||||||
func (o *PermissionResource) SetId(v string) {
|
func (o *PermissionResource) SetId(v string) {
|
||||||
o.Id.Set(&v)
|
o.Id = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetIdNil sets the value for Id to be an explicit nil
|
// GetName returns the Name field value if set, zero value otherwise.
|
||||||
func (o *PermissionResource) SetIdNil() {
|
|
||||||
o.Id.Set(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnsetId ensures that no value is present for Id, not even an explicit nil
|
|
||||||
func (o *PermissionResource) UnsetId() {
|
|
||||||
o.Id.Unset()
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetName returns the Name field value if set, zero value otherwise (both if not set or set to explicit null).
|
|
||||||
func (o *PermissionResource) GetName() string {
|
func (o *PermissionResource) GetName() string {
|
||||||
if o == nil || o.Name.Get() == nil {
|
if o == nil || o.Name == nil {
|
||||||
var ret string
|
var ret string
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.Name.Get()
|
return *o.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
|
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
|
||||||
func (o *PermissionResource) GetNameOk() (*string, bool) {
|
func (o *PermissionResource) GetNameOk() (*string, bool) {
|
||||||
if o == nil {
|
if o == nil || o.Name == nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
return o.Name.Get(), o.Name.IsSet()
|
return o.Name, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasName returns a boolean if a field has been set.
|
// HasName returns a boolean if a field has been set.
|
||||||
func (o *PermissionResource) HasName() bool {
|
func (o *PermissionResource) HasName() bool {
|
||||||
if o != nil && o.Name.IsSet() {
|
if o != nil && o.Name != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetName gets a reference to the given NullableString and assigns it to the Name field.
|
// SetName gets a reference to the given string and assigns it to the Name field.
|
||||||
func (o *PermissionResource) SetName(v string) {
|
func (o *PermissionResource) SetName(v string) {
|
||||||
o.Name.Set(&v)
|
o.Name = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNameNil sets the value for Name to be an explicit nil
|
// GetOrgID returns the OrgID field value if set, zero value otherwise.
|
||||||
func (o *PermissionResource) SetNameNil() {
|
|
||||||
o.Name.Set(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnsetName ensures that no value is present for Name, not even an explicit nil
|
|
||||||
func (o *PermissionResource) UnsetName() {
|
|
||||||
o.Name.Unset()
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetOrgID returns the OrgID field value if set, zero value otherwise (both if not set or set to explicit null).
|
|
||||||
func (o *PermissionResource) GetOrgID() string {
|
func (o *PermissionResource) GetOrgID() string {
|
||||||
if o == nil || o.OrgID.Get() == nil {
|
if o == nil || o.OrgID == nil {
|
||||||
var ret string
|
var ret string
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.OrgID.Get()
|
return *o.OrgID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrgIDOk returns a tuple with the OrgID field value if set, nil otherwise
|
// GetOrgIDOk returns a tuple with the OrgID field value if set, nil otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
|
||||||
func (o *PermissionResource) GetOrgIDOk() (*string, bool) {
|
func (o *PermissionResource) GetOrgIDOk() (*string, bool) {
|
||||||
if o == nil {
|
if o == nil || o.OrgID == nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
return o.OrgID.Get(), o.OrgID.IsSet()
|
return o.OrgID, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasOrgID returns a boolean if a field has been set.
|
// HasOrgID returns a boolean if a field has been set.
|
||||||
func (o *PermissionResource) HasOrgID() bool {
|
func (o *PermissionResource) HasOrgID() bool {
|
||||||
if o != nil && o.OrgID.IsSet() {
|
if o != nil && o.OrgID != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetOrgID gets a reference to the given NullableString and assigns it to the OrgID field.
|
// SetOrgID gets a reference to the given string and assigns it to the OrgID field.
|
||||||
func (o *PermissionResource) SetOrgID(v string) {
|
func (o *PermissionResource) SetOrgID(v string) {
|
||||||
o.OrgID.Set(&v)
|
o.OrgID = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetOrgIDNil sets the value for OrgID to be an explicit nil
|
// GetOrg returns the Org field value if set, zero value otherwise.
|
||||||
func (o *PermissionResource) SetOrgIDNil() {
|
|
||||||
o.OrgID.Set(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnsetOrgID ensures that no value is present for OrgID, not even an explicit nil
|
|
||||||
func (o *PermissionResource) UnsetOrgID() {
|
|
||||||
o.OrgID.Unset()
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetOrg returns the Org field value if set, zero value otherwise (both if not set or set to explicit null).
|
|
||||||
func (o *PermissionResource) GetOrg() string {
|
func (o *PermissionResource) GetOrg() string {
|
||||||
if o == nil || o.Org.Get() == nil {
|
if o == nil || o.Org == nil {
|
||||||
var ret string
|
var ret string
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.Org.Get()
|
return *o.Org
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrgOk returns a tuple with the Org field value if set, nil otherwise
|
// GetOrgOk returns a tuple with the Org field value if set, nil otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
|
||||||
func (o *PermissionResource) GetOrgOk() (*string, bool) {
|
func (o *PermissionResource) GetOrgOk() (*string, bool) {
|
||||||
if o == nil {
|
if o == nil || o.Org == nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
return o.Org.Get(), o.Org.IsSet()
|
return o.Org, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasOrg returns a boolean if a field has been set.
|
// HasOrg returns a boolean if a field has been set.
|
||||||
func (o *PermissionResource) HasOrg() bool {
|
func (o *PermissionResource) HasOrg() bool {
|
||||||
if o != nil && o.Org.IsSet() {
|
if o != nil && o.Org != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetOrg gets a reference to the given NullableString and assigns it to the Org field.
|
// SetOrg gets a reference to the given string and assigns it to the Org field.
|
||||||
func (o *PermissionResource) SetOrg(v string) {
|
func (o *PermissionResource) SetOrg(v string) {
|
||||||
o.Org.Set(&v)
|
o.Org = &v
|
||||||
}
|
|
||||||
|
|
||||||
// SetOrgNil sets the value for Org to be an explicit nil
|
|
||||||
func (o *PermissionResource) SetOrgNil() {
|
|
||||||
o.Org.Set(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnsetOrg ensures that no value is present for Org, not even an explicit nil
|
|
||||||
func (o *PermissionResource) UnsetOrg() {
|
|
||||||
o.Org.Unset()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o PermissionResource) MarshalJSON() ([]byte, error) {
|
func (o PermissionResource) MarshalJSON() ([]byte, error) {
|
||||||
@ -246,17 +202,17 @@ func (o PermissionResource) MarshalJSON() ([]byte, error) {
|
|||||||
if true {
|
if true {
|
||||||
toSerialize["type"] = o.Type
|
toSerialize["type"] = o.Type
|
||||||
}
|
}
|
||||||
if o.Id.IsSet() {
|
if o.Id != nil {
|
||||||
toSerialize["id"] = o.Id.Get()
|
toSerialize["id"] = o.Id
|
||||||
}
|
}
|
||||||
if o.Name.IsSet() {
|
if o.Name != nil {
|
||||||
toSerialize["name"] = o.Name.Get()
|
toSerialize["name"] = o.Name
|
||||||
}
|
}
|
||||||
if o.OrgID.IsSet() {
|
if o.OrgID != nil {
|
||||||
toSerialize["orgID"] = o.OrgID.Get()
|
toSerialize["orgID"] = o.OrgID
|
||||||
}
|
}
|
||||||
if o.Org.IsSet() {
|
if o.Org != nil {
|
||||||
toSerialize["org"] = o.Org.Get()
|
toSerialize["org"] = o.Org
|
||||||
}
|
}
|
||||||
return json.Marshal(toSerialize)
|
return json.Marshal(toSerialize)
|
||||||
}
|
}
|
||||||
|
438
clients/v1_auth/v1_auth.go
Normal file
438
clients/v1_auth/v1_auth.go
Normal file
@ -0,0 +1,438 @@
|
|||||||
|
package v1_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.LegacyAuthorizationsApi
|
||||||
|
api.UsersApi
|
||||||
|
api.OrganizationsApi
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthLookupParams struct {
|
||||||
|
ID influxid.ID
|
||||||
|
Username string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p AuthLookupParams) Validate() (err error) {
|
||||||
|
if p.Username == "" && !p.ID.Valid() {
|
||||||
|
err = fmt.Errorf("id or username required")
|
||||||
|
} else if p.Username != "" && p.ID.Valid() {
|
||||||
|
err = fmt.Errorf("specify id or username, not both")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p AuthLookupParams) IsSet() bool {
|
||||||
|
return p.ID.Valid() || p.Username != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type v1PrintOpts struct {
|
||||||
|
deleted bool
|
||||||
|
token *v1Token
|
||||||
|
tokens []v1Token
|
||||||
|
}
|
||||||
|
|
||||||
|
type v1Token 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 CreateParams struct {
|
||||||
|
clients.OrgParams
|
||||||
|
Desc string
|
||||||
|
Username string
|
||||||
|
Password string
|
||||||
|
NoPassword bool
|
||||||
|
ReadBucket []string
|
||||||
|
WriteBucket []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) Create(ctx context.Context, params *CreateParams) error {
|
||||||
|
if params.Password != "" && params.NoPassword {
|
||||||
|
return fmt.Errorf("only one of --password and --no-password may be specified")
|
||||||
|
}
|
||||||
|
|
||||||
|
orgID, err := c.getOrgID(ctx, params.OrgParams)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify an existing token with the same username doesn't already exist
|
||||||
|
auths, err := c.LegacyAuthorizationsApi.GetAuthorizations(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)
|
||||||
|
} else if len(auths.GetAuthorizations()) != 0 {
|
||||||
|
return fmt.Errorf("authorization with username %q already exists", params.Username)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
password := params.Password
|
||||||
|
if password == "" && !params.NoPassword {
|
||||||
|
pass, err := c.StdIO.GetPassword("Please type your password")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
password = pass
|
||||||
|
}
|
||||||
|
|
||||||
|
bucketPerms := []struct {
|
||||||
|
action string
|
||||||
|
perms []string
|
||||||
|
}{
|
||||||
|
{action: "read", perms: params.ReadBucket},
|
||||||
|
{action: "write", perms: params.WriteBucket},
|
||||||
|
}
|
||||||
|
|
||||||
|
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: api.PermissionResource{
|
||||||
|
Type: "buckets",
|
||||||
|
Id: &p,
|
||||||
|
OrgID: &orgID,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
permissions = append(permissions, newPerm)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
authReq := api.LegacyAuthorizationPostRequest{
|
||||||
|
Description: ¶ms.Desc,
|
||||||
|
OrgID: orgID,
|
||||||
|
Permissions: permissions,
|
||||||
|
Token: ¶ms.Username,
|
||||||
|
}
|
||||||
|
|
||||||
|
newAuth, err := c.LegacyAuthorizationsApi.PostAuthorizations(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()).
|
||||||
|
PasswordResetBody(api.PasswordResetBody{Password: password}).
|
||||||
|
Execute()
|
||||||
|
if err != nil {
|
||||||
|
_ = c.LegacyAuthorizationsApi.DeleteAuthorizationsID(ctx, newAuth.GetId()).Execute()
|
||||||
|
return fmt.Errorf("failed to set password for %q: %w", params.Username, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
usr, err := c.UsersApi.GetUsersID(ctx, newAuth.GetUserID()).Execute()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ps := make([]string, 0, len(newAuth.Permissions))
|
||||||
|
for _, p := range newAuth.Permissions {
|
||||||
|
ps = append(ps, permString(p))
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.printV1Tokens(&v1PrintOpts{
|
||||||
|
token: &v1Token{
|
||||||
|
ID: newAuth.GetId(),
|
||||||
|
Description: newAuth.GetDescription(),
|
||||||
|
Token: newAuth.GetToken(),
|
||||||
|
Status: newAuth.GetStatus(),
|
||||||
|
UserName: usr.GetName(),
|
||||||
|
UserID: usr.GetId(),
|
||||||
|
Permissions: ps,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type RemoveParams struct {
|
||||||
|
AuthLookupParams
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) Remove(ctx context.Context, params *RemoveParams) error {
|
||||||
|
id, err := c.getAuthReqID(ctx, ¶ms.AuthLookupParams)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
auth, err := c.LegacyAuthorizationsApi.GetAuthorizationsID(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()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not remove Authorization with ID %q: %w", id, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
usr, err := c.UsersApi.GetUsersID(ctx, auth.GetUserID()).Execute()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not find user from user ID %q: %w", auth.GetUserID(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ps := make([]string, 0, len(auth.GetPermissions()))
|
||||||
|
for _, p := range auth.GetPermissions() {
|
||||||
|
ps = append(ps, permString(p))
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.printV1Tokens(&v1PrintOpts{
|
||||||
|
deleted: true,
|
||||||
|
token: &v1Token{
|
||||||
|
ID: auth.GetId(),
|
||||||
|
Description: auth.GetDescription(),
|
||||||
|
Token: auth.GetToken(),
|
||||||
|
Status: auth.GetStatus(),
|
||||||
|
UserName: usr.GetName(),
|
||||||
|
UserID: usr.GetId(),
|
||||||
|
Permissions: ps,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListParams struct {
|
||||||
|
clients.OrgParams
|
||||||
|
AuthLookupParams
|
||||||
|
User string
|
||||||
|
UserID string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) List(ctx context.Context, params *ListParams) error {
|
||||||
|
req := c.LegacyAuthorizationsApi.GetAuthorizations(ctx)
|
||||||
|
|
||||||
|
if params.User != "" {
|
||||||
|
req = req.User(params.User)
|
||||||
|
}
|
||||||
|
if params.UserID != "" {
|
||||||
|
req = req.UserID(params.UserID)
|
||||||
|
}
|
||||||
|
if params.OrgID.Valid() {
|
||||||
|
req = req.OrgID(params.OrgID.String())
|
||||||
|
}
|
||||||
|
if params.OrgName != "" {
|
||||||
|
req = req.Org(params.OrgName)
|
||||||
|
}
|
||||||
|
if params.Username != "" {
|
||||||
|
req = req.Token(params.Username)
|
||||||
|
}
|
||||||
|
if params.ID.Valid() {
|
||||||
|
req = req.AuthID(params.ID.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
auths, err := req.Execute()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not find Authorizations for specified arguments: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var tokens []v1Token
|
||||||
|
for _, a := range auths.GetAuthorizations() {
|
||||||
|
var permissions []string
|
||||||
|
for _, p := range a.GetPermissions() {
|
||||||
|
permissions = append(permissions, permString(p))
|
||||||
|
}
|
||||||
|
|
||||||
|
usr, err := c.UsersApi.GetUsersID(ctx, a.GetUserID()).Execute()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not find user with ID %q: %w", a.GetUserID(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tokens = append(tokens, v1Token{
|
||||||
|
ID: a.GetId(),
|
||||||
|
Description: a.GetDescription(),
|
||||||
|
Token: a.GetToken(),
|
||||||
|
Status: a.GetStatus(),
|
||||||
|
UserName: usr.GetName(),
|
||||||
|
UserID: usr.GetId(),
|
||||||
|
Permissions: permissions,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.printV1Tokens(&v1PrintOpts{tokens: tokens})
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActiveParams struct {
|
||||||
|
AuthLookupParams
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) SetActive(ctx context.Context, params *ActiveParams, active bool) error {
|
||||||
|
id, err := c.getAuthReqID(ctx, ¶ms.AuthLookupParams)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
req := c.LegacyAuthorizationsApi.PatchAuthorizationsID(ctx, id)
|
||||||
|
var status string
|
||||||
|
if active {
|
||||||
|
status = "active"
|
||||||
|
} else {
|
||||||
|
status = "inactive"
|
||||||
|
}
|
||||||
|
req = req.AuthorizationUpdateRequest(api.AuthorizationUpdateRequest{
|
||||||
|
Status: &status,
|
||||||
|
})
|
||||||
|
|
||||||
|
auth, err := req.Execute()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to update status of authorization with ID %q: %w", id, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
usr, err := c.UsersApi.GetUsersID(ctx, auth.GetUserID()).Execute()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not find user from User ID %q: %w", auth.GetUserID(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ps := make([]string, 0, len(auth.GetPermissions()))
|
||||||
|
for _, p := range auth.GetPermissions() {
|
||||||
|
ps = append(ps, permString(p))
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.printV1Tokens(&v1PrintOpts{
|
||||||
|
token: &v1Token{
|
||||||
|
ID: auth.GetId(),
|
||||||
|
Description: auth.GetDescription(),
|
||||||
|
Token: auth.GetToken(),
|
||||||
|
Status: auth.GetStatus(),
|
||||||
|
UserName: usr.GetName(),
|
||||||
|
UserID: usr.GetId(),
|
||||||
|
Permissions: ps,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetPasswordParams struct {
|
||||||
|
AuthLookupParams
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) SetPassword(ctx context.Context, params *SetPasswordParams) error {
|
||||||
|
id, err := c.getAuthReqID(ctx, ¶ms.AuthLookupParams)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
password := params.Password
|
||||||
|
if password == "" {
|
||||||
|
pass, err := c.StdIO.GetPassword("Please type new password")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
password = pass
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.LegacyAuthorizationsApi.PostAuthorizationsIDPassword(ctx, id).
|
||||||
|
PasswordResetBody(api.PasswordResetBody{Password: password}).
|
||||||
|
Execute()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error setting password: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) printV1Tokens(params *v1PrintOpts) error {
|
||||||
|
if c.PrintAsJSON {
|
||||||
|
var v interface{}
|
||||||
|
if params.token != nil {
|
||||||
|
v = params.token
|
||||||
|
} else {
|
||||||
|
v = params.tokens
|
||||||
|
}
|
||||||
|
return c.PrintJSON(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
headers := []string{
|
||||||
|
"ID",
|
||||||
|
"Description",
|
||||||
|
"Name / Token",
|
||||||
|
"User Name",
|
||||||
|
"User ID",
|
||||||
|
"Permissions",
|
||||||
|
}
|
||||||
|
if params.deleted {
|
||||||
|
headers = append(headers, "Deleted")
|
||||||
|
}
|
||||||
|
if params.token != nil {
|
||||||
|
params.tokens = append(params.tokens, *params.token)
|
||||||
|
}
|
||||||
|
|
||||||
|
var rows []map[string]interface{}
|
||||||
|
for _, u := range params.tokens {
|
||||||
|
row := map[string]interface{}{
|
||||||
|
"ID": u.ID,
|
||||||
|
"Description": u.Description,
|
||||||
|
"Name / Token": u.Token,
|
||||||
|
"User Name": u.UserName,
|
||||||
|
"User ID": u.UserID,
|
||||||
|
"Permissions": u.Permissions,
|
||||||
|
}
|
||||||
|
if params.deleted {
|
||||||
|
row["Deleted"] = true
|
||||||
|
}
|
||||||
|
rows = append(rows, row)
|
||||||
|
}
|
||||||
|
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()
|
||||||
|
if err != nil || len(auths.GetAuthorizations()) == 0 {
|
||||||
|
err = fmt.Errorf("could not find v1 auth with token (username) %q: %w", params.Username, err)
|
||||||
|
} else {
|
||||||
|
id = auths.GetAuthorizations()[0].GetId()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
233
cmd/influx/v1_auth.go
Normal file
233
cmd/influx/v1_auth.go
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/influxdata/influx-cli/v2/clients/v1_auth"
|
||||||
|
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// getAuthLookupFlags returns flags used for authorization, requiring either an ID or Username,
|
||||||
|
// and can specify to require one but not both.
|
||||||
|
func getAuthLookupFlags(params *v1_auth.AuthLookupParams) []cli.Flag {
|
||||||
|
return []cli.Flag{
|
||||||
|
&cli.GenericFlag{
|
||||||
|
Name: "id",
|
||||||
|
Usage: "The ID of the authorization",
|
||||||
|
Value: ¶ms.ID,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Usage: "The username of the authorization",
|
||||||
|
Destination: ¶ms.Username,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newV1AuthCommand() *cli.Command {
|
||||||
|
return &cli.Command{
|
||||||
|
Name: "auth",
|
||||||
|
Usage: "Authorization management commands for v1 APIs",
|
||||||
|
Aliases: []string{"authorization"},
|
||||||
|
Subcommands: []*cli.Command{
|
||||||
|
newCreateV1AuthCmd(),
|
||||||
|
newRemoveV1AuthCmd(),
|
||||||
|
newListV1AuthCmd(),
|
||||||
|
newSetActiveV1AuthCmd(),
|
||||||
|
newSetInactiveV1AuthCmd(),
|
||||||
|
newSetPswdV1AuthCmd(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCreateV1AuthCmd() *cli.Command {
|
||||||
|
var params v1_auth.CreateParams
|
||||||
|
flags := append(commonFlags(), getOrgFlags(¶ms.OrgParams)...)
|
||||||
|
flags = append(flags,
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "description",
|
||||||
|
Usage: "Token description",
|
||||||
|
Aliases: []string{"d"},
|
||||||
|
Destination: ¶ms.Desc,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "username",
|
||||||
|
Usage: "The username to identify this token",
|
||||||
|
Required: true,
|
||||||
|
Destination: ¶ms.Username,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "password",
|
||||||
|
Usage: "The password to set on this token",
|
||||||
|
Destination: ¶ms.Password,
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "no-password",
|
||||||
|
Usage: "Don't prompt for a password. You must use v1 auth set-password command before using the token.",
|
||||||
|
Destination: ¶ms.NoPassword,
|
||||||
|
},
|
||||||
|
&cli.StringSliceFlag{
|
||||||
|
Name: "read-bucket",
|
||||||
|
Usage: "The bucket id",
|
||||||
|
},
|
||||||
|
&cli.StringSliceFlag{
|
||||||
|
Name: "write-bucket",
|
||||||
|
Usage: "The bucket id",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return &cli.Command{
|
||||||
|
Name: "create",
|
||||||
|
Usage: "Create authorization",
|
||||||
|
Flags: flags,
|
||||||
|
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||||
|
Action: func(ctx *cli.Context) error {
|
||||||
|
params.ReadBucket = ctx.StringSlice("read-bucket")
|
||||||
|
params.WriteBucket = ctx.StringSlice("write-bucket")
|
||||||
|
api := getAPI(ctx)
|
||||||
|
client := v1_auth.Client{
|
||||||
|
CLI: getCLI(ctx),
|
||||||
|
LegacyAuthorizationsApi: api.LegacyAuthorizationsApi,
|
||||||
|
UsersApi: api.UsersApi,
|
||||||
|
OrganizationsApi: api.OrganizationsApi,
|
||||||
|
}
|
||||||
|
return client.Create(ctx.Context, ¶ms)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRemoveV1AuthCmd() *cli.Command {
|
||||||
|
var params v1_auth.RemoveParams
|
||||||
|
flags := append(commonFlags(), getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||||
|
return &cli.Command{
|
||||||
|
Name: "delete",
|
||||||
|
Usage: "Delete authorization",
|
||||||
|
Flags: flags,
|
||||||
|
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||||
|
Action: func(ctx *cli.Context) error {
|
||||||
|
if err := params.AuthLookupParams.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
api := getAPI(ctx)
|
||||||
|
client := v1_auth.Client{
|
||||||
|
CLI: getCLI(ctx),
|
||||||
|
LegacyAuthorizationsApi: api.LegacyAuthorizationsApi,
|
||||||
|
UsersApi: api.UsersApi,
|
||||||
|
OrganizationsApi: api.OrganizationsApi,
|
||||||
|
}
|
||||||
|
return client.Remove(ctx.Context, ¶ms)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newListV1AuthCmd() *cli.Command {
|
||||||
|
var params v1_auth.ListParams
|
||||||
|
flags := append(commonFlags(), getOrgFlags(¶ms.OrgParams)...)
|
||||||
|
flags = append(flags, getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||||
|
flags = append(flags,
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "user",
|
||||||
|
Usage: "The user",
|
||||||
|
Aliases: []string{"u"},
|
||||||
|
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{"ls", "find"},
|
||||||
|
Flags: flags,
|
||||||
|
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||||
|
Action: func(ctx *cli.Context) error {
|
||||||
|
api := getAPI(ctx)
|
||||||
|
client := v1_auth.Client{
|
||||||
|
CLI: getCLI(ctx),
|
||||||
|
LegacyAuthorizationsApi: api.LegacyAuthorizationsApi,
|
||||||
|
UsersApi: api.UsersApi,
|
||||||
|
OrganizationsApi: api.OrganizationsApi,
|
||||||
|
}
|
||||||
|
return client.List(ctx.Context, ¶ms)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSetActiveV1AuthCmd() *cli.Command {
|
||||||
|
var params v1_auth.ActiveParams
|
||||||
|
flags := append(commonFlags(), getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||||
|
return &cli.Command{
|
||||||
|
Name: "set-active",
|
||||||
|
Usage: "Change the status of an authorization to active",
|
||||||
|
Flags: flags,
|
||||||
|
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||||
|
Action: func(ctx *cli.Context) error {
|
||||||
|
if err := params.AuthLookupParams.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
api := getAPI(ctx)
|
||||||
|
client := v1_auth.Client{
|
||||||
|
CLI: getCLI(ctx),
|
||||||
|
LegacyAuthorizationsApi: api.LegacyAuthorizationsApi,
|
||||||
|
UsersApi: api.UsersApi,
|
||||||
|
OrganizationsApi: api.OrganizationsApi,
|
||||||
|
}
|
||||||
|
return client.SetActive(ctx.Context, ¶ms, true)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSetInactiveV1AuthCmd() *cli.Command {
|
||||||
|
var params v1_auth.ActiveParams
|
||||||
|
flags := append(commonFlags(), getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||||
|
return &cli.Command{
|
||||||
|
Name: "set-inactive",
|
||||||
|
Usage: "Change the status of an authorization to inactive",
|
||||||
|
Flags: flags,
|
||||||
|
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||||
|
Action: func(ctx *cli.Context) error {
|
||||||
|
if err := params.AuthLookupParams.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
api := getAPI(ctx)
|
||||||
|
client := v1_auth.Client{
|
||||||
|
CLI: getCLI(ctx),
|
||||||
|
LegacyAuthorizationsApi: api.LegacyAuthorizationsApi,
|
||||||
|
UsersApi: api.UsersApi,
|
||||||
|
OrganizationsApi: api.OrganizationsApi,
|
||||||
|
}
|
||||||
|
return client.SetActive(ctx.Context, ¶ms, false)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSetPswdV1AuthCmd() *cli.Command {
|
||||||
|
var params v1_auth.SetPasswordParams
|
||||||
|
flags := append(coreFlags(), commonTokenFlag())
|
||||||
|
flags = append(flags, getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||||
|
flags = append(flags,
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "password",
|
||||||
|
Usage: "Password to set on the authorization",
|
||||||
|
Destination: ¶ms.Password,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return &cli.Command{
|
||||||
|
Name: "set-password",
|
||||||
|
Usage: "Set a password for an existing authorization",
|
||||||
|
Flags: flags,
|
||||||
|
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||||
|
Action: func(ctx *cli.Context) error {
|
||||||
|
api := getAPI(ctx)
|
||||||
|
client := v1_auth.Client{
|
||||||
|
CLI: getCLI(ctx),
|
||||||
|
LegacyAuthorizationsApi: api.LegacyAuthorizationsApi,
|
||||||
|
}
|
||||||
|
return client.SetPassword(ctx.Context, ¶ms)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ func newV1SubCommand() *cli.Command {
|
|||||||
Usage: "InfluxDB v1 management commands",
|
Usage: "InfluxDB v1 management commands",
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
newV1DBRPCmd(),
|
newV1DBRPCmd(),
|
||||||
|
newV1AuthCommand(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user