tenants

package
v0.0.0-...-cd80d89 Latest Latest
Warning

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

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

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()
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(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(identityClient, tenantID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Tenant

tenantID := "e6db6ed6277c461a853458589063b295"

err := tenants.Delete(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]interface{}, error)

ToTenantCreateMap assembles a request body based on the contents of a CreateOpts.

type CreateOptsBuilder

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

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(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create is the operation responsible for creating new tenant.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Tenant, error)

Extract interprets any tenantResults as a 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.

func Delete

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

Delete is the operation responsible for permanently deleting a tenant.

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.

func Get

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

Get requests details on a single tenant by ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Tenant, error)

Extract interprets any tenantResults 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]interface{}, error)

ToTenantUpdateMap formats an UpdateOpts structure into a request body.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToTenantUpdateMap() (map[string]interface{}, error)
}

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(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update is the operation responsible for updating exist tenants by their TenantID.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Tenant, error)

Extract interprets any tenantResults as a Tenant.

Directories

Path Synopsis
tenants unit tests
tenants unit tests

Jump to

Keyboard shortcuts

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