zenodoapi

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package zenodoapi implements the reviewed read-only Zenodo REST adapter. It performs no deposition, upload, publication, or OAI-PMH operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResponseTooLarge indicates a response exceeded the configured memory budget.
	ErrResponseTooLarge = errors.New("zenodo response exceeds configured size limit")
	// ErrPaginationLimit indicates a search exceeded its page budget.
	ErrPaginationLimit = errors.New("zenodo pagination exceeds configured page limit")
	// ErrCrossOriginPagination indicates an upstream link escaped the API origin or path.
	ErrCrossOriginPagination = errors.New("zenodo pagination link leaves configured API origin")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Method     string
	Path       string
	Message    string
	RetryAfter time.Duration
	RateLimit  RateLimit
}

APIError preserves safe Zenodo HTTP failure details.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client is a bounded, read-only client for published Zenodo REST records.

func New

func New(baseURL string, options ...Option) (*Client, error)

New constructs a read-only Zenodo client.

func (*Client) GetRecord

func (client *Client) GetRecord(ctx context.Context, id string) (Record, error)

GetRecord returns one published Zenodo record.

func (*Client) LastRateLimit

func (client *Client) LastRateLimit() RateLimit

LastRateLimit returns the most recently observed response limit headers.

func (*Client) ListRecordFiles

func (client *Client) ListRecordFiles(ctx context.Context, id string) ([]File, error)

ListRecordFiles returns the files embedded in a published record response.

func (*Client) SearchRecords

func (client *Client) SearchRecords(ctx context.Context, query string, limit int) ([]Record, error)

SearchRecords searches published records and follows bounded same-origin pagination.

type Creator

type Creator struct {
	Name        string `json:"name"`
	Affiliation string `json:"affiliation,omitempty"`
	ORCID       string `json:"orcid,omitempty"`
}

Creator is a Zenodo creator entry.

type File

type File struct {
	ID       string            `json:"id,omitempty"`
	Key      string            `json:"key"`
	Size     int64             `json:"size,omitempty"`
	Checksum string            `json:"checksum,omitempty"`
	Links    map[string]string `json:"links,omitempty"`
}

File models both current record-file entries and the legacy file array shape.

func (File) ContentURL

func (file File) ContentURL() string

ContentURL returns the preferred read URL without inferring authorization.

type License

type License struct {
	ID string `json:"id,omitempty"`
}

License preserves Zenodo's license identifier.

type Option

type Option func(*Client)

Option configures a Client.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets the HTTP transport. Nil restores the bounded default.

func WithMaxConcurrency

func WithMaxConcurrency(limit int) Option

WithMaxConcurrency bounds simultaneous requests made by this client.

func WithMaxPages

func WithMaxPages(limit int) Option

WithMaxPages sets the automatic search pagination budget.

func WithMaxResponseBytes

func WithMaxResponseBytes(limit int64) Option

WithMaxResponseBytes sets the per-response in-memory budget.

func WithObserver

func WithObserver(emitter observability.Emitter) Option

WithObserver enables redacted provider-tagged request events.

func WithRetryPolicy

func WithRetryPolicy(maxRetries int, baseDelay time.Duration) Option

WithRetryPolicy sets retry count and base delay for idempotent GET requests.

func WithToken

func WithToken(token string) Option

WithToken configures an optional bearer token. Public reads do not require it.

type RateLimit

type RateLimit struct {
	Limit     int64
	Remaining int64
	ResetUnix int64
}

RateLimit captures the reviewed Zenodo response headers.

type Record

type Record struct {
	ID           string            `json:"id"`
	ConceptRecID string            `json:"conceptrecid,omitempty"`
	DOI          string            `json:"doi,omitempty"`
	ConceptDOI   string            `json:"conceptdoi,omitempty"`
	Created      string            `json:"created,omitempty"`
	Updated      string            `json:"updated,omitempty"`
	Metadata     RecordMetadata    `json:"metadata"`
	Files        []File            `json:"files,omitempty"`
	Links        map[string]string `json:"links,omitempty"`
	// contains filtered or unexported fields
}

Record models a published Zenodo record and preserves its original JSON.

func (Record) Envelope

func (record Record) Envelope() (repository.RecordEnvelope, error)

Envelope converts a record without dropping native fields or identifiers.

func (Record) NativeJSON

func (record Record) NativeJSON() []byte

NativeJSON returns an independent copy of the original provider response.

func (*Record) UnmarshalJSON

func (record *Record) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts the current entries map and the legacy files array.

type RecordMetadata

type RecordMetadata struct {
	Title       string    `json:"title"`
	Description string    `json:"description,omitempty"`
	Creators    []Creator `json:"creators,omitempty"`
	Keywords    []string  `json:"keywords,omitempty"`
	AccessRight string    `json:"access_right,omitempty"`
	License     License   `json:"license,omitempty"`
}

RecordMetadata contains stable discovery fields while raw record JSON remains available.

Jump to

Keyboard shortcuts

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