Documentation ¶
Overview ¶
Package tenants provides information and interaction with the tenants API resource for the OpenStack Identity service.
See http://developer.openstack.org/api-ref-identity-v2.html#identity-auth-v2 and http://developer.openstack.org/api-ref-identity-v2.html#admin-tenants for more information.
Example to List Tenants
listOpts := &tenants.ListOpts{ Limit: 2, } allPages, err := tenants.List(identityClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } allTenants, err := tenants.ExtractTenants(allPages) if err != nil { panic(err) } for _, tenant := range allTenants { fmt.Printf("%+v\n", tenant) }
Example to Create a Tenant
createOpts := tenants.CreateOpts{ Name: "tenant_name", Description: "this is a tenant", Enabled: gophercloud.Enabled, } tenant, err := tenants.Create(context.TODO(), identityClient, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Tenant
tenantID := "e6db6ed6277c461a853458589063b295" updateOpts := tenants.UpdateOpts{ Description: "this is a new description", Enabled: gophercloud.Disabled, } tenant, err := tenants.Update(context.TODO(), identityClient, tenantID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Tenant
tenantID := "e6db6ed6277c461a853458589063b295" err := tenants.Delete(context.TODO(), identitYClient, tenantID).ExtractErr() if err != nil { panic(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager
List enumerates the Tenants to which the current token has access.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // Name is the name of the tenant. Name string `json:"name" required:"true"` // Description is the description of the tenant. Description string `json:"description,omitempty"` // Enabled sets the tenant status to enabled or disabled. Enabled *bool `json:"enabled,omitempty"` }
CreateOpts represents the options needed when creating new tenant.
func (CreateOpts) ToTenantCreateMap ¶
func (opts CreateOpts) ToTenantCreateMap() (map[string]any, error)
ToTenantCreateMap assembles a request body based on the contents of a CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder enables 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 request. Call its Extract method to interpret it as a Tenant.
func Create ¶
func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create is the operation responsible for creating new tenant.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the response from a Get request. Call its ExtractErr method to determine if the call succeeded or failed.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response from a Get request. Call its Extract method to interpret it as a Tenant.
type ListOpts ¶
type ListOpts struct { // Marker is the ID of the last Tenant on the previous page. Marker string `q:"marker"` // Limit specifies the page size. Limit int `q:"limit"` }
ListOpts filters the Tenants that are returned by the List call.
type Tenant ¶
type Tenant struct { // ID is a unique identifier for this tenant. ID string `json:"id"` // Name is a friendlier user-facing name for this tenant. Name string `json:"name"` // Description is a human-readable explanation of this Tenant's purpose. Description string `json:"description"` // Enabled indicates whether or not a tenant is active. Enabled bool `json:"enabled"` }
Tenant is a grouping of users in the identity service.
func ExtractTenants ¶
func ExtractTenants(r pagination.Page) ([]Tenant, error)
ExtractTenants returns a slice of Tenants contained in a single page of results.
type TenantPage ¶
type TenantPage struct {
pagination.LinkedPageBase
}
TenantPage is a single page of Tenant results.
func (TenantPage) IsEmpty ¶
func (r TenantPage) IsEmpty() (bool, error)
IsEmpty determines whether or not a page of Tenants contains any results.
func (TenantPage) NextPageURL ¶
func (r TenantPage) NextPageURL() (string, error)
NextPageURL extracts the "next" link from the tenants_links section of the result.
type UpdateOpts ¶
type UpdateOpts struct { // Name is the name of the tenant. Name string `json:"name,omitempty"` // Description is the description of the tenant. Description *string `json:"description,omitempty"` // Enabled sets the tenant status to enabled or disabled. Enabled *bool `json:"enabled,omitempty"` }
UpdateOpts specifies the base attributes that may be updated on an existing tenant.
func (UpdateOpts) ToTenantUpdateMap ¶
func (opts UpdateOpts) ToTenantUpdateMap() (map[string]any, error)
ToTenantUpdateMap formats an UpdateOpts structure into a request body.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult is the response from a Update request. Call its Extract method to interpret it as a Tenant.
func Update ¶
func Update(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update is the operation responsible for updating exist tenants by their TenantID.