Documentation ¶
Overview ¶
Package grafton provides A simple interface to the provider api. it is used both within the grafton test tool, and by our own internal services.
Index ¶
- Constants
- Variables
- func CreateSsoURL(base *nurl.URL, code string, resourceID manifold.ID) *nurl.URL
- func IsFatal(err error) bool
- func NewErrWithMsg(t merrors.Type, m *string) error
- func ToError(err error) manifold.HTTPError
- func ValidCredentialName(name string) bool
- type Client
- func (c *Client) ChangePlan(ctx context.Context, cbID, resourceID manifold.ID, newPlan string, ...) (string, bool, error)
- func (c *Client) CreateSsoURL(code string, resourceID manifold.ID) *nurl.URL
- func (c *Client) DeprovisionCredentials(ctx context.Context, cbID, credentialID manifold.ID) (string, bool, error)
- func (c *Client) DeprovisionResource(ctx context.Context, cbID, resourceID manifold.ID) (string, bool, error)
- func (c *Client) ProvisionCredentials(ctx context.Context, cbID, resID, credID manifold.ID) (map[string]string, string, bool, error)
- func (c *Client) ProvisionResource(ctx context.Context, cbID, resID manifold.ID, product, plan, region string, ...) (string, bool, error)
- func (c *Client) PullResourceMeasures(ctx context.Context, rid manifold.ID, start, end time.Time) (*models.ResourceMeasures, error)
- type Error
- type Signer
Constants ¶
const NameRegexpString = "^[A-Z][A-Z0-9_]{0,127}$"
NameRegexpString is the string form of a regular expression for determining if a credential name is valid or not.
Specified in Shell and Utilities volume of IEEE 1003.1-2001.
Variables ¶
var ErrMissingMsg = errors.New("`message` field was missing from the response")
ErrMissingMsg occurs when a provider's response is missing the Message field
Functions ¶
func CreateSsoURL ¶ added in v0.7.0
CreateSsoURL generates and returns a *url.URL to initiate a single sign-on request against the provided base url, code, and resourceID.
func IsFatal ¶ added in v0.8.0
IsFatal returns true or false depending on whether or not the given error is considered to be fatal
func NewErrWithMsg ¶ added in v0.8.0
NewErrWithMsg creates a new Error from a string pointer, if the pointer is nil then an ErrMissingMsg is returned instead.
func ToError ¶
func ToError(err error) manifold.HTTPError
ToError receives an error and mutates it into a grafton.Error based on the concrete type of the error.
func ValidCredentialName ¶ added in v0.9.0
ValidCredentialName returns true or false depending on whether or not the given name is a valid credential name.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around the generated provisioning api client, providing convenience methods, and signing outgoing requests.
func (*Client) ChangePlan ¶
func (c *Client) ChangePlan(ctx context.Context, cbID, resourceID manifold.ID, newPlan string, features map[string]interface{}) (string, bool, error)
ChangePlan makes a patch call to change the resource's plan.
A message will be returned if a callback was used *or* a provider returned an error with an explanation.
func (*Client) CreateSsoURL ¶
CreateSsoURL Generates and returns a *url.URL to initiate single sign-on against the provider for this client.
func (*Client) DeprovisionCredentials ¶
func (c *Client) DeprovisionCredentials(ctx context.Context, cbID, credentialID manifold.ID) (string, bool, error)
DeprovisionCredentials deletes credentials from the remote provider.
A message will be presented if a callback is provided or if a message was returned from the provider due to an error.
func (*Client) DeprovisionResource ¶
func (c *Client) DeprovisionResource(ctx context.Context, cbID, resourceID manifold.ID) (string, bool, error)
DeprovisionResource deletes resources from the remote provider.
A message will be returned if a callback was used *or* a provider returned an error with an explanation.
func (*Client) ProvisionCredentials ¶
func (c *Client) ProvisionCredentials(ctx context.Context, cbID, resID, credID manifold.ID) (map[string]string, string, bool, error)
ProvisionCredentials makes a credential provisioning call.
A message will be returned if a callback was used *or* a provider returned an error with an explanation.
func (*Client) ProvisionResource ¶
func (c *Client) ProvisionResource(ctx context.Context, cbID, resID manifold.ID, product, plan, region string, features map[string]interface{}) (string, bool, error)
ProvisionResource makes a resource provisioning call.
A message will be returned if a callback was used *or* a provider returned an error with an explanation.
func (*Client) PullResourceMeasures ¶ added in v0.13.0
func (c *Client) PullResourceMeasures(ctx context.Context, rid manifold.ID, start, end time.Time) (*models.ResourceMeasures, error)
PullResourceMeasures tries to get information about a resource usage.
type Error ¶
Error is the error type we'll use for providers to return.
func (*Error) StatusCode ¶
StatusCode returns the StatusCode for the current error type.
func (*Error) WriteResponse ¶
func (e *Error) WriteResponse(rw http.ResponseWriter, pr runtime.Producer)
WriteResponse completes the interface for a HTTPError; enabling an error to be returned as a middleware.Responder from go-openapi/runtime
A panic will occur if the given producer errors.