nasadonki

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package nasadonki exposes the NASA DONKI space weather API as a kit Domain driver.

A multi-domain host (ant) enables it with a single blank import:

import _ "github.com/tamnd/nasadonki-cli/nasadonki"

The same Domain also builds the standalone donki binary (see cli.NewApp).

Package nasadonki is the library behind the donki command line: the HTTP client, request shaping, and typed data models for NASA's DONKI (Space Weather Database Of Notifications, Knowledge, Information) API (api.nasa.gov/DONKI).

Index

Constants

View Source
const Host = "api.nasa.gov"

Host is the API host this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type CME

type CME struct {
	ID             string   `json:"id"`
	StartTime      string   `json:"start_time"`
	SourceLocation string   `json:"source_location"`
	Instruments    []string `json:"instruments"`
}

CME is a coronal mass ejection event from NASA DONKI.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the NASA DONKI API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) CMEs

func (c *Client) CMEs(ctx context.Context, start, end string) ([]CME, error)

CMEs fetches coronal mass ejection events for a date range.

func (*Client) Flares

func (c *Client) Flares(ctx context.Context, start, end string) ([]Flare, error)

Flares fetches solar flare events for a date range.

func (*Client) HSSs

func (c *Client) HSSs(ctx context.Context, start, end string) ([]HSS, error)

HSSs fetches high speed stream events for a date range.

func (*Client) Notifications

func (c *Client) Notifications(ctx context.Context, start, end string) ([]Notification, error)

Notifications fetches all DONKI notifications for a date range.

func (*Client) SEPs

func (c *Client) SEPs(ctx context.Context, start, end string) ([]SEP, error)

SEPs fetches solar energetic particle events for a date range.

type Config

type Config struct {
	BaseURL   string
	APIKey    string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the nasadonki driver.

func (Domain) Classify

func (Domain) Classify(input string) (string, string, error)

Classify turns any input into the canonical (type, id).

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.

func (Domain) Locate

func (Domain) Locate(t, id string) (string, error)

Locate returns the live DONKI URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Flare

type Flare struct {
	ID             string   `json:"id"`
	BeginTime      string   `json:"begin_time"`
	PeakTime       string   `json:"peak_time"`
	EndTime        string   `json:"end_time"`
	ClassType      string   `json:"class_type"`
	SourceLocation string   `json:"source_location"`
	LinkedEvents   []string `json:"linked_events"`
}

Flare is a solar flare event from NASA DONKI.

type HSS

type HSS struct {
	ID        string `json:"id"`
	EventTime string `json:"event_time"`
}

HSS is a high speed stream event from NASA DONKI.

type Notification

type Notification struct {
	MessageType      string `json:"message_type"`
	MessageID        string `json:"message_id"`
	MessageURL       string `json:"message_url"`
	MessageBody      string `json:"message_body"`
	MessageIssueTime string `json:"message_issue_time"`
}

Notification is a DONKI alert/notification message.

type SEP

type SEP struct {
	ID          string   `json:"id"`
	EventTime   string   `json:"event_time"`
	Instruments []string `json:"instruments"`
}

SEP is a solar energetic particle event from NASA DONKI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL