Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) Delete(ctx context.Context, id uint) error
- func (c *Client) Get(ctx context.Context, id uint) (*Document, error)
- func (c *Client) Link(ctx context.Context, id uint, opts LinkOptions) (*Link, error)
- func (c *Client) List(ctx context.Context, limit int) ([]Document, error)
- func (c *Client) Product() Product
- func (c *Client) RevokeAllLinks(ctx context.Context) error
- func (c *Client) Upload(ctx context.Context, in Upload) (*Document, error)
- func (c *Client) Usage(ctx context.Context) (*Quota, error)
- type Document
- type Error
- type Link
- type LinkOptions
- type Option
- type Product
- type Quota
- type Upload
Constants ¶
const ( CodeQuotaExceeded = "quota_exceeded" CodeNotFound = "not_found" CodeTooLarge = "too_large" CodeInvalid = "invalid_request" CodeRateLimited = "rate_limited" CodeServer = "server_error" )
Stable error codes.
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 ¶
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) RevokeAllLinks ¶
RevokeAllLinks invalidates every outstanding signed link at once.
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 Link ¶
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 ¶
LinkOptions shape a re-minted link.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL points the client at another deployment, for local testing.
func WithHTTPClient ¶
WithHTTPClient supplies the transport.
func WithTimeout ¶
WithTimeout bounds each request. Default 30s.
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.