Documentation ¶
Index ¶
- Constants
- Variables
- func IsName(s string) bool
- func IsUUID(s string) bool
- func ParseRef(ref string) (namespace string, name string, err error)
- func ValidateNamespace(namespace string) error
- func ValidateNamespaceAndRef(namespace, ref string) error
- type APIVersion
- type Client
- func (c *Client) CPHealth(ctx context.Context, hostname string) (*types.CPHealthStatus, error)
- func (c *Client) ClientVersion() string
- func (c *Client) ClusterHealth(ctx context.Context) ([]*types.ClusterHealthNode, error)
- func (c *Client) DPHealth(ctx context.Context, hostname string) (*types.DPHealthStatus, error)
- func (c *Client) DisableMaintenance() error
- func (c *Client) EnableMaintenance() error
- func (c *Client) GetDialContext() dialContext
- func (c *Client) Licence() (*types.Licence, error)
- func (c *Client) LicenceApply(licenceKey string) error
- func (c *Client) LicenceDelete() error
- func (c *Client) LoggerConfig(opts types.ListOptions) ([]*types.Logger, error)
- func (c *Client) LoggerUpdate(opts types.LoggerUpdateOptions) ([]*types.Logger, error)
- func (c *Client) Login() (token string, err error)
- func (c *Client) Maintenance() (*types.Maintenance, error)
- func (c *Client) Namespace(ref string) (*types.Namespace, error)
- func (c *Client) NamespaceCreate(opts types.NamespaceCreateOptions) (*types.Namespace, error)
- func (c *Client) NamespaceDelete(opts types.DeleteOptions) error
- func (c *Client) NamespaceList(opts types.ListOptions) ([]*types.Namespace, error)
- func (c *Client) NamespaceUpdate(opts types.NamespaceCreateOptions) (*types.Namespace, error)
- func (c *Client) NetworkDiagnostics(ref string) (types.ConnectivityResults, error)
- func (c *Client) Node(ref string) (*types.Node, error)
- func (c *Client) NodeDelete(opts types.DeleteOptions) error
- func (c *Client) NodeList(opts types.ListOptions) ([]*types.Node, error)
- func (c *Client) NodeUpdate(opts types.NodeUpdateOptions) (*types.Node, error)
- func (c *Client) Ping() error
- func (c *Client) Policy(id string) (*types.Policy, error)
- func (c *Client) PolicyCreate(ctx context.Context, jsonl []byte) error
- func (c *Client) PolicyDelete(opts types.DeleteOptions) error
- func (c *Client) PolicyList(opts types.ListOptions) (types.PolicySet, error)
- func (c *Client) Pool(ref string) (*types.Pool, error)
- func (c *Client) PoolCreate(opts types.PoolOptions) (*types.Pool, error)
- func (c *Client) PoolDelete(opts types.DeleteOptions) error
- func (c *Client) PoolList(opts types.ListOptions) ([]*types.Pool, error)
- func (c *Client) PoolUpdate(opts types.PoolOptions) (*types.Pool, error)
- func (c *Client) Rule(namespace string, ref string) (*types.Rule, error)
- func (c *Client) RuleCreate(opts types.RuleCreateOptions) (*types.Rule, error)
- func (c *Client) RuleDelete(opts types.DeleteOptions) error
- func (c *Client) RuleList(opts types.ListOptions) ([]*types.Rule, error)
- func (c *Client) RuleUpdate(opts types.RuleUpdateOptions) (*types.Rule, error)
- func (c *Client) ServerVersion(ctx context.Context) (*types.VersionInfo, error)
- func (c *Client) SetAuth(username string, secret string)
- func (c *Client) SetDialContext(dial dialContext) error
- func (c *Client) SetProxy(proxy *url.URL) error
- func (c *Client) SetTimeout(t time.Duration)
- func (c *Client) SetUserAgent(useragent string)
- func (c *Client) Template(ref string) (*types.Template, error)
- func (c *Client) TemplateCreate(opts types.TemplateCreateOptions) (string, error)
- func (c *Client) TemplateDelete(ref string) error
- func (c *Client) TemplateList(opts types.ListOptions) ([]types.Template, error)
- func (c *Client) User(username string) (*types.User, error)
- func (c *Client) UserCreate(opts types.UserCreateOptions) error
- func (c *Client) UserDelete(opts types.DeleteOptions) error
- func (c *Client) UserList(opts types.ListOptions) ([]*types.User, error)
- func (c *Client) UserUpdate(ctx context.Context, user *types.User) error
- func (c *Client) Volume(namespace string, ref string) (*types.Volume, error)
- func (c *Client) VolumeCreate(opts types.VolumeCreateOptions) (*types.Volume, error)
- func (c *Client) VolumeDelete(opts types.DeleteOptions) error
- func (c *Client) VolumeList(opts types.ListOptions) ([]*types.Volume, error)
- func (c *Client) VolumeMount(opts types.VolumeMountOptions) error
- func (c *Client) VolumeUnmount(opts types.VolumeUnmountOptions) error
- func (c *Client) VolumeUpdate(opts types.VolumeUpdateOptions) (*types.Volume, error)
- type Dialer
- type Error
Constants ¶
const ( // DefaultUserAgent is the default User-Agent header to include in HTTP requests. DefaultUserAgent = "go-storageosclient" // DefaultVersionStr is the string value of the default API version. DefaultVersionStr = "1" // DefaultVersion is the default API version. DefaultVersion = 1 )
const ( // IDFormat are the characters allowed to represent an ID. IDFormat = `[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}` // NameFormat are the characters allowed to represent a name. NameFormat = `[a-zA-Z0-9][a-zA-Z0-9~_.-]+` )
Variables ¶
var ( // ErrConnectionRefused is returned when the client cannot connect to the given endpoint. ErrConnectionRefused = errors.New("cannot connect to StorageOS API endpoint") // ErrInactivityTimeout is returned when a streamable call has been inactive for some time. ErrInactivityTimeout = errors.New("inactivity time exceeded timeout") // ErrInvalidVersion is returned when a versioned client was requested but no version specified. ErrInvalidVersion = errors.New("invalid version") // ErrProxyNotSupported is returned when a client is unable to set a proxy for http requests. ErrProxyNotSupported = errors.New("client does not support http proxy") // ErrDialerNotSupported is returned when a client is unable to set a DialContext for http requests. ErrDialerNotSupported = errors.New("client does not support setting DialContext") // DefaultPort is the default API port. DefaultPort = "5705" // DataplaneHealthPort is the the port used by the dataplane health-check service. DataplaneHealthPort = "5704" // DefaultHost is the default API host. DefaultHost = "http://localhost:" + DefaultPort )
var ( // LoginAPIPrefix is a partial path to the HTTP endpoint. LoginAPIPrefix = "auth/login" // ErrLoginFailed is the error returned on an unsuccessful login. ErrLoginFailed = errors.New("failed to get token from API endpoint") )
var ( // NamespaceAPIPrefix is a partial path to the HTTP endpoint. NamespaceAPIPrefix = "namespaces" // ErrNoSuchNamespace is the error returned when the namespace does not exist. ErrNoSuchNamespace = errors.New("no such namespace") // ErrNamespaceInUse is the error returned when the namespace requested to be removed is still in use. ErrNamespaceInUse = errors.New("namespace in use and cannot be removed") )
var ( // NodeAPIPrefix is a partial path to the HTTP endpoint. NodeAPIPrefix = "nodes" // ErrNoSuchNode is the error returned when the node does not exist. ErrNoSuchNode = errors.New("no such node") // ErrNodeInUse is the error returned when the node requested to be removed is still in use. ErrNodeInUse = errors.New("node in use and cannot be removed") )
var ( // PolicyAPIPrefix is a partial path to the HTTP endpoint. PolicyAPIPrefix = "policies" // ErrNoSuchPolicy is the error returned when the policy does not exist. ErrNoSuchPolicy = errors.New("no such policy") )
var ( // PoolAPIPrefix is a partial path to the HTTP endpoint. PoolAPIPrefix = "pools" // ErrNoSuchPool is the error returned when the pool does not exist. ErrNoSuchPool = errors.New("no such pool") // ErrPoolInUse is the error returned when the pool requested to be removed is still in use. ErrPoolInUse = errors.New("pool in use and cannot be removed") )
var ( // RuleAPIPrefix is a partial path to the HTTP endpoint. RuleAPIPrefix = "rules" // ErrNoSuchRule is the error returned when the rule does not exist. ErrNoSuchRule = errors.New("no such rule") // ErrRuleInUse is the error returned when the rule requested to be removed is still in use. ErrRuleInUse = errors.New("rule in use and cannot be removed") )
var ( // TemplateAPIPrefix is a partial path to the HTTP endpoint. TemplateAPIPrefix = "/templates" // ErrNoSuchTemplate is the error returned when the template does not exist. ErrNoSuchTemplate = errors.New("no such template") // ErrTemplateInUse is the error returned when the template requested to be removed is still in use. ErrTemplateInUse = errors.New("template in use and cannot be removed") )
var ( // UserAPIPrefix is a partial path to the HTTP endpoint. UserAPIPrefix = "users" // ErrNoSuchUser is the error returned when the user does not exist. ErrNoSuchUser = errors.New("no such user") )
var ( // IDPattern is a regular expression to validate a unique id against the // collection of restricted characters. IDPattern = regexp.MustCompile(`^` + IDFormat + `$`) // NamePattern is a regular expression to validate names against the // collection of restricted characters. NamePattern = regexp.MustCompile(`^` + NameFormat + `$`) // ErrNoRef is given when the reference given is invalid. ErrNoRef = errors.New("no ref provided or incorrect format") // ErrNoNamespace is given when the namespace given is invalid. ErrNoNamespace = errors.New("no namespace provided or incorrect format") )
var ( // VolumeAPIPrefix is a partial path to the HTTP endpoint. VolumeAPIPrefix = "volumes" // ErrNoSuchVolume is the error returned when the volume does not exist. ErrNoSuchVolume = errors.New("no such volume") // ErrVolumeInUse is the error returned when the volume requested to be removed is still in use. ErrVolumeInUse = errors.New("volume in use and cannot be removed") )
var ( // ClusterMaintenanceAPIPrefix is a path to the HTTP endpoint for managing // the cluster maintenance mode. ClusterMaintenanceAPIPrefix = "cluster/maintenance" )
var (
// HealthAPIPrefix is a partial path to the HTTP endpoint.
HealthAPIPrefix = "health"
)
var (
// LoggerAPIPrefix is a partial path to the HTTP endpoint.
LoggerAPIPrefix = "logs"
)
var ( // NetworkDiagnosticsAPIPrefix is a partial path to the HTTP endpoint for // the node connectivity diagnostics report. NetworkDiagnosticsAPIPrefix = "diagnostics/network" )
Functions ¶
func ValidateNamespace ¶
ValidateNamespace returns true if the namespace uses a valid name.
func ValidateNamespaceAndRef ¶
ValidateNamespaceAndRef returns true if both the namespace and ref are valid.
Types ¶
type APIVersion ¶
type APIVersion int
APIVersion is an internal representation of a version of the Remote API.
func NewAPIVersion ¶
func NewAPIVersion(input string) (APIVersion, error)
NewAPIVersion returns an instance of APIVersion for the given string.
The given string must be in the form <major>
func (APIVersion) String ¶
func (version APIVersion) String() string
type Client ¶
type Client struct { SkipServerVersionCheck bool // contains filtered or unexported fields }
Client is the basic type of this package. It provides methods for interaction with the API.
func NewClient ¶
NewClient returns a Client instance ready for communication with the given server endpoint. It will use the latest remote API version available in the server.
func NewVersionedClient ¶
NewVersionedClient returns a Client instance ready for communication with the given server endpoint, using a specific remote API version.
func (*Client) ClientVersion ¶
ClientVersion returns the API version of the client
func (*Client) ClusterHealth ¶
func (*Client) DisableMaintenance ¶
DisableMaintenance disables maintenance mode in the cluster
func (*Client) EnableMaintenance ¶
EnableMaintenance enables maintenance mode in the cluster
func (*Client) GetDialContext ¶
func (c *Client) GetDialContext() dialContext
GetDialContext returns the current DialContext function, or nil if there is none.
func (*Client) LicenceApply ¶
LicenceApply applies a licence on the server.
func (*Client) LicenceDelete ¶
LicenceDelete removes the current licence.
func (*Client) LoggerConfig ¶
LoggerConfig returns every cluster node's logging configuration.
func (*Client) LoggerUpdate ¶
LoggerUpdate patches updates to logging configuration. Fields to update must be listed in the Fields value, and if a list of Nodes is given it will only apply to the nodes listed. Returns the updated configuration.
func (*Client) Maintenance ¶
func (c *Client) Maintenance() (*types.Maintenance, error)
Maintenance returns the maintenance status of the cluster
func (*Client) NamespaceCreate ¶
NamespaceCreate creates a namespace on the server and returns the new object.
func (*Client) NamespaceDelete ¶
func (c *Client) NamespaceDelete(opts types.DeleteOptions) error
NamespaceDelete removes a namespace by its reference.
func (*Client) NamespaceList ¶
NamespaceList returns the list of available namespaces.
func (*Client) NamespaceUpdate ¶
NamespaceUpdate updates a namespace on the server and returns the updated object.
func (*Client) NetworkDiagnostics ¶
func (c *Client) NetworkDiagnostics(ref string) (types.ConnectivityResults, error)
NetworkDiagnostics returns a collection of network connectivity reports. If a reference to a node is given, it will only check connectivity from that node. Otherwise, connectivity between all cluster nodes will be returned.
func (*Client) NodeDelete ¶
func (c *Client) NodeDelete(opts types.DeleteOptions) error
NodeDelete removes a node by its reference.
func (*Client) NodeUpdate ¶
NodeUpdate updates a node on the server.
func (*Client) PolicyCreate ¶
PolicyCreate creates a policy on the server.
func (*Client) PolicyDelete ¶
func (c *Client) PolicyDelete(opts types.DeleteOptions) error
PolicyDelete deletes a policy on the server by ID.
func (*Client) PolicyList ¶
PolicyList returns the list of policies on the server.
func (*Client) PoolCreate ¶
PoolCreate creates a pool on the server and returns the new object.
func (*Client) PoolDelete ¶
func (c *Client) PoolDelete(opts types.DeleteOptions) error
PoolDelete removes a pool by its reference.
func (*Client) PoolUpdate ¶
PoolUpdate - update pool
func (*Client) RuleCreate ¶
RuleCreate creates a rule on the server and returns the new object.
func (*Client) RuleDelete ¶
func (c *Client) RuleDelete(opts types.DeleteOptions) error
RuleDelete removes a rule by its reference.
func (*Client) RuleUpdate ¶
RuleUpdate updates a rule on the server.
func (*Client) ServerVersion ¶
ServerVersion returns the server's version and runtime info.
func (*Client) SetAuth ¶
SetAuth sets the API username and secret to be used for all API requests. It should not be called concurrently with any other Client methods.
func (*Client) SetDialContext ¶
SetDialContext uses the given dial function to establish TCP connections in the HTTPClient.
func (*Client) SetProxy ¶
SetProxy will set the proxy URL for both the HTTPClient. If the transport method does not support usage of proxies, an error will be returned.
func (*Client) SetTimeout ¶
SetTimeout takes a timeout and applies it to both the HTTPClient and nativeHTTPClient. It should not be called concurrently with any other Client methods.
func (*Client) SetUserAgent ¶
SetUserAgent sets the client useragent.
func (*Client) TemplateCreate ¶
func (c *Client) TemplateCreate(opts types.TemplateCreateOptions) (string, error)
TemplateCreate creates a template on the server and returns the new object.
func (*Client) TemplateDelete ¶
TemplateDelete removes a template by its reference.
func (*Client) TemplateList ¶
TemplateList returns the list of available templates.
func (*Client) UserCreate ¶
func (c *Client) UserCreate(opts types.UserCreateOptions) error
UserCreate creates a user on the server.
func (*Client) UserDelete ¶
func (c *Client) UserDelete(opts types.DeleteOptions) error
UserDelete removes a user by its reference.
func (*Client) UserUpdate ¶
UserUpdate updates a user on the server.
func (*Client) VolumeCreate ¶
VolumeCreate creates a volume on the server and returns the new object.
func (*Client) VolumeDelete ¶
func (c *Client) VolumeDelete(opts types.DeleteOptions) error
VolumeDelete removes a volume by its reference.
func (*Client) VolumeList ¶
VolumeList returns the list of available volumes.
func (*Client) VolumeMount ¶
func (c *Client) VolumeMount(opts types.VolumeMountOptions) error
VolumeMount updates the volume with the client that mounted it.
func (*Client) VolumeUnmount ¶
func (c *Client) VolumeUnmount(opts types.VolumeUnmountOptions) error
VolumeUnmount removes the client from the mount reference.
func (*Client) VolumeUpdate ¶
VolumeUpdate updates a volume on the server.