Documentation
¶
Overview ¶
Package smapi provides access to the Synthetic Monitoring API.
Index ¶
- Variables
- type Client
- func (h *Client) AddCheck(ctx context.Context, check synthetic_monitoring.Check) (*synthetic_monitoring.Check, error)
- func (h *Client) AddProbe(ctx context.Context, probe synthetic_monitoring.Probe) (*synthetic_monitoring.Probe, []byte, error)
- func (h *Client) CreateToken(ctx context.Context) (string, error)
- func (h *Client) DeleteCheck(ctx context.Context, id int64) error
- func (h *Client) DeleteProbe(ctx context.Context, id int64) error
- func (h *Client) DeleteToken(ctx context.Context) error
- func (h *Client) GetTenant(ctx context.Context) (*synthetic_monitoring.Tenant, error)
- func (h *Client) Init(ctx context.Context, adminToken string) (*model.RegistrationInitResponse, error)
- func (h *Client) Install(ctx context.Context, stackID, metricsInstanceID, logsInstanceID int64, ...) (*model.RegistrationInstallResponse, error)
- func (h *Client) ListChecks(ctx context.Context) ([]synthetic_monitoring.Check, error)
- func (h *Client) ListProbes(ctx context.Context) ([]synthetic_monitoring.Probe, error)
- func (h *Client) RefreshToken(ctx context.Context) error
- func (h *Client) ResetProbeToken(ctx context.Context, probe synthetic_monitoring.Probe) (*synthetic_monitoring.Probe, []byte, error)
- func (h *Client) Save(ctx context.Context, adminToken string, metricInstanceID, logInstanceID int64) error
- func (h *Client) UpdateCheck(ctx context.Context, check synthetic_monitoring.Check) (*synthetic_monitoring.Check, error)
- func (h *Client) UpdateProbe(ctx context.Context, probe synthetic_monitoring.Probe) (*synthetic_monitoring.Probe, error)
- func (h *Client) UpdateTenant(ctx context.Context, tenant synthetic_monitoring.Tenant) (*synthetic_monitoring.Tenant, error)
- func (h *Client) ValidateToken(ctx context.Context) error
- type HTTPError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAuthorizationTokenRequired is the error returned by client // calls that require an authorization token. // // Authorization tokens can be obtained using Install or Init. ErrAuthorizationTokenRequired = errors.New("authorization token required") // ErrCannotEncodeJSONRequest is the error returned if it's not // possible to encode the request as a JSON object. This error // should never happen. ErrCannotEncodeJSONRequest = errors.New("cannot encode request") // ErrUnexpectedResponse is returned by client calls that get // unexpected responses, for example some field that must not be // zero is zero. If possible a more specific error should be // used. ErrUnexpectedResponse = errors.New("unexpected response") )
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.0.1
type Client struct {
// contains filtered or unexported fields
}
Client is a Synthetic Monitoring API client.
It should be initialized using the NewClient function in this package.
func NewClient ¶
NewClient creates a new client for the Synthetic Monitoring API.
The accessToken is optional. If it's not specified, it's necessary to use one of the registration calls to obtain one, Install or Init.
If no client is provided, http.DefaultClient will be used.
func NewDatasourceClient ¶ added in v0.0.1
NewDatasourceClient creates a new client for the Synthetic Monitoring API using a Grafana datasource proxy.
The accessToken should be the grafana access token.
If no client is provided, http.DefaultClient will be used.
func (*Client) AddCheck ¶ added in v0.0.1
func (h *Client) AddCheck(ctx context.Context, check synthetic_monitoring.Check) (*synthetic_monitoring.Check, error)
AddCheck creates a new Synthetic Monitoring check in the API server.
The return value contains the assigned ID.
func (*Client) AddProbe ¶ added in v0.0.1
func (h *Client) AddProbe(ctx context.Context, probe synthetic_monitoring.Probe) (*synthetic_monitoring.Probe, []byte, error)
AddProbe is used to create a new Synthetic Monitoring probe.
The return value includes the assigned probe ID as well as the access token that should be used by that probe to communicate with the Synthetic Monitoring API.
func (*Client) CreateToken ¶ added in v0.0.1
CreateToken is used to obtain a new access token for the authenticated tenant.
The newly created token _does not_ replace the token currently used by the client.
func (*Client) DeleteCheck ¶ added in v0.0.1
DeleteCheck deletes an existing Synthetic Monitoring check from the API server.
func (*Client) DeleteProbe ¶ added in v0.0.1
DeleteProbe is used to remove a new Synthetic Monitoring probe.
func (*Client) DeleteToken ¶ added in v0.0.1
DeleteToken deletes the access token that the client is currently using.
After this call, the client won't be able to make furhter calls into the API.
func (*Client) GetTenant ¶ added in v0.0.1
GetTenant retrieves the information associated with the authenticated tenant.
func (*Client) Init ¶ added in v0.0.1
func (h *Client) Init(ctx context.Context, adminToken string) (*model.RegistrationInitResponse, error)
Init uses provided admin token to call the deprecated registration init entrypoint in order to create a Synthetic Monitoring tenant.
Note that the client will not any validation on the provided token and it will simply pass it to the corresponding API server.
The returned RegistrationInitResponse will contain the access token used to make further calls to the API server. This call will _modify_ the client in order to use that access token.
func (*Client) Install ¶ added in v0.0.1
func (h *Client) Install(ctx context.Context, stackID, metricsInstanceID, logsInstanceID int64, publisherToken string) (*model.RegistrationInstallResponse, error)
Install takes a stack ID, a hosted metrics instance ID, a hosted logs instance ID and a publisher token that can be used to publish data to those instances and sets up a new Synthetic Monitoring tenant using those parameters.
Note that the client will not any validation on these arguments and it will simply pass them to the corresponding API server.
The returned RegistrationInstallResponse will contain the access token used to make further calls to the API server. This call will _modify_ the client in order to use that access token.
func (*Client) ListChecks ¶ added in v0.0.1
ListChecks returns the list of Synthetic Monitoring checks for the authenticated tenant.
func (*Client) ListProbes ¶ added in v0.0.1
ListProbes returns the list of probes accessible to the authenticated tenant.
func (*Client) RefreshToken ¶ added in v0.0.1
RefreshToken creates a new access token in the API which replaces the one that the client is currently using.
func (*Client) ResetProbeToken ¶ added in v0.0.1
func (h *Client) ResetProbeToken(ctx context.Context, probe synthetic_monitoring.Probe) (*synthetic_monitoring.Probe, []byte, error)
ResetProbeToken requests a _new_ token for the probe.
func (*Client) Save ¶ added in v0.0.1
func (h *Client) Save(ctx context.Context, adminToken string, metricInstanceID, logInstanceID int64) error
Save should be called after Init to select the desired hosted metrics and hosted logs instance to be used by Synthetic Monitoring probes.
After this call, the tenant is fully configured and can be used to create checks and probes.
Just as Init, Save is deprecated.
func (*Client) UpdateCheck ¶ added in v0.0.1
func (h *Client) UpdateCheck(ctx context.Context, check synthetic_monitoring.Check) (*synthetic_monitoring.Check, error)
UpdateCheck updates an existing check in the API server.
The return value contains the updated check (updated timestamps, etc).
func (*Client) UpdateProbe ¶ added in v0.0.1
func (h *Client) UpdateProbe(ctx context.Context, probe synthetic_monitoring.Probe) (*synthetic_monitoring.Probe, error)
UpdateProbe is used to update details about an existing Synthetic Monitoring probe.
The return value contains the new representation of the probe according the Synthetic Monitoring API server.
func (*Client) UpdateTenant ¶ added in v0.0.1
func (h *Client) UpdateTenant(ctx context.Context, tenant synthetic_monitoring.Tenant) (*synthetic_monitoring.Tenant, error)
UpdateTenant updates the specified tenant in the Synthetic Monitoring API. The updated tenant (possibly with updated timestamps) is returned.