trusts

package
v1.1.36 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package trusts enables management of OpenStack Identity Trusts.

Example to Create a Token with Username, Password, and Trust ID

var trustToken struct {
	tokens.Token
	trusts.TokenExt
}

authOptions := tokens.AuthOptions{
	UserID:   "username",
	Password: "password",
}

createOpts := trusts.AuthOptsExt{
	AuthOptionsBuilder: authOptions,
	TrustID:            "de0945a",
}

err := tokens.Create(identityClient, createOpts).ExtractInto(&trustToken)
if err != nil {
	panic(err)
}

Example to Create a Trust

expiresAt := time.Date(2019, 12, 1, 14, 0, 0, 999999999, time.UTC)
createOpts := trusts.CreateOpts{
    ExpiresAt:         &expiresAt,
    Impersonation:     true,
    AllowRedelegation: true,
    ProjectID:         "9b71012f5a4a4aef9193f1995fe159b2",
    Roles: []trusts.Role{
        {
            Name: "member",
        },
    },
    TrusteeUserID: "ecb37e88cc86431c99d0332208cb6fbf",
    TrustorUserID: "959ed913a32c4ec88c041c98e61cbbc3",
}

trust, err := trusts.Create(identityClient, createOpts).Extract()
if err != nil {
    panic(err)
}

fmt.Printf("Trust: %+v\n", trust)

Example to Delete a Trust

trustID := "3422b7c113894f5d90665e1a79655e23"
err := trusts.Delete(identityClient, trustID).ExtractErr()
if err != nil {
    panic(err)
}

Example to Get a Trust

trustID := "3422b7c113894f5d90665e1a79655e23"
err := trusts.Get(identityClient, trustID).ExtractErr()
if err != nil {
    panic(err)
}

Example to List a Trust

listOpts := trusts.ListOpts{
	TrustorUserId: "3422b7c113894f5d90665e1a79655e23",
}

allPages, err := trusts.List(identityClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allTrusts, err := trusts.ExtractTrusts(allPages)
if err != nil {
	panic(err)
}

for _, trust := range allTrusts {
	fmt.Printf("%+v\n", region)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List enumerates the Trust to which the current token has access.

func ListRoles

func ListRoles(client *gophercloud.ServiceClient, id string) pagination.Pager

ListRoles lists roles delegated by a Trust.

Types

type AuthOptsExt

type AuthOptsExt struct {
	tokens.AuthOptionsBuilder

	// TrustID is the ID of the trust.
	TrustID string `json:"id"`
}

AuthOptsExt extends the base Identity v3 tokens AuthOpts with a TrustID.

func (AuthOptsExt) CanReauth

func (opts AuthOptsExt) CanReauth() bool

func (AuthOptsExt) ToTokenV3CreateMap

func (opts AuthOptsExt) ToTokenV3CreateMap(scope map[string]interface{}) (map[string]interface{}, error)

ToTokenV3CreateMap builds a create request body from the AuthOpts.

func (AuthOptsExt) ToTokenV3ScopeMap

func (opts AuthOptsExt) ToTokenV3ScopeMap() (map[string]interface{}, error)

ToTokenV3ScopeMap builds a scope from AuthOpts.

type CheckRoleResult

type CheckRoleResult struct {
	gophercloud.ErrResult
}

func CheckRole

func CheckRole(client *gophercloud.ServiceClient, id string, roleID string) (r CheckRoleResult)

CheckRole checks whether a role ID is delegated by a Trust.

type CreateOpts

type CreateOpts struct {
	// Impersonation allows the trustee to impersonate the trustor.
	Impersonation bool `json:"impersonation"`

	// TrusteeUserID is a user who is capable of consuming the trust.
	TrusteeUserID string `json:"trustee_user_id" required:"true"`

	// TrustorUserID is a user who created the trust.
	TrustorUserID string `json:"trustor_user_id" required:"true"`

	// AllowRedelegation enables redelegation of a trust.
	AllowRedelegation bool `json:"allow_redelegation,omitempty"`

	// ExpiresAt sets expiration time on trust.
	ExpiresAt *time.Time `json:"-"`

	// ProjectID identifies the project.
	ProjectID string `json:"project_id,omitempty"`

	// RedelegationCount specifies a depth of the redelegation chain.
	RedelegationCount int `json:"redelegation_count,omitempty"`

	// RemainingUses specifies how many times a trust can be used to get a token.
	RemainingUses int `json:"remaining_uses,omitempty"`

	// Roles specifies roles that need to be granted to trustee.
	Roles []Role `json:"roles,omitempty"`
}

CreateOpts provides options used to create a new trust.

func (CreateOpts) ToTrustCreateMap

func (opts CreateOpts) ToTrustCreateMap() (map[string]interface{}, error)

ToTrustCreateMap formats a CreateOpts into a create request.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToTrustCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

CreateResult is the response from a Create operation. Call its Extract method to interpret it as a Trust.

func Create

func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create creates a new Trust.

func (CreateResult) Extract

func (t CreateResult) Extract() (*Trust, error)

Extract interprets any trust result as a Trust.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the response from a Delete operation. Call its ExtractErr to determine if the request succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, trustID string) (r DeleteResult)

Delete deletes a Trust.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult is the response from a Get operation. Call its Extract method to interpret it as a Trust.

func Get

func Get(client *gophercloud.ServiceClient, id string) (r GetResult)

Get retrieves details on a single Trust, by ID.

func (GetResult) Extract

func (t GetResult) Extract() (*Trust, error)

Extract interprets any trust result as a Trust.

type GetRoleResult

type GetRoleResult struct {
	gophercloud.Result
}

func GetRole

func GetRole(client *gophercloud.ServiceClient, id string, roleID string) (r GetRoleResult)

GetRole retrieves details on a single role delegated by a Trust.

func (GetRoleResult) Extract

func (r GetRoleResult) Extract() (*Role, error)

Extract interprets any GetRoleResult result as an Role.

type ListOpts

type ListOpts struct {
	// TrustorUserID filters the response by a trustor user Id.
	TrustorUserID string `q:"trustor_user_id"`

	// TrusteeUserID filters the response by a trustee user Id.
	TrusteeUserID string `q:"trustee_user_id"`
}

ListOpts provides options to filter the List results.

func (ListOpts) ToTrustListQuery

func (opts ListOpts) ToTrustListQuery() (string, error)

ToTrustListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToTrustListQuery() (string, error)
}

type Role

type Role struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Role specifies a single role that is granted to a trustee.

func ExtractRoles

func ExtractRoles(r pagination.Page) ([]Role, error)

ExtractRoles returns a slice of Role contained in a single page of results.

type RolesPage

type RolesPage struct {
	pagination.LinkedPageBase
}

RolesPage is a single page of Trust roles results.

func (RolesPage) IsEmpty

func (r RolesPage) IsEmpty() (bool, error)

IsEmpty determines whether or not a a Page contains any results.

func (RolesPage) NextPageURL

func (r RolesPage) NextPageURL() (string, error)

NextPageURL extracts the "next" link from the links section of the result.

type TokenExt

type TokenExt struct {
	Trust Trust `json:"OS-TRUST:trust"`
}

TokenExt represents an extension of the base token result.

type Trust

type Trust struct {
	ID                 string    `json:"id"`
	Impersonation      bool      `json:"impersonation"`
	TrusteeUserID      string    `json:"trustee_user_id"`
	TrustorUserID      string    `json:"trustor_user_id"`
	RedelegatedTrustID string    `json:"redelegated_trust_id"`
	RedelegationCount  int       `json:"redelegation_count,omitempty"`
	AllowRedelegation  bool      `json:"allow_redelegation,omitempty"`
	ProjectID          string    `json:"project_id,omitempty"`
	RemainingUses      int       `json:"remaining_uses,omitempty"`
	Roles              []Role    `json:"roles,omitempty"`
	DeletedAt          time.Time `json:"deleted_at"`
	ExpiresAt          time.Time `json:"expires_at"`
}

Trust represents a delegated authorization request between two identities.

func ExtractTrusts

func ExtractTrusts(r pagination.Page) ([]Trust, error)

ExtractProjects returns a slice of Trusts contained in a single page of results.

type TrustPage

type TrustPage struct {
	pagination.LinkedPageBase
}

TrustPage is a single page of Region results.

func (TrustPage) IsEmpty

func (t TrustPage) IsEmpty() (bool, error)

IsEmpty determines whether or not a page of Trusts contains any results.

func (TrustPage) NextPageURL

func (t TrustPage) NextPageURL() (string, error)

NextPageURL extracts the "next" link from the links section of the result.

Directories

Path Synopsis
trusts unit tests
trusts unit tests

Jump to

Keyboard shortcuts

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