Documentation ¶
Overview ¶
Package roles provides the ability to retrieve and manage roles through the Resell v2 API.
Example of getting roles in the current domain
allRoles, _, err = roles.List(context, resellClient) if err != nil { log.Fatal(err) } for _, myRole := range allRoles { fmt.Println(myRole) }
Example of getting roles in the specified project
allRoles, _, err := roles.ListProject(context, resellClient, projectID) if err != nil { log.Fatal(err) } for _, myRole := range allRoles { fmt.Println(myRole) }
Example of getting roles for the specified user
allRoles, _, err := roles.ListUser(context, resellClient, userID) if err != nil { log.Fatal(err) } for _, myRole := range allRoles { fmt.Println(myRole) }
Example of creating a single role
createOpts := roles.RoleOpt{ ProjectID: "49338ac045f448e294b25d013f890317", UserID: "763eecfaeb0c8e9b76ab12a82eb4c11", } role, _, err := roles.Create(ctx, resellClient, createOpts) if err != nil { log.Fatal(err) } fmt.Println(myRole)
Example of creating several roles
createOpts := roles.RoleOpts{ Roles: []roles.RoleOpt{ { ProjectID: "81800a8ec3fc49fca2cf00857de3ae9d", UserID: "763eecfaeb0c8e9b76ab12a82eb4c11", }, { ProjectID: "d7452adc9769422a908edfd2281d7c55", UserID: "763eecfaeb0c8e9b76ab12a82eb4c11", }, }, } allRoles, httpResponse, err := roles.CreateBulk(ctx, testEnv.Client, createOpts) for _, myRole := range allRoles { fmt.Println(myRole) }
Example of deleting a single role
deleteOpts := roles.RoleOpt{ ProjectID: "49338ac045f448e294b25d013f890317", UserID: "763eecfaeb0c8e9b76ab12a82eb4c11", } _, err := roles.Delete(ctx, resellClient, deleteOpts) if err != nil { log.Fatal(err) }
Index ¶
- func Delete(ctx context.Context, client *selvpcclient.ServiceClient, deleteOpts RoleOpt) (*selvpcclient.ResponseResult, error)
- type Role
- func Create(ctx context.Context, client *selvpcclient.ServiceClient, createOpts RoleOpt) (*Role, *selvpcclient.ResponseResult, error)
- func CreateBulk(ctx context.Context, client *selvpcclient.ServiceClient, createOpts RoleOpts) ([]*Role, *selvpcclient.ResponseResult, error)
- func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Role, *selvpcclient.ResponseResult, error)
- func ListProject(ctx context.Context, client *selvpcclient.ServiceClient, id string) ([]*Role, *selvpcclient.ResponseResult, error)
- func ListUser(ctx context.Context, client *selvpcclient.ServiceClient, id string) ([]*Role, *selvpcclient.ResponseResult, error)
- type RoleOpt
- type RoleOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(ctx context.Context, client *selvpcclient.ServiceClient, deleteOpts RoleOpt) (*selvpcclient.ResponseResult, error)
Delete requests a deletion of the single role for the specified project and user.
Types ¶
type Role ¶
type Role struct { // ProjectID represents an associated Identity service project. ProjectID string `json:"project_id"` // UserID represents an associated Identity service user. UserID string `json:"user_id"` }
Role represents a single Resell role.
func Create ¶
func Create(ctx context.Context, client *selvpcclient.ServiceClient, createOpts RoleOpt) (*Role, *selvpcclient.ResponseResult, error)
Create requests a creation of the single role for the specified project and user.
func CreateBulk ¶
func CreateBulk(ctx context.Context, client *selvpcclient.ServiceClient, createOpts RoleOpts) ([]*Role, *selvpcclient.ResponseResult, error)
CreateBulk requests a creation of several roles.
func List ¶ added in v1.6.0
func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Role, *selvpcclient.ResponseResult, error)
List returns all roles in the current domain.
func ListProject ¶
func ListProject(ctx context.Context, client *selvpcclient.ServiceClient, id string) ([]*Role, *selvpcclient.ResponseResult, error)
ListProject returns all roles in the specified project.
func ListUser ¶
func ListUser(ctx context.Context, client *selvpcclient.ServiceClient, id string) ([]*Role, *selvpcclient.ResponseResult, error)
ListUser returns all roles that are associated with the specified user.