Documentation
¶
Index ¶
- Constants
- Variables
- func CheckResponse(r *http.Response) error
- type Application
- type AutoscalersResponse
- type CFLinksResponse
- type Client
- func (c *Client) Close()
- func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)
- func (c *Client) Expires() int64
- func (c *Client) HttpClient() *http.Client
- func (c *Client) IDToken() string
- func (c *Client) Login(username, password string) error
- func (c *Client) NewRequest(endpoint, method, path string, opt interface{}, options []OptionFunc) (*http.Request, error)
- func (c *Client) RefreshToken() string
- func (c *Client) SetBaseConsoleURL(urlStr string) error
- func (c *Client) SetBaseUAAURL(urlStr string) error
- func (c *Client) Token() string
- func (c *Client) TokenRefresh() error
- func (c *Client) WithLogin(username, password string) (*Client, error)
- type Config
- type ContextKey
- type Endpoint
- type Error
- type Group
- type Instance
- type MetricsResponse
- type MetricsService
- func (c *MetricsService) GetApplicationAutoscaler(id, app string, options ...OptionFunc) (*Application, *Response, error)
- func (c *MetricsService) GetApplicationAutoscalers(id string, options ...OptionFunc) (*[]Application, *Response, error)
- func (c *MetricsService) GetGroupedRules(options ...OptionFunc) (*[]Group, *Response, error)
- func (c *MetricsService) GetInstanceByID(id string, options ...OptionFunc) (*Instance, *Response, error)
- func (c *MetricsService) GetInstances(options ...OptionFunc) (*[]Instance, *Response, error)
- func (c *MetricsService) GetRuleByID(id string, options ...OptionFunc) (*Rule, *Response, error)
- func (c *MetricsService) UpdateApplicationAutoscaler(id string, settings Application, options ...OptionFunc) (*Application, *Response, error)
- type OptionFunc
- type Response
- type Rule
- type RuleResponse
- type Threshold
Constants ¶
const ( UAA = "UAA" CONSOLE = "CONSOLE" )
Constants
Variables ¶
var ( ErrNotFound = errors.New("entity not found") ErrMissingName = errors.New("missing name value") ErrMissingDescription = errors.New("missing description value") ErrMalformedInputValue = errors.New("malformed input value") ErrNotImplementedByHSDP = errors.New("method not implemented by HSDP") ErrCouldNoReadResourceAfterCreate = errors.New("could not read resource after create") ErrConsoleURLCannotBeEmpty = errors.New("console base URL cannot be empty") ErrUAAURLCannotBeEmpty = errors.New("UAA URL cannot be empty") ErrEmptyResults = errors.New("empty results") ErrOperationFailed = errors.New("operation failed") ErrMissingEtagInformation = errors.New("missing etag information") ErrMissingRefreshToken = errors.New("missing refresh token") ErrNotAuthorized = errors.New("not authorized") ErrNonHttp20xResponse = errors.New("non http 20x console response") )
Exported Errors
Functions ¶
func CheckResponse ¶ added in v0.27.0
CheckResponse checks the API response for errors, and returns them if present.
Types ¶
type Application ¶
type AutoscalersResponse ¶
type AutoscalersResponse struct { Data struct { Applications []Application `json:"applications"` } `json:"data"` Status string `json:"status"` Error Error `json:"error,omitempty"` }
type CFLinksResponse ¶
type CFLinksResponse struct { Links struct { Self struct { Href string `json:"href"` } `json:"self"` CloudControllerV2 struct { Href string `json:"href"` Meta struct { Version string `json:"version"` } `json:"meta"` } `json:"cloud_controller_v2"` CloudControllerV3 struct { Href string `json:"href"` Meta struct { Version string `json:"version"` } `json:"meta"` } `json:"cloud_controller_v3"` NetworkPolicyV0 struct { Href string `json:"href"` } `json:"network_policy_v0"` NetworkPolicyV1 struct { Href string `json:"href"` } `json:"network_policy_v1"` Login struct { Href string `json:"href"` } `json:"login"` UAA struct { Href string `json:"href"` } `json:"uaa"` Credhub interface{} `json:"credhub"` Routing struct { Href string `json:"href"` } `json:"routing"` Logging struct { Href string `json:"href"` } `json:"logging"` LogCache struct { Href string `json:"href"` } `json:"log_cache"` LogStream struct { Href string `json:"href"` } `json:"log_stream"` AppSSH struct { Href string `json:"href"` Meta struct { HostKeyFingerprint string `json:"host_key_fingerprint"` OauthClient string `json:"oauth_client"` } `json:"meta"` } `json:"app_ssh"` } `json:"links"` }
type Client ¶
type Client struct { // User agent used when communicating with the HSDP IAM API. UserAgent string Metrics *MetricsService sync.Mutex // contains filtered or unexported fields }
A Client manages communication with HSDP IAM API
func NewClient ¶
NewClient returns a new HSDP Console API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide a valid oAuth bearer token.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) HttpClient ¶
Returns the http Client used for connections
func (*Client) NewRequest ¶
func (c *Client) NewRequest(endpoint, method, path string, opt interface{}, options []OptionFunc) (*http.Request, error)
NewRequest creates an API request. A relative URL path can be provided in urlStr, in which case it is resolved relative to the base URL of the Client. Relative URL paths should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Client) RefreshToken ¶
RefreshToken returns the refresh token
func (*Client) SetBaseConsoleURL ¶
SetBaseConsoleURL sets the base URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.
func (*Client) SetBaseUAAURL ¶
SetBaseIDMURL sets the base URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.
func (*Client) TokenRefresh ¶
TokenRefresh refreshes the accessToken
type Config ¶
type Config struct { Region string BaseConsoleURL string UAAURL string Scopes []string Debug bool DebugLog string }
Config contains the configuration of a client
type ContextKey ¶
type ContextKey string
type MetricsResponse ¶
type MetricsService ¶
type MetricsService struct {
// contains filtered or unexported fields
}
func (*MetricsService) GetApplicationAutoscaler ¶
func (c *MetricsService) GetApplicationAutoscaler(id, app string, options ...OptionFunc) (*Application, *Response, error)
GetApplicationAutoscaler looks up a specific application autoscaler settings
func (*MetricsService) GetApplicationAutoscalers ¶
func (c *MetricsService) GetApplicationAutoscalers(id string, options ...OptionFunc) (*[]Application, *Response, error)
GetApplicationAutoscalers looks up all available autoscalers
func (*MetricsService) GetGroupedRules ¶
func (c *MetricsService) GetGroupedRules(options ...OptionFunc) (*[]Group, *Response, error)
GetGroupedRules looks up available rules
func (*MetricsService) GetInstanceByID ¶
func (c *MetricsService) GetInstanceByID(id string, options ...OptionFunc) (*Instance, *Response, error)
GetInstanceByID looks up an instance by ID
func (*MetricsService) GetInstances ¶
func (c *MetricsService) GetInstances(options ...OptionFunc) (*[]Instance, *Response, error)
GetInstances looks up available instances
func (*MetricsService) GetRuleByID ¶
func (c *MetricsService) GetRuleByID(id string, options ...OptionFunc) (*Rule, *Response, error)
GetRuleByID looks up available instances
func (*MetricsService) UpdateApplicationAutoscaler ¶
func (c *MetricsService) UpdateApplicationAutoscaler(id string, settings Application, options ...OptionFunc) (*Application, *Response, error)
GetApplicationAutoscaler looks up a specific application autoscaler settings
type OptionFunc ¶
OptionFunc is the function signature function for options
func WithContext ¶
func WithContext(ctx context.Context) OptionFunc
WithContext runs the request with the provided context
type Response ¶
Response is a HSDP Console API response. This wraps the standard http.Response returned from HSDP Console and provides convenient access to things like errors
type Rule ¶
type Rule struct { Annotations struct { Description string `json:"description"` Resolved string `json:"resolved"` Summary string `json:"summary"` } `json:"annotations"` Description string `json:"description"` ID string `json:"id"` Metric string `json:"metric"` Rule struct { ExtraFor []struct { Name string `json:"name"` Options []string `json:"options"` Type string `json:"type"` VariableName string `json:"variableName"` } `json:"extraFor,omitempty"` Extras []struct { Name string `json:"name"` Options []string `json:"options"` Type string `json:"type"` VariableName string `json:"variableName"` } `json:"extras"` Operators []string `json:"operators"` Subject string `json:"subject"` Threshold Threshold `json:"threshold"` } `json:"rule"` Template string `json:"template"` }