roles

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

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, client)
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, client, 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, client, 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(client, 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(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(client, deleteOpts)
if err != nil {
  log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(client *selvpcclient.Client, deleteOpts RoleOpt) (*clientservices.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(client *selvpcclient.Client, createOpts RoleOpt) (*Role, *clientservices.ResponseResult, error)

Create requests a creation of the single role for the specified project and user.

func CreateBulk

func CreateBulk(client *selvpcclient.Client, createOpts RoleOpts) ([]*Role, *clientservices.ResponseResult, error)

CreateBulk requests a creation of several roles.

func List

List returns all roles in the current domain.

func ListProject

func ListProject(client *selvpcclient.Client, id string) ([]*Role, *clientservices.ResponseResult, error)

ListProject returns all roles in the specified project.

func ListUser

func ListUser(client *selvpcclient.Client, id string) ([]*Role, *clientservices.ResponseResult, error)

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