Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
AccountID string `json:"accountId"`
ID string `json:"bucketId"`
Info map[string]string `json:"bucketInfo"`
Name string `json:"bucketName"`
Type string `json:"bucketType"`
LifecycleRules []BucketLifecycleRule `json:"lifecycleRules"`
Revision int `json:"revision"`
}
Bucket is used to represent a B2 Bucket
type BucketCorsRule ¶
type BucketCorsRule struct {
Name string `json:"corsRuleName"`
AllowedOrigins []string `json:"allowedOrigins"`
AllowedHeaders []string `json:"allowedHeaders"`
AllowedOperations []string `json:"allowedOperations"`
ExposeHeaders []string `json:"exposeHeaders"`
MaxAgeSeconds int `json:"maxAgeSeconds"`
}
BucketCorsRule is used to represent a Bucket's CORS rule
See more on https://www.backblaze.com/b2/docs/cors_rules.html
type BucketCreateRequest ¶
type BucketCreateRequest struct {
AccountID string `json:"accountId"`
Name string `json:"bucketName"`
Type string `json:"bucketType"`
Info map[string]string `json:"bucketInfo,omitempty"`
CorsRules []BucketCorsRule `json:"corsRules,omitempty"`
LifecycleRules []BucketLifecycleRule `json:"lifecycleRules,omitempty"`
}
BucketCreateRequest represents a request to create a Bucket
type BucketLifecycleRule ¶
type BucketLifecycleRule struct {
DaysFromHidingToDeleting int `json:"daysFromHidingToDeleting"`
DaysFromUploadingToHiding int `json:"daysFromUploadingToHiding"`
FileNamePrefix string `json:"fileNamePrefix"`
}
BucketLifecycleRule tells B2 to automatically hide and/or delete old files
See more on https://www.backblaze.com/b2/docs/lifecycle_rules.html
type BucketListRequest ¶
type BucketListRequest struct {
AccountID string `json:"accountId"`
BucketID string `json:"bucketId,omitempty"`
Name string `json:"bucketName,omitempty"`
Types string `json:"bucketTypes,omitempty"`
}
BucketListRequest represents a request to list Buckets
type BucketService ¶
type BucketService struct {
// contains filtered or unexported fields
}
BucketService handles communication with the Bucket related methods of the B2 API
func (*BucketService) Create ¶
func (s *BucketService) Create(createRequest *BucketCreateRequest) (*Bucket, *http.Response, error)
Create a new Bucket
func (*BucketService) List ¶
func (s *BucketService) List(listRequest *BucketListRequest) ([]Bucket, *http.Response, error)
List all Buckets
type Client ¶
type Client struct {
// The identifier for the account
AccountID string
// The base URL for downloading files
DownloadURL *url.URL
// Services used for communicating with the API
Bucket *BucketService
File *FileService
// contains filtered or unexported fields
}
Client manages communication with Backblaze API
func (*Client) Do ¶
Do sends an API request and returns the API response
The API response is JSON decoded and stored in the value pointed to by v. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request suitable for use with Client.Do
The path should always be specified without a preceding slash. It will be resolved to the BaseURL of the Client.
If specified, the value pointed to by body is JSON encoded and included in as the request body.
type ClientOpt ¶
ClientOpt are options for New
func SetBaseURL ¶
SetBaseURL is a client option for setting the base URL
type File ¶ added in v0.3.0
type File struct {
AccountID string `json:"accountId"`
Action string `json:"action"`
BucketID string `json:"bucketId"`
ContentLength int `json:"contentLength"`
ContentSha1 string `json:"contentSha1"`
ContentType string `json:"contentType"`
FileID string `json:"fileId"`
FileInfo map[string]string `json:"fileInfo"`
FileName string `json:"fileName"`
UploadTimestamp int64 `json:"uploadTimestamp"`
}
File describes a File or a Folder in a Bucket
type FileListRequest ¶ added in v0.3.0
type FileListRequest struct {
BucketID string `json:"bucketId"`
StartFileName string `json:"startFileName,omitempty"`
MaxFileCount int `json:"maxFileCount,omitempty"`
Prefix string `json:"prefix,omitempty"`
Delimiter string `json:"delimiter,omitempty"`
}
FileListRequest represents a request to list files in a Bucket
type FileService ¶ added in v0.3.0
type FileService struct {
// contains filtered or unexported fields
}
FileService handles communication with the File related methods of the B2 API
func (*FileService) List ¶ added in v0.3.0
func (s *FileService) List(listRequest *FileListRequest) ([]File, *http.Response, error)
List files in a Bucket