roles

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 6 Imported by: 3

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

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

List returns all roles in the current domain.

func ListProject

ListProject returns all roles in the specified project.

func ListUser

ListUser returns all roles that are associated with the specified user.

type RoleOpt

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

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

RoleOpts represents options for several Resell roles.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL