Documentation
¶
Overview ¶
Package pathly is the official Go client for the Pathly public `/v1` API (https://pathlyhq.com — docs: https://pathlyhq.com/en/developers).
Hand-written rather than generated: creates stay idempotent, Retry-After is honoured, and a missing resource (404) stays distinct from a transport failure.
Index ¶
- Constants
- func IsNotFound(err error) bool
- type APIError
- type Client
- func (c *Client) CreateMaintenanceWindow(ctx context.Context, in MaintenanceWindowInput, idempotencyKey string) (*MaintenanceWindow, error)
- func (c *Client) CreateScenario(ctx context.Context, in ScenarioInput, idempotencyKey string) (*Scenario, error)
- func (c *Client) CreateWebhook(ctx context.Context, in WebhookInput, idempotencyKey string) (*Webhook, error)
- func (c *Client) DeleteMaintenanceWindow(ctx context.Context, id string) error
- func (c *Client) DeleteScenario(ctx context.Context, id string) error
- func (c *Client) DeleteSlaTarget(ctx context.Context, id string) error
- func (c *Client) DeleteWebhook(ctx context.Context, id string) error
- func (c *Client) GetMaintenanceWindow(ctx context.Context, id string) (*MaintenanceWindow, error)
- func (c *Client) GetScenario(ctx context.Context, id string) (*Scenario, error)
- func (c *Client) GetSlaTarget(ctx context.Context, id string) (*SlaTarget, error)
- func (c *Client) GetWebhook(ctx context.Context, id string) (*Webhook, error)
- func (c *Client) ListMaintenanceWindows(ctx context.Context) ([]MaintenanceWindow, error)
- func (c *Client) ListScenarios(ctx context.Context) ([]Scenario, error)
- func (c *Client) ListSlaTargets(ctx context.Context) ([]SlaTarget, error)
- func (c *Client) ListWebhooks(ctx context.Context) ([]Webhook, error)
- func (c *Client) MuteScenario(ctx context.Context, id string, until *string) error
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) UpdateScenario(ctx context.Context, id string, in ScenarioInput) (*Scenario, error)
- func (c *Client) UpsertSlaTarget(ctx context.Context, in SlaTargetInput, idempotencyKey string) (*SlaTarget, error)
- type MaintenanceWindow
- type MaintenanceWindowInput
- type Option
- type Scenario
- type ScenarioInput
- type SlaTarget
- type SlaTargetInput
- type Webhook
- type WebhookInput
Constants ¶
const ( // Version is the SDK semver (also used in the default User-Agent). Version = "0.1.0" // DefaultBaseURL is the production API. DefaultBaseURL = "https://api.pathlyhq.com" )
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound is true when the error reports a missing resource.
Types ¶
type APIError ¶
APIError carries the status and the message returned by the API.
The API messages are written to be displayed as they are: rewording them would lose the detail that makes the fix possible (the named missing scope, the offending field, the exceeded limit).
func (*APIError) IsNotFound ¶
IsNotFound reports a resource missing from this organization.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is ready to use and safe for concurrent use. The token is never logged.
func New ¶
New builds a client. Token defaults to PATHLY_API_TOKEN; base URL to PATHLY_API_URL or DefaultBaseURL.
func (*Client) CreateMaintenanceWindow ¶
func (c *Client) CreateMaintenanceWindow(ctx context.Context, in MaintenanceWindowInput, idempotencyKey string) (*MaintenanceWindow, error)
CreateMaintenanceWindow creates a maintenance window.
func (*Client) CreateScenario ¶
func (c *Client) CreateScenario(ctx context.Context, in ScenarioInput, idempotencyKey string) (*Scenario, error)
CreateScenario creates an HTTP scenario. An Idempotency-Key is always sent.
func (*Client) CreateWebhook ¶
func (c *Client) CreateWebhook(ctx context.Context, in WebhookInput, idempotencyKey string) (*Webhook, error)
CreateWebhook creates a signed outbound webhook. Store Secret immediately.
func (*Client) DeleteMaintenanceWindow ¶
DeleteMaintenanceWindow removes a window.
func (*Client) DeleteScenario ¶
DeleteScenario removes a scenario.
func (*Client) DeleteSlaTarget ¶
DeleteSlaTarget removes an SLA target.
func (*Client) DeleteWebhook ¶
DeleteWebhook removes a webhook.
func (*Client) GetMaintenanceWindow ¶
GetMaintenanceWindow reads one window by id.
func (*Client) GetScenario ¶
GetScenario reads one scenario by id.
func (*Client) GetSlaTarget ¶
GetSlaTarget reads one SLA target by id.
func (*Client) GetWebhook ¶
GetWebhook reads one webhook by id (URL never returned, only fingerprint).
func (*Client) ListMaintenanceWindows ¶
func (c *Client) ListMaintenanceWindows(ctx context.Context) ([]MaintenanceWindow, error)
ListMaintenanceWindows lists every page of maintenance windows.
func (*Client) ListScenarios ¶
ListScenarios walks every page of HTTP scenarios.
func (*Client) ListSlaTargets ¶
ListSlaTargets lists every page of SLA targets.
func (*Client) ListWebhooks ¶
ListWebhooks lists every page of webhooks.
func (*Client) MuteScenario ¶
MuteScenario mutes or unmutes. A nil until wakes the scenario up.
func (*Client) Ping ¶
Ping checks that the token is accepted.
A 403 is not a failure: it proves the key is valid and only signals that it does not carry org:read. Treating that as an error would force every scenario-only key to request an organization scope.
func (*Client) UpdateScenario ¶
func (c *Client) UpdateScenario(ctx context.Context, id string, in ScenarioInput) (*Scenario, error)
UpdateScenario patches an existing scenario.
func (*Client) UpsertSlaTarget ¶
func (c *Client) UpsertSlaTarget(ctx context.Context, in SlaTargetInput, idempotencyKey string) (*SlaTarget, error)
UpsertSlaTarget creates or replaces an SLA target (PUT).
type MaintenanceWindow ¶
type MaintenanceWindow struct {
ID string `json:"id"`
MonitorID *string `json:"monitorId"`
StartsAt *string `json:"startsAt"`
EndsAt *string `json:"endsAt"`
Reason *string `json:"reason"`
Weekday *int64 `json:"weekday"`
StartMinute *int64 `json:"startMinute"`
DurationMin *int64 `json:"durationMin"`
}
MaintenanceWindow is a planned silence window for a scenario.
type MaintenanceWindowInput ¶
type MaintenanceWindowInput struct {
MonitorID *string `json:"monitorId,omitempty"`
StartsAt *string `json:"startsAt,omitempty"`
EndsAt *string `json:"endsAt,omitempty"`
Reason *string `json:"reason,omitempty"`
Weekday *int64 `json:"weekday,omitempty"`
StartMinute *int64 `json:"startMinute,omitempty"`
DurationMin *int64 `json:"durationMin,omitempty"`
}
MaintenanceWindowInput is the write payload for a maintenance window.
type Option ¶
type Option func(*Client)
Option configures the client at construction time.
func WithHTTPClient ¶
WithHTTPClient forces an HTTP client, for tests or a corporate proxy.
func WithUserAgent ¶
WithUserAgent identifies the SDK version in the API logs.
type Scenario ¶
type Scenario struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
URL *string `json:"url"`
Enabled *bool `json:"enabled"`
IntervalSec *int64 `json:"intervalSec"`
Method *string `json:"method"`
ExpectedStatus *int64 `json:"expectedStatus"`
MaxLatencyMs *int64 `json:"maxLatencyMs"`
ExpectText *string `json:"expectText"`
Runbook *string `json:"runbook"`
Cron *string `json:"cron"`
LastStatus *string `json:"lastStatus"`
Regions []string `json:"regions"`
Tags []string `json:"tags"`
Folder *string `json:"folder"`
Severity *string `json:"severity"`
MutedUntil *string `json:"mutedUntil"`
ScenarioFingerprint *string `json:"scenarioFingerprint"`
CreatedAt *string `json:"createdAt"`
}
Scenario mirrors the public projection of an HTTP monitoring scenario.
type ScenarioInput ¶
type ScenarioInput struct {
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
URL *string `json:"url,omitempty"`
IntervalSec *int64 `json:"intervalSec,omitempty"`
Method *string `json:"method,omitempty"`
ExpectedStatus *int64 `json:"expectedStatus,omitempty"`
MaxLatencyMs *int64 `json:"maxLatencyMs,omitempty"`
ExpectText *string `json:"expectText,omitempty"`
Regions []string `json:"regions,omitempty"`
Tags []string `json:"tags,omitempty"`
Folder *string `json:"folder,omitempty"`
Severity *string `json:"severity,omitempty"`
Runbook *string `json:"runbook,omitempty"`
Cron *string `json:"cron,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
ScenarioInput serves both create and update. Absent pointer fields are not sent so the API keeps the existing value.
type SlaTarget ¶
type SlaTarget struct {
ID string `json:"id"`
MonitorID *string `json:"monitorId"`
Name *string `json:"name"`
ObjectivePct *float64 `json:"objectivePct"`
WindowDays *int64 `json:"windowDays"`
ExcludeMaintenance *bool `json:"excludeMaintenance"`
WarnAtBudgetRatio *float64 `json:"warnAtBudgetRatio"`
Enabled *bool `json:"enabled"`
}
SlaTarget is an availability objective bound to a scenario.
type SlaTargetInput ¶
type SlaTargetInput struct {
MonitorID *string `json:"monitorId,omitempty"`
Name *string `json:"name,omitempty"`
ObjectivePct float64 `json:"objectivePct"`
WindowDays int64 `json:"windowDays"`
ExcludeMaintenance *bool `json:"excludeMaintenance,omitempty"`
WarnAtBudgetRatio *float64 `json:"warnAtBudgetRatio,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
SlaTargetInput creates or replaces an SLA target (PUT upsert).
type Webhook ¶
type Webhook struct {
ID string `json:"id"`
Events []string `json:"events"`
Enabled *bool `json:"enabled"`
HasSecret *bool `json:"hasSecret"`
URLFingerprint *string `json:"urlFingerprint"`
CreatedAt *string `json:"createdAt"`
Secret *string `json:"secret"`
}
Webhook is an outbound signed webhook. The destination URL is never returned on read — only urlFingerprint. Secret is filled only on create.
type WebhookInput ¶
WebhookInput creates an outbound webhook.