Documentation
¶
Overview ¶
Package nps is the library behind the nps command line: the HTTP client, request shaping, and the typed data models for the National Park Service (NPS) public API.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load.
Index ¶
- Constants
- type Alert
- type AlertsInput
- type Campground
- type CampgroundsInput
- type Client
- func (c *Client) Alerts(ctx context.Context, in AlertsInput) ([]Alert, error)
- func (c *Client) Campgrounds(ctx context.Context, in CampgroundsInput) ([]Campground, error)
- func (c *Client) Parks(ctx context.Context, in ParksInput) ([]Park, error)
- func (c *Client) VisitorCenters(ctx context.Context, in VisitorCentersInput) ([]VisitorCenter, error)
- type Config
- type Domain
- type Park
- type ParksInput
- type VisitorCenter
- type VisitorCentersInput
Constants ¶
const Host = "developer.nps.gov"
Host is the NPS API host. Used in domain.go for the driver's host list.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Category string `json:"category"`
ParkCode string `json:"parkCode"`
URL string `json:"url,omitempty"`
}
Alert is returned by the /alerts endpoint.
type AlertsInput ¶
AlertsInput controls the /alerts query.
type Campground ¶
type Campground struct {
ID string `json:"id"`
Name string `json:"name"`
ParkCode string `json:"parkCode"`
Description string `json:"description"`
URL string `json:"url,omitempty"`
Latitude string `json:"latitude,omitempty"`
Longitude string `json:"longitude,omitempty"`
ReservableSites string `json:"numberOfSitesReservable,omitempty"`
WalkupSites string `json:"numberOfSitesFirstComeFirstServe,omitempty"`
}
Campground is returned by the /campgrounds endpoint.
type CampgroundsInput ¶
CampgroundsInput controls the /campgrounds query.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the NPS API over HTTP.
func (*Client) Campgrounds ¶
func (c *Client) Campgrounds(ctx context.Context, in CampgroundsInput) ([]Campground, error)
Campgrounds fetches campgrounds from the NPS API.
func (*Client) VisitorCenters ¶
func (c *Client) VisitorCenters(ctx context.Context, in VisitorCentersInput) ([]VisitorCenter, error)
VisitorCenters fetches visitor centers from the NPS API.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
APIKey string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable knobs for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for the NPS API.
type Domain ¶
type Domain struct{}
Domain is the nps driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Park ¶
type Park struct {
ID string `json:"id"`
Code string `json:"parkCode"`
Name string `json:"fullName"`
Description string `json:"description"`
States string `json:"states"`
URL string `json:"url"`
LatLong string `json:"latLong,omitempty"`
}
Park is a national park unit returned by the /parks endpoint.
type ParksInput ¶
type ParksInput struct {
State string // two-letter state code, e.g. "CA"
ParkCode string // e.g. "grca"
Limit int // 0 means server default (50)
Start int // pagination offset
}
ParksInput controls the /parks query.
type VisitorCenter ¶
type VisitorCenter struct {
ID string `json:"id"`
Name string `json:"name"`
ParkCode string `json:"parkCode"`
Description string `json:"description"`
URL string `json:"url,omitempty"`
Latitude string `json:"latitude,omitempty"`
Longitude string `json:"longitude,omitempty"`
}
VisitorCenter is returned by the /visitor-centers endpoint.