diff --git a/api/authmethods/account.gen.go b/api/authmethods/account.gen.go index 352b28335..ce483c670 100644 --- a/api/authmethods/account.gen.go +++ b/api/authmethods/account.gen.go @@ -39,13 +39,11 @@ func (c *AccountsClient) Create(ctx context.Context, authMethodId string, opt .. if authMethodId == "" { return nil, nil, fmt.Errorf("empty authMethodId value passed into Create request") } - + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - opts, apiOpts := getOpts(opt...) - req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("auth-methods/%s/accounts", authMethodId), opts.valueMap, apiOpts...) if err != nil { return nil, nil, fmt.Errorf("error creating Create request: %w", err) diff --git a/api/authmethods/authmethods.gen.go b/api/authmethods/authmethods.gen.go index 90a244070..9a6cab6f1 100644 --- a/api/authmethods/authmethods.gen.go +++ b/api/authmethods/authmethods.gen.go @@ -34,12 +34,16 @@ func NewAuthMethodsClient(c *api.Client) *AuthMethodsClient { return &AuthMethodsClient{client: c} } -func (c *AuthMethodsClient) Create(ctx context.Context, opt ...Option) (*AuthMethod, *api.Error, error) { +func (c *AuthMethodsClient) Create(ctx context.Context, resourceType string, opt ...Option) (*AuthMethod, *api.Error, error) { + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - - opts, apiOpts := getOpts(opt...) + if resourceType == "" { + return nil, nil, fmt.Errorf("empty resourceType value passed into Create request") + } else { + opts.valueMap["type"] = resourceType + } req, err := c.client.NewRequest(ctx, "POST", "auth-methods", opts.valueMap, apiOpts...) if err != nil { diff --git a/api/groups/group.gen.go b/api/groups/group.gen.go index 9a1298784..0362ee0a3 100644 --- a/api/groups/group.gen.go +++ b/api/groups/group.gen.go @@ -35,12 +35,11 @@ func NewGroupsClient(c *api.Client) *GroupsClient { } func (c *GroupsClient) Create(ctx context.Context, opt ...Option) (*Group, *api.Error, error) { + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - opts, apiOpts := getOpts(opt...) - req, err := c.client.NewRequest(ctx, "POST", "groups", opts.valueMap, apiOpts...) if err != nil { return nil, nil, fmt.Errorf("error creating Create request: %w", err) diff --git a/api/hosts/host.gen.go b/api/hosts/host.gen.go index ca3604c79..364338cb6 100644 --- a/api/hosts/host.gen.go +++ b/api/hosts/host.gen.go @@ -38,13 +38,11 @@ func (c *HostsClient) Create(ctx context.Context, hostCatalogId string, opt ...O if hostCatalogId == "" { return nil, nil, fmt.Errorf("empty hostCatalogId value passed into Create request") } - + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - opts, apiOpts := getOpts(opt...) - req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("host-catalogs/%s/hosts", hostCatalogId), opts.valueMap, apiOpts...) if err != nil { return nil, nil, fmt.Errorf("error creating Create request: %w", err) diff --git a/api/hosts/host_catalog.gen.go b/api/hosts/host_catalog.gen.go index 969303c00..3b699ef11 100644 --- a/api/hosts/host_catalog.gen.go +++ b/api/hosts/host_catalog.gen.go @@ -34,12 +34,16 @@ func NewHostCatalogsClient(c *api.Client) *HostCatalogsClient { return &HostCatalogsClient{client: c} } -func (c *HostCatalogsClient) Create(ctx context.Context, opt ...Option) (*HostCatalog, *api.Error, error) { +func (c *HostCatalogsClient) Create(ctx context.Context, resourceType string, opt ...Option) (*HostCatalog, *api.Error, error) { + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - - opts, apiOpts := getOpts(opt...) + if resourceType == "" { + return nil, nil, fmt.Errorf("empty resourceType value passed into Create request") + } else { + opts.valueMap["type"] = resourceType + } req, err := c.client.NewRequest(ctx, "POST", "host-catalogs", opts.valueMap, apiOpts...) if err != nil { diff --git a/api/hosts/host_set.gen.go b/api/hosts/host_set.gen.go index ce774a7ef..68a15d359 100644 --- a/api/hosts/host_set.gen.go +++ b/api/hosts/host_set.gen.go @@ -39,13 +39,11 @@ func (c *HostSetsClient) Create(ctx context.Context, hostCatalogId string, opt . if hostCatalogId == "" { return nil, nil, fmt.Errorf("empty hostCatalogId value passed into Create request") } - + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - opts, apiOpts := getOpts(opt...) - req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("host-catalogs/%s/host-sets", hostCatalogId), opts.valueMap, apiOpts...) if err != nil { return nil, nil, fmt.Errorf("error creating Create request: %w", err) diff --git a/api/internal/genapi/input.go b/api/internal/genapi/input.go index 98452994e..57903076f 100644 --- a/api/internal/genapi/input.go +++ b/api/internal/genapi/input.go @@ -62,6 +62,10 @@ type structInfo struct { // operations all values are used for the function argument. // For collection based operations the last value is ignored for generating function argument. pathArgs []string + + // typeOnCreate indicates that create will be creating a concrete + // implementation of an abstract type and thus a type field is necessary + typeOnCreate bool } var inputStructs = []*structInfo{ @@ -185,6 +189,7 @@ var inputStructs = []*structInfo{ listTemplate, }, pathArgs: []string{"auth-method"}, + typeOnCreate: true, versionEnabled: true, }, { @@ -236,6 +241,7 @@ var inputStructs = []*structInfo{ listTemplate, }, pathArgs: []string{"host-catalog"}, + typeOnCreate: true, versionEnabled: true, }, { diff --git a/api/internal/genapi/templates.go b/api/internal/genapi/templates.go index 032b22338..d793746d8 100644 --- a/api/internal/genapi/templates.go +++ b/api/internal/genapi/templates.go @@ -70,6 +70,7 @@ type templateInput struct { ResourcePath string SliceSubTypes map[string]string VersionEnabled bool + TypeOnCreate bool } func fillTemplates() { @@ -83,6 +84,7 @@ func fillTemplates() { Fields: in.generatedStructure.fields, PathArgs: in.pathArgs, VersionEnabled: in.versionEnabled, + TypeOnCreate: in.typeOnCreate, } if len(in.pathArgs) > 0 { @@ -292,16 +294,19 @@ func (c *{{ .ClientName }}Client) Delete(ctx context.Context, {{ range .Resource `)) var createTemplate = template.Must(template.New("").Parse(` -func (c *{{ .ClientName }}Client) Create(ctx context.Context, {{ range .CollectionFunctionArgs }} {{ . }} string, {{ end }} opt... Option) (*{{ .Name }}, *api.Error, error) { {{ range .CollectionFunctionArgs }} +func (c *{{ .ClientName }}Client) Create(ctx context.Context, {{ if .TypeOnCreate }} resourceType string, {{ end }} {{ range .CollectionFunctionArgs }} {{ . }} string, {{ end }} opt... Option) (*{{ .Name }}, *api.Error, error) { {{ range .CollectionFunctionArgs }} if {{ . }} == "" { return nil, nil, fmt.Errorf("empty {{ . }} value passed into Create request") } - {{ end }} + {{ end }}opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - - opts, apiOpts := getOpts(opt...) + {{ if .TypeOnCreate }} if resourceType == "" { + return nil, nil, fmt.Errorf("empty resourceType value passed into Create request") + } else { + opts.valueMap["type"] = resourceType + }{{ end }} req, err := c.client.NewRequest(ctx, "POST", {{ .CollectionPath }}, opts.valueMap, apiOpts...) if err != nil { diff --git a/api/output_string.go b/api/output_string.go index af6a481bd..17bb839db 100644 --- a/api/output_string.go +++ b/api/output_string.go @@ -47,7 +47,7 @@ func (d *OutputStringError) parseRequest() { for k, v := range d.Request.Header { for _, h := range v { if strings.ToLower(k) == "authorization" { - h = `Bearer: ` + h = `Bearer ` } d.parsedCurlString = fmt.Sprintf("%s-H \"%s: %s\" ", d.parsedCurlString, k, h) } diff --git a/api/roles/role.gen.go b/api/roles/role.gen.go index 6a3a8c261..974efeed3 100644 --- a/api/roles/role.gen.go +++ b/api/roles/role.gen.go @@ -38,12 +38,11 @@ func NewRolesClient(c *api.Client) *RolesClient { } func (c *RolesClient) Create(ctx context.Context, opt ...Option) (*Role, *api.Error, error) { + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - opts, apiOpts := getOpts(opt...) - req, err := c.client.NewRequest(ctx, "POST", "roles", opts.valueMap, apiOpts...) if err != nil { return nil, nil, fmt.Errorf("error creating Create request: %w", err) diff --git a/api/scopes/scope.gen.go b/api/scopes/scope.gen.go index cb2e219ff..222b3689d 100644 --- a/api/scopes/scope.gen.go +++ b/api/scopes/scope.gen.go @@ -35,13 +35,11 @@ func (c *ScopesClient) Create(ctx context.Context, scopeId string, opt ...Option if scopeId == "" { return nil, nil, fmt.Errorf("empty scopeId value passed into Create request") } - + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - opts, apiOpts := getOpts(opt...) - req, err := c.client.NewRequest(ctx, "POST", "scopes", opts.valueMap, apiOpts...) if err != nil { return nil, nil, fmt.Errorf("error creating Create request: %w", err) diff --git a/api/users/user.gen.go b/api/users/user.gen.go index 9785b923b..07e62fd62 100644 --- a/api/users/user.gen.go +++ b/api/users/user.gen.go @@ -33,12 +33,11 @@ func NewUsersClient(c *api.Client) *UsersClient { } func (c *UsersClient) Create(ctx context.Context, opt ...Option) (*User, *api.Error, error) { + opts, apiOpts := getOpts(opt...) if c.client == nil { return nil, nil, fmt.Errorf("nil client") } - opts, apiOpts := getOpts(opt...) - req, err := c.client.NewRequest(ctx, "POST", "users", opts.valueMap, apiOpts...) if err != nil { return nil, nil, fmt.Errorf("error creating Create request: %w", err) diff --git a/internal/cmd/base/base.go b/internal/cmd/base/base.go index 1e0c73d3a..eafc29128 100644 --- a/internal/cmd/base/base.go +++ b/internal/cmd/base/base.go @@ -104,12 +104,14 @@ func MakeShutdownCh() chan struct{} { // Client returns the HTTP API client. The client is cached on the command to // save performance on future calls. -func (c *Command) Client() (*api.Client, error) { +func (c *Command) Client(opt ...Option) (*api.Client, error) { // Read the test client if present if c.client != nil { return c.client, nil } + opts := getOpts(opt...) + config, err := api.DefaultConfig() if err != nil { return nil, err @@ -194,7 +196,9 @@ func (c *Command) Client() (*api.Client, error) { c.UI.Error(fmt.Sprintf("Error unmarshaling stored token information after reading from system credential store: %s", err)) } else { c.client.SetToken(authToken.Token) - c.client.SetScopeId(authToken.Scope.Id) + if !opts.withNoTokenScope { + c.client.SetScopeId(authToken.Scope.Id) + } } } } @@ -211,7 +215,7 @@ func (c *Command) Client() (*api.Client, error) { c.UI.Info(fmt.Sprintf("Scope of %q set from -scope command flag", c.flagScope)) } } - } else if c.client.ScopeId() != "" { + } else if c.client.ScopeId() != "" && !opts.withNoTokenScope { // If it didn't come from env or a flag but isn't empty, it must have come from the token if c.flagFormat == "table" && c.flagVerbose { c.UI.Info(fmt.Sprintf("Scope of %q set from saved token with name %q", c.client.ScopeId(), tokenName)) diff --git a/internal/cmd/base/format.go b/internal/cmd/base/format.go index 076035668..82938acd3 100644 --- a/internal/cmd/base/format.go +++ b/internal/cmd/base/format.go @@ -54,6 +54,29 @@ func WrapForHelpText(lines []string) string { return strings.Join(ret, "\n") } +func WrapMap(prefixSpaces, maxLengthOverride int, input map[string]interface{}) string { + maxKeyLength := maxLengthOverride + if maxKeyLength == 0 { + for k := range input { + if len(k) > maxKeyLength { + maxKeyLength = len(k) + } + } + } + var ret []string + for k, v := range input { + spaces := maxKeyLength - len(k) + ret = append(ret, fmt.Sprintf("%s%s%s%s", + strings.Repeat(" ", prefixSpaces), + fmt.Sprintf("%s: ", k), + strings.Repeat(" ", spaces), + fmt.Sprintf("%v", v)), + ) + } + + return strings.Join(ret, "\n") +} + type FormatOptions struct { Format string } diff --git a/internal/cmd/base/option.go b/internal/cmd/base/option.go new file mode 100644 index 000000000..c0b33b868 --- /dev/null +++ b/internal/cmd/base/option.go @@ -0,0 +1,31 @@ +package base + +// getOpts - iterate the inbound Options and return a struct. +func getOpts(opt ...Option) Options { + opts := getDefaultOptions() + for _, o := range opt { + o(&opts) + } + return opts +} + +// Option - how Options are passed as arguments. +type Option func(*Options) + +// Options - how Options are represented. +type Options struct { + withNoTokenScope bool +} + +func getDefaultOptions() Options { + return Options{} +} + +// WithNoTokenScope tells the client not to set a scope for the client from a +// saved token's scope, as this can cause confusing behavior at authentication +// time. +func WithNoTokenScope() Option { + return func(o *Options) { + o.withNoTokenScope = true + } +} diff --git a/internal/cmd/commands.go b/internal/cmd/commands.go index ba1403352..02525a1ad 100644 --- a/internal/cmd/commands.go +++ b/internal/cmd/commands.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/commands/authenticate" + "github.com/hashicorp/boundary/internal/cmd/commands/authmethods" "github.com/hashicorp/boundary/internal/cmd/commands/authtokens" "github.com/hashicorp/boundary/internal/cmd/commands/config" "github.com/hashicorp/boundary/internal/cmd/commands/controller" @@ -68,6 +69,49 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { }, nil }, + "auth-methods": func() (cli.Command, error) { + return &authmethods.Command{ + Command: base.NewCommand(ui), + }, nil + }, + "auth-methods read": func() (cli.Command, error) { + return &authmethods.Command{ + Command: base.NewCommand(ui), + Func: "read", + }, nil + }, + "auth-methods delete": func() (cli.Command, error) { + return &authmethods.Command{ + Command: base.NewCommand(ui), + Func: "delete", + }, nil + }, + "auth-methods list": func() (cli.Command, error) { + return &authmethods.Command{ + Command: base.NewCommand(ui), + Func: "list", + }, nil + }, + "auth-methods password": func() (cli.Command, error) { + return &authmethods.Command{ + Command: base.NewCommand(ui), + Func: "password", + }, nil + }, + "auth-methods password create": func() (cli.Command, error) { + return &authmethods.PasswordCommand{ + Command: base.NewCommand(ui), + Func: "create", + }, nil + }, + + "auth-methods password update": func() (cli.Command, error) { + return &authmethods.PasswordCommand{ + Command: base.NewCommand(ui), + Func: "update", + }, nil + }, + "auth-tokens": func() (cli.Command, error) { return &authtokens.Command{ Command: base.NewCommand(ui), diff --git a/internal/cmd/commands/authenticate/password.go b/internal/cmd/commands/authenticate/password.go index 657a8b36a..6b4166441 100644 --- a/internal/cmd/commands/authenticate/password.go +++ b/internal/cmd/commands/authenticate/password.go @@ -112,7 +112,7 @@ func (c *PasswordCommand) Run(args []string) int { c.flagPassword = strings.TrimSpace(value) } - client, err := c.Client() + client, err := c.Client(base.WithNoTokenScope()) if err != nil { c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error())) return 2 diff --git a/internal/cmd/commands/authmethods/authmethod.go b/internal/cmd/commands/authmethods/authmethod.go new file mode 100644 index 000000000..c64a9894b --- /dev/null +++ b/internal/cmd/commands/authmethods/authmethod.go @@ -0,0 +1,240 @@ +package authmethods + +import ( + "fmt" + + "github.com/hashicorp/boundary/api" + "github.com/hashicorp/boundary/api/authmethods" + "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/cmd/common" + "github.com/hashicorp/boundary/internal/types/resource" + "github.com/hashicorp/vault/sdk/helper/strutil" + "github.com/kr/pretty" + "github.com/mitchellh/cli" + "github.com/posener/complete" +) + +var _ cli.Command = (*Command)(nil) +var _ cli.CommandAutocomplete = (*Command)(nil) + +type Command struct { + *base.Command + + Func string +} + +func (c *Command) Synopsis() string { + if c.Func == "password" { + return "Manage password auth-methods within Boundary" + } + return common.SynopsisFunc(c.Func, "auth-method") +} + +var flagsMap = map[string][]string{ + "read": {"id"}, + "delete": {"id"}, +} + +func (c *Command) Help() string { + helpMap := common.HelpMap("auth-method") + switch c.Func { + case "": + return base.WrapForHelpText([]string{ + "Usage: boundary auth-methods [sub command] [options] [args]", + "", + " This command allows operations on Boundary auth-method resources. Example:", + "", + " Read an auth-method:", + "", + ` $ boundary auth-methods read -id paum_1234567890`, + "", + " Please see the auth-methods subcommand help for detailed usage information.", + }) + case "password": + return base.WrapForHelpText([]string{ + "Usage: boundary auth-methods password [sub command] [options] [args]", + "", + " This command allows operations on Boundary password-type auth-method resources. Example:", + "", + " Create a password-type auth-method:", + "", + ` $ boundary auth-methods pasword create -name prodops -description "For ProdOps usage"`, + "", + " Please see the subcommand help for detailed usage information.", + }) + default: + return helpMap[c.Func]() + c.Flags().Help() + } +} + +func (c *Command) Flags() *base.FlagSets { + set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat) + + if len(flagsMap[c.Func]) > 0 { + f := set.NewFlagSet("Command Options") + common.PopulateCommonFlags(c.Command, f, resource.User.String(), flagsMap[c.Func]) + } + + return set +} + +func (c *Command) AutocompleteArgs() complete.Predictor { + return complete.PredictAnything +} + +func (c *Command) AutocompleteFlags() complete.Flags { + return c.Flags().Completions() +} + +func (c *Command) Run(args []string) int { + if c.Func == "" || c.Func == "password" { + return cli.RunResultHelp + } + + f := c.Flags() + + if err := f.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if strutil.StrListContains(flagsMap[c.Func], "id") && c.FlagId == "" { + c.UI.Error("ID is required but not passed in via -id") + return 1 + } + + client, err := c.Client() + if err != nil { + c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error())) + return 2 + } + + var opts []authmethods.Option + + switch c.FlagName { + case "": + case "null": + opts = append(opts, authmethods.DefaultName()) + default: + opts = append(opts, authmethods.WithName(c.FlagName)) + } + + switch c.FlagDescription { + case "": + case "null": + opts = append(opts, authmethods.DefaultDescription()) + default: + opts = append(opts, authmethods.WithDescription(c.FlagDescription)) + } + + authmethodClient := authmethods.NewAuthMethodsClient(client) + + var existed bool + var method *authmethods.AuthMethod + var listedMethods []*authmethods.AuthMethod + var apiErr *api.Error + + switch c.Func { + case "read": + method, apiErr, err = authmethodClient.Read(c.Context, c.FlagId, opts...) + case "delete": + existed, apiErr, err = authmethodClient.Delete(c.Context, c.FlagId, opts...) + case "list": + listedMethods, apiErr, err = authmethodClient.List(c.Context, opts...) + } + + plural := "auth method" + if c.Func == "list" { + plural = "auth methods" + } + if err != nil { + c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error())) + return 2 + } + if apiErr != nil { + c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr))) + return 1 + } + + switch c.Func { + case "delete": + switch base.Format(c.UI) { + case "json": + c.UI.Output("null") + case "table": + output := "The delete operation completed successfully" + switch existed { + case true: + output += "." + default: + output += ", however the resource did not exist at the time." + } + c.UI.Output(output) + } + return 0 + + case "list": + switch base.Format(c.UI) { + case "json": + if len(listedMethods) == 0 { + c.UI.Output("null") + return 0 + } + b, err := base.JsonFormatter{}.Format(listedMethods) + if err != nil { + c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error()) + return 1 + } + c.UI.Output(string(b)) + + case "table": + if len(listedMethods) == 0 { + c.UI.Output("No auth methods found") + return 0 + } + var output []string + output = []string{ + "", + "Auth Method information:", + } + for i, m := range listedMethods { + if i > 0 { + output = append(output, "") + } + if true { + output = append(output, + fmt.Sprintf(" ID: %s", m.Id), + fmt.Sprintf(" Version: %d", m.Version), + fmt.Sprintf(" Type: %s", m.Type), + ) + } + if m.Name != "" { + output = append(output, + fmt.Sprintf(" Name: %s", m.Name), + ) + } + if m.Description != "" { + output = append(output, + fmt.Sprintf(" Description: %s", m.Description), + ) + } + } + c.UI.Output(base.WrapForHelpText(output)) + } + return 0 + } + + switch base.Format(c.UI) { + case "table": + c.UI.Output(generateAuthMethodTableOutput(method)) + case "json": + b, err := base.JsonFormatter{}.Format(method) + if err != nil { + c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error()) + return 1 + } + c.UI.Output(string(b)) + } + + return 0 +} diff --git a/internal/cmd/commands/authmethods/funcs.go b/internal/cmd/commands/authmethods/funcs.go new file mode 100644 index 000000000..6b0ab6eca --- /dev/null +++ b/internal/cmd/commands/authmethods/funcs.go @@ -0,0 +1,86 @@ +package authmethods + +import ( + "fmt" + "time" + + "github.com/hashicorp/boundary/api/authmethods" + "github.com/hashicorp/boundary/internal/cmd/base" +) + +func addPasswordFlags(c *PasswordCommand, f *base.FlagSet) { + f.StringVar(&base.StringVar{ + Name: "min-login-name-length", + Target: &c.flagMinLoginNameLength, + Usage: "The minimum length of login names", + }) + f.StringVar(&base.StringVar{ + Name: "min-password-length", + Target: &c.flagMinPasswordLength, + Usage: "The minimum length of passwords", + }) +} + +func generateAuthMethodTableOutput(in *authmethods.AuthMethod) string { + var ret []string + + nonAttributeMap := map[string]interface{}{ + "ID": in.Id, + "Version": in.Version, + "Type": in.Type, + "Created Time": in.CreatedTime.Local().Format(time.RFC3339), + "Updated Time": in.UpdatedTime.Local().Format(time.RFC3339), + } + + if in.Name != "" { + nonAttributeMap["Name"] = in.Name + } + if in.Description != "" { + nonAttributeMap["Description"] = in.Description + } + + maxLength := 0 + for k := range nonAttributeMap { + if len(k) > maxLength { + maxLength = len(k) + } + } + if len(in.Attributes) > 0 { + for k, v := range in.Attributes { + if attributeMap[k] != "" { + in.Attributes[attributeMap[k]] = v + delete(in.Attributes, k) + } + } + for k := range in.Attributes { + if len(k) > maxLength { + maxLength = len(k) + } + } + } + + ret = append(ret, "", "User information:") + + ret = append(ret, + // We do +2 because there is another +2 offset for attributes below + base.WrapMap(2, maxLength+2, nonAttributeMap), + ) + + if len(in.Attributes) > 0 { + if true { + ret = append(ret, + fmt.Sprintf(" Attributes: %s", ""), + ) + } + ret = append(ret, + base.WrapMap(4, maxLength, in.Attributes), + ) + } + + return base.WrapForHelpText(ret) +} + +var attributeMap = map[string]string{ + "min_login_name_length": "Minimum Login Name Length", + "min_password_length": "Minimum Password Length", +} diff --git a/internal/cmd/commands/authmethods/password.go b/internal/cmd/commands/authmethods/password.go new file mode 100644 index 000000000..0716f2229 --- /dev/null +++ b/internal/cmd/commands/authmethods/password.go @@ -0,0 +1,216 @@ +package authmethods + +import ( + "fmt" + "net/textproto" + "strconv" + + "github.com/hashicorp/boundary/api" + "github.com/hashicorp/boundary/api/authmethods" + "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/cmd/common" + "github.com/hashicorp/vault/sdk/helper/strutil" + "github.com/kr/pretty" + "github.com/mitchellh/cli" + "github.com/posener/complete" +) + +var _ cli.Command = (*PasswordCommand)(nil) +var _ cli.CommandAutocomplete = (*PasswordCommand)(nil) + +type PasswordCommand struct { + *base.Command + + Func string + + flagMinLoginNameLength string + flagMinPasswordLength string +} + +func (c *PasswordCommand) Synopsis() string { + return fmt.Sprintf("%s a password-type auth-method within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func)) +} + +var passwordFlagsMap = map[string][]string{ + "create": {"name", "description"}, + "update": {"id", "name", "description", "version"}, +} + +func (c *PasswordCommand) Help() string { + var info string + switch c.Func { + case "create": + info = base.WrapForHelpText([]string{ + "Usage: boundary auth-methods password create [options] [args]", + "", + " Create a password-type auth-method. Example:", + "", + ` $ boundary auth-methods password create -name prodops -description "Password auth-method for ProdOps"`, + "", + "", + }) + + case "update": + info = base.WrapForHelpText([]string{ + "Usage: boundary auth-methods password update [options] [args]", + "", + " Update a password-type auth-method given its ID. Example:", + "", + ` $ boundary auth-methods password update -id paum_1234567890 -name "devops" -description "Password auth-method for DevOps"`, + "", + "", + }) + } + return info + c.Flags().Help() +} + +func (c *PasswordCommand) Flags() *base.FlagSets { + set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat) + + if len(passwordFlagsMap[c.Func]) > 0 { + f := set.NewFlagSet("Command Options") + common.PopulateCommonFlags(c.Command, f, "password-type auth-method", passwordFlagsMap[c.Func]) + } + + f := set.NewFlagSet("Password Auth-Method Options") + addPasswordFlags(c, f) + + return set +} + +func (c *PasswordCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictAnything +} + +func (c *PasswordCommand) AutocompleteFlags() complete.Flags { + return c.Flags().Completions() +} + +func (c *PasswordCommand) Run(args []string) int { + if c.Func == "" { + return cli.RunResultHelp + } + + f := c.Flags() + + if err := f.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if strutil.StrListContains(passwordFlagsMap[c.Func], "id") && c.FlagId == "" { + c.UI.Error("ID is required but not passed in via -id") + return 1 + } + + client, err := c.Client() + if err != nil { + c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error())) + return 2 + } + + var opts []authmethods.Option + + switch c.FlagName { + case "": + case "null": + opts = append(opts, authmethods.DefaultName()) + default: + opts = append(opts, authmethods.WithName(c.FlagName)) + } + + switch c.FlagDescription { + case "": + case "null": + opts = append(opts, authmethods.DefaultDescription()) + default: + opts = append(opts, authmethods.WithDescription(c.FlagDescription)) + } + + var attributes map[string]interface{} + addAttribute := func(name string, value interface{}) { + if attributes == nil { + attributes = make(map[string]interface{}) + } + attributes[name] = value + } + switch c.flagMinLoginNameLength { + case "": + case "null": + addAttribute("min_login_name_length", nil) + default: + length, err := strconv.ParseUint(c.flagMinLoginNameLength, 10, 32) + if err != nil { + c.UI.Error(fmt.Sprintf("Error parsing %q: %s", c.flagMinLoginNameLength, err)) + return 1 + } + addAttribute("min_login_name_length", uint32(length)) + } + + switch c.flagMinPasswordLength { + case "": + case "null": + addAttribute("min_password_length", nil) + default: + length, err := strconv.ParseUint(c.flagMinPasswordLength, 10, 32) + if err != nil { + c.UI.Error(fmt.Sprintf("Error parsing %q: %s", c.flagMinPasswordLength, err)) + return 1 + } + addAttribute("min_password_length", uint32(length)) + } + + if attributes != nil { + opts = append(opts, authmethods.WithAttributes(attributes)) + } + + authmethodClient := authmethods.NewAuthMethodsClient(client) + + // Perform check-and-set when needed + var version uint32 + switch c.Func { + case "create": + // These don't update so don't need the existing version + default: + switch c.FlagVersion { + case 0: + opts = append(opts, authmethods.WithAutomaticVersioning()) + default: + version = uint32(c.FlagVersion) + } + } + + var method *authmethods.AuthMethod + var apiErr *api.Error + + switch c.Func { + case "create": + method, apiErr, err = authmethodClient.Create(c.Context, "password", opts...) + case "update": + method, apiErr, err = authmethodClient.Update(c.Context, c.FlagId, version, opts...) + } + + plural := "password-type auth-method" + if err != nil { + c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error())) + return 2 + } + if apiErr != nil { + c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr))) + return 1 + } + + switch base.Format(c.UI) { + case "table": + c.UI.Output(generateAuthMethodTableOutput(method)) + case "json": + b, err := base.JsonFormatter{}.Format(method) + if err != nil { + c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error()) + return 1 + } + c.UI.Output(string(b)) + } + + return 0 +} diff --git a/internal/cmd/commands/authtokens/authtokens.go b/internal/cmd/commands/authtokens/authtokens.go index f40f6cee5..08e39ae96 100644 --- a/internal/cmd/commands/authtokens/authtokens.go +++ b/internal/cmd/commands/authtokens/authtokens.go @@ -38,7 +38,7 @@ func (c *Command) Help() string { if c.Func == "" { return helpMap["base"]() } - return helpMap[c.Func]() + "\n\n" + c.Flags().Help() + return helpMap[c.Func]() + c.Flags().Help() } func (c *Command) Flags() *base.FlagSets { @@ -46,7 +46,7 @@ func (c *Command) Flags() *base.FlagSets { if len(flagsMap[c.Func]) > 0 { f := set.NewFlagSet("Command Options") - common.PopulateCommonFlags(c.Command, f, resource.AuthToken, flagsMap[c.Func]) + common.PopulateCommonFlags(c.Command, f, resource.AuthToken.String(), flagsMap[c.Func]) } return set diff --git a/internal/cmd/commands/groups/funcs.go b/internal/cmd/commands/groups/funcs.go index cc083f13b..ce25e07bf 100644 --- a/internal/cmd/commands/groups/funcs.go +++ b/internal/cmd/commands/groups/funcs.go @@ -56,7 +56,7 @@ func removeMembersHelp() string { } func populateFlags(c *Command, f *base.FlagSet, flagNames []string) { - common.PopulateCommonFlags(c.Command, f, resource.Group, flagNames) + common.PopulateCommonFlags(c.Command, f, resource.Group.String(), flagNames) for _, name := range flagNames { switch name { diff --git a/internal/cmd/commands/groups/group.go b/internal/cmd/commands/groups/group.go index 446c69749..0c09bd3a5 100644 --- a/internal/cmd/commands/groups/group.go +++ b/internal/cmd/commands/groups/group.go @@ -57,7 +57,7 @@ func (c *Command) Help() string { if c.Func == "" { return hm["base"]() } - return hm[c.Func]() + "\n\n" + c.Flags().Help() + return hm[c.Func]() + c.Flags().Help() } func (c *Command) Flags() *base.FlagSets { diff --git a/internal/cmd/commands/roles/funcs.go b/internal/cmd/commands/roles/funcs.go index 484db5872..d28c9468e 100644 --- a/internal/cmd/commands/roles/funcs.go +++ b/internal/cmd/commands/roles/funcs.go @@ -60,7 +60,7 @@ func removePrincipalsHelp() string { } func populateFlags(c *Command, f *base.FlagSet, flagNames []string) { - common.PopulateCommonFlags(c.Command, f, resource.Role, flagNames) + common.PopulateCommonFlags(c.Command, f, resource.Role.String(), flagNames) for _, name := range flagNames { switch name { diff --git a/internal/cmd/commands/roles/role.go b/internal/cmd/commands/roles/role.go index 7cea501a8..857a0beb4 100644 --- a/internal/cmd/commands/roles/role.go +++ b/internal/cmd/commands/roles/role.go @@ -68,7 +68,7 @@ func (c *Command) Help() string { if c.Func == "" { return hm["base"]() } - return hm[c.Func]() + "\n\n" + c.Flags().Help() + return hm[c.Func]() + c.Flags().Help() } func (c *Command) Flags() *base.FlagSets { diff --git a/internal/cmd/commands/scopes/scope.go b/internal/cmd/commands/scopes/scope.go index 4e03cbd2a..cf5369622 100644 --- a/internal/cmd/commands/scopes/scope.go +++ b/internal/cmd/commands/scopes/scope.go @@ -39,7 +39,7 @@ func (c *Command) Help() string { if c.Func == "" { return helpMap["base"]() } - return helpMap[c.Func]() + "\n\n" + c.Flags().Help() + return helpMap[c.Func]() + c.Flags().Help() } func (c *Command) Flags() *base.FlagSets { @@ -47,7 +47,7 @@ func (c *Command) Flags() *base.FlagSets { if len(flagsMap[c.Func]) > 0 { f := set.NewFlagSet("Command Options") - common.PopulateCommonFlags(c.Command, f, resource.Scope, flagsMap[c.Func]) + common.PopulateCommonFlags(c.Command, f, resource.Scope.String(), flagsMap[c.Func]) } return set diff --git a/internal/cmd/commands/users/user.go b/internal/cmd/commands/users/user.go index 32ffdcae2..8ca9423f1 100644 --- a/internal/cmd/commands/users/user.go +++ b/internal/cmd/commands/users/user.go @@ -39,7 +39,7 @@ func (c *Command) Help() string { if c.Func == "" { return helpMap["base"]() } - return helpMap[c.Func]() + "\n\n" + c.Flags().Help() + return helpMap[c.Func]() + c.Flags().Help() } func (c *Command) Flags() *base.FlagSets { @@ -47,7 +47,7 @@ func (c *Command) Flags() *base.FlagSets { if len(flagsMap[c.Func]) > 0 { f := set.NewFlagSet("Command Options") - common.PopulateCommonFlags(c.Command, f, resource.User, flagsMap[c.Func]) + common.PopulateCommonFlags(c.Command, f, resource.User.String(), flagsMap[c.Func]) } return set diff --git a/internal/cmd/common/flags.go b/internal/cmd/common/flags.go index ef47a516b..c30ce8111 100644 --- a/internal/cmd/common/flags.go +++ b/internal/cmd/common/flags.go @@ -4,35 +4,34 @@ import ( "fmt" "github.com/hashicorp/boundary/internal/cmd/base" - "github.com/hashicorp/boundary/internal/types/resource" ) -func PopulateCommonFlags(c *base.Command, f *base.FlagSet, resourceType resource.Type, flagNames []string) { +func PopulateCommonFlags(c *base.Command, f *base.FlagSet, resourceType string, flagNames []string) { for _, name := range flagNames { switch name { case "id": f.StringVar(&base.StringVar{ Name: "id", Target: &c.FlagId, - Usage: fmt.Sprintf("ID of the %s on which to operate", resourceType.String()), + Usage: fmt.Sprintf("ID of the %s on which to operate", resourceType), }) case "name": f.StringVar(&base.StringVar{ Name: "name", Target: &c.FlagName, - Usage: fmt.Sprintf("Name to set on the %s", resourceType.String()), + Usage: fmt.Sprintf("Name to set on the %s", resourceType), }) case "description": f.StringVar(&base.StringVar{ Name: "description", Target: &c.FlagDescription, - Usage: fmt.Sprintf("Description to set on the %s", resourceType.String()), + Usage: fmt.Sprintf("Description to set on the %s", resourceType), }) case "version": f.IntVar(&base.IntVar{ Name: "version", Target: &c.FlagVersion, - Usage: fmt.Sprintf("The version of the %s against which to perform an update operation. If not specified, the command will perform a check-and-set automatically.", resourceType.String()), + Usage: fmt.Sprintf("The version of the %s against which to perform an update operation. If not specified, the command will perform a check-and-set automatically.", resourceType), }) } } diff --git a/internal/cmd/common/help.go b/internal/cmd/common/help.go index b6858a4ca..a30bba090 100644 --- a/internal/cmd/common/help.go +++ b/internal/cmd/common/help.go @@ -38,7 +38,7 @@ func HelpMap(resType string) map[string]func() string { return base.WrapForHelpText(subType([]string{ "Usage: boundary {{type}}s [sub command] [options] [args]", "", - " This command allows operations on Boundary {{type}} resources. Examples", + " This command allows operations on Boundary {{type}} resources. Example:", "", " Create {{articletype}}:", "", @@ -67,6 +67,8 @@ func HelpMap(resType string) map[string]func() string { " Update {{articletype}} given its ID. Example:", "", ` $ boundary {{type}}s update -id {{prefix}}_1234567890 -name "devops" -description "{{uppertype}} for DevOps"`, + "", + "", }, resType, prefixMap)) }, @@ -77,6 +79,8 @@ func HelpMap(resType string) map[string]func() string { " Read {{articletype}} given its ID. Example:", "", ` $ boundary {{type}}s read -id {{prefix}}_1234567890`, + "", + "", }, resType, prefixMap)) }, @@ -87,6 +91,8 @@ func HelpMap(resType string) map[string]func() string { " Delete {{articletype}} given its ID. Example:", "", ` $ boundary {{type}}s delete -id {{prefix}}_1234567890`, + "", + "", }, resType, prefixMap)) }, @@ -97,6 +103,8 @@ func HelpMap(resType string) map[string]func() string { " List {{type}}s within an enclosing scope or resource. Example:", "", ` $ boundary {{type}}s list`, + "", + "", }, resType, prefixMap)) }, } diff --git a/internal/gen/controller.swagger.json b/internal/gen/controller.swagger.json index dddeaa562..647b869ee 100644 --- a/internal/gen/controller.swagger.json +++ b/internal/gen/controller.swagger.json @@ -65,6 +65,12 @@ "schema": { "$ref": "#/definitions/controller.api.resources.scopes.v1.Scope" } + }, + { + "name": "scope_id", + "in": "query", + "required": false, + "type": "string" } ], "tags": [ @@ -280,6 +286,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.authmethods.v1.Account" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -477,6 +500,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.authmethods.v1.AuthMethod" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -691,6 +731,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.groups.v1.Group" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -724,6 +781,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.GroupMemberIdsMessage" } + }, + { + "name": "version", + "description": "The version ensures the group hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -757,6 +822,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.GroupMemberIdsMessage" } + }, + { + "name": "version", + "description": "The version ensures the group hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -790,6 +863,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.GroupMemberIdsMessage" } + }, + { + "name": "version", + "description": "The version ensures the group hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -1006,6 +1087,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.hosts.v1.HostSet" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -1268,6 +1366,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.hosts.v1.Host" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -1354,6 +1469,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.hosts.v1.HostCatalog" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -1489,6 +1621,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.roles.v1.Role" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -1522,6 +1671,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.GrantStringsMessage" } + }, + { + "name": "version", + "description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -1555,6 +1712,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.PrincipalIdsMessage" } + }, + { + "name": "version", + "description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -1588,6 +1753,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.GrantStringsMessage" } + }, + { + "name": "version", + "description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -1621,6 +1794,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.PrincipalIdsMessage" } + }, + { + "name": "version", + "description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -1654,6 +1835,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.GrantStringsMessage" } + }, + { + "name": "version", + "description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -1687,6 +1876,14 @@ "schema": { "$ref": "#/definitions/controller.api.services.v1.PrincipalIdsMessage" } + }, + { + "name": "version", + "description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail.", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" } ], "tags": [ @@ -1822,6 +2019,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.users.v1.User" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -1907,6 +2121,23 @@ "schema": { "$ref": "#/definitions/controller.api.resources.scopes.v1.Scope" } + }, + { + "name": "version", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" } ], "tags": [ @@ -3272,20 +3503,6 @@ }, "title": "Timestamp for storage messages. We've defined a new local type wrapper\nof google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer\ninterfaces. See:\nhttps://golang.org/pkg/database/sql/#Scanner\nhttps://golang.org/pkg/database/sql/driver/#Valuer" }, - "google.protobuf.FieldMask": { - "type": "object", - "properties": { - "paths": { - "type": "array", - "items": { - "type": "string" - }, - "description": "The set of field mask paths." - } - }, - "description": "paths: \"f.a\"\n paths: \"f.b.d\"\n\nHere `f` represents a field in some root message, `a` and `b`\nfields in the message found in `f`, and `d` a field found in the\nmessage in `f.b`.\n\nField masks are used to specify a subset of fields that should be\nreturned by a get operation or modified by an update operation.\nField masks also have a custom JSON encoding (see below).\n\n# Field Masks in Projections\n\nWhen used in the context of a projection, a response message or\nsub-message is filtered by the API to only contain those fields as\nspecified in the mask. For example, if the mask in the previous\nexample is applied to a response message as follows:\n\n f {\n a : 22\n b {\n d : 1\n x : 2\n }\n y : 13\n }\n z: 8\n\nThe result will not contain specific values for fields x,y and z\n(their value will be set to the default, and omitted in proto text\noutput):\n\n\n f {\n a : 22\n b {\n d : 1\n }\n }\n\nA repeated field is not allowed except at the last position of a\npaths string.\n\nIf a FieldMask object is not present in a get operation, the\noperation applies to all fields (as if a FieldMask of all fields\nhad been specified).\n\nNote that a field mask does not necessarily apply to the\ntop-level response message. In case of a REST get operation, the\nfield mask applies directly to the response, but in case of a REST\nlist operation, the mask instead applies to each individual message\nin the returned resource list. In case of a REST custom method,\nother definitions may be used. Where the mask applies will be\nclearly documented together with its declaration in the API. In\nany case, the effect on the returned resource/resources is required\nbehavior for APIs.\n\n# Field Masks in Update Operations\n\nA field mask in update operations specifies which fields of the\ntargeted resource are going to be updated. The API is required\nto only change the values of the fields as specified in the mask\nand leave the others untouched. If a resource is passed in to\ndescribe the updated values, the API ignores the values of all\nfields not covered by the mask.\n\nIf a repeated field is specified for an update operation, new values will\nbe appended to the existing repeated field in the target resource. Note that\na repeated field is only allowed in the last position of a `paths` string.\n\nIf a sub-message is specified in the last position of the field mask for an\nupdate operation, then new value will be merged into the existing sub-message\nin the target resource.\n\nFor example, given the target message:\n\n f {\n b {\n d: 1\n x: 2\n }\n c: [1]\n }\n\nAnd an update message:\n\n f {\n b {\n d: 10\n }\n c: [2]\n }\n\nthen if the field mask is:\n\n paths: [\"f.b\", \"f.c\"]\n\nthen the result will be:\n\n f {\n b {\n d: 10\n x: 2\n }\n c: [1, 2]\n }\n\nAn implementation may provide options to override this default behavior for\nrepeated and message fields.\n\nIn order to reset a field's value to the default, the field must\nbe in the mask and set to the default value in the provided resource.\nHence, in order to reset all fields of a resource, provide a default\ninstance of the resource and set all fields in the mask, or do\nnot provide a mask as described below.\n\nIf a field mask is not present on update, the operation applies to\nall fields (as if a field mask of all fields has been specified).\nNote that in the presence of schema evolution, this may mean that\nfields the client does not know and has therefore not filled into\nthe request will be reset to their default. If this is unwanted\nbehavior, a specific service may require a client to always specify\na field mask, producing an error if not.\n\nAs with get operations, the location of the resource which\ndescribes the updated values in the request message depends on the\noperation kind. In any case, the effect of the field mask is\nrequired to be honored by the API.\n\n## Considerations for HTTP REST\n\nThe HTTP kind of an update operation which uses a field mask must\nbe set to PATCH instead of PUT in order to satisfy HTTP semantics\n(PUT must only be used for full updates).\n\n# JSON Encoding of Field Masks\n\nIn JSON, a field mask is encoded as a single string where paths are\nseparated by a comma. Fields name in each path are converted\nto/from lower-camel naming conventions.\n\nAs an example, consider the following message declarations:\n\n message Profile {\n User user = 1;\n Photo photo = 2;\n }\n message User {\n string display_name = 1;\n string address = 2;\n }\n\nIn proto a field mask for `Profile` may look as such:\n\n mask {\n paths: \"user.display_name\"\n paths: \"photo\"\n }\n\nIn JSON, the same mask is represented as below:\n\n {\n mask: \"user.displayName,photo\"\n }\n\n# Field Masks and Oneof Fields\n\nField masks treat fields in oneofs just as regular fields. Consider the\nfollowing message:\n\n message SampleMessage {\n oneof test_oneof {\n string name = 4;\n SubMessage sub_message = 9;\n }\n }\n\nThe field mask can be:\n\n mask {\n paths: \"name\"\n }\n\nOr:\n\n mask {\n paths: \"sub_message\"\n }\n\nNote that oneof type names (\"test_oneof\" in this case) cannot be used in\npaths.\n\n## Field Mask Verification\n\nThe implementation of any API method which has a FieldMask type field in the\nrequest should verify the included field paths, and return an\n`INVALID_ARGUMENT` error if any path is unmappable.", - "title": "`FieldMask` represents a set of symbolic field paths, for example:" - }, "google.protobuf.NullValue": { "type": "string", "enum": [ diff --git a/internal/gen/controller/api/services/account_service.pb.gw.go b/internal/gen/controller/api/services/account_service.pb.gw.go index 7b7a30ff4..38dc25400 100644 --- a/internal/gen/controller/api/services/account_service.pb.gw.go +++ b/internal/gen/controller/api/services/account_service.pb.gw.go @@ -50,7 +50,6 @@ func request_AccountService_GetAccount_0(ctx context.Context, marshaler runtime. } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -61,7 +60,6 @@ func request_AccountService_GetAccount_0(ctx context.Context, marshaler runtime. } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -95,7 +93,6 @@ func local_request_AccountService_GetAccount_0(ctx context.Context, marshaler ru } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -106,7 +103,6 @@ func local_request_AccountService_GetAccount_0(ctx context.Context, marshaler ru } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -144,7 +140,6 @@ func request_AccountService_ListAccounts_0(ctx context.Context, marshaler runtim } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -178,7 +173,6 @@ func local_request_AccountService_ListAccounts_0(ctx context.Context, marshaler } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -220,7 +214,6 @@ func request_AccountService_CreateAccount_0(ctx context.Context, marshaler runti } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -255,7 +248,6 @@ func local_request_AccountService_CreateAccount_0(ctx context.Context, marshaler } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -301,7 +293,6 @@ func request_AccountService_UpdateAccount_0(ctx context.Context, marshaler runti } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -312,7 +303,6 @@ func request_AccountService_UpdateAccount_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -361,7 +351,6 @@ func local_request_AccountService_UpdateAccount_0(ctx context.Context, marshaler } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -372,7 +361,6 @@ func local_request_AccountService_UpdateAccount_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -406,7 +394,6 @@ func request_AccountService_DeleteAccount_0(ctx context.Context, marshaler runti } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -417,7 +404,6 @@ func request_AccountService_DeleteAccount_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -444,7 +430,6 @@ func local_request_AccountService_DeleteAccount_0(ctx context.Context, marshaler } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -455,7 +440,6 @@ func local_request_AccountService_DeleteAccount_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -490,7 +474,6 @@ func request_AccountService_SetPassword_0(ctx context.Context, marshaler runtime } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -501,7 +484,6 @@ func request_AccountService_SetPassword_0(ctx context.Context, marshaler runtime } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -536,7 +518,6 @@ func local_request_AccountService_SetPassword_0(ctx context.Context, marshaler r } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -547,7 +528,6 @@ func local_request_AccountService_SetPassword_0(ctx context.Context, marshaler r } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -582,7 +562,6 @@ func request_AccountService_ChangePassword_0(ctx context.Context, marshaler runt } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -593,7 +572,6 @@ func request_AccountService_ChangePassword_0(ctx context.Context, marshaler runt } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -628,7 +606,6 @@ func local_request_AccountService_ChangePassword_0(ctx context.Context, marshale } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -639,7 +616,6 @@ func local_request_AccountService_ChangePassword_0(ctx context.Context, marshale } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -652,6 +628,7 @@ func local_request_AccountService_ChangePassword_0(ctx context.Context, marshale // RegisterAccountServiceHandlerServer registers the http handlers for service AccountService to "mux". // UnaryRPC :call AccountServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterAccountServiceHandlerFromEndpoint instead. func RegisterAccountServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AccountServiceServer) error { mux.Handle("GET", pattern_AccountService_GetAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/auth_method_service.pb.gw.go b/internal/gen/controller/api/services/auth_method_service.pb.gw.go index bbd0e7b4d..00a83c184 100644 --- a/internal/gen/controller/api/services/auth_method_service.pb.gw.go +++ b/internal/gen/controller/api/services/auth_method_service.pb.gw.go @@ -50,7 +50,6 @@ func request_AuthMethodService_GetAuthMethod_0(ctx context.Context, marshaler ru } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -84,7 +83,6 @@ func local_request_AuthMethodService_GetAuthMethod_0(ctx context.Context, marsha } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -207,7 +205,6 @@ func request_AuthMethodService_UpdateAuthMethod_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -256,7 +253,6 @@ func local_request_AuthMethodService_UpdateAuthMethod_0(ctx context.Context, mar } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -290,7 +286,6 @@ func request_AuthMethodService_DeleteAuthMethod_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -317,7 +312,6 @@ func local_request_AuthMethodService_DeleteAuthMethod_0(ctx context.Context, mar } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -330,6 +324,7 @@ func local_request_AuthMethodService_DeleteAuthMethod_0(ctx context.Context, mar // RegisterAuthMethodServiceHandlerServer registers the http handlers for service AuthMethodService to "mux". // UnaryRPC :call AuthMethodServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterAuthMethodServiceHandlerFromEndpoint instead. func RegisterAuthMethodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthMethodServiceServer) error { mux.Handle("GET", pattern_AuthMethodService_GetAuthMethod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/authenticate_service.pb.gw.go b/internal/gen/controller/api/services/authenticate_service.pb.gw.go index e1fad30d5..3ff53e0af 100644 --- a/internal/gen/controller/api/services/authenticate_service.pb.gw.go +++ b/internal/gen/controller/api/services/authenticate_service.pb.gw.go @@ -54,7 +54,6 @@ func request_AuthenticationService_Authenticate_0(ctx context.Context, marshaler } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -89,7 +88,6 @@ func local_request_AuthenticationService_Authenticate_0(ctx context.Context, mar } protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) } @@ -102,6 +100,7 @@ func local_request_AuthenticationService_Authenticate_0(ctx context.Context, mar // RegisterAuthenticationServiceHandlerServer registers the http handlers for service AuthenticationService to "mux". // UnaryRPC :call AuthenticationServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterAuthenticationServiceHandlerFromEndpoint instead. func RegisterAuthenticationServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthenticationServiceServer) error { mux.Handle("POST", pattern_AuthenticationService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/authtokens_service.pb.gw.go b/internal/gen/controller/api/services/authtokens_service.pb.gw.go index 668b30220..1413fcd7b 100644 --- a/internal/gen/controller/api/services/authtokens_service.pb.gw.go +++ b/internal/gen/controller/api/services/authtokens_service.pb.gw.go @@ -50,7 +50,6 @@ func request_AuthTokenService_GetAuthToken_0(ctx context.Context, marshaler runt } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -84,7 +83,6 @@ func local_request_AuthTokenService_GetAuthToken_0(ctx context.Context, marshale } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -154,7 +152,6 @@ func request_AuthTokenService_DeleteAuthToken_0(ctx context.Context, marshaler r } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -181,7 +178,6 @@ func local_request_AuthTokenService_DeleteAuthToken_0(ctx context.Context, marsh } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -194,6 +190,7 @@ func local_request_AuthTokenService_DeleteAuthToken_0(ctx context.Context, marsh // RegisterAuthTokenServiceHandlerServer registers the http handlers for service AuthTokenService to "mux". // UnaryRPC :call AuthTokenServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterAuthTokenServiceHandlerFromEndpoint instead. func RegisterAuthTokenServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthTokenServiceServer) error { mux.Handle("GET", pattern_AuthTokenService_GetAuthToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/group_service.pb.gw.go b/internal/gen/controller/api/services/group_service.pb.gw.go index 6b2526562..47f42daf8 100644 --- a/internal/gen/controller/api/services/group_service.pb.gw.go +++ b/internal/gen/controller/api/services/group_service.pb.gw.go @@ -50,7 +50,6 @@ func request_GroupService_GetGroup_0(ctx context.Context, marshaler runtime.Mars } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -84,7 +83,6 @@ func local_request_GroupService_GetGroup_0(ctx context.Context, marshaler runtim } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -207,7 +205,6 @@ func request_GroupService_UpdateGroup_0(ctx context.Context, marshaler runtime.M } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -256,7 +253,6 @@ func local_request_GroupService_UpdateGroup_0(ctx context.Context, marshaler run } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -290,7 +286,6 @@ func request_GroupService_DeleteGroup_0(ctx context.Context, marshaler runtime.M } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -317,7 +312,6 @@ func local_request_GroupService_DeleteGroup_0(ctx context.Context, marshaler run } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -356,7 +350,6 @@ func request_GroupService_AddGroupMembers_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -398,7 +391,6 @@ func local_request_GroupService_AddGroupMembers_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -444,7 +436,6 @@ func request_GroupService_SetGroupMembers_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -486,7 +477,6 @@ func local_request_GroupService_SetGroupMembers_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -532,7 +522,6 @@ func request_GroupService_RemoveGroupMembers_0(ctx context.Context, marshaler ru } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -574,7 +563,6 @@ func local_request_GroupService_RemoveGroupMembers_0(ctx context.Context, marsha } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -594,6 +582,7 @@ func local_request_GroupService_RemoveGroupMembers_0(ctx context.Context, marsha // RegisterGroupServiceHandlerServer registers the http handlers for service GroupService to "mux". // UnaryRPC :call GroupServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterGroupServiceHandlerFromEndpoint instead. func RegisterGroupServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GroupServiceServer) error { mux.Handle("GET", pattern_GroupService_GetGroup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/host_catalog_service.pb.gw.go b/internal/gen/controller/api/services/host_catalog_service.pb.gw.go index 0ffa76ea7..ce65f11c0 100644 --- a/internal/gen/controller/api/services/host_catalog_service.pb.gw.go +++ b/internal/gen/controller/api/services/host_catalog_service.pb.gw.go @@ -50,7 +50,6 @@ func request_HostCatalogService_GetHostCatalog_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -84,7 +83,6 @@ func local_request_HostCatalogService_GetHostCatalog_0(ctx context.Context, mars } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -207,7 +205,6 @@ func request_HostCatalogService_UpdateHostCatalog_0(ctx context.Context, marshal } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -256,7 +253,6 @@ func local_request_HostCatalogService_UpdateHostCatalog_0(ctx context.Context, m } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -290,7 +286,6 @@ func request_HostCatalogService_DeleteHostCatalog_0(ctx context.Context, marshal } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -317,7 +312,6 @@ func local_request_HostCatalogService_DeleteHostCatalog_0(ctx context.Context, m } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -330,6 +324,7 @@ func local_request_HostCatalogService_DeleteHostCatalog_0(ctx context.Context, m // RegisterHostCatalogServiceHandlerServer registers the http handlers for service HostCatalogService to "mux". // UnaryRPC :call HostCatalogServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterHostCatalogServiceHandlerFromEndpoint instead. func RegisterHostCatalogServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HostCatalogServiceServer) error { mux.Handle("GET", pattern_HostCatalogService_GetHostCatalog_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/host_service.pb.gw.go b/internal/gen/controller/api/services/host_service.pb.gw.go index 59ac025df..c684bb937 100644 --- a/internal/gen/controller/api/services/host_service.pb.gw.go +++ b/internal/gen/controller/api/services/host_service.pb.gw.go @@ -50,7 +50,6 @@ func request_HostService_GetHost_0(ctx context.Context, marshaler runtime.Marsha } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -61,7 +60,6 @@ func request_HostService_GetHost_0(ctx context.Context, marshaler runtime.Marsha } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -95,7 +93,6 @@ func local_request_HostService_GetHost_0(ctx context.Context, marshaler runtime. } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -106,7 +103,6 @@ func local_request_HostService_GetHost_0(ctx context.Context, marshaler runtime. } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -144,7 +140,6 @@ func request_HostService_ListHosts_0(ctx context.Context, marshaler runtime.Mars } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -178,7 +173,6 @@ func local_request_HostService_ListHosts_0(ctx context.Context, marshaler runtim } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -220,7 +214,6 @@ func request_HostService_CreateHost_0(ctx context.Context, marshaler runtime.Mar } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -255,7 +248,6 @@ func local_request_HostService_CreateHost_0(ctx context.Context, marshaler runti } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -301,7 +293,6 @@ func request_HostService_UpdateHost_0(ctx context.Context, marshaler runtime.Mar } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -312,7 +303,6 @@ func request_HostService_UpdateHost_0(ctx context.Context, marshaler runtime.Mar } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -361,7 +351,6 @@ func local_request_HostService_UpdateHost_0(ctx context.Context, marshaler runti } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -372,7 +361,6 @@ func local_request_HostService_UpdateHost_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -406,7 +394,6 @@ func request_HostService_DeleteHost_0(ctx context.Context, marshaler runtime.Mar } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -417,7 +404,6 @@ func request_HostService_DeleteHost_0(ctx context.Context, marshaler runtime.Mar } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -444,7 +430,6 @@ func local_request_HostService_DeleteHost_0(ctx context.Context, marshaler runti } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -455,7 +440,6 @@ func local_request_HostService_DeleteHost_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -468,6 +452,7 @@ func local_request_HostService_DeleteHost_0(ctx context.Context, marshaler runti // RegisterHostServiceHandlerServer registers the http handlers for service HostService to "mux". // UnaryRPC :call HostServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterHostServiceHandlerFromEndpoint instead. func RegisterHostServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HostServiceServer) error { mux.Handle("GET", pattern_HostService_GetHost_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/host_set_service.pb.gw.go b/internal/gen/controller/api/services/host_set_service.pb.gw.go index 037efcf34..c3d491357 100644 --- a/internal/gen/controller/api/services/host_set_service.pb.gw.go +++ b/internal/gen/controller/api/services/host_set_service.pb.gw.go @@ -50,7 +50,6 @@ func request_HostSetService_GetHostSet_0(ctx context.Context, marshaler runtime. } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -61,7 +60,6 @@ func request_HostSetService_GetHostSet_0(ctx context.Context, marshaler runtime. } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -95,7 +93,6 @@ func local_request_HostSetService_GetHostSet_0(ctx context.Context, marshaler ru } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -106,7 +103,6 @@ func local_request_HostSetService_GetHostSet_0(ctx context.Context, marshaler ru } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -144,7 +140,6 @@ func request_HostSetService_ListHostSets_0(ctx context.Context, marshaler runtim } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -178,7 +173,6 @@ func local_request_HostSetService_ListHostSets_0(ctx context.Context, marshaler } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -220,7 +214,6 @@ func request_HostSetService_CreateHostSet_0(ctx context.Context, marshaler runti } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -255,7 +248,6 @@ func local_request_HostSetService_CreateHostSet_0(ctx context.Context, marshaler } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -301,7 +293,6 @@ func request_HostSetService_UpdateHostSet_0(ctx context.Context, marshaler runti } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -312,7 +303,6 @@ func request_HostSetService_UpdateHostSet_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -361,7 +351,6 @@ func local_request_HostSetService_UpdateHostSet_0(ctx context.Context, marshaler } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -372,7 +361,6 @@ func local_request_HostSetService_UpdateHostSet_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -406,7 +394,6 @@ func request_HostSetService_DeleteHostSet_0(ctx context.Context, marshaler runti } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -417,7 +404,6 @@ func request_HostSetService_DeleteHostSet_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -444,7 +430,6 @@ func local_request_HostSetService_DeleteHostSet_0(ctx context.Context, marshaler } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -455,7 +440,6 @@ func local_request_HostSetService_DeleteHostSet_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -486,7 +470,6 @@ func request_HostSetService_AddHostSetHosts_0(ctx context.Context, marshaler run } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -497,7 +480,6 @@ func request_HostSetService_AddHostSetHosts_0(ctx context.Context, marshaler run } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -531,7 +513,6 @@ func local_request_HostSetService_AddHostSetHosts_0(ctx context.Context, marshal } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -542,7 +523,6 @@ func local_request_HostSetService_AddHostSetHosts_0(ctx context.Context, marshal } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -580,7 +560,6 @@ func request_HostSetService_SetHostSetHosts_0(ctx context.Context, marshaler run } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -591,7 +570,6 @@ func request_HostSetService_SetHostSetHosts_0(ctx context.Context, marshaler run } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -625,7 +603,6 @@ func local_request_HostSetService_SetHostSetHosts_0(ctx context.Context, marshal } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -636,7 +613,6 @@ func local_request_HostSetService_SetHostSetHosts_0(ctx context.Context, marshal } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -674,7 +650,6 @@ func request_HostSetService_RemoveHostSetHosts_0(ctx context.Context, marshaler } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -685,7 +660,6 @@ func request_HostSetService_RemoveHostSetHosts_0(ctx context.Context, marshaler } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -719,7 +693,6 @@ func local_request_HostSetService_RemoveHostSetHosts_0(ctx context.Context, mars } protoReq.HostCatalogId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "host_catalog_id", err) } @@ -730,7 +703,6 @@ func local_request_HostSetService_RemoveHostSetHosts_0(ctx context.Context, mars } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -750,6 +722,7 @@ func local_request_HostSetService_RemoveHostSetHosts_0(ctx context.Context, mars // RegisterHostSetServiceHandlerServer registers the http handlers for service HostSetService to "mux". // UnaryRPC :call HostSetServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterHostSetServiceHandlerFromEndpoint instead. func RegisterHostSetServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HostSetServiceServer) error { mux.Handle("GET", pattern_HostSetService_GetHostSet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/role_service.pb.gw.go b/internal/gen/controller/api/services/role_service.pb.gw.go index 506914b6f..762a94e09 100644 --- a/internal/gen/controller/api/services/role_service.pb.gw.go +++ b/internal/gen/controller/api/services/role_service.pb.gw.go @@ -50,7 +50,6 @@ func request_RoleService_GetRole_0(ctx context.Context, marshaler runtime.Marsha } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -84,7 +83,6 @@ func local_request_RoleService_GetRole_0(ctx context.Context, marshaler runtime. } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -207,7 +205,6 @@ func request_RoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Mar } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -256,7 +253,6 @@ func local_request_RoleService_UpdateRole_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -290,7 +286,6 @@ func request_RoleService_DeleteRole_0(ctx context.Context, marshaler runtime.Mar } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -317,7 +312,6 @@ func local_request_RoleService_DeleteRole_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -356,7 +350,6 @@ func request_RoleService_AddRolePrincipals_0(ctx context.Context, marshaler runt } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -398,7 +391,6 @@ func local_request_RoleService_AddRolePrincipals_0(ctx context.Context, marshale } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -444,7 +436,6 @@ func request_RoleService_SetRolePrincipals_0(ctx context.Context, marshaler runt } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -486,7 +477,6 @@ func local_request_RoleService_SetRolePrincipals_0(ctx context.Context, marshale } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -532,7 +522,6 @@ func request_RoleService_RemoveRolePrincipals_0(ctx context.Context, marshaler r } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -574,7 +563,6 @@ func local_request_RoleService_RemoveRolePrincipals_0(ctx context.Context, marsh } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -620,7 +608,6 @@ func request_RoleService_AddRoleGrants_0(ctx context.Context, marshaler runtime. } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -662,7 +649,6 @@ func local_request_RoleService_AddRoleGrants_0(ctx context.Context, marshaler ru } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -708,7 +694,6 @@ func request_RoleService_SetRoleGrants_0(ctx context.Context, marshaler runtime. } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -750,7 +735,6 @@ func local_request_RoleService_SetRoleGrants_0(ctx context.Context, marshaler ru } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -796,7 +780,6 @@ func request_RoleService_RemoveRoleGrants_0(ctx context.Context, marshaler runti } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -838,7 +821,6 @@ func local_request_RoleService_RemoveRoleGrants_0(ctx context.Context, marshaler } protoReq.RoleId, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role_id", err) } @@ -858,6 +840,7 @@ func local_request_RoleService_RemoveRoleGrants_0(ctx context.Context, marshaler // RegisterRoleServiceHandlerServer registers the http handlers for service RoleService to "mux". // UnaryRPC :call RoleServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterRoleServiceHandlerFromEndpoint instead. func RegisterRoleServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RoleServiceServer) error { mux.Handle("GET", pattern_RoleService_GetRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/scope_service.pb.gw.go b/internal/gen/controller/api/services/scope_service.pb.gw.go index 02a2a49e2..1368059b6 100644 --- a/internal/gen/controller/api/services/scope_service.pb.gw.go +++ b/internal/gen/controller/api/services/scope_service.pb.gw.go @@ -50,7 +50,6 @@ func request_ScopeService_GetScope_0(ctx context.Context, marshaler runtime.Mars } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -84,7 +83,6 @@ func local_request_ScopeService_GetScope_0(ctx context.Context, marshaler runtim } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -225,7 +223,6 @@ func request_ScopeService_UpdateScope_0(ctx context.Context, marshaler runtime.M } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -274,7 +271,6 @@ func local_request_ScopeService_UpdateScope_0(ctx context.Context, marshaler run } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -308,7 +304,6 @@ func request_ScopeService_DeleteScope_0(ctx context.Context, marshaler runtime.M } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -335,7 +330,6 @@ func local_request_ScopeService_DeleteScope_0(ctx context.Context, marshaler run } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -348,6 +342,7 @@ func local_request_ScopeService_DeleteScope_0(ctx context.Context, marshaler run // RegisterScopeServiceHandlerServer registers the http handlers for service ScopeService to "mux". // UnaryRPC :call ScopeServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterScopeServiceHandlerFromEndpoint instead. func RegisterScopeServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ScopeServiceServer) error { mux.Handle("GET", pattern_ScopeService_GetScope_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/internal/gen/controller/api/services/user_service.pb.gw.go b/internal/gen/controller/api/services/user_service.pb.gw.go index a1a747ea9..658e768c9 100644 --- a/internal/gen/controller/api/services/user_service.pb.gw.go +++ b/internal/gen/controller/api/services/user_service.pb.gw.go @@ -50,7 +50,6 @@ func request_UserService_GetUser_0(ctx context.Context, marshaler runtime.Marsha } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -84,7 +83,6 @@ func local_request_UserService_GetUser_0(ctx context.Context, marshaler runtime. } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -207,7 +205,6 @@ func request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Mar } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -256,7 +253,6 @@ func local_request_UserService_UpdateUser_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -290,7 +286,6 @@ func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Mar } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -317,7 +312,6 @@ func local_request_UserService_DeleteUser_0(ctx context.Context, marshaler runti } protoReq.Id, err = runtime.String(val) - if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -330,6 +324,7 @@ func local_request_UserService_DeleteUser_0(ctx context.Context, marshaler runti // RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". // UnaryRPC :call UserServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterUserServiceHandlerFromEndpoint instead. func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error { mux.Handle("GET", pattern_UserService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {