Documentation
¶
Overview ¶
Package console provides support for HSDP Console APIs
Index ¶
- Constants
- Variables
- type Application
- type AutoscalersResponse
- type CFLinksResponse
- type Client
- func (c *Client) Close()
- 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) RefreshToken() string
- func (c *Client) SetBaseConsoleURL(urlStr string) error
- func (c *Client) SetBaseUAAURL(urlStr string) error
- func (c *Client) SetToken(token string) *Client
- func (c *Client) SetTokens(accessToken, refreshToken, idToken string, expiresAt int64)
- func (c *Client) Token() (*oauth2.Token, error)
- func (c *Client) TokenRefresh() error
- func (c *Client) UserID() (string, error)
- func (c *Client) WithLogin(username, password string) (*Client, error)
- type Config
- type ContextKey
- type Data
- type DataResponse
- type Details
- type Endpoint
- type Error
- type Group
- type Instance
- type MetricsResponse
- type MetricsService
- func (c *MetricsService) GQLGetInstanceByID(ctx context.Context, guid string) (*Instance, error)
- func (c *MetricsService) GQLGetInstances(ctx context.Context) (*[]Instance, error)
- 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) PrometheusGetData(_ context.Context, host, query string, options ...OptionFunc) (*DataResponse, *Response, error)
- func (c *MetricsService) UpdateApplicationAutoscaler(id string, settings Application, options ...OptionFunc) (*Application, *Response, error)
- type OptionFunc
- type Response
- type Result
- type Rule
- type RuleResponse
- type Threshold
Constants ¶
const ( UAA = "UAA" CONSOLE = "CONSOLE" PROMETHEUS = "PROMETHEUS" )
Constants
Variables ¶
var ( ErrConsoleURLCannotBeEmpty = errors.New("console base URL cannot be empty") ErrUAAURLCannotBeEmpty = errors.New("UAA URL cannot be empty") ErrMissingRefreshToken = errors.New("missing refresh token") ErrNotAuthorized = errors.New("not authorized") )
Exported Errors
Functions ¶
This section is empty.
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 {
// HTTP client used to communicate with the API.
*http.Client
// 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) HttpClient ¶
HttpClient returns the http Client used for connections
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 ¶
SetBaseUAAURL 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
MetricsAPIURL string
Scopes []string
Debug bool
DebugLog io.Writer
}
Config contains the configuration of a client
type ContextKey ¶
type ContextKey string
type DataResponse ¶
type MetricsResponse ¶
type MetricsService ¶
type MetricsService struct {
// contains filtered or unexported fields
}
func (*MetricsService) GQLGetInstanceByID ¶
func (*MetricsService) GQLGetInstances ¶
func (c *MetricsService) GQLGetInstances(ctx context.Context) (*[]Instance, error)
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 retrieves a rule by ID
func (*MetricsService) PrometheusGetData ¶
func (c *MetricsService) PrometheusGetData(_ context.Context, host, query string, options ...OptionFunc) (*DataResponse, *Response, error)
func (*MetricsService) UpdateApplicationAutoscaler ¶
func (c *MetricsService) UpdateApplicationAutoscaler(id string, settings Application, options ...OptionFunc) (*Application, *Response, error)
UpdateApplicationAutoscaler updates a specific application autoscaler settings
type OptionFunc ¶
OptionFunc is the function signature function for options
func WithEnd ¶
func WithEnd(end int64) OptionFunc
func WithHost ¶
func WithHost(host string) OptionFunc
func WithQuery ¶
func WithQuery(query string) OptionFunc
func WithStart ¶
func WithStart(start int64) OptionFunc
func WithStep ¶
func WithStep(step int64) OptionFunc
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
func (*Response) StatusCode ¶
type Result ¶
type Result struct {
Metric json.RawMessage `json:"metric"`
Values [][]any `json:"values"`
}
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"`
}