go-selvpcclient: github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/roles Index | Files | Directories

package roles

import "github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/roles"

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

Package Files

doc.go requests.go requests_opts.go schemas.go

func Delete Uses

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.

type Role Uses

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 Uses

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 Uses

func CreateBulk(ctx context.Context, client *selvpcclient.ServiceClient, createOpts RoleOpts) ([]*Role, *selvpcclient.ResponseResult, error)

CreateBulk requests a creation of several roles.

func List Uses

func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Role, *selvpcclient.ResponseResult, error)

List returns all roles in the current domain.

func ListProject Uses

func ListProject(ctx context.Context, client *selvpcclient.ServiceClient, id string) ([]*Role, *selvpcclient.ResponseResult, error)

ListProject returns all roles in the specified project.

func ListUser Uses

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.

type RoleOpt Uses

type RoleOpt struct {
    // ProjectID represents Identity service project.
    ProjectID string `json:"project_id"`

    // UserID represents Identity service user.
    UserID string `json:"user_id"`
}

RoleOpt represents options for a single Resell role.

type RoleOpts Uses

type RoleOpts struct {
    Roles []RoleOpt `json:"roles"`
}

RoleOpts represents options for several Resell roles.

Directories

PathSynopsis
testing

Package roles imports 6 packages (graph) and is imported by 1 packages. Updated 2019-01-03. Refresh now. Tools for package owners.