client

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: LGPL-3.0 Imports: 19 Imported by: 25

Documentation

Index

Constants

View Source
const (

	// The HTTP request methods.
	GET    = "GET"
	POST   = "POST"
	PUT    = "PUT"
	DELETE = "DELETE"
	HEAD   = "HEAD"
	COPY   = "COPY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiVersion

type ApiVersion struct {
	Major int
	Minor int
}

ApiVersion represents choices.id from the openstack api version Multiple choices JSON response, broken into major and minor from the string.

func (*ApiVersion) UnmarshalJSON

func (v *ApiVersion) UnmarshalJSON(b []byte) error

type ApiVersionInfo

type ApiVersionInfo struct {
	Version ApiVersion       `json:"id"`
	Links   []ApiVersionLink `json:"links"`
	Status  string           `json:"status"`
}

ApiVersionInfo represents choices from the openstack api version Multiple choices JSON response.

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

ApiVersionLink represents choices.links from the openstack api version Multiple choices JSON response.

type AuthenticatingClient

type AuthenticatingClient interface {
	Client

	// SetVersionDiscoveryDisabled enables or disables API version
	// discovery on a per service basis. Discovery is enabled by
	// default. If enabled, the client will attempt to list all
	// versions available for a service and use the best match.
	// Otherwise, any API version specified in an SendRequest or
	// MakeServiceURL call will be ignored, and the service
	// catalogue endpoint URL will be used directly.
	SetVersionDiscoveryDisabled(string, bool)

	// SetRequiredServiceTypes sets the service types that the
	// openstack must provide.
	SetRequiredServiceTypes(requiredServiceTypes []string)

	// Authenticate authenticates the client with the OpenStack
	// identity service.
	Authenticate() error

	// IsAuthenticated reports whether the client is
	// authenticated.
	IsAuthenticated() bool

	// Token returns the authentication token. If the client
	// is not yet authenticated, this will return an empty
	// string.
	Token() string

	// UserId returns the user ID for authentication.
	UserId() string

	// TenantId returns the tenant ID for authentication.
	TenantId() string

	// EndpointsForRegion returns the service catalog URLs
	// for the specified region.
	EndpointsForRegion(region string) identity.ServiceURLs

	// IdentityAuthOptions returns a list of valid auth options
	// for the given openstack or error if fetching fails.
	IdentityAuthOptions() (identity.AuthOptions, error)
}

AuthenticatingClient sends service requests to an OpenStack deployment after first validating a user's credentials.

func NewClient

func NewClient(creds *identity.Credentials, authMethod identity.AuthMode, logger logging.CompatLogger, options ...Option) AuthenticatingClient

NewClient creates a new authenticated client.

func NewClientTLSConfig

func NewClientTLSConfig(creds *identity.Credentials, authMethod identity.AuthMode, logger logging.CompatLogger, config *tls.Config, options ...Option) AuthenticatingClient

NewClientTLSConfig creates a new authenticated client that allows passing in a new TLS config.

func NewNonValidatingClient

func NewNonValidatingClient(creds *identity.Credentials, authMethod identity.AuthMode, logger logging.CompatLogger, options ...Option) AuthenticatingClient

NewNonValidatingClient creates a new authenticated client that doesn't validate against TLS.

type Client

type Client interface {
	SendRequest(method, svcType, svcVersion, apiCall string, requestData *goosehttp.RequestData) (err error)
	// MakeServiceURL prepares a full URL to a service endpoint, with optional
	// URL parts.
	MakeServiceURL(serviceType, apiVersion string, parts []string) (string, error)
}

Client implementations sends service requests to an OpenStack deployment.

func NewNonValidatingPublicClient

func NewNonValidatingPublicClient(baseURL string, logger logging.CompatLogger, options ...Option) Client

NewNonValidatingPublicClient creates a new Client that doesn't validate against TLS.

func NewPublicClient

func NewPublicClient(baseURL string, logger logging.CompatLogger, options ...Option) Client

NewPublicClient creates a new Client that validates against TLS.

type Option

type Option func(*options)

Option allows the adaptation of a client given new options. Both client.Client and http.Client have Options. To allow isolation between layers, we have separate options. If client.Client and http.Client want different options they can do so, without causing conflict.

func WithHTTPHeadersFunc

func WithHTTPHeadersFunc(httpHeadersFunc goosehttp.HeadersFunc) Option

WithHTTPHeadersFunc allows passing in a new HTTP headers func for the client to execute for each request.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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