edgecloud

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MPL-2.0 Imports: 27 Imported by: 1

README ¶

EdgeCenter cloud API client

Command line client to EdgeCenter cloud API.

Building the binary locally

To build the binary locally, run the following command:

make build

This will create a binary called ec_client in the bin directory.

Getting started

Downloading and using the environment file from Vault

To download the environment file from Vault, first, install Vault and jq by running:

make install_vault
make install_jq

Next, set your Vault token to terminal for install_vault command

Then, download the environment file by running:

make download_env_file

This will download the environment file and save it as .env :

  • EC_CLOUD_USERNAME - username
  • EC_CLOUD_PASSWORD - user's password
  • EC_CLOUD_PROJECT - project id
  • EC_CLOUD_REGION - region id
  • EC_CLOUD_AUTH_URL - authentication url, you could use the same as in example above
  • EC_CLOUD_API_URL - api url, you could use the same as in example above
  • EC_CLOUD_CLIENT_TYPE - client type, you could use the same as in example above
Running the client:

After setting the env, use -h key to retrieve all available commands:

./bin/ec_client -h

   NAME:
   ec_client - EdgeCloud API client

   Environment variables example:

   EC_CLOUD_AUTH_URL=
   EC_CLOUD_API_URL=
   EC_CLOUD_API_VERSION=v1
   EC_CLOUD_USERNAME=
   EC_CLOUD_PASSWORD=
   EC_CLOUD_REGION=
   EC_CLOUD_PROJECT=

USAGE:
   ./bin/ec_client [global options] command [command options] [arguments...]

VERSION:
   v0.3.00

COMMANDS:
   network        EdgeCloud networks API
   task           EdgeCloud tasks API
   keypair        EdgeCloud keypairs V2 API
   volume         EdgeCloud volumes API
   subnet         EdgeCloud subnets API
   flavor         EdgeCloud flavors API
   loadbalancer   EdgeCloud loadbalancers API
   instance       EdgeCloud instances API
   heat           EdgeCloud Heat API
   securitygroup  EdgeCloud security groups API
   floatingip     EdgeCloud floating ips API
   port           EdgeCloud ports API
   snapshot       EdgeCloud snapshots API
   image          EdgeCloud images API
   region         EdgeCloud regions API
   project        EdgeCloud projects API
   keystone       EdgeCloud keystones API
   quota          EdgeCloud quotas API
   limit          EdgeCloud limits API
   cluster        EdgeCloud k8s cluster commands
   pool           EdgeCloud K8s pool commands
   l7policy       EdgeCloud l7policy API
   router         EdgeCloud router API
   fixed_ip       EdgeCloud reserved fixed ip API
   help, h        Shows a list of commands or help for one command

Running tests locally

To run the tests locally using the following command:

make run_local_tests

This command will run the tests and display the output, excluding lines with 'no test files'.

Running linters locally

To run linters locally, you will need to run a series of checks, including go vet, go fmt, gofumpt, and golangci-lint. First, run the following commands to check the code for errors and format it:

make checks

Next, run the linters using the following command:

make linters

This will run the golangci-lint tool and display any issues found in the code.

Note: If you don't have golangci-lint installed, the make linters command will automatically download and install it for you.

Documentation ¶

Index ¶

Constants ¶

View Source
const DefaultUserAgent = "edgecloud-go-client/0.3.0"

DefaultUserAgent is the default User-Agent string set in the request header.

View Source
const RFC3339Date = "2006-01-02"

RFC3339Date describes a common time format used by some API responses.

View Source
const RFC3339Milli = "2006-01-02T15:04:05.999999Z"

RFC3339Milli describes a common time format used by some API responses.

View Source
const RFC3339MilliNoZ = "2006-01-02T15:04:05.999999"

RFC3339MilliNoZ is the time format with millis.

View Source
const RFC3339NoZ = "2006-01-02T15:04:05"

RFC3339NoZ is the time format used in Heat (Orchestration).

View Source
const RFC3339Z = "2006-01-02T15:04:05-0700"

RFC3339Z is the time format used in Heat (Orchestration).

View Source
const RFC3339ZColon = "2006-01-02T15:04:05-07:00"

RFC3339ZColon is the time format used in secrets.

View Source
const RFC3339ZNoT = "2006-01-02 15:04:05-07:00"

RFC3339ZNoT is the time format used in Zun (Containers Service).

View Source
const RFC3339ZNoTNoZ = "2006-01-02 15:04:05"

RFC3339ZNoTNoZ is another time format used in Zun (Containers Service).

View Source
const RFC3339ZZ = "2006-01-02T15:04:05Z"

RFC3339ZZ describes a common time format used by some API responses.

Variables ¶

View Source
var (
	Validate *validator.Validate
	Trans    ut.Translator
)

Functions ¶

func BuildHeaders ¶

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

BuildHeaders is an internal function to be used by request methods in individual resource packages.

It accepts an arbitrary tagged structure and produces a string map that's suitable for use as the HTTP headers of an outgoing request. Field names are mapped to header names based in "h" tags.

type struct Something {
  Bar string `h:"x_bar"`
  Baz int    `h:"lorem_ipsum"`
}

instance := Something{
  Bar: "AAA",
  Baz: "BBB",
}

will be converted into:

map[string]string{
  "x_bar": "AAA",
  "lorem_ipsum": "BBB",
}

Untagged fields and fields left at their zero values are skipped. Integers, booleans and string values are supported.

func BuildQueryString ¶

func BuildQueryString(opts interface{}) (*url.URL, error)

BuildQueryString is an internal function to be used by request methods in individual resource packages.

It accepts a tagged structure and expands it into a URL struct. Field names are converted into query parameters based on a "q" tag. For example:

type struct Something {
   Bar string `q:"x_bar"`
   Baz int    `q:"lorem_ipsum"`
}

instance := Something{
   Bar: "AAA",
   Baz: "BBB",
}

will be converted into "?x_bar=AAA&lorem_ipsum=BBB".

type struct Something {
   Bar []string `q:"x_bar",delimiter:"comma"`
   Baz int    `q:"lorem_ipsum"`
}

instance := Something{
   Bar: []string{"AAA", "CCC"},
   Baz: "BBB",
}

will be converted into "?x_bar=AAA,CCC&lorem_ipsum=BBB".

type struct Something {
   Bar []string `q:"x_bar"`
   Baz int    `q:"lorem_ipsum"`
}

instance := Something{
   Bar: []string{"AAA", "CCC"},
   Baz: "BBB",
}

will be converted into "?x_bar=AAA&x_bar=CCC&lorem_ipsum=BBB".

The struct's fields may be strings, integers, or boolean values. Fields left at their type's zero value will be omitted from the query.

func BuildRequestBody ¶

func BuildRequestBody(opts interface{}, parent string) (map[string]interface{}, error)

func BuildSliceRequestBody ¶

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

func ContainsString ¶

func ContainsString(s []string, e string) bool

func ExtractNextURL ¶

func ExtractNextURL(links []Link) (string, error)

ExtractNextURL is an internal function useful for packages of collection resources that are paginated in a certain way.

It attempts to extract the "next" URL from slice of Link structs, or "" if no such URL is present.

func FailOnErrorF ¶

func FailOnErrorF(err error, msg string, args ...interface{})

func IDSliceToQueryString ¶

func IDSliceToQueryString(name string, ids []int) string

IDSliceToQueryString takes a slice of elements and converts them into a query string. For example, if name=foo and slice=[]int{20, 40, 60}, then the result would be `?name=20&name=40&name=60'.

func IntToPointer ¶

func IntToPointer(i int) *int

IntToPointer is a function for converting integers into integer pointers. This is useful when passing in options to operations.

func IntWithinRange ¶

func IntWithinRange(val, min, max int) bool

IntWithinRange returns TRUE if an integer falls within a defined range, and FALSE if not.

func MaybeInt ¶

func MaybeInt(original int) *int

MaybeInt is an internal function to be used by request methods in individual resource packages.

Like MaybeString, it accepts an int that may or may not be a zero value, and returns either a pointer to its address or nil. It's intended to hint that the JSON serializer should omit its field.

func MaybeString ¶

func MaybeString(original string) *string

MaybeString is an internal function to be used by request methods in individual resource packages.

It takes a string that might be a zero value and returns either a pointer to its address or nil. This is useful for allowing users to conveniently omit values from an options struct by leaving them zeroed, but still pass nil to the JSON serializer so they'll be omitted from the request body.

func NativeMapToStruct ¶

func NativeMapToStruct(nativeMap interface{}, obj interface{}) error

NativeMapToStruct converts from map to struct.

func NormalizePathURL ¶

func NormalizePathURL(basePath, rawPath string) (string, error)

NormalizePathURL is used to convert rawPath to a fqdn, using basePath as a reference in the filesystem, if necessary. basePath is assumed to contain either '.' when first used, or the file:// type fqdn of the parent resource. e.g. myFavScript.yaml => file://opt/lib/myFavScript.yaml

func NormalizeURL ¶

func NormalizeURL(url string) string

NormalizeURL is an internal function to be used by provider clients.

It ensures that each endpoint URL has a closing `/`, as expected by ServiceClient's methods.

func StripLastSlashURL ¶

func StripLastSlashURL(url string) string

StripLastSlashURL removes last slash symbols from url.

func TranslateValidationError ¶

func TranslateValidationError(err error) error

func ValidateStruct ¶

func ValidateStruct(s interface{}) error

func WaitFor ¶

func WaitFor(timeout int, predicate func() (bool, error)) error

WaitFor polls a predicate function, once per second, up to a timeout limit. This is useful to wait for a resource to transition to a certain state. To handle situations when the predicate might hang indefinitely, the predicate will be prematurely cancelled after the timeout. Resource packages will wrap this in a more convenient function that's specific to a certain resource, but it can also be useful on its own.

Types ¶

type APIKeyProvidedError ¶ added in v0.1.4

type APIKeyProvidedError struct{ BaseError }

APIKeyProvidedError indicates that an APIKey was provided but can't be used.

func (APIKeyProvidedError) Error ¶ added in v0.1.4

func (e APIKeyProvidedError) Error() string

type APITokenAPISettings ¶

type APITokenAPISettings struct {
	APIURL   string `json:"url,omitempty"`
	APIToken string `json:"-"`
	Type     string `json:"type,omitempty"`
	Name     string `json:"name,omitempty"`
	Region   int    `json:"region,omitempty"`
	Project  int    `json:"project,omitempty"`
	Version  string `json:"version,omitempty"`
	Debug    bool   `json:"debug,omitempty"`
}

APITokenAPISettings - settings for api token client building.

func (APITokenAPISettings) ToAPITokenOptions ¶

func (gs APITokenAPISettings) ToAPITokenOptions() APITokenOptions

ToAPITokenOptions implements APITokenClientSettings interface.

func (APITokenAPISettings) ToEndpointOptions ¶

func (gs APITokenAPISettings) ToEndpointOptions() EndpointOpts

ToEndpointOptions implements APITokenClientSettings interface.

func (APITokenAPISettings) Validate ¶

func (gs APITokenAPISettings) Validate() error

Validate implements TokenClientSettings interface.

type APITokenClientSettings ¶

type APITokenClientSettings interface {
	ToAPITokenOptions() APITokenOptions
	ToEndpointOptions() EndpointOpts
	Validate() error
}

APITokenClientSettings interface.

type APITokenOptions ¶

type APITokenOptions struct {
	APIURL   string `json:"-"`
	APIToken string `json:"-"`
}

APITokenOptions edgecenter API.

type AfterReauthenticationError ¶ added in v0.1.4

type AfterReauthenticationError struct {
	BaseError
	ErrOriginal error
}

AfterReauthenticationError is the error type returned when reauthentication succeeds, but an error occurs afterword (usually an HTTP error).

func (AfterReauthenticationError) Error ¶ added in v0.1.4

type AppCredMissingSecretError ¶ added in v0.1.4

type AppCredMissingSecretError struct{ BaseError }

AppCredMissingSecretError indicates that no Application Credential Secret was provided with Application Credential ID or Name.

func (AppCredMissingSecretError) Error ¶ added in v0.1.4

type AuthClientSettings ¶

type AuthClientSettings interface {
	ToAuthOptions() AuthOptions
	ToEndpointOptions() EndpointOpts
	Validate() error
}

AuthClientSettings interface.

type AuthOptions ¶

type AuthOptions struct {
	APIURL      string `json:"-"`
	AuthURL     string `json:"-"`
	Username    string `json:"username,omitempty"`
	Password    string `json:"password,omitempty"`
	AllowReauth bool   `json:"-"`
	ClientID    string `json:"-"`
}

AuthOptions edgecenter API.

func (AuthOptions) ToMap ¶

func (ao AuthOptions) ToMap() map[string]interface{}

ToMap implements AuthOptionsBuilder.

type AuthOptionsBuilder ¶

type AuthOptionsBuilder interface {
	ToMap() map[string]interface{}
}

AuthOptionsBuilder build auth options to map.

type AuthResult ¶

type AuthResult interface {
	ExtractAccessToken() (string, error)
	ExtractRefreshToken() (string, error)
	ExtractTokensPair() (string, string, error)
}

AuthResult interface.

type BaseError ¶

type BaseError struct {
	DefaultErrString string
	Info             string
}

BaseError is an error type that all other error types embed.

func (BaseError) Error ¶

func (e BaseError) Error() string

type CIDR ¶

type CIDR struct {
	net.IPNet
}

func ParseCIDRString ¶

func ParseCIDRString(s string) (*CIDR, error)

func ParseCIDRStringOrNil ¶

func ParseCIDRStringOrNil(s string) (*CIDR, error)

func (CIDR) MarshalJSON ¶

func (c CIDR) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface for CIDR.

func (CIDR) String ¶

func (c CIDR) String() string

String - implements Stringer.

func (*CIDR) UnmarshalJSON ¶

func (c *CIDR) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for CIDR.

type Currency ¶

type Currency struct {
	*currency.Currency
}

func ParseCurrency ¶

func ParseCurrency(s string) (*Currency, error)

func (Currency) MarshalJSON ¶

func (c Currency) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface for Currency.

func (Currency) String ¶

func (c Currency) String() string

String - implements Stringer.

func (*Currency) UnmarshalJSON ¶

func (c *Currency) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for Currency.

type Default400Error ¶ added in v0.1.4

type Default400Error struct {
	UnexpectedResponseCodeError
}

Default400Error is the default error type returned on a 400 HTTP response code.

func (Default400Error) Error ¶ added in v0.1.4

func (e Default400Error) Error() string

type Default401Error ¶ added in v0.1.4

type Default401Error struct {
	UnexpectedResponseCodeError
}

Default401Error is the default error type returned on a 401 HTTP response code.

func (Default401Error) Error ¶ added in v0.1.4

func (e Default401Error) Error() string

type Default403Error ¶ added in v0.1.4

type Default403Error struct {
	UnexpectedResponseCodeError
}

Default403Error is the default error type returned on a 403 HTTP response code.

func (Default403Error) Error ¶ added in v0.1.4

func (e Default403Error) Error() string

type Default404Error ¶ added in v0.1.4

type Default404Error struct {
	UnexpectedResponseCodeError
}

Default404Error is the default error type returned on a 404 HTTP response code.

func (Default404Error) Error ¶ added in v0.1.4

func (e Default404Error) Error() string

type Default405Error ¶ added in v0.1.4

type Default405Error struct {
	UnexpectedResponseCodeError
}

Default405Error is the default error type returned on a 405 HTTP response code.

func (Default405Error) Error ¶ added in v0.1.4

func (e Default405Error) Error() string

type Default408Error ¶ added in v0.1.4

type Default408Error struct {
	UnexpectedResponseCodeError
}

Default408Error is the default error type returned on a 408 HTTP response code.

func (Default408Error) Error ¶ added in v0.1.4

func (e Default408Error) Error() string

type Default409Error ¶ added in v0.1.4

type Default409Error struct {
	UnexpectedResponseCodeError
}

Default409Error is the default error type returned on a 409 HTTP response code.

func (Default409Error) Error ¶ added in v0.1.4

func (e Default409Error) Error() string

type Default429Error ¶ added in v0.1.4

type Default429Error struct {
	UnexpectedResponseCodeError
}

Default429Error is the default error type returned on a 429 HTTP response code.

func (Default429Error) Error ¶ added in v0.1.4

func (e Default429Error) Error() string

type Default500Error ¶ added in v0.1.4

type Default500Error struct {
	UnexpectedResponseCodeError
}

Default500Error is the default error type returned on a 500 HTTP response code.

func (Default500Error) Error ¶ added in v0.1.4

func (e Default500Error) Error() string

type Default503Error ¶ added in v0.1.4

type Default503Error struct {
	UnexpectedResponseCodeError
}

Default503Error is the default error type returned on a 503 HTTP response code.

func (Default503Error) Error ¶ added in v0.1.4

func (e Default503Error) Error() string

type DomainIDOrDomainNameError ¶ added in v0.1.4

type DomainIDOrDomainNameError struct{ BaseError }

DomainIDOrDomainNameError indicates that a username was provided, but no domain to scope it. It may also indicate that both a DomainID and a DomainName were provided at once.

func (DomainIDOrDomainNameError) Error ¶ added in v0.1.4

type DomainIDWithTokenError ¶ added in v0.1.4

type DomainIDWithTokenError struct{ BaseError }

DomainIDWithTokenError indicates that a DomainID was provided, but token authentication is being used instead.

func (DomainIDWithTokenError) Error ¶ added in v0.1.4

func (e DomainIDWithTokenError) Error() string

type DomainIDWithUserIDError ¶ added in v0.1.4

type DomainIDWithUserIDError struct{ BaseError }

DomainIDWithUserIDError indicates that a DomainID was provided, but unnecessary because a UserID is being used.

func (DomainIDWithUserIDError) Error ¶ added in v0.1.4

func (e DomainIDWithUserIDError) Error() string

type DomainNameWithTokenError ¶ added in v0.1.4

type DomainNameWithTokenError struct{ BaseError }

DomainNameWithTokenError indicates that a DomainName was provided, but token authentication is being used instead.

func (DomainNameWithTokenError) Error ¶ added in v0.1.4

func (e DomainNameWithTokenError) Error() string

type DomainNameWithUserIDError ¶ added in v0.1.4

type DomainNameWithUserIDError struct{ BaseError }

DomainNameWithUserIDError indicates that a DomainName was provided, but unnecessary because a UserID is being used.

func (DomainNameWithUserIDError) Error ¶ added in v0.1.4

type ECErrorType ¶

type ECErrorType struct {
	ExceptionClass string `json:"exception_class"`
	Message        string `json:"message"`
	Traceback      string `json:"traceback"`
}

type EnabledState ¶

type EnabledState *bool

EnabledState is a convenience type, mostly used in Create and Update operations. Because the zero value of a bool is FALSE, we need to use a pointer instead to indicate zero-ness.

var (
	Enabled  EnabledState = &iTrue
	Disabled EnabledState = &iFalse
)

Convenience vars for EnabledState values.

type EndpointLocator ¶

type EndpointLocator func(EndpointOpts) (string, error)

EndpointLocator is an internal function to be used by provider implementations.

It provides an implementation that locates a single endpoint from a service catalog for a specific ProviderClient based on user-provided EndpointOpts. The provider then uses it to discover related ServiceClients.

func DefaultEndpointLocator ¶

func DefaultEndpointLocator(endpoint string) EndpointLocator

DefaultEndpointLocator - function to prepare API endpoint.

type EndpointNotFoundError ¶ added in v0.1.4

type EndpointNotFoundError struct {
	BaseError
}

EndpointNotFoundError is returned when no available endpoints match the provided EndpointOpts. This is also generally returned by provider service factory methods, and usually indicates that a region was specified incorrectly.

func (EndpointNotFoundError) Error ¶ added in v0.1.4

func (e EndpointNotFoundError) Error() string

type EndpointOpts ¶

type EndpointOpts struct {
	// Type [required] is the service type for the client (e.g., "cluster",
	// "nodegroup", "clustertemplates"). Generally, this will be supplied by the service client
	// function, but a user-given value will be honored if provided.
	Type string

	// Name [optional] is the service name for the client (e.g., "k8s") as it
	// appears in the service catalog. Services can have the same Type but a
	// different Name, which is why both Type and Name are sometimes needed.
	Name string

	// Region [required] is the geographic region in which the endpoint resides,
	// generally specifying which datacenter should house your resources.
	// Required only for services that span multiple regions.
	Region int

	// Project [required] is EdgeCenter project
	Project int

	// version
	Version string
}

EndpointOpts specifies search criteria used by queries against an EdgeCenter service. The options must contain enough information to unambiguously identify one, and only one, endpoint within the catalog.

Usually, these are passed to service client factory functions in a provider package, like "edgecenter.NewClusterTemplateV1()".

func (*EndpointOpts) ApplyDefaults ¶

func (eo *EndpointOpts) ApplyDefaults(t string)

ApplyDefaults is an internal method to be used by provider implementations.

It sets EndpointOpts fields if not already set, including a default type.

type EnumValidator ¶

type EnumValidator interface {
	IsValid() error
	StringList() []string
}

type Err400er ¶

type Err400er interface {
	Error400(UnexpectedResponseCodeError) error
}

Err400er is the interface resource error types implement to override the error message from a 400 error.

type Err401er ¶

type Err401er interface {
	Error401(UnexpectedResponseCodeError) error
}

Err401er is the interface resource error types implement to override the error message from a 401 error.

type Err403er ¶

type Err403er interface {
	Error403(UnexpectedResponseCodeError) error
}

Err403er is the interface resource error types implement to override the error message from a 403 error.

type Err404er ¶

type Err404er interface {
	Error404(UnexpectedResponseCodeError) error
}

Err404er is the interface resource error types implement to override the error message from a 404 error.

type Err405er ¶

type Err405er interface {
	Error405(UnexpectedResponseCodeError) error
}

Err405er is the interface resource error types implement to override the error message from a 405 error.

type Err408er ¶

type Err408er interface {
	Error408(UnexpectedResponseCodeError) error
}

Err408er is the interface resource error types implement to override the error message from a 408 error.

type Err409er ¶

type Err409er interface {
	Error409(UnexpectedResponseCodeError) error
}

Err409er is the interface resource error types implement to override the error message from a 409 error.

type Err429er ¶

type Err429er interface {
	Error429(UnexpectedResponseCodeError) error
}

Err429er is the interface resource error types implement to override the error message from a 429 error.

type Err500er ¶

type Err500er interface {
	Error500(UnexpectedResponseCodeError) error
}

Err500er is the interface resource error types implement to override the error message from a 500 error.

type Err503er ¶

type Err503er interface {
	Error503(UnexpectedResponseCodeError) error
}

Err503er is the interface resource error types implement to override the error message from a 503 error.

type ErrResult ¶

type ErrResult struct {
	Result
}

ErrResult is an internal type to be used by individual resource packages, but its methods will be available on a wide variety of user-facing embedding types.

It represents results that only contain a potential error and nothing else. Usually, if the operation executed successfully, the Err field will be nil; otherwise it will be stocked with a relevant error. Use the ExtractErr method to cleanly pull it out.

func (ErrResult) ExtractErr ¶

func (r ErrResult) ExtractErr() error

ExtractErr is a function that extracts error information, or nil, from a result.

type HeaderResult ¶

type HeaderResult struct {
	Result
}

HeaderResult is an internal type to be used by individual resource packages, but its methods will be available on a wide variety of user-facing embedding types.

It represents a result that only contains an error (possibly nil) and an http.Header. This is used, for example, by the objectstorage packages in openstack, because most of the operations don't return response bodies, but do have relevant information in headers.

func (HeaderResult) ExtractInto ¶

func (r HeaderResult) ExtractInto(to interface{}) error

ExtractInto allows users to provide an object into which `Extract` will extract the http.Header headers of the result.

type IPVersion ¶

type IPVersion int

IPVersion is a type for the possible IP address versions. Valid instances are IPv4 and IPv6.

const (
	// IPv4 is used for IP version 4 addresses.
	IPv4 IPVersion = 4
	// IPv6 is used for IP version 6 addresses.
	IPv6 IPVersion = 6
)

type InvalidInputError ¶ added in v0.1.4

type InvalidInputError struct {
	MissingInputError
	Value interface{}
}

InvalidInputError is an error type used for most non-HTTP Gophercloud errors.

func (InvalidInputError) Error ¶ added in v0.1.4

func (e InvalidInputError) Error() string

type ItemID ¶

type ItemID struct {
	ID string `json:"id"`
}

type ItemIDName ¶

type ItemIDName struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type ItemName ¶

type ItemName struct {
	Name string `json:"name"`
}

type JSONRFC1123 ¶

type JSONRFC1123 time.Time

JSONRFC1123 describes time.Time in time.RFC1123 format.

func (*JSONRFC1123) UnmarshalJSON ¶

func (jt *JSONRFC1123) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC1123.

type JSONRFC3339Date ¶

type JSONRFC3339Date struct {
	time.Time
}

JSONRFC3339Date describes time.Time in RFC3339Date format.

func (*JSONRFC3339Date) MarshalJSON ¶

func (jt *JSONRFC3339Date) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface for JSONRFC3339Date.

func (*JSONRFC3339Date) UnmarshalJSON ¶

func (jt *JSONRFC3339Date) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339Date.

type JSONRFC3339Milli ¶

type JSONRFC3339Milli time.Time

JSONRFC3339Milli describes time.Time in RFC3339Milli format.

func (*JSONRFC3339Milli) UnmarshalJSON ¶

func (jt *JSONRFC3339Milli) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339Milli.

type JSONRFC3339MilliNoZ ¶

type JSONRFC3339MilliNoZ time.Time

JSONRFC3339MilliNoZ describes time.Time in RFC3339MilliNoZ format.

func (*JSONRFC3339MilliNoZ) UnmarshalJSON ¶

func (jt *JSONRFC3339MilliNoZ) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339MilliNoZ.

type JSONRFC3339NoZ ¶

type JSONRFC3339NoZ struct {
	time.Time
}

JSONRFC3339NoZ describes time.Time in RFC3339NoZ format.

func (*JSONRFC3339NoZ) MarshalJSON ¶

func (jt *JSONRFC3339NoZ) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface for JSONRFC3339NoZ.

func (*JSONRFC3339NoZ) String ¶

func (jt *JSONRFC3339NoZ) String() string

func (*JSONRFC3339NoZ) UnmarshalJSON ¶

func (jt *JSONRFC3339NoZ) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339NoZ.

type JSONRFC3339Z ¶

type JSONRFC3339Z struct {
	time.Time
}

JSONRFC3339Z describes time.Time in RFC3339Z format.

func (*JSONRFC3339Z) MarshalJSON ¶

func (jt *JSONRFC3339Z) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface for JSONRFC3339Z.

func (*JSONRFC3339Z) UnmarshalJSON ¶

func (jt *JSONRFC3339Z) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339Z.

type JSONRFC3339ZColon ¶

type JSONRFC3339ZColon struct {
	time.Time
}

JSONRFC3339ZColon describes time.Time in RFC3339ZColon format.

func (*JSONRFC3339ZColon) MarshalJSON ¶

func (jt *JSONRFC3339ZColon) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface for JSONRFC3339ZColon.

func (*JSONRFC3339ZColon) UnmarshalJSON ¶

func (jt *JSONRFC3339ZColon) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339ZColon.

type JSONRFC3339ZNoT ¶

type JSONRFC3339ZNoT time.Time

JSONRFC3339ZNoT describes time.Time in RFC3339ZNoT format.

func (*JSONRFC3339ZNoT) UnmarshalJSON ¶

func (jt *JSONRFC3339ZNoT) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339ZNoT.

type JSONRFC3339ZNoTNoZ ¶

type JSONRFC3339ZNoTNoZ time.Time

JSONRFC3339ZNoTNoZ describes time.Time in RFC3339ZNoTNoZ format.

func (*JSONRFC3339ZNoTNoZ) UnmarshalJSON ¶

func (jt *JSONRFC3339ZNoTNoZ) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339ZNoTNoZ.

type JSONRFC3339ZZ ¶

type JSONRFC3339ZZ struct {
	time.Time
}

JSONRFC3339ZZ describes time.Time in RFC3339ZZ format.

func (*JSONRFC3339ZZ) MarshalJSON ¶

func (jt *JSONRFC3339ZZ) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface for JSONRFC3339ZZ.

func (*JSONRFC3339ZZ) UnmarshalJSON ¶

func (jt *JSONRFC3339ZZ) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONRFC3339ZZ.

type JSONUnix ¶

type JSONUnix time.Time

JSONUnix describes time.Time in unix format.

func (*JSONUnix) UnmarshalJSON ¶

func (jt *JSONUnix) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for JSONUnix.

type Link struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
}

Link is an internal type to be used in packages of collection resources that are paginated in a certain way.

It's a response substructure common to many paginated collection results that is used to point to related pages. Usually, the one we care about is the one with Rel field set to "next".

type MAC ¶

type MAC struct {
	net.HardwareAddr
}

func ParseMacString ¶

func ParseMacString(s string) (*MAC, error)

func (MAC) MarshalJSON ¶

func (m MAC) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface for MAC.

func (MAC) String ¶

func (m MAC) String() string

String - implements Stringer.

func (*MAC) UnmarshalJSON ¶

func (m *MAC) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface for MAC.

type MissingAnyoneOfEnvironmentVariablesError ¶ added in v0.1.4

type MissingAnyoneOfEnvironmentVariablesError struct {
	BaseError
	EnvironmentVariables []string
}

MissingAnyoneOfEnvironmentVariablesError is the error when anyone of the environment variables is required in a particular situation but not provided by the user.

func (MissingAnyoneOfEnvironmentVariablesError) Error ¶ added in v0.1.4

type MissingEnvironmentVariableError ¶ added in v0.1.4

type MissingEnvironmentVariableError struct {
	BaseError
	EnvironmentVariable string
}

MissingEnvironmentVariableError is the error when environment variable is required in a particular situation but not provided by the user.

func (MissingEnvironmentVariableError) Error ¶ added in v0.1.4

type MissingInputError ¶ added in v0.1.4

type MissingInputError struct {
	BaseError
	Argument string
}

MissingInputError is the error when input is required in a particular situation but not provided by the user.

func (MissingInputError) Error ¶ added in v0.1.4

func (e MissingInputError) Error() string

type MissingPasswordError ¶ added in v0.1.4

type MissingPasswordError struct{ BaseError }

MissingPasswordError indicates that no password was provided and no token is available.

func (MissingPasswordError) Error ¶ added in v0.1.4

func (e MissingPasswordError) Error() string

type MultipleResourcesFoundError ¶ added in v0.1.4

type MultipleResourcesFoundError struct {
	BaseError
	Name         string
	Count        int
	ResourceType string
}

MultipleResourcesFoundError is the error when trying to retrieve a resource's ID by name and multiple resources have the user-provided name.

func (MultipleResourcesFoundError) Error ¶ added in v0.1.4

type PasswordAPISettings ¶

type PasswordAPISettings struct {
	APIURL      string `json:"api-url,omitempty"`
	AuthURL     string `json:"auth-url,omitempty"`
	Username    string `json:"username,omitempty"`
	Password    string `json:"password,omitempty"`
	AllowReauth bool   `json:"-"`
	Type        string `json:"type,omitempty"`
	Name        string `json:"name,omitempty"`
	Region      int    `json:"region,omitempty"`
	Project     int    `json:"project,omitempty"`
	Version     string `json:"version,omitempty"`
	Debug       bool   `json:"debug,omitempty"`
}

PasswordAPISettings - settings for password client building.

func (PasswordAPISettings) ToAuthOptions ¶

func (gs PasswordAPISettings) ToAuthOptions() AuthOptions

ToAuthOptions implements AuthClientSettings interface.

func (PasswordAPISettings) ToEndpointOptions ¶

func (gs PasswordAPISettings) ToEndpointOptions() EndpointOpts

ToEndpointOptions implements AuthClientSettings interface.

func (PasswordAPISettings) Validate ¶

func (gs PasswordAPISettings) Validate() error

Validate implements AuthClientSettings interface.

type ProviderClient ¶

type ProviderClient struct {
	// IdentityBase is the base URL used for a particular provider's identity
	// service - it will be used when issuing authentication requests. It
	// should point to the root resource of the identity service, not a specific
	// identity version.
	IdentityBase string

	// APIURL is the identity endpoint. This may be a specific version
	// of the identity service. If this is the case, this endpoint is used rather
	// than querying versions first.
	IdentityEndpoint string

	// AccessTokenID and RefreshTokenID is the IDs of the most recently issued valid tokens.
	// NOTE: Aside from within a custom ReauthFunc, this field shouldn't be set by an application.
	// To safely read or write this value, call `AccessToken` or `SetAccessToken`
	// call `RefreshToken` or `SetRefreshToken`, respectively
	AccessTokenID  string
	RefreshTokenID string

	// EndpointLocator describes how this provider discovers the endpoints for
	// its constituent services.
	EndpointLocator EndpointLocator

	// HTTPClient allows users to interject arbitrary http, https, or other transit behaviors.
	HTTPClient http.Client

	// UserAgent represents the User-Agent header in the HTTP request.
	UserAgent UserAgent

	// ReauthFunc is the function used to re-authenticate the user if the request
	// fails with a 401 HTTP response code. This a needed because there may be multiple
	// authentication functions for different Identity service versions.
	ReauthFunc func() error

	// Throwaway determines whether if this client is a throw-away client. It's a copy of user's provider client
	// with the token and reauth func zeroed. Such client can be used to perform reauthorization.
	Throwaway bool

	// Context is the context passed to the HTTP request.
	Context context.Context //nolint: containedctx

	APIToken string
	APIBase  string
	// contains filtered or unexported fields
}

ProviderClient stores details that are required to interact with any services within a specific provider's API.

Generally, you acquire a ProviderClient by calling the NewClient method in the appropriate provider's child package, providing whatever authentication credentials are required.

func NewProviderClient ¶

func NewProviderClient() *ProviderClient

NewProviderClient - Default constructor.

func (*ProviderClient) AccessToken ¶

func (client *ProviderClient) AccessToken() string

AccessToken safely reads the value of the auth token from the ProviderClient. Applications should call this method to access the token instead of the AccessTokenID field.

func (*ProviderClient) AuthenticatedHeaders ¶

func (client *ProviderClient) AuthenticatedHeaders() (m map[string]string)

AuthenticatedHeaders returns a map of HTTP headers that are common for all authenticated service requests. Blocks if Reauthenticate is in progress.

func (*ProviderClient) CopyTokensFrom ¶

func (client *ProviderClient) CopyTokensFrom(other *ProviderClient)

CopyTokensFrom safely copies the token from another ProviderClient into this one.

func (*ProviderClient) GetAuthResult ¶

func (client *ProviderClient) GetAuthResult() AuthResult

GetAuthResult returns the result from the request that was used to obtain a provider client's token.

The result is nil when authentication has not yet taken place, when the token was set manually with SetToken(), or when a ReauthFunc was used that does not record the AuthResult.

func (*ProviderClient) IsDebug ¶

func (client *ProviderClient) IsDebug() bool

func (*ProviderClient) IsThrowaway ¶

func (client *ProviderClient) IsThrowaway() bool

IsThrowaway safely reads the value of the client Throwaway field.

func (*ProviderClient) Reauthenticate ¶

func (client *ProviderClient) Reauthenticate(previousToken string) error

Reauthenticate calls client.ReauthFunc in a thread-safe way. If this is called because of a 401 response, the caller may pass the previous token. In this case, the reauthentication can be skipped if another thread has already reauthenticated in the meantime. If no previous token is known, an empty string should be passed instead to force unconditional reauthentication.

func (*ProviderClient) RefreshToken ¶

func (client *ProviderClient) RefreshToken() string

RefreshToken safely reads the value of the auth token from the ProviderClient. Applications should call this method to access the token instead of the RefreshTokenID field.

func (*ProviderClient) Request ¶

func (client *ProviderClient) Request(method, url string, options *RequestOpts) (*http.Response, error)

Request performs an HTTP request using the ProviderClient's current HTTPClient. An authentication header will automatically be provided.

func (*ProviderClient) SetAPIToken ¶

func (client *ProviderClient) SetAPIToken(opt APITokenOptions) error

SetAPIToken safely sets the value of the api token in the ProviderClient.

func (*ProviderClient) SetDebug ¶

func (client *ProviderClient) SetDebug(debug bool)

SetDebug for request and response.

func (*ProviderClient) SetThrowaway ¶

func (client *ProviderClient) SetThrowaway(v bool)

SetThrowaway safely sets the value of the client Throwaway field.

func (*ProviderClient) SetTokensAndAuthResult ¶

func (client *ProviderClient) SetTokensAndAuthResult(r AuthResult) error

SetTokensAndAuthResult safely sets the value of the auth token in the ProviderClient and also records the AuthResult that was returned from the token creation request. Applications may call this in a custom ReauthFunc.

func (ProviderClient) ToTokenOptions ¶

func (client ProviderClient) ToTokenOptions() TokenOptions

ToTokenOptions - TokenOptions from ProviderClient.

func (*ProviderClient) UseTokenLock ¶

func (client *ProviderClient) UseTokenLock()

UseTokenLock creates a mutex that is used to allow safe concurrent access to the auth token. If the application's ProviderClient is not used concurrently, this doesn't need to be called.

type RequestOpts ¶

type RequestOpts struct {
	// JSONBody, if provided, will be encoded as JSON and used as the body of the HTTP request. The
	// content type of the request will default to "application/json" unless overridden by MoreHeaders.
	// It's an error to specify both a JSONBody and a RawBody.
	JSONBody interface{}
	// RawBody contains an io.Reader that will be consumed by the request directly. No content-type
	// will be set unless one is provided explicitly by MoreHeaders.
	RawBody io.Reader
	// JSONResponse, if provided, will be populated with the contents of the response body parsed as
	// JSON.
	JSONResponse interface{}
	// OkCodes contains a list of numeric HTTP status codes that should be interpreted as success. If
	// the response has a different code, an error will be returned.
	OkCodes []int
	// MoreHeaders specifies additional HTTP headers to be provide on the request. If a header is
	// provided with a blank value (""), that header will be *omitted* instead: use this to suppress
	// the default Accept header or an inferred Content-Type, for example.
	MoreHeaders map[string]string
	// ErrorContext specifies the resource error type to return if an error is encountered.
	// This lets resources override default error messages based on the response status code.
	ErrorContext error
}

RequestOpts customizes the behavior of the provider.Request() method.

type ResourceNotFoundError ¶ added in v0.1.4

type ResourceNotFoundError struct {
	BaseError
	Name         string
	ResourceType string
}

ResourceNotFoundError is the error when trying to retrieve a resource's ID by name and the resource doesn't exist.

func (ResourceNotFoundError) Error ¶ added in v0.1.4

func (e ResourceNotFoundError) Error() string

type Result ¶

type Result struct {
	// Body is the payload of the HTTP response from the server. In most cases,
	// this will be the deserialized JSON structure.
	Body interface{}

	// Header contains the HTTP header structure from the original response.
	Header http.Header

	// Err is an error that occurred during the operation. It's deferred until
	// extraction to make it easier to chain the Extract call.
	Err error
}

Result is an internal type to be used by individual resource packages, but its methods will be available on a wide variety of user-facing embedding types.

It acts as a base struct that other Result types, returned from request functions, can embed for convenience. All Results capture basic information from the HTTP transaction that was performed, including the response body, HTTP headers, and any errors that happened.

Generally, each Result type will have an Extract method that can be used to further interpret the result's payload in a specific context. Extensions or providers can then provide additional extraction functions to pull out provider- or extension-specific information as well.

func (Result) ExtractInto ¶

func (r Result) ExtractInto(to interface{}) error

ExtractInto allows users to provide an object into which `Extract` will extract the `Result.Body`. This would be useful for OpenStack providers that have different fields in the response object than OpenStack proper.

func (Result) ExtractIntoMapPtr ¶

func (r Result) ExtractIntoMapPtr(to interface{}, label string) error

ExtractIntoMapPtr will unmarshal the Result (r) into the provided interface{} (to).

NOTE: For internal use only

`to` must be a pointer to an underlying map type

If provided, `label` will be filtered out of the response body prior to `r` being unmarshalled into `to`.

func (Result) ExtractIntoSlicePtr ¶

func (r Result) ExtractIntoSlicePtr(to interface{}, label string) error

ExtractIntoSlicePtr will unmarshal the Result (r) into the provided interface{} (to).

NOTE: For internal use only

`to` must be a pointer to an underlying slice type

If provided, `label` will be filtered out of the response body prior to `r` being unmarshalled into `to`.

func (Result) ExtractIntoStructPtr ¶

func (r Result) ExtractIntoStructPtr(to interface{}, label string) error

ExtractIntoStructPtr will unmarshal the Result (r) into the provided interface{} (to).

NOTE: For internal use only

`to` must be a pointer to an underlying struct type

If provided, `label` will be filtered out of the response body prior to `r` being unmarshalled into `to`.

func (Result) PrettyPrintJSON ¶

func (r Result) PrettyPrintJSON() string

PrettyPrintJSON creates a string containing the full response body as pretty-printed JSON. It's useful for capturing test fixtures and for debugging extraction bugs. If you include its output in an issue related to a buggy extraction function, we will all love you forever.

type ScopeDomainIDOrDomainNameError ¶ added in v0.1.4

type ScopeDomainIDOrDomainNameError struct{ BaseError }

ScopeDomainIDOrDomainNameError indicates that a domain ID or Name was required in a Scope, but not present.

func (ScopeDomainIDOrDomainNameError) Error ¶ added in v0.1.4

type ScopeEmptyError ¶ added in v0.1.4

type ScopeEmptyError struct{ BaseError }

ScopeEmptyError indicates that no credentials were provided in a Scope.

func (ScopeEmptyError) Error ¶ added in v0.1.4

func (e ScopeEmptyError) Error() string

type ScopeProjectIDAloneError ¶ added in v0.1.4

type ScopeProjectIDAloneError struct{ BaseError }

ScopeProjectIDAloneError indicates that a ProjectID was provided with other constraints in a Scope.

func (ScopeProjectIDAloneError) Error ¶ added in v0.1.4

func (e ScopeProjectIDAloneError) Error() string

type ScopeProjectIDOrProjectNameError ¶ added in v0.1.4

type ScopeProjectIDOrProjectNameError struct{ BaseError }

ScopeProjectIDOrProjectNameError indicates that both a ProjectID and a ProjectName were provided in a Scope.

func (ScopeProjectIDOrProjectNameError) Error ¶ added in v0.1.4

type ServiceClient ¶

type ServiceClient struct {
	// ProviderClient is a reference to the provider that implements this service.
	*ProviderClient

	// Endpoint is the base URL of the service's API, acquired from a service catalog.
	// It MUST end with a /.
	Endpoint string

	// ResourceBase is the base URL shared by the resources within a service's API. It should include
	// the API version and, like Endpoint, MUST end with a / if set. If not set, the Endpoint is used
	// as-is, instead.
	ResourceBase string

	// This is the service client type (e.g. cluster, clustertemplates, nodegroup).
	// NOTE: FOR INTERNAL USE ONLY. DO NOT SET. EDGECENTER CLOUD WILL SET THIS.
	// It is only exported because it gets set in a different package.
	Type string

	// MoreHeaders allows users (or EdgeCenter cloud) to set service-wide headers on requests. Put another way,
	// values set in this field will be set on all the HTTP requests the service client sends.
	MoreHeaders map[string]string

	// RegionID is an id of chosen region
	RegionID int
}

ServiceClient stores details required to interact with a specific service API implemented by a provider. Generally, you'll acquire these by calling the appropriate `New` method on a ProviderClient.

func (*ServiceClient) BaseServiceURL ¶

func (client *ServiceClient) BaseServiceURL(parts ...string) string

BaseServiceURL constructs a URL for a resource belonging to this provider.

func (*ServiceClient) Delete ¶

func (client *ServiceClient) Delete(url string, opts *RequestOpts) (*http.Response, error)

Delete calls `Request` with the "DELETE" HTTP verb.

func (*ServiceClient) DeleteWithResponse ¶

func (client *ServiceClient) DeleteWithResponse(url string, jsonResponse interface{}, opts *RequestOpts) (*http.Response, error)

DeleteWithResponse calls `Request` with the "DELETE" HTTP verb.

func (*ServiceClient) Get ¶

func (client *ServiceClient) Get(url string, jsonResponse interface{}, opts *RequestOpts) (*http.Response, error)

Get calls `Request` with the "GET" HTTP verb.

func (*ServiceClient) Head ¶

func (client *ServiceClient) Head(url string, opts *RequestOpts) (*http.Response, error)

Head calls `Request` with the "HEAD" HTTP verb.

func (*ServiceClient) Patch ¶

func (client *ServiceClient) Patch(url string, jsonBody interface{}, jsonResponse interface{}, opts *RequestOpts) (*http.Response, error)

Patch calls `Request` with the "PATCH" HTTP verb.

func (*ServiceClient) Post ¶

func (client *ServiceClient) Post(url string, jsonBody interface{}, jsonResponse interface{}, opts *RequestOpts) (*http.Response, error)

Post calls `Request` with the "POST" HTTP verb.

func (*ServiceClient) Put ¶

func (client *ServiceClient) Put(url string, jsonBody interface{}, jsonResponse interface{}, opts *RequestOpts) (*http.Response, error)

Put calls `Request` with the "PUT" HTTP verb.

func (*ServiceClient) Request ¶

func (client *ServiceClient) Request(method, url string, options *RequestOpts) (*http.Response, error)

Request carries out the HTTP operation for the service client.

func (*ServiceClient) ResourceBaseURL ¶

func (client *ServiceClient) ResourceBaseURL() string

ResourceBaseURL returns the base URL of any resources used by this service. It MUST end with a /.

func (*ServiceClient) ServiceURL ¶

func (client *ServiceClient) ServiceURL(parts ...string) string

ServiceURL constructs a URL for a resource belonging to this provider.

type ServiceNotFoundError ¶ added in v0.1.4

type ServiceNotFoundError struct {
	BaseError
}

ServiceNotFoundError is returned when no service in a service catalog matches the provided EndpointOpts. This is generally returned by provider service factory methods like "NewComputeV2()" and can mean that a service is not enabled for your account.

func (ServiceNotFoundError) Error ¶ added in v0.1.4

func (e ServiceNotFoundError) Error() string

type StatusCodeError ¶

type StatusCodeError interface {
	Error() string
	GetStatusCode() int
}

StatusCodeError is a convenience interface to easily allow access to the status code field of the various ErrDefault* types.

By using this interface, you only have to make a single type cast of the returned error to err.(StatusCodeError) and then call GetStatusCode() instead of having a large switch statement checking for each of the ErrDefault* types.

type TenantIDProvidedError ¶ added in v0.1.4

type TenantIDProvidedError struct{ BaseError }

TenantIDProvidedError indicates that a TenantID was provided but can't be used.

func (TenantIDProvidedError) Error ¶ added in v0.1.4

func (e TenantIDProvidedError) Error() string

type TenantNameProvidedError ¶ added in v0.1.4

type TenantNameProvidedError struct{ BaseError }

TenantNameProvidedError indicates that a TenantName was provided but can't be used.

func (TenantNameProvidedError) Error ¶ added in v0.1.4

func (e TenantNameProvidedError) Error() string

type TimeOutError ¶ added in v0.1.4

type TimeOutError struct {
	BaseError
}

TimeOutError is the error type returned when an operations time out.

func (TimeOutError) Error ¶ added in v0.1.4

func (e TimeOutError) Error() string

type TokenAPISettings ¶

type TokenAPISettings struct {
	APIURL       string `json:"url,omitempty"`
	AccessToken  string `json:"access,omitempty"`
	RefreshToken string `json:"refresh,omitempty"`
	AllowReauth  bool   `json:"-"`
	Type         string `json:"type,omitempty"`
	Name         string `json:"name,omitempty"`
	Region       int    `json:"region,omitempty"`
	Project      int    `json:"project,omitempty"`
	Version      string `json:"version,omitempty"`
	Debug        bool   `json:"debug,omitempty"`
}

TokenAPISettings - settings for token client building.

func (TokenAPISettings) ToEndpointOptions ¶

func (gs TokenAPISettings) ToEndpointOptions() EndpointOpts

ToEndpointOptions implements TokenClientSettings interface.

func (TokenAPISettings) ToTokenOptions ¶

func (gs TokenAPISettings) ToTokenOptions() TokenOptions

ToTokenOptions implements TokenClientSettings interface.

func (TokenAPISettings) Validate ¶

func (gs TokenAPISettings) Validate() error

Validate implements TokenClientSettings interface.

type TokenClientSettings ¶

type TokenClientSettings interface {
	ToTokenOptions() TokenOptions
	ToEndpointOptions() EndpointOpts
	Validate() error
}

TokenClientSettings interface.

type TokenOptions ¶

type TokenOptions struct {
	APIURL       string `json:"-"`
	AccessToken  string `json:"access,omitempty"`
	RefreshToken string `json:"refresh,omitempty"`
	AllowReauth  bool   `json:"-"`
}

TokenOptions edgecenter API.

func (TokenOptions) ExtractAccessToken ¶

func (to TokenOptions) ExtractAccessToken() (string, error)

ExtractAccessToken implements AuthResult.

func (TokenOptions) ExtractRefreshToken ¶

func (to TokenOptions) ExtractRefreshToken() (string, error)

ExtractRefreshToken implements AuthResult.

func (TokenOptions) ExtractTokensPair ¶

func (to TokenOptions) ExtractTokensPair() (string, string, error)

ExtractTokensPair implements AuthResult.

func (TokenOptions) ToMap ¶

func (to TokenOptions) ToMap() map[string]interface{}

ToMap implements TokenOptionsBuilder.

type TokenOptionsBuilder ¶

type TokenOptionsBuilder interface {
	ToMap() map[string]interface{}
}

TokenOptionsBuilder build token options to map.

type URL ¶

type URL struct {
	*url.URL
}

func MustParseURL ¶

func MustParseURL(s string) *URL

func ParseURL ¶

func ParseURL(s string) (*URL, error)

func ParseURLNonMandatory ¶

func ParseURLNonMandatory(s string) (*URL, error)

func (URL) MarshalJSON ¶

func (u URL) MarshalJSON() ([]byte, error)

MarshalJSON - implements Marshaler interface.

func (URL) String ¶

func (u URL) String() string

String - implements Stringer.

func (*URL) UnmarshalJSON ¶

func (u *URL) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface.

type UnableToReauthenticateError ¶ added in v0.1.4

type UnableToReauthenticateError struct {
	BaseError
	ErrOriginal error
}

UnableToReauthenticateError is the error type returned when reauthentication fails.

func (UnableToReauthenticateError) Error ¶ added in v0.1.4

type UnexpectedResponseCodeError ¶ added in v0.1.4

type UnexpectedResponseCodeError struct {
	BaseError
	URL      string
	Method   string
	Expected []int
	Actual   int
	Body     []byte
}

UnexpectedResponseCodeError is returned by the Request method when a response code other than those listed in OkCodes is encountered.

func (UnexpectedResponseCodeError) Error ¶ added in v0.1.4

func (UnexpectedResponseCodeError) GetStatusCode ¶ added in v0.1.4

func (e UnexpectedResponseCodeError) GetStatusCode() int

GetStatusCode returns the actual status code of the error.

func (*UnexpectedResponseCodeError) ReadEcError ¶ added in v0.1.4

func (e *UnexpectedResponseCodeError) ReadEcError()

type UnexpectedTypeError ¶ added in v0.1.4

type UnexpectedTypeError struct {
	BaseError
	Expected string
	Actual   string
}

UnexpectedTypeError is the error when an unexpected type is encountered.

func (UnexpectedTypeError) Error ¶ added in v0.1.4

func (e UnexpectedTypeError) Error() string

type UserAgent ¶

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

UserAgent represents a User-Agent header.

func (*UserAgent) Join ¶

func (ua *UserAgent) Join() string

Join concatenates all the user-defined User-Agent strings with the default EdgeCenter cloud User-Agent string.

func (*UserAgent) Prepend ¶

func (ua *UserAgent) Prepend(s ...string)

Prepend prepends a user-defined string to the default User-Agent string. Users may pass in one or more strings to prepend.

type UserIDWithTokenError ¶ added in v0.1.4

type UserIDWithTokenError struct{ BaseError }

UserIDWithTokenError indicates that a UserID was provided, but token authentication is being used instead.

func (UserIDWithTokenError) Error ¶ added in v0.1.4

func (e UserIDWithTokenError) Error() string

type UsernameOrUserIDError ¶ added in v0.1.4

type UsernameOrUserIDError struct{ BaseError }

UsernameOrUserIDError indicates that neither username nor userID are specified, or both are at once.

func (UsernameOrUserIDError) Error ¶ added in v0.1.4

func (e UsernameOrUserIDError) Error() string

type UsernameWithTokenError ¶ added in v0.1.4

type UsernameWithTokenError struct{ BaseError }

UsernameWithTokenError indicates that a Username was provided, but token authentication is being used instead.

func (UsernameWithTokenError) Error ¶ added in v0.1.4

func (e UsernameWithTokenError) Error() string

Directories ¶

Path Synopsis
client
cmd
Package edgecenter contains resources for the individual projects.
Package edgecenter contains resources for the individual projects.
flavor/v1/flavors
Package flavors contains functionality for working EdgeCloud flavors API resources
Package flavors contains functionality for working EdgeCloud flavors API resources
flavor/v1/flavors/testing
flavors unit tests
flavors unit tests
heat/v1/stack/resources/testing
resources unit tests
resources unit tests
identity/tokens/testing
tokens unit tests
tokens unit tests
instance/v1/instances/testing
instances unit tests
instances unit tests
keypair/v1/keypairs
Package keypair contains functionality for working EdgeCloud keypairs API resources
Package keypair contains functionality for working EdgeCloud keypairs API resources
keypair/v1/keypairs/testing
keypairs unit tests
keypairs unit tests
loadbalancer/v1/lbpools/testing
loadbalancers unit tests
loadbalancers unit tests
loadbalancer/v1/listeners/testing
listeners unit tests
listeners unit tests
loadbalancer/v1/loadbalancers
Package loadbalancer contains functionality for working EdgeCloud loadbalancers API resources
Package loadbalancer contains functionality for working EdgeCloud loadbalancers API resources
loadbalancer/v1/loadbalancers/testing
loadbalancers unit tests
loadbalancers unit tests
network/v1/availablenetworks
Package network contains functionality for working EdgeCloud networks API resources
Package network contains functionality for working EdgeCloud networks API resources
networks unit tests
network/v1/extensions/testing
extensions unit tests
extensions unit tests
network/v1/networks
Package network contains functionality for working EdgeCloud networks API resources
Package network contains functionality for working EdgeCloud networks API resources
network/v1/networks/testing
networks unit tests
networks unit tests
router/v1/routers/testing
routers unit tests
routers unit tests
subnet/v1/subnets/testing
subnets unit tests
subnets unit tests
task/v1/tasks/testing
tasks unit tests
tasks unit tests
volume/v1/volumes
Package volume contains functionality for working EdgeCloud volumes API resources
Package volume contains functionality for working EdgeCloud volumes API resources
volume/v1/volumes/testing
volumes unit tests
volumes unit tests
Package pagination contains utilities and convenience structs that implement common pagination idioms within OpenStack APIs.
Package pagination contains utilities and convenience structs that implement common pagination idioms within OpenStack APIs.
testing
pagination
pagination
Package testhelper container methods that are useful for writing unit tests.
Package testhelper container methods that are useful for writing unit tests.
edgecloud
edgecloud

Jump to

Keyboard shortcuts

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