Documentation
¶
Overview ¶
Package zenodoapi implements the reviewed read-only Zenodo REST adapter. It performs no deposition, upload, publication, or OAI-PMH operations.
Index ¶
- Variables
- type APIError
- type Client
- func (client *Client) GetRecord(ctx context.Context, id string) (Record, error)
- func (client *Client) LastRateLimit() RateLimit
- func (client *Client) ListRecordFiles(ctx context.Context, id string) ([]File, error)
- func (client *Client) SearchRecords(ctx context.Context, query string, limit int) ([]Record, error)
- type Creator
- type File
- type License
- type Option
- func WithHTTPClient(client *http.Client) Option
- func WithMaxConcurrency(limit int) Option
- func WithMaxPages(limit int) Option
- func WithMaxResponseBytes(limit int64) Option
- func WithObserver(emitter observability.Emitter) Option
- func WithRetryPolicy(maxRetries int, baseDelay time.Duration) Option
- func WithToken(token string) Option
- type RateLimit
- type Record
- type RecordMetadata
Constants ¶
This section is empty.
Variables ¶
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.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a bounded, read-only client for published Zenodo REST records.
func (*Client) LastRateLimit ¶
LastRateLimit returns the most recently observed response limit headers.
func (*Client) ListRecordFiles ¶
ListRecordFiles returns the files embedded in a published record response.
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 ¶
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 ¶
WithHTTPClient sets the HTTP transport. Nil restores the bounded default.
func WithMaxConcurrency ¶
WithMaxConcurrency bounds simultaneous requests made by this client.
func WithMaxPages ¶
WithMaxPages sets the automatic search pagination budget.
func WithMaxResponseBytes ¶
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 ¶
WithRetryPolicy sets retry count and base delay for idempotent GET requests.
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 ¶
NativeJSON returns an independent copy of the original provider response.
func (*Record) UnmarshalJSON ¶
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.