tenants

package
v4.0.0 Latest Latest
Warning

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

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

Documentation

Overview

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

Example to List Tenants

listOpts := tenants.ListOpts{}

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

allTenants, 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)
}

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 {
	// Workspace ID.
	WorkspaceID string `json:"workspace_id" required:"true"`
	// TenantRegion of the tenant.
	TenantRegion string `json:"region" required:"true"`
}

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 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 belongs.
	TenantRegion string `json:"region"`
	// Time that the tenant is created.
	StartTime time.Time `json:"-"`
	// SSS API endpoint for the region.
	RegionApiEndpoint string `json:"region_api_endpoint"`
	// Users information who have access to this tenant.
	User []User `json:"users"`
	// Brand ID which this tenant belongs. (ex. ecl2)
	BrandID string `json:"brand_id"`
	// Workspace ID of the tenant.
	WorkspaceID string `json:"workspace_id"`
}

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 User

type User struct {
	// ID of the users who have access to this tenant.
	UserID string `json:"user_id"`
	// Contract which owns the tenant.
	ContractID string `json:"contract_id"`
	// This user is contract owner / or not.
	ContractOwner bool `json:"contract_owner"`
}

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