tenants

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package projects manages and retrieves Projects in the ECL SSS Service.

Example to List Tenants

listOpts := tenants.ListOpts{
	Enabled: eclcloud.Enabled,
}

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

allProjects, err := tenants.ExtractProjects(allPages)
if err != nil {
	panic(err)
}

for _, tenant := range allTenants {
	fmt.Printf("%+v\n", tenant)
}

Example to Create a Tenant

createOpts := projects.CreateOpts{
	Name:        "tenant_name",
	Description: "Tenant Description"
}

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

Example to Update a Tenant

tenantID := "966b3c7d36a24facaf20b7e458bf2192"

updateOpts := tenants.UpdateOpts{
	Description: "Tenant Description - New",
}

tenant, err := tenants.Update(identityClient, tenantID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Tenant

tenantID := "966b3c7d36a24facaf20b7e458bf2192"
err := projects.Delete(identityClient, projectID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(client *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

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

Types

type CreateOpts

type CreateOpts struct {
	// Name of this tenant.
	TenantName string `json:"tenant_name" required:"true"`

	// Description of the tenant.
	Description string `json:"description" required:"true"`

	// TenantRegion of the tenant.
	TenantRegion string `json:"region" required:"true"`

	// ID of contract which new tenant belongs.
	ContractID string `json:"contract_id,omitempty"`
}

CreateOpts represents parameters used to create a tenant.

func (CreateOpts) ToTenantCreateMap

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

ToTenantCreateMap formats a CreateOpts into a create request.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToTenantCreateMap() (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 result of a Create request. Call its Extract method to interpret it as a Tenant.

func Create

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

Create creates a new Project.

func (CreateResult) Extract

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

Extract interprets any projectResults as a Tenant.

type DeleteResult

type DeleteResult struct {
	eclcloud.ErrResult
}

DeleteResult is the result of a Delete request. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(client *eclcloud.ServiceClient, tenantID string) (r DeleteResult)

Delete deletes a tenant.

type GetResult

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

GetResult is the result of a Get request. Call its Extract method to interpret it as a Tenant.

func Get

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

Get retrieves details on a single tenant, by ID.

func (GetResult) Extract

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

Extract interprets any projectResults as a Tenant.

type InvalidListFilter

type InvalidListFilter struct {
	FilterName string
}

InvalidListFilter is returned by the ToUserListQuery method when validation of a filter does not pass

func (InvalidListFilter) Error

func (e InvalidListFilter) Error() string

type ListOpts

type ListOpts struct {
}

ListOpts enables filtering of a list request. Currently SSS Tenant API does not support any of query parameters.

func (ListOpts) ToTenantListQuery

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

ToTenantListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add additional parameters to the List request

type Tenant

type Tenant struct {
	// 	ID of contract which owns these tenants.
	ContractID string `json:"contract_id"`
	// ID is the unique ID of the tenant.
	TenantID string `json:"tenant_id"`
	// Name of the tenant.
	TenantName string `json:"tenant_name"`
	// Description of the tenant.
	Description string `json:"description"`
	// TenantRegion the tenant blongs.
	TenantRegion string `json:"region"`
	// Time that the tenant is created.
	StartTime time.Time `json:"-"`
}

Tenant represents an ECL SSS Tenant.

func ExtractTenants

func ExtractTenants(r pagination.Page) ([]Tenant, error)

ExtractTenants returns a slice of Tenants contained in a single page of results.

func (*Tenant) UnmarshalJSON

func (r *Tenant) UnmarshalJSON(b []byte) error

UnmarshalJSON creates JSON format of tenant

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 links section of the result.

type UpdateOpts

type UpdateOpts struct {
	// Description of the tenant.
	Description *string `json:"description,omitempty"`
}

UpdateOpts represents parameters to update a tenant.

func (UpdateOpts) ToTenantUpdateMap

func (opts UpdateOpts) ToTenantUpdateMap() (map[string]interface{}, error)

ToTenantUpdateMap formats a UpdateOpts into an update request.

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 result of an Update request. Call its Extract method to interpret it as a Tenant.

func Update

func Update(client *eclcloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update modifies the attributes of a tenant. SSS Tenant PUT API does not have response body, so set JSONResponse option as nil.

func (UpdateResult) Extract

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

Extract interprets any projectResults as a Tenant.

Directories

Path Synopsis
sss tenant unit tests
sss tenant unit tests

Jump to

Keyboard shortcuts

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