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 ¶
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListRoles(client *gophercloud.ServiceClient, id string) pagination.Pager
- type AuthOptsExt
- type CheckRoleResult
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type GetRoleResult
- type ListOpts
- type ListOptsBuilder
- type Role
- type RolesPage
- type TokenExt
- type Trust
- type TrustPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶ added in v0.9.0
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List enumerates the Trust to which the current token has access.
func ListRoles ¶ added in v0.11.0
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 ¶ added in v0.11.0
type CheckRoleResult struct {
gophercloud.ErrResult
}
func CheckRole ¶ added in v0.11.0
func CheckRole(client *gophercloud.ServiceClient, id string, roleID string) (r CheckRoleResult)
CheckRole checks whether a role ID is delegated by a Trust.
type CreateOpts ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (opts CreateOpts) ToTrustCreateMap() (map[string]interface{}, error)
ToTrustCreateMap formats a CreateOpts into a create request.
type CreateOptsBuilder ¶ added in v0.3.0
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶ added in v0.3.0
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 ¶ added in v0.3.0
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create creates a new Trust.
type DeleteResult ¶ added in v0.3.0
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 ¶ added in v0.3.0
func Delete(client *gophercloud.ServiceClient, trustID string) (r DeleteResult)
Delete deletes a Trust.
type GetResult ¶ added in v0.9.0
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 ¶ added in v0.9.0
func Get(client *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves details on a single Trust, by ID.
type GetRoleResult ¶ added in v0.11.0
type GetRoleResult struct {
gophercloud.Result
}
func GetRole ¶ added in v0.11.0
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 ¶ added in v0.11.0
func (r GetRoleResult) Extract() (*Role, error)
Extract interprets any GetRoleResult result as an Role.
type ListOpts ¶ added in v0.9.0
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 ¶ added in v0.9.0
ToTrustListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶ added in v0.9.0
type Role ¶ added in v0.3.0
Role specifies a single role that is granted to a trustee.
func ExtractRoles ¶ added in v0.11.0
func ExtractRoles(r pagination.Page) ([]Role, error)
ExtractRoles returns a slice of Role contained in a single page of results.
type RolesPage ¶ added in v0.11.0
type RolesPage struct {
pagination.LinkedPageBase
}
RolesPage is a single page of Trust roles results.
func (RolesPage) IsEmpty ¶ added in v0.11.0
IsEmpty determines whether or not a a Page contains any results.
func (RolesPage) NextPageURL ¶ added in v0.11.0
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 ¶ added in v0.9.0
func ExtractTrusts(r pagination.Page) ([]Trust, error)
ExtractProjects returns a slice of Trusts contained in a single page of results.
type TrustPage ¶ added in v0.9.0
type TrustPage struct {
pagination.LinkedPageBase
}
TrustPage is a single page of Region results.
func (TrustPage) IsEmpty ¶ added in v0.9.0
IsEmpty determines whether or not a page of Trusts contains any results.
func (TrustPage) NextPageURL ¶ added in v0.9.0
NextPageURL extracts the "next" link from the links section of the result.