Documentation
¶
Overview ¶
Package bunnystorage provides an API client to the BunnyCDN Storage API.
Index ¶
- Constants
- func ComputeSHA256(r io.Reader) (string, error)
- type Client
- func (c *Client) Delete(ctx context.Context, path, filename string) (*resty.Response, error)
- func (c *Client) Download(ctx context.Context, path, filename string) ([]byte, *resty.Response, error)
- func (c *Client) List(ctx context.Context, path string) ([]*Object, *resty.Response, error)
- func (c *Client) Upload(ctx context.Context, path, filename, checksum string, body io.Reader) (*resty.Response, error)
- type Config
- type Endpoint
- type Logger
- type Object
- type Operation
- type Response
Constants ¶
const ( // ErrInvalidApplication is returned when an application is invalid. ErrInvalidApplication xerrors.Error = "invalid application" // ErrInvalidConfig is returned when Config is invalid. ErrInvalidConfig xerrors.Error = "invalid config" // ErrInvalidEndpoint is returned when an endpoint is invalid. ErrInvalidEndpoint xerrors.Error = "invalid endpoint" // ErrStorageZoneRequired is returned when a Config is created without a // storage zone. ErrStorageZoneRequired xerrors.Error = "storage zone required" // ErrStorageZoneNameRequired is returned when a storage zone is created // without a name. ErrStorageZoneNameRequired xerrors.Error = "storage zone name required" // ErrStorageZoneKeyRequired is returned when a storage zone is created // without an API key. ErrStorageZoneKeyRequired xerrors.Error = "storage zone key required" // ErrEndpointRequired is returned when a Config is created without an // endpoint. ErrEndpointRequired xerrors.Error = "endpoint required" // ErrApplicationKeyRequired is returned when an application is created // without an API key. ErrApplicationKeyRequired xerrors.Error = "application key required" // ErrUserAgentRequired is returned when no UserAgent is set ErrUserAgentRequired xerrors.Error = "user agent required" )
Default values for the Config struct.
const ( // ErrConfigRequired is returned when a Client is created without a Config. ErrConfigRequired xerrors.Error = "config is required" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the LanguageTool API client.
func (*Client) Download ¶
func (c *Client) Download(ctx context.Context, path, filename string) ([]byte, *resty.Response, error)
Download downloads a file from the storage zone.
type Config ¶
type Config struct { // Application is the application that is making requests to the API. UserAgent string // Logger is the logger to use for logging requests when debugging. Logger Logger // StorageZone is the name of the storage zone to connect to. StorageZone string // Key is the API key used to authenticate with the API. The storage zone // password also doubles as your key. Key string // ReadOnlyKey is the read-only API key used to authenticate with the API. // This key is optional and only used for read-only operations. ReadOnlyKey string // Endpoint is the endpoint to use for the API. Endpoint Endpoint // MaxRetries specifies the maximum number of times to retry a request if it // fails due to rate limiting. // // This field is optional. MaxRetries int // Timeout is the time limit for requests made by the client to the API. // // This field is optional. Timeout time.Duration // Debug specifies whether or not to enable debug logging. // // This field is optional. Debug bool // contains filtered or unexported fields }
Config holds the basic configuration for the Bunny.net Storage API.
type Endpoint ¶
type Endpoint int
Endpoint represents the primary storage region of a storage zone.
const ( EndpointFalkenstein Endpoint = iota + 1 EndpointNewYork EndpointLosAngeles EndpointSingapore EndpointSydney EndpointLondon EndpointStockholm EndpointSaoPaulo EndpointJohannesburg EndpointLocalhost // For testing purposes only )
The following endpoints are available for use with the Edge Storage API.
func Parse ¶
Parse parses a string representation of an endpoint into an Endpoint. If the string is not a valid endpoint, EndpointFalkenstein is returned.
type Logger ¶
Logger defines the interface for logging. It is basically a thin wrapper around the standard logger which implements only a subset of the logger API.
type Object ¶
type Object struct { UserID string `json:"UserId,omitempty"` ContentType string `json:"ContentType,omitempty"` Path string `json:"Path,omitempty"` ObjectName string `json:"ObjectName,omitempty"` ReplicatedZones string `json:"ReplicatedZones,omitempty"` LastChanged string `json:"LastChanged,omitempty"` StorageZoneName string `json:"StorageZoneName,omitempty"` Checksum string `json:"Checksum,omitempty"` DateCreated string `json:"DateCreated,omitempty"` GUID string `json:"Guid,omitempty"` Length int `json:"Length,omitempty"` ServerID int `json:"ServerId,omitempty"` StorageZoneID int `json:"StorageZoneId,omitempty"` ArrayNumber int `json:"ArrayNumber,omitempty"` IsDirectory bool `json:"IsDirectory,omitempty"` }
Object represents a file or directory in the BunnyCDN Storage API.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
bunnystoragectl/internal/app
Package app is the main package for the application.
|
Package app is the main package for the application. |
bunnystoragectl/internal/meta
Package meta provides build information and other metadata for the application.
|
Package meta provides build information and other metadata for the application. |
bunnystoragectl/internal/osutil
Package osutil provides useful functions and utilities for working with the operating system.
|
Package osutil provides useful functions and utilities for working with the operating system. |
internal
|
|
build
Package build provides build information about [the bunnystorage package].
|
Package build provides build information about [the bunnystorage package]. |
testutil
Package testutil provides utilities for testing.
|
Package testutil provides utilities for testing. |
tests
|
|
integration
Package integration contains integration tests for the Bunny Storage client.
|
Package integration contains integration tests for the Bunny Storage client. |