dataone

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package dataone is the library behind the dataone command line: the HTTP client, request shaping, and the typed data models for the DataONE federated scientific data network.

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. Build your endpoint calls and JSON decoding on top of it.

Index

Constants

View Source
const BaseURL = "https://search.dataone.org/cn/v2/query/solr/"

BaseURL is the Solr endpoint every request is built from.

View Source
const DefaultUserAgent = "dataone-cli/0.1.0 (github.com/tamnd/dataone-cli)"

DefaultUserAgent identifies the client to DataONE.

View Source
const Host = "search.dataone.org"

Host is the DataONE hostname this client talks to, and the host the URI driver in domain.go claims.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to DataONE over HTTPS.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client using the given Config.

func (*Client) GetDataset

func (c *Client) GetDataset(ctx context.Context, id string) (*Dataset, error)

GetDataset fetches a single DataONE dataset by its ID.

func (*Client) RecentDatasets

func (c *Client) RecentDatasets(ctx context.Context, limit int) ([]Dataset, error)

RecentDatasets lists the most recently updated DataONE metadata records.

func (*Client) SearchDatasets

func (c *Client) SearchDatasets(ctx context.Context, query string, limit, offset int) ([]Dataset, int, error)

SearchDatasets searches DataONE for metadata records matching query. It returns the matching datasets, the total hit count, and any error.

type Config

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

Config holds the runtime settings for the DataONE client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Dataset

type Dataset struct {
	ID         string   `json:"id"          kit:"id"`
	Title      string   `json:"title"`
	Authors    []string `json:"authors"`
	Abstract   string   `json:"abstract"`
	Keywords   []string `json:"keywords"`
	Datasource string   `json:"datasource"`
	Published  string   `json:"published"`
	NorthBound float64  `json:"north_bound"`
	SouthBound float64  `json:"south_bound"`
	EastBound  float64  `json:"east_bound"`
	WestBound  float64  `json:"west_bound"`
}

Dataset is a single DataONE metadata record.

type Domain

type Domain struct{}

Domain is the DataONE driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Classify

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

Classify turns any accepted input into the canonical (type, id). Any non-empty string maps to ("dataset", input).

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 is the inverse: the live https URL for a (type, id).

func (Domain) Register

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

Register installs the client factory and every operation onto app.

Jump to

Keyboard shortcuts

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