b2api

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allowed

type Allowed struct {
	BucketId   string   `json:"bucketId"`     // when present, access is restricted to one bucket
	BucketName string   `json:"bucketName"`   // if it exists and bucketId is present this will be the name
	Capability []string `json:"capabilities"` // listKeys, writeKeys, deleteKeys, listBuckets, writeBuckets,
	// deleteBuckets, listFiles, readFiles, shareFiles, writeFiles,
	// and deleteFiles
	NamePrefix string `json:"namePrefix"` // when present, access restricted to names that start with this
}

Allowed lists capabilities and any restrictions

type AuthConfig

type AuthConfig struct {
	AccountID     string
	ApplicationID string
	Clear         bool
	AppName       string
}

type AuthorizationResp

type AuthorizationResp struct {
	AbsoluteMinimumPartSize int64   `json:"absoluteMinimumPartSize"` // smallest possible size part of a large file except last one
	AccountID               string  `json:"accountId"`
	Allowed                 Allowed `json:"allowed"` // base url for all calls except up/download
	APIURL                  string  `json:"apiUrl"`
	AuthorizationToken      string  `json:"authorizationToken"`  // valid for 24hr
	DownloadURL             string  `json:"downloadUrl"`         // base url for downloading files
	RecommendedPartSize     int64   `json:"recommendedPartSize"` // recommended size for each part of a large file

}

B2Response contains the response from the B2Cloud

func (*AuthorizationResp) Valid

func (a *AuthorizationResp) Valid() bool

Valid is authorization valid

type Bucket

type Bucket struct {
	AccountID      string           `json:"accountId"`
	BucketID       string           `json:"bucketId"`
	BucketName     string           `json:"bucketName"`
	BucketType     string           `json:"bucketType"` //"allPublic", "allPrivate", "snapshot", or other values in future
	BucketInfo     json.RawMessage  `json:"bucketInfo"` //user data stored with this bucket
	CorsRules      []CorsRules      `json:"corsRules"`  // CORS rules for this bucket.
	LifecycleRules []LifecycleRules `json:"lifecycleRules"`
	Revision       int              `json:"revision"`
}

Bucket bucket struct

type BucketType

type BucketType int

BucketType enum type

const (
	All BucketType = 1 + iota
	AllPublic
	AllPrivate
	Snapshot
)

func (BucketType) Id

func (bt BucketType) Id(val string) int

Id show int value

func (BucketType) String

func (bt BucketType) String() string

String output type

func (BucketType) Types

func (bt BucketType) Types() []string

Types show all types

type CanxUpLgFileReq

type CanxUpLgFileReq struct {
	FileId string `json:"fileId"` // id returned by B2StartLargeFileResp
}

B2CanxUpLgFileReq struct

type CanxUpLgFileResp

type CanxUpLgFileResp struct {
	FileId    string `json:"fileId"`
	AccountId string `json:"accountId"`
	BucketId  string `json:"bucketId"`
	FileName  string `json:"fileName"`
}

B2CanxUpLgFileResp struct

type CorsRules

type CorsRules struct {
	CorsRuleName      string   `json:"corsRuleName"`
	ExposeHeaders     string   `json:"exposeHeaders"`
	MaxAgeSeconds     int      `json:"maxAgeSeconds"`
	AllowedHeaders    []string `json:"allowedHeaders"`
	AllowedOperations []string `json:"allowedOperations"`
	AllowedOrigins    []string `json:"allowedOrigins"`
}

CorsRules struct

type CreateBucketReq

type CreateBucketReq struct {
	AccountID      string           `json:"accountId"`                // required
	BucketName     string           `json:"bucketName"`               // required
	BucketType     string           `json:"bucketType"`               // BucketType .Id or .String or Types
	BucketInfo     string           `json:"bucketInfo,omitempty"`     // optional
	CorsRules      []CorsRules      `json:"corsRules,omitempty"`      // https://www.backblaze.com/b2/docs/cors_rules.html
	LifecycleRules []LifecycleRules `json:"lifecycleRules,omitempty"` // https://www.backblaze.com/b2/docs/lifecycle_rules.html
}

B2CreateBucketReq create bucket request

type CreateBucketResp

type CreateBucketResp struct {
	Bucket
}

B2CreateBucketResp create bucket response

type CreateKeyReq

type CreateKeyReq struct {
	AccountId              string   `json:"accountId"`
	Capabilities           []string `json:"capabilities,omitempty"`
	KeyName                string   `json:"keyName,omitempty"`
	ValidDurationInSeconds int      `json:"validDurationInSeconds,omitempty"`
	BucketId               string   `json:"bucketId,omitempty"`
	NamePrefix             string   `json:"namePrefix,omitempty"`
}

B2CreateKeyReq create req

type CreateKeyResp

type CreateKeyResp struct {
	KeyName          string   `json:"keyName"`
	ApplicationKeyId string   `json:"applicationKeyId"`
	ApplicationKey   string   `json:"applicationKey"`
	Capability       []string `json:"capabilities"` // listKeys, writeKeys, deleteKeys, listBuckets, writeBuckets,
	// deleteBuckets, listFiles, readFiles, shareFiles, writeFiles,
	// and deleteFiles
	AccountID           string `json:"accountId"`
	ExpirationTimestamp string `json:"expirationTimestamp"`
	BucketId            string `json:"bucketId"`
	NamePrefix          string `json:"namePrefix"` // when present, access restricted to names that start with this
}

B2CreateKeyResp create key response

type DeleteBucketReq

type DeleteBucketReq struct {
	AccountID string `json:"accountId"` // required
	BucketID  string `json:"bucketId"`  // filter (optional)
}

B2DeleteBucketReq delete bucket request

type DeleteBucketResp

type DeleteBucketResp struct {
	Bucket
}

B2DeleteBucketResp delete bucket response

type DeleteFileVersionReq

type DeleteFileVersionReq struct {
	FileName string `json:"fileName"`
	FileID   string `json:"fileId"`
}

type DeleteFileVersionResponse

type DeleteFileVersionResponse struct {
	FileID   string `json:"fileId"`
	FileName string `json:"fileName"`
}

type DeleteKeyReq

type DeleteKeyReq struct {
	ApplicationKeyId string `json:"applicationKeyId"`
}

B2DeleteKeyReq delete key req

type DeleteKeyResp

type DeleteKeyResp struct {
	Key Key
}

B2DeleteKeyResp delete key response

type DownloadAuthReq

type DownloadAuthReq struct {
	BucketId               string `json:"bucketId"`                       //
	FilenamePrefix         string `json:"fileNamePrefix"`                 // Directory name below bucket
	ValidDurationInSeconds int64  `json:"validDurationInSeconds"`         // Min 1 second. The maximum value is 604800
	B2ContentDisposition   string `json:"b2ContentDisposition,omitempty"` // Optional RFC 6266
}

type DownloadAuthResponse

type DownloadAuthResponse struct {
	BucketId           string `json:"bucketId"`           //
	FilenamePrefix     string `json:"fileNamePrefix"`     // Directory name below bucket
	AuthorizationToken string `json:"authorizationToken"` // Token to use for download
}

type DownloadFileByIDReq

type DownloadFileByIDReq struct {
	FileID string `json:"fileId"`
}

type File

type File struct {
	UploadResp
}

Files struct

type FileInfo

type FileInfo struct {
	SrcLastModifiedMillis string `json:"src_last_modified_millis"`
	LargeFileSha1         string `json:"large_file_sha1,omitempty"`
}

type FinishUpLgFileReq

type FinishUpLgFileReq struct {
	FileId string   `json:"fileId"`        // id returned by B2StartLargeFileResp
	Sha1Ar []string `json:"partSha1Array"` // file part sha1 arrays in correct order
}

B2FinishUpLgFileReq struct

type FinishUpLgFileResp

type FinishUpLgFileResp struct {
	UploadResp
}

B2FinishUpLgFileResp struct

type GetFileInfoReq

type GetFileInfoReq struct {
	FileID string `json:"fileId"`
}

type GetFileInfoResponse

type GetFileInfoResponse struct {
	UploadResp
}

type GetFileUploadPartReq

type GetFileUploadPartReq struct {
	FileID string `json:"fileId"` // Unique ID of file being uploaded
}

type GetFileUploadPartResponse

type GetFileUploadPartResponse struct {
	FileID             string `json:"fileId"`             // Unique ID of file being uploaded
	UploadURL          string `json:"uploadUrl"`          // URL that can be used to upload parts of this file
	AuthorizationToken string `json:"authorizationToken"` // Valid 24hrs or until endpoint rejects upload
}

type HideFileReq

type HideFileReq struct {
	BucketId string `json:"bucketId"`
	FileName string `json:"fileName"`
}

type HideFileResponse

type HideFileResponse struct {
	UploadResp
}

type Key

type Key struct {
	KeyName             string   `json:"keyName"`
	ApplicationKeyId    string   `json:"applicationKeyId"`
	Capabilities        []string `json:"capabilities"`
	AccountId           string   `json:"accountId"`
	ExpirationTimestamp string   `json:"expirationTimestamp"`
	BucketId            string   `json:"bucketId"`
	NamePrefix          string   `json:"namePrefix"`
}

Key struct

type KeysResp

type KeysResp struct {
	NextApplicationKeyId string `json:"nextApplicationKeyId"`
	Keys                 []Key  `json:"keys"`
}

B2KeysResp keys response

type LifecycleRules

type LifecycleRules struct {
	DaysFromHidingToDeleting  int    `json:"daysFromHidingToDeleting"`
	DaysFromUploadingToHiding int    `json:"daysFromUploadingToHiding"`
	FileNamePrefix            string `json:"fileNamePrefix"`
}

LifecycleRules struct

type ListBucketReq

type ListBucketReq struct {
	AccountID   string   `json:"accountId"`             // required
	BucketID    string   `json:"bucketId,omitempty"`    // filter (optional)
	BucketName  string   `json:"bucketName,omitempty"`  // filter (optional)
	BucketTypes []string `json:"bucketTypes,omitempty"` // BucketType .Id or .String or Types
}

B2ListBucketReq b2 bucket list request

type ListBucketsResp

type ListBucketsResp struct {
	Buckets []Bucket `json:"buckets"`
}

B2ListBucketsResp list buckets response

type ListFileReq

type ListFileReq struct {
	BucketID      string       `json:"bucketId"`
	StartFileName string       `json:"startFileName,omitempty"`
	MaxFileCount  MaxFileCount `json:"maxFileCount,omitempty"`
	Prefix        string       `json:"prefix,omitempty"`
	Delimiter     string       `json:"delimiter,omitempty"`
}

type ListFileVersionsReq

type ListFileVersionsReq struct {
	BucketID      string       `json:"bucketId"`
	StartFileName string       `json:"startFileName,omitempty"`
	StartFileID   string       `json:"startFileId,omitempty"` // requires StartFileName if defined
	MaxFileCount  MaxFileCount `json:"maxFileCount,omitempty"`
	Prefix        string       `json:"prefix,omitempty"`
	Delimiter     string       `json:"delimiter,omitempty"`
}

type ListFileVersionsResponse

type ListFileVersionsResponse struct {
	Files        []File `json:"files"`
	NextFileName string `json:"nextFileName"`
	NextFileId   string `json:"nextFileId"`
}

type ListFilesResponse

type ListFilesResponse struct {
	File         []File `json:"files"`
	NextFileName string `json:"nextFileName"`
}

type ListKeyReq

type ListKeyReq struct {
	AccountId             string `json:"accountId"`
	MaxKeyCount           int    `json:"maxKeyCount,omitempty"`
	StartApplicationKeyId string `json:"startApplicationKeyId,omitempty"`
}

B2ListKeyReq list key request

type ListPartsReq

type ListPartsReq struct {
	FileID          string `json:"fileId"` // Unique ID of file being uploaded
	StartPartNumber int64  `json:"startPartNumber"`
	MaxPartCount    int64  `json:"maxPartCount"`
}

type ListPartsResponse

type ListPartsResponse struct {
	FileID             string `json:"fileId"`             // Unique ID of file being uploaded
	UploadURL          string `json:"uploadUrl"`          // URL that can be used to upload parts of this file
	AuthorizationToken string `json:"authorizationToken"` // Valid 24hrs or until endpoint rejects upload
	Parts              []Part `json:"parts"`
	NextPartNumber     int64  `json:"nextPartNumber"` // What to pass into startPartNumber for next search to continue
}

type ListUnfinishUpLgFilesReq

type ListUnfinishUpLgFilesReq struct {
	BucketId     string       `json:"bucketId"`
	NamePrefix   string       `json:"namePrefix,omitempty"`   // optional, only files matching prefix will return
	StartFileId  string       `json:"startFileId,omitempty"`  // optional, first to return, if not found next will return
	MaxFileCount MaxFileCount `json:"maxFileCount,omitempty"` // optional, default 100, max 100
}

B2ListUnfinishUpLgFilesReq struct

type ListUnfinishUpLgFilesResp

type ListUnfinishUpLgFilesResp struct {
	Files     []File `json:"files"`
	NextField string `json:"nextField"`
}

B2ListUnfinishUpLgFilesResp struct

type ListUnfinishedLargeFilesReq

type ListUnfinishedLargeFilesReq struct {
	BucketId     string       `json:"bucketId"`               //
	NamePrefix   string       `json:"namePrefix,omitempty"`   // Optional
	StartFileId  string       `json:"startFileId,omitempty"`  // Optional
	MaxFileCount MaxFileCount `json:"maxFileCount,omitempty"` // Optional
}

type ListUnfinishedLargeFilesResponse

type ListUnfinishedLargeFilesResponse struct {
	Files      []UploadResp `json:"files"`
	NextFileId string       `json:"nextFileId"`
}

type MaxFileCount

type MaxFileCount int

MaxFileCount type for default

func (*MaxFileCount) UnmarshalJSON

func (m *MaxFileCount) UnmarshalJSON(b []byte) error

UnmarshalJSON Overrides and sets default to 100 on custom type

type Part

type Part struct {
	FileID          string `json:"fileId"` // Unique ID of file being uploaded
	PartNumber      int64  `json:"partNumber"`
	ContentLength   int64  `json:"contentLength"`
	ContentSha1     string `json:"contentSha1"`
	UploadTimestamp int64  `json:"uploadTimestamp"`
}

type StartLargeFileReq

type StartLargeFileReq struct {
	BucketId    string   `json:"bucketId"` //
	FileName    string   `json:"fileName"`
	ContentType string   `json:"contentType"` // use as default b2/x-auto
	FileInfo    FileInfo `json:"fileInfo"`    // Optional
}

type StartLargeFileResponse

type StartLargeFileResponse struct {
	UploadResp
}

type StartUpLgFileReq

type StartUpLgFileReq struct {
	BucketId    string `json:"bucketId"`
	FileName    string `json:"fileName"`
	ContentType string `json:"contentType"`
	FileInfo    string `json:"fileInfo"`
}

B2StartUpLgFileReq struct

type StartUpLgFileResp

type StartUpLgFileResp struct {
	AccountId  string `json:"accountId"`
	UploadResp        // FileId stores unique id to reuse for part uploads
}

B2StartUpLgFileResp struct

type UpdateBucketReq

type UpdateBucketReq struct {
	AccountID      string           `json:"accountId"`                // required
	BucketID       string           `json:"bucketId,omitempty"`       // BucketId used instead of name
	BucketType     string           `json:"bucketType,omitempty"`     // BucketType .Id or .String or Types
	BucketInfo     string           `json:"bucketInfo,omitempty"`     // optional
	CorsRules      []CorsRules      `json:"corsRules,omitempty"`      // https://www.backblaze.com/b2/docs/cors_rules.html
	LifecycleRules []LifecycleRules `json:"lifecycleRules,omitempty"` // https://www.backblaze.com/b2/docs/lifecycle_rules.html
	IfRevisionIs   bool             `json:"ifRevisionIs,omitempty"`   //
}

B2UpdateBucketReq update request

type UploadPartResponse

type UploadPartResponse struct {
	ContentLength   int64  `json:"contentLength"`
	ContentSha1     string `json:"contentSha1"`
	FileId          string `json:"fileId"`
	PartNumber      int64  `json:"partNumber"`
	UploadTimestamp int64  `json:"uploadTimestamp"`
}

type UploadResp

type UploadResp struct {
	AccountID       string   `json:"accountId"`
	Action          string   `json:"action"` // start,upload,hide,folder currently but others can be added
	BucketID        string   `json:"bucketId"`
	ContentLength   int64    `json:"contentLength"`
	ContentSha1     string   `json:"contentSha1"`
	ContentType     string   `json:"contentType"`
	FileID          string   `json:"fileId"`
	FileInfo        FileInfo `json:"fileInfo"`
	FileName        string   `json:"fileName"`
	UploadTimestamp int64    `json:"uploadTimestamp"` // time in millis
}

B2UploadResp struct

type UploadURLReq

type UploadURLReq struct {
	BucketId string `json:"bucketId"`
}

B2UploadURLReq struct

type UploadURLResp

type UploadURLResp struct {
	BucketId           string `json:"bucketId"`
	UploadURL          string `json:"uploadUrl"`
	AuthorizationToken string `json:"authorizationToken"`
}

B2UploadURLResp struct

Jump to

Keyboard shortcuts

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