Skip to main content

GrantRole

This operation assigns a role to a user.

go
func (c *Client) GrantRole(ctx context.Context, opt GrantRoleOption, callOpts ...grpc.CallOption) error

Request Syntax​

Creates the request for GrantRole().

go
option := milvusclient.NewGrantRoleOption(userName, roleName)

err := client.GrantRole(ctx, option)

PARAMETERS:

  • userName (string) -

    [REQUIRED]

    The name of the user.

  • roleName (string) -

    [REQUIRED]

    The name of the role.

BUILDER METHODS:

  • NewGrantRoleOption(userName string, roleName string)

    Creates the request for GrantRole().

RETURN TYPE:

error

RETURNS:

Returns nil on success, or an error describing what went wrong.

ERROR HANDLING:

  • error

    The operation fails. Check err != nil for failure details.

Example​

Demonstrates GrantRole() usage.

go
import (
"context"

"github.com/milvus-io/milvus/client/v3/milvusclient"
)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: "YOUR_CLUSTER_ENDPOINT",
})
if err != nil {
// handle error
}
defer cli.Close(ctx)

err = cli.GrantRole(ctx, milvusclient.NewGrantRoleOption("my_user", "my_role"))
if err != nil {
// handle error
}
Minimum SDK versionv3.0.x
Was this page helpful?