quotamanager

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package quotamanager provides methods and structures to work with the Quotas Manager API.

Example of creating QuotaRegional client

  resellClient := resell.NewV2ResellClient(APIToken)
  ctx := context.Background()
  accountName := "123456"
  token, _, _ := reselTokens.Create(ctx, resellClient, reselTokens.TokenOpts{
	  AccountName: accountName,
  })

  OpenstackClient := resell.NewOpenstackClient(token.ID)
  identity := quotamanager.NewIdentityManager(resellClient, OpenstackClient, accountName)
  QuotaRegionalClient := quotamanager.NewQuotaRegionalClient(selvpcclient.NewHTTPClient(), identity)

Index

Constants

View Source
const (
	MinTokenTTL      = 180
	QuotaServiceType = "quota-manager"
	PublicInterface  = "public"
)

Variables

View Source
var (
	NoSuchRegionErr = "no such region: %s"
	GetCatalogErr   = "failed to get endpoints: %v"
	ExtractTokenErr = "failed to extract token: %v"
	CreateTokenErr  = "failed to create token: %v"
)

Functions

This section is empty.

Types

type IdentityManager

type IdentityManager struct {
	AccountName     string
	Token           *tokens.Token
	OpenstackClient *gophercloud.ServiceClient
	ResellClient    *selvpcclient.ServiceClient
	// contains filtered or unexported fields
}

IdentityManager stores details that are needed to authenticate in quotas Selectel APIs.

func NewIdentityManager

func NewIdentityManager(resellClient *selvpcclient.ServiceClient, openstackClient *gophercloud.ServiceClient,
	accountName string,
) *IdentityManager

NewIdentityManager creates client for Openstack authentication.

func (*IdentityManager) GetEndpointForRegion

func (mgr *IdentityManager) GetEndpointForRegion(region string) (string, error)

GetEndpointForRegion returns quotas url for specific region.

func (*IdentityManager) GetToken

func (mgr *IdentityManager) GetToken() (string, error)

GetToken returns Openstack token.

type IdentityManagerInterface

type IdentityManagerInterface interface {
	GetToken() (string, error)
	GetEndpointForRegion(region string) (string, error)
}

type QuotaRegionalClient

type QuotaRegionalClient struct {
	UserAgent   string
	HTTPClient  *http.Client
	IdentityMgr IdentityManagerInterface
}

QuotaRegionalClient stores details that are needed to work with quotas Selectel APIs.

func NewQuotaRegionalClient

func NewQuotaRegionalClient(httpClient *http.Client, identityMgr IdentityManagerInterface) *QuotaRegionalClient

NewQuotaRegionalClient creates regional quota client with Openstack identity and HTTP client.

func (*QuotaRegionalClient) BuildPath

func (mgr *QuotaRegionalClient) BuildPath(region, projectID, path string) (string, error)

BuildPath builds quotas url for specific region and project.

func (*QuotaRegionalClient) DoRequest

func (mgr *QuotaRegionalClient) DoRequest(ctx context.Context, method, path string, body io.Reader) (*ResponseResult, error)

DoRequest performs the HTTP request with the current ServiceClient's HTTPClient. Authentication and optional headers will be added automatically.

type ResponseResult

type ResponseResult struct {
	*http.Response

	// Err contains error that can be provided to a caller.
	Err error
}

func (*ResponseResult) ExtractErr

func (result *ResponseResult) ExtractErr() (string, error)

func (*ResponseResult) ExtractResult

func (result *ResponseResult) ExtractResult(to interface{}) error

ExtractResult allows to provide an object into which ResponseResult body will be extracted.

Directories

Path Synopsis
Package quotas provides the ability to retrieve and update quotas through the Quota Manager API.
Package quotas provides the ability to retrieve and update quotas through the Quota Manager API.

Jump to

Keyboard shortcuts

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