nimbusdocs

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeUnauthorized  = "unauthorized"
	CodeQuotaExceeded = "quota_exceeded"
	CodeNotFound      = "not_found"
	CodeTooLarge      = "too_large"
	CodeInvalid       = "invalid_request"
	CodeRateLimited   = "rate_limited"
	CodeServer        = "server_error"
)

Stable error codes.

View Source
const DefaultBaseURL = "https://nimbusgo.space"

DefaultBaseURL is where the API lives.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to one product with one key.

func New

func New(product Product, apiKey string, opts ...Option) (*Client, error)

New builds a client. The key must belong to the product: a Carbon key presented to Sigma is refused by the API, not silently accepted.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, id uint) error

Delete removes a document and its content.

func (*Client) Get

func (c *Client) Get(ctx context.Context, id uint) (*Document, error)

Get returns one document's metadata.

func (c *Client) Link(ctx context.Context, id uint, opts LinkOptions) (*Link, error)

Link mints a fresh signed URL — the answer to an expired one.

func (*Client) List

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

List returns documents, newest first.

func (*Client) Product

func (c *Client) Product() Product

Product this client serves.

func (c *Client) RevokeAllLinks(ctx context.Context) error

RevokeAllLinks invalidates every outstanding signed link at once.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, in Upload) (*Document, error)

Upload creates a document and returns it with a signed URL.

func (*Client) Usage

func (c *Client) Usage(ctx context.Context) (*Quota, error)

Usage reports this period's allowance.

type Document

type Document struct {
	ID           uint       `json:"id"`
	Product      Product    `json:"product"`
	Title        string     `json:"title"`
	Filename     string     `json:"filename"`
	MIME         string     `json:"mime"`
	Size         int64      `json:"size"`
	Checksum     string     `json:"checksum"`
	CreatedAt    time.Time  `json:"created_at"`
	ExpiresAt    *time.Time `json:"expires_at,omitempty"`
	URL          string     `json:"url,omitempty"`
	URLExpiresAt *time.Time `json:"url_expires_at,omitempty"`
	Mode         string     `json:"mode,omitempty"`
}

Document is one stored document. URL fields are set on responses that minted a link.

type Error

type Error struct {
	Code    string
	Status  int
	Message string
	Quota   *Quota
}

Error is every failure the API reports. Code is stable; branch on it.

func (*Error) Error

func (e *Error) Error() string
type Link struct {
	URL       string    `json:"url"`
	Mode      string    `json:"mode"`
	ExpiresAt time.Time `json:"expires_at"`
}

Link is a freshly minted signed URL.

type LinkOptions

type LinkOptions struct {
	TTL  time.Duration
	Mode string
}

LinkOptions shape a re-minted link.

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL points the client at another deployment, for local testing.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient supplies the transport.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout bounds each request. Default 30s.

type Product

type Product string

Product selects which app a client talks to.

const (
	Sigma  Product = "sigma"
	Carbon Product = "carbon"
)

The products served by the API.

type Quota

type Quota struct {
	Period      string `json:"period"`
	Limit       int    `json:"limit"`
	Used        int    `json:"used"`
	Remaining   int    `json:"remaining"`
	Overage     int    `json:"overage"`
	UsedPercent int    `json:"used_percent"`
	Allowed     bool   `json:"allowed"`
	Warn        bool   `json:"warn"`
	Paid        bool   `json:"paid"`
}

Quota is this period's allowance.

type Upload

type Upload struct {
	Content  []byte
	Filename string
	Title    string
	MIME     string
	// TTL of the link returned with the document. Zero means the default.
	TTL  time.Duration
	Mode string
	// RetainDays deletes the document after this many days. Zero keeps it.
	RetainDays int
	// IdempotencyKey makes a retried upload return the original document
	// instead of creating, and charging for, a second one.
	IdempotencyKey string
}

Upload describes a document to create.

Jump to

Keyboard shortcuts

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