feat: add flags for remotes, replications, and functions to auth create (#325)

This commit is contained in:
Daniel Moran 2021-11-10 11:33:01 -05:00 committed by GitHub
parent 1eadcf12e1
commit 99791bafd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 144 additions and 78 deletions

1
.gitignore vendored
View File

@ -20,6 +20,7 @@ vendor/
# Docs generated from our openapi repo
api/cli.yml
api/cli.gen.yml
api/cli-extras.gen.yml
# GPG private key generated by CI during release.
private.key

View File

@ -23,7 +23,7 @@ var (
_ _context.Context
)
type ResourceListApi interface {
type ResourcesApi interface {
/*
* GetResources List all known resources
@ -41,30 +41,30 @@ type ResourceListApi interface {
// Sets additional descriptive text in the error message if any request in
// this API fails, indicating that it is intended to be used only on OSS
// servers.
OnlyOSS() ResourceListApi
OnlyOSS() ResourcesApi
// Sets additional descriptive text in the error message if any request in
// this API fails, indicating that it is intended to be used only on cloud
// servers.
OnlyCloud() ResourceListApi
OnlyCloud() ResourcesApi
}
// ResourceListApiService ResourceListApi service
type ResourceListApiService service
// ResourcesApiService ResourcesApi service
type ResourcesApiService service
func (a *ResourceListApiService) OnlyOSS() ResourceListApi {
func (a *ResourcesApiService) OnlyOSS() ResourcesApi {
a.isOnlyOSS = true
return a
}
func (a *ResourceListApiService) OnlyCloud() ResourceListApi {
func (a *ResourcesApiService) OnlyCloud() ResourcesApi {
a.isOnlyCloud = true
return a
}
type ApiGetResourcesRequest struct {
ctx _context.Context
ApiService ResourceListApi
ApiService ResourcesApi
zapTraceSpan *string
}
@ -85,7 +85,7 @@ func (r ApiGetResourcesRequest) Execute() ([]string, error) {
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiGetResourcesRequest
*/
func (a *ResourceListApiService) GetResources(ctx _context.Context) ApiGetResourcesRequest {
func (a *ResourcesApiService) GetResources(ctx _context.Context) ApiGetResourcesRequest {
return ApiGetResourcesRequest{
ApiService: a,
ctx: ctx,
@ -96,7 +96,7 @@ func (a *ResourceListApiService) GetResources(ctx _context.Context) ApiGetResour
* Execute executes the request
* @return []string
*/
func (a *ResourceListApiService) GetResourcesExecute(r ApiGetResourcesRequest) ([]string, error) {
func (a *ResourcesApiService) GetResourcesExecute(r ApiGetResourcesRequest) ([]string, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
@ -106,7 +106,7 @@ func (a *ResourceListApiService) GetResourcesExecute(r ApiGetResourcesRequest) (
localVarReturnValue []string
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ResourceListApiService.GetResources")
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ResourcesApiService.GetResources")
if err != nil {
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
}

View File

@ -507,6 +507,7 @@ type ApiGetTasksRequest struct {
orgID *string
status *string
limit *int32
type_ *string
}
func (r ApiGetTasksRequest) ZapTraceSpan(zapTraceSpan string) ApiGetTasksRequest {
@ -573,6 +574,14 @@ func (r ApiGetTasksRequest) GetLimit() *int32 {
return r.limit
}
func (r ApiGetTasksRequest) Type_(type_ string) ApiGetTasksRequest {
r.type_ = &type_
return r
}
func (r ApiGetTasksRequest) GetType_() *string {
return r.type_
}
func (r ApiGetTasksRequest) Execute() (Tasks, error) {
return r.ApiService.GetTasksExecute(r)
}
@ -635,6 +644,9 @@ func (a *TasksApiService) GetTasksExecute(r ApiGetTasksRequest) (Tasks, error) {
if r.limit != nil {
localVarQueryParams.Add("limit", parameterToString(*r.limit, ""))
}
if r.type_ != nil {
localVarQueryParams.Add("type", parameterToString(*r.type_, ""))
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}

View File

@ -38,7 +38,9 @@ type WriteApi interface {
- **InfluxDB URL** _See [InfluxDB URLs]({{% INFLUXDB_DOCS_URL %}}/reference/urls/)_.
- data in [line protocol]({{% INFLUXDB_DOCS_URL %}}/reference/syntax/line-protocol) format.
For more information and examples, see [Write data with the InfluxDB API]({{% INFLUXDB_DOCS_URL %}}/write-data/developer-tools/api).
For more information and examples, see the following:
- [Write data with the InfluxDB API]({{% INFLUXDB_DOCS_URL %}}/write-data/developer-tools/api).
- [Optimize writes to InfluxDB]({{% INFLUXDB_DOCS_URL %}}/write-data/best-practices/optimize-writes/).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostWriteRequest
@ -186,7 +188,9 @@ To write data into InfluxDB, you need the following:
- **InfluxDB URL** _See [InfluxDB URLs]({{% INFLUXDB_DOCS_URL %}}/reference/urls/)_.
- data in [line protocol]({{% INFLUXDB_DOCS_URL %}}/reference/syntax/line-protocol) format.
For more information and examples, see [Write data with the InfluxDB API]({{% INFLUXDB_DOCS_URL %}}/write-data/developer-tools/api).
For more information and examples, see the following:
- [Write data with the InfluxDB API]({{% INFLUXDB_DOCS_URL %}}/write-data/developer-tools/api).
- [Optimize writes to InfluxDB]({{% INFLUXDB_DOCS_URL %}}/write-data/best-practices/optimize-writes/).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostWriteRequest
@ -348,6 +352,17 @@ func (a *WriteApiService) PostWriteExecute(r ApiPostWriteRequest) error {
newErr.model = &v
return newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
return newErr
}
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
newErr.model = &v
return newErr
}
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {

View File

@ -1,52 +0,0 @@
openapi: 3.0.0
info:
title: Extra configuration to force openapi to generate enum validators
version: 2.0.0
servers: []
paths: {}
components:
schemas:
ResourceEnumOSS:
type: string
enum:
- authorizations
- buckets
- dashboards
- orgs
- sources
- tasks
- telegrafs
- users
- variables
- scrapers
- secrets
- labels
- views
- documents
- notificationRules
- notificationEndpoints
- checks
- dbrp
- notebooks
ResourceEnumCloud:
type: string
enum:
- authorizations
- buckets
- dashboards
- orgs
- tasks
- telegrafs
- users
- variables
- secrets
- labels
- views
- documents
- notificationRules
- notificationEndpoints
- checks
- dbrp
- flows
- annotations
- functions

View File

@ -72,7 +72,7 @@ type APIClient struct {
ReplicationsApi ReplicationsApi
ResourceListApi ResourceListApi
ResourcesApi ResourcesApi
RestoreApi RestoreApi
@ -124,7 +124,7 @@ func NewAPIClient(cfg *Configuration) *APIClient {
c.QueryApi = (*QueryApiService)(&c.common)
c.RemoteConnectionsApi = (*RemoteConnectionsApiService)(&c.common)
c.ReplicationsApi = (*ReplicationsApiService)(&c.common)
c.ResourceListApi = (*ResourceListApiService)(&c.common)
c.ResourcesApi = (*ResourcesApiService)(&c.common)
c.RestoreApi = (*RestoreApiService)(&c.common)
c.SecretsApi = (*SecretsApiService)(&c.common)
c.SetupApi = (*SetupApiService)(&c.common)

View File

@ -12,7 +12,7 @@ paths:
/setup:
$ref: "./openapi/src/common/paths/setup.yml"
/write:
$ref: "./openapi/src/common/paths/write.yml"
$ref: "./openapi/src/oss/paths/write.yml"
/buckets:
$ref: "./openapi/src/common/paths/buckets.yml"
/buckets/{bucketID}:

@ -1 +1 @@
Subproject commit 588064fe68e7dfeebd019695aa805832632cbfb6
Subproject commit 7d9edc32995f38b3474a24c36b89a8e125837f3c

View File

@ -39,10 +39,13 @@ const (
RESOURCEENUMOSS_CHECKS ResourceEnumOSS = "checks"
RESOURCEENUMOSS_DBRP ResourceEnumOSS = "dbrp"
RESOURCEENUMOSS_NOTEBOOKS ResourceEnumOSS = "notebooks"
RESOURCEENUMOSS_ANNOTATIONS ResourceEnumOSS = "annotations"
RESOURCEENUMOSS_REMOTES ResourceEnumOSS = "remotes"
RESOURCEENUMOSS_REPLICATIONS ResourceEnumOSS = "replications"
)
func ResourceEnumOSSValues() []ResourceEnumOSS {
return []ResourceEnumOSS{"authorizations", "buckets", "dashboards", "orgs", "sources", "tasks", "telegrafs", "users", "variables", "scrapers", "secrets", "labels", "views", "documents", "notificationRules", "notificationEndpoints", "checks", "dbrp", "notebooks"}
return []ResourceEnumOSS{"authorizations", "buckets", "dashboards", "orgs", "sources", "tasks", "telegrafs", "users", "variables", "scrapers", "secrets", "labels", "views", "documents", "notificationRules", "notificationEndpoints", "checks", "dbrp", "notebooks", "annotations", "remotes", "replications"}
}
func (v *ResourceEnumOSS) UnmarshalJSON(src []byte) error {
@ -52,7 +55,7 @@ func (v *ResourceEnumOSS) UnmarshalJSON(src []byte) error {
return err
}
enumTypeValue := ResourceEnumOSS(value)
for _, existing := range []ResourceEnumOSS{"authorizations", "buckets", "dashboards", "orgs", "sources", "tasks", "telegrafs", "users", "variables", "scrapers", "secrets", "labels", "views", "documents", "notificationRules", "notificationEndpoints", "checks", "dbrp", "notebooks"} {
for _, existing := range []ResourceEnumOSS{"authorizations", "buckets", "dashboards", "orgs", "sources", "tasks", "telegrafs", "users", "variables", "scrapers", "secrets", "labels", "views", "documents", "notificationRules", "notificationEndpoints", "checks", "dbrp", "notebooks", "annotations", "remotes", "replications"} {
if existing == enumTypeValue {
*v = enumTypeValue
return nil

View File

@ -17,8 +17,12 @@ import (
// MeasurementSchema The schema definition for a single measurement
type MeasurementSchema struct {
Id string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Id string `json:"id" yaml:"id"`
// ID of organization that the measurement schema is associated with.
OrgID *string `json:"orgID,omitempty" yaml:"orgID,omitempty"`
// ID of the bucket that the measurement schema is associated with.
BucketID *string `json:"bucketID,omitempty" yaml:"bucketID,omitempty"`
Name string `json:"name" yaml:"name"`
// An ordered collection of column definitions
Columns []MeasurementSchemaColumn `json:"columns" yaml:"columns"`
CreatedAt time.Time `json:"createdAt" yaml:"createdAt"`
@ -71,6 +75,70 @@ func (o *MeasurementSchema) SetId(v string) {
o.Id = v
}
// GetOrgID returns the OrgID field value if set, zero value otherwise.
func (o *MeasurementSchema) 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 *MeasurementSchema) 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 *MeasurementSchema) 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 *MeasurementSchema) SetOrgID(v string) {
o.OrgID = &v
}
// GetBucketID returns the BucketID field value if set, zero value otherwise.
func (o *MeasurementSchema) GetBucketID() string {
if o == nil || o.BucketID == nil {
var ret string
return ret
}
return *o.BucketID
}
// GetBucketIDOk returns a tuple with the BucketID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MeasurementSchema) GetBucketIDOk() (*string, bool) {
if o == nil || o.BucketID == nil {
return nil, false
}
return o.BucketID, true
}
// HasBucketID returns a boolean if a field has been set.
func (o *MeasurementSchema) HasBucketID() bool {
if o != nil && o.BucketID != nil {
return true
}
return false
}
// SetBucketID gets a reference to the given string and assigns it to the BucketID field.
func (o *MeasurementSchema) SetBucketID(v string) {
o.BucketID = &v
}
// GetName returns the Name field value
func (o *MeasurementSchema) GetName() string {
if o == nil {
@ -172,6 +240,12 @@ func (o MeasurementSchema) MarshalJSON() ([]byte, error) {
if true {
toSerialize["id"] = o.Id
}
if o.OrgID != nil {
toSerialize["orgID"] = o.OrgID
}
if o.BucketID != nil {
toSerialize["bucketID"] = o.BucketID
}
if true {
toSerialize["name"] = o.Name
}

View File

@ -15,7 +15,7 @@ type Client struct {
api.AuthorizationsApi
api.UsersApi
api.OrganizationsApi
api.ResourceListApi
api.ResourcesApi
}
const (

View File

@ -395,7 +395,7 @@ func TestClient_RemoveMembers(t *testing.T) {
req := api.ApiDeleteOrgsIDMembersIDRequest{ApiService: orgApi}.OrgID(id1.String()).UserID(id2.String())
orgApi.EXPECT().
DeleteOrgsIDMembersID(gomock.Any(), gomock.Eq(id2.String()), gomock.Eq(id1.String()), ).Return(req)
DeleteOrgsIDMembersID(gomock.Any(), gomock.Eq(id2.String()), gomock.Eq(id1.String())).Return(req)
orgApi.EXPECT().DeleteOrgsIDMembersIDExecute(gomock.Eq(req)).Return(nil)
},
expectedOut: "user \"2222222222222222\" has been removed from org \"1111111111111111\"",

View File

@ -46,6 +46,16 @@ func helpText(perm string) struct{ readHelp, writeHelp string } {
return help
}
func hidden(perm string) bool {
var hiddenTypes = map[string]struct{}{
"functions": {},
"remotes": {},
"replications": {},
}
_, ok := hiddenTypes[perm]
return ok
}
func newCreateCommand() cli.Command {
var params auth.CreateParams
flags := append(commonFlags(), getOrgFlags(&params.OrgParams)...)
@ -96,11 +106,13 @@ func newCreateCommand() cli.Command {
Name: "read-" + perm.Name,
Usage: help.readHelp + ossVsCloud,
Destination: &perm.Read,
Hidden: hidden(perm.Name),
},
&cli.BoolFlag{
Name: "write-" + perm.Name,
Usage: help.writeHelp + ossVsCloud,
Destination: &perm.Write,
Hidden: hidden(perm.Name),
})
}
@ -119,7 +131,7 @@ func newCreateCommand() cli.Command {
AuthorizationsApi: api.AuthorizationsApi,
UsersApi: api.UsersApi,
OrganizationsApi: api.OrganizationsApi,
ResourceListApi: api.ResourceListApi,
ResourcesApi: api.ResourcesApi,
}
return client.Create(getContext(ctx), &params)
},

View File

@ -11,10 +11,11 @@
package backup_restore
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
const (