Documentation
¶
Overview ¶
Package b2types implements internal types common to the B2 API.
Index ¶
- Constants
- type APIInfo
- type Allowance
- type Allowed
- type AllowedBucket
- type AsReplicationDestination
- type AsReplicationSource
- type AuthorizeAccountResponse
- type CORSRule
- type CancelLargeFileRequest
- type CopyFileRequest
- type CopyFileResponse
- type CreateBucketRequest
- type CreateBucketResponse
- type CreateKeyRequestV3
- type CreateKeyRequestV4
- type CreateKeyResponse
- type DeleteBucketRequest
- type DeleteFileVersionRequest
- type DeleteKeyRequest
- type DeleteKeyResponse
- type ErrorMessage
- type EventNotificationRule
- type EventNotificationTargetConfiguration
- type FileLockConfiguration
- type FileRetention
- type FileRetentionResponse
- type FinishLargeFileRequest
- type FinishLargeFileResponse
- type GetBucketNotificationRulesRequest
- type GetBucketNotificationRulesResponse
- type GetDownloadAuthorizationRequest
- type GetDownloadAuthorizationResponse
- type GetFileInfoRequest
- type GetFileInfoResponse
- type GetUploadURLRequest
- type GetUploadURLResponse
- type GroupsAPIInfo
- type HideFileRequest
- type HideFileResponse
- type Key
- type LegalHoldResponse
- type LifecycleRule
- type ListBucketsRequest
- type ListBucketsResponse
- type ListFileNamesRequest
- type ListFileNamesResponse
- type ListFileVersionsRequest
- type ListFileVersionsResponse
- type ListKeysRequest
- type ListKeysResponse
- type ListPartsRequest
- type ListPartsResponse
- type ListUnfinishedLargeFilesRequest
- type ListUnfinishedLargeFilesResponse
- type NotificationCustomHeader
- type ReplicationConfiguration
- type ReplicationConfigurationResponse
- type ReplicationRules
- type Retention
- type RetentionPeriod
- type ServerSideEncryption
- type ServerSideEncryptionResponse
- type SetBucketNotificationRulesRequest
- type SetBucketNotificationRulesResponse
- type StartLargeFileRequest
- type StartLargeFileResponse
- type StorageAPIInfo
- type UpdateBucketRequest
- type UpdateBucketResponse
- type UpdateFileLegalHoldRequest
- type UpdateFileLegalHoldResponse
- type UpdateFileRetentionRequest
- type UpdateFileRetentionResponse
- type UploadFileResponse
- type WebhookNotificationTarget
Constants ¶
const ( V3api = "/b2api/v3/" V4api = "/b2api/v4/" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIInfo ¶ added in v0.7.0
type APIInfo struct {
StorageAPIInfo *StorageAPIInfo `json:"storageApi,omitempty"`
GroupsAPIInfo *GroupsAPIInfo `json:"groupsApi,omitempty"`
}
type Allowed ¶ added in v0.9.0
type Allowed struct {
Buckets []AllowedBucket `json:"buckets"`
Capabilities []string `json:"capabilities"`
Prefix string `json:"namePrefix"`
}
Allowed is the authorizing key's scope, from apiInfo.storageApi.allowed in the v4 b2_authorize_account response.
type AllowedBucket ¶ added in v0.9.0
AllowedBucket is a bucket a key is restricted to. Name is empty only if the bucket no longer exists.
type AsReplicationDestination ¶ added in v0.7.0
type AsReplicationSource ¶ added in v0.7.0
type AsReplicationSource struct {
ReplicationRules []ReplicationRules `json:"replicationRules,omitempty"`
KeyID string `json:"sourceApplicationKeyId,omitempty"`
}
type CORSRule ¶ added in v0.7.0
type CORSRule struct {
Name string `json:"corsRuleName,omitempty"`
AllowedOrigins []string `json:"allowedOrigins,omitempty"`
AllowedHeaders []string `json:"allowedHeaders,omitempty"`
AllowedOperations []string `json:"allowedOperations,omitempty"`
ExposeHeaders []string `json:"exposeHeaders,omitempty"`
MaxAgeSeconds int `json:"maxAgeSeconds,omitempty"`
}
type CancelLargeFileRequest ¶
type CancelLargeFileRequest struct {
ID string `json:"fileId"`
}
type CopyFileRequest ¶ added in v0.9.0
type CopyFileRequest struct {
SourceFileID string `json:"sourceFileId"`
FileName string `json:"fileName"`
DestinationBucketID string `json:"destinationBucketId,omitempty"`
Range string `json:"range,omitempty"`
MetadataDirective string `json:"metadataDirective"`
ContentType *string `json:"contentType,omitempty"`
// A nil pointer omits fileInfo (COPY); a pointer to an empty map sends {}.
FileInfo *map[string]string `json:"fileInfo,omitempty"`
}
type CopyFileResponse ¶ added in v0.9.0
type CopyFileResponse UploadFileResponse
type CreateBucketRequest ¶
type CreateBucketRequest struct {
AccountID string `json:"accountId"`
Name string `json:"bucketName"`
Type string `json:"bucketType"`
Info map[string]string `json:"bucketInfo"`
LifecycleRules []LifecycleRule `json:"lifecycleRules"`
CORSRules []CORSRule `json:"corsRules,omitempty"`
FileLockEnabled bool `json:"fileLockEnabled,omitempty"`
DefaultServerSideEncryption *ServerSideEncryption `json:"defaultServerSideEncryption,omitempty"`
}
type CreateBucketResponse ¶
type CreateBucketResponse struct {
BucketID string `json:"bucketId"`
Name string `json:"bucketName"`
Type string `json:"bucketType"`
Info map[string]string `json:"bucketInfo"`
LifecycleRules []LifecycleRule `json:"lifecycleRules"`
Revision int `json:"revision"`
CORSRules []CORSRule `json:"corsRules,omitempty"`
DefaultRetention string `json:"defaultRetention,omitempty"`
DefaultServerSideEncryption ServerSideEncryptionResponse `json:"defaultServerSideEncryption"`
FileLockConfig *FileLockConfiguration `json:"fileLockConfiguration,omitempty"`
ReplicationConfiguration *ReplicationConfigurationResponse `json:"replicationConfiguration,omitempty"`
}
type CreateKeyRequestV3 ¶ added in v0.9.0
type CreateKeyRequestV3 struct {
AccountID string `json:"accountId"`
Capabilities []string `json:"capabilities"`
Name string `json:"keyName"`
Valid int `json:"validDurationInSeconds,omitempty"`
BucketID string `json:"bucketId,omitempty"`
Prefix string `json:"namePrefix,omitempty"`
}
CreateKeyRequestV3 is the v3 b2_create_key body: a single bucket restriction.
type CreateKeyRequestV4 ¶ added in v0.9.0
type CreateKeyRequestV4 struct {
AccountID string `json:"accountId"`
Capabilities []string `json:"capabilities"`
Name string `json:"keyName"`
Valid int `json:"validDurationInSeconds,omitempty"`
BucketIDs []string `json:"bucketIds,omitempty"`
Prefix string `json:"namePrefix,omitempty"`
}
CreateKeyRequestV4 is the v4 b2_create_key body: a list of bucket IDs.
type CreateKeyResponse ¶ added in v0.5.0
type CreateKeyResponse Key
type DeleteBucketRequest ¶
type DeleteKeyRequest ¶ added in v0.5.0
type DeleteKeyRequest struct {
KeyID string `json:"applicationKeyId"`
}
type DeleteKeyResponse ¶ added in v0.5.0
type DeleteKeyResponse Key
type ErrorMessage ¶
type EventNotificationRule ¶ added in v0.9.0
type EventNotificationRule struct {
EventTypes []string `json:"eventTypes"`
IsEnabled bool `json:"isEnabled"`
IsSuspended bool `json:"isSuspended,omitempty"`
Name string `json:"name"`
ObjectNamePrefix string `json:"objectNamePrefix"`
SuspensionReason string `json:"suspensionReason,omitempty"`
TargetConfiguration EventNotificationTargetConfiguration `json:"targetConfiguration"`
}
EventNotificationRule is one bucket event-notification rule.
type EventNotificationTargetConfiguration ¶ added in v0.9.0
type EventNotificationTargetConfiguration struct {
TargetType string `json:"targetType"`
Webhook *WebhookNotificationTarget `json:"-"`
}
EventNotificationTargetConfiguration is a tagged union. B2 currently supports the webhook target type, whose fields are flattened into the targetConfiguration object on the wire.
func (EventNotificationTargetConfiguration) MarshalJSON ¶ added in v0.9.0
func (c EventNotificationTargetConfiguration) MarshalJSON() ([]byte, error)
func (*EventNotificationTargetConfiguration) UnmarshalJSON ¶ added in v0.9.0
func (c *EventNotificationTargetConfiguration) UnmarshalJSON(data []byte) error
type FileLockConfiguration ¶ added in v0.7.0
type FileLockConfiguration struct {
IsClientAuthorizedToRead bool `json:"isClientAuthorizedToRead"`
Val struct {
DefaultRetention struct {
Mode *string `json:"mode"`
Period struct {
Duration int `json:"duration"`
Unit *string `json:"unit"`
} `json:"period"`
} `json:"defaultRetention"`
IsFileLockEnabled bool `json:"isFileLockEnabled"`
} `json:"value"`
}
type FileRetention ¶ added in v0.9.0
type FileRetention struct {
Mode *string `json:"mode"`
RetainUntilTimestamp *int64 `json:"retainUntilTimestamp"`
}
FileRetention is per-file Object Lock retention. Neither field is omitted, so the zero value serializes as both null, which removes retention.
type FileRetentionResponse ¶ added in v0.9.0
type FileRetentionResponse struct {
IsClientAuthorizedToRead bool `json:"isClientAuthorizedToRead"`
Value *FileRetention `json:"value"`
}
FileRetentionResponse is the read-authorization envelope B2 uses when a file response carries Object Lock retention settings.
type FinishLargeFileRequest ¶
type FinishLargeFileResponse ¶
type GetBucketNotificationRulesRequest ¶ added in v0.9.0
type GetBucketNotificationRulesRequest struct {
BucketID string `json:"bucketId"`
}
GetBucketNotificationRulesRequest is the request for b2_get_bucket_notification_rules.
type GetBucketNotificationRulesResponse ¶ added in v0.9.0
type GetBucketNotificationRulesResponse struct {
BucketID string `json:"bucketId"`
EventNotificationRules []EventNotificationRule `json:"eventNotificationRules"`
}
GetBucketNotificationRulesResponse is the response from b2_get_bucket_notification_rules.
type GetFileInfoRequest ¶
type GetFileInfoRequest struct {
ID string `json:"fileId"`
}
type GetFileInfoResponse ¶
type GetFileInfoResponse struct {
FileID string `json:"fileId,omitempty"`
Name string `json:"fileName,omitempty"`
AccountID string `json:"accountId,omitempty"`
BucketID string `json:"bucketId,omitempty"`
Size int64 `json:"contentLength,omitempty"`
SHA1 string `json:"contentSha1,omitempty"`
MD5 string `json:"contentMd5,omitempty"`
ContentType string `json:"contentType,omitempty"`
Info map[string]string `json:"fileInfo,omitempty"`
Action string `json:"action,omitempty"`
Timestamp int64 `json:"uploadTimestamp,omitempty"`
Retention FileRetentionResponse `json:"fileRetention,omitempty"`
LegalHold LegalHoldResponse `json:"legalHold,omitempty"`
}
type GetUploadURLRequest ¶
type GetUploadURLRequest struct {
BucketID string `json:"bucketId"`
}
type GetUploadURLResponse ¶
type GroupsAPIInfo ¶ added in v0.7.0
type HideFileRequest ¶
type HideFileResponse ¶
type Key ¶ added in v0.5.0
type Key struct {
ID string `json:"applicationKeyId"`
Secret string `json:"applicationKey"`
AccountID string `json:"accountId"`
Capabilities []string `json:"capabilities"`
Name string `json:"keyName"`
Expires int64 `json:"expirationTimestamp"`
BucketID string `json:"bucketId,omitempty"`
BucketIDs []string `json:"bucketIds,omitempty"`
Prefix string `json:"namePrefix"`
}
Key is the b2_create_key/b2_list_keys/b2_delete_key response for both API versions: v3 returns a singular bucketId, v4 a bucketIds array. Both tags are present so one struct decodes either; exactly one is populated per response.
type LegalHoldResponse ¶ added in v0.9.0
type LegalHoldResponse struct {
IsClientAuthorizedToRead bool `json:"isClientAuthorizedToRead"`
Value string `json:"value"`
}
LegalHoldResponse is the read-authorization envelope B2 uses when a file response carries an Object Lock legal hold. An absent value decodes as "".
type LifecycleRule ¶
type ListBucketsRequest ¶
type ListBucketsResponse ¶
type ListBucketsResponse struct {
Buckets []CreateBucketResponse `json:"buckets"`
}
type ListFileNamesRequest ¶
type ListFileNamesResponse ¶
type ListFileNamesResponse struct {
Continuation string `json:"nextFileName"`
Files []GetFileInfoResponse `json:"files"`
}
type ListFileVersionsRequest ¶
type ListFileVersionsResponse ¶
type ListFileVersionsResponse struct {
NextName string `json:"nextFileName"`
NextID string `json:"nextFileId"`
Files []GetFileInfoResponse `json:"files"`
}
type ListKeysRequest ¶ added in v0.5.0
type ListKeysResponse ¶ added in v0.5.0
type ListPartsRequest ¶
type ListPartsResponse ¶
type ListUnfinishedLargeFilesRequest ¶ added in v0.2.2
type ListUnfinishedLargeFilesResponse ¶ added in v0.2.2
type ListUnfinishedLargeFilesResponse struct {
Files []GetFileInfoResponse `json:"files"`
Continuation string `json:"nextFileId"`
}
type NotificationCustomHeader ¶ added in v0.9.0
NotificationCustomHeader is an HTTP header B2 includes in a webhook call.
type ReplicationConfiguration ¶ added in v0.7.0
type ReplicationConfiguration struct {
AsReplicationSource *AsReplicationSource `json:"asReplicationSource,omitempty"`
AsReplicationDestination *AsReplicationDestination `json:"asReplicationDestination,omitempty"`
}
type ReplicationConfigurationResponse ¶ added in v0.7.0
type ReplicationConfigurationResponse struct {
IsClientAuthorizedToRead bool `json:"isClientAuthorizedToRead,omitempty"`
Value *ReplicationConfiguration `json:"value,omitempty"`
}
type ReplicationRules ¶ added in v0.7.0
type ReplicationRules struct {
DestinationBucketID string `json:"destinationBucketId"`
FileNamePrefix string `json:"fileNamePrefix"`
IncludeExistingFiles bool `json:"includeExistingFiles"`
IsEnabled bool `json:"isEnabled"`
Priority int `json:"priority"`
ReplicationRuleName string `json:"replicationRuleName"`
}
type Retention ¶ added in v0.7.0
type Retention struct {
Mode string `json:"mode,omitempty"`
Period *RetentionPeriod `json:"period,omitempty"`
}
type RetentionPeriod ¶ added in v0.7.0
type ServerSideEncryption ¶ added in v0.7.0
type ServerSideEncryptionResponse ¶ added in v0.8.0
type ServerSideEncryptionResponse struct {
IsClientAuthorizedToRead bool `json:"isClientAuthorizedToRead"`
Value *ServerSideEncryption `json:"value"`
}
ServerSideEncryptionResponse is the shape in which bucket responses report the default encryption setting. Value is nil when the application key lacks the readBucketEncryption capability.
type SetBucketNotificationRulesRequest ¶ added in v0.9.0
type SetBucketNotificationRulesRequest struct {
BucketID string `json:"bucketId"`
EventNotificationRules []EventNotificationRule `json:"eventNotificationRules"`
}
SetBucketNotificationRulesRequest replaces a bucket's complete notification rule set.
type SetBucketNotificationRulesResponse ¶ added in v0.9.0
type SetBucketNotificationRulesResponse GetBucketNotificationRulesResponse
SetBucketNotificationRulesResponse is the response from b2_set_bucket_notification_rules.
type StartLargeFileRequest ¶
type StartLargeFileResponse ¶
type StartLargeFileResponse struct {
ID string `json:"fileId"`
}
type StorageAPIInfo ¶ added in v0.7.0
type StorageAPIInfo struct {
AbsMinPartSize int `json:"absoluteMinimumPartSize"`
URI string `json:"apiUrl"`
Capabilities []string `json:"capabilities"`
DownloadURI string `json:"downloadUrl"`
Type string `json:"storageApi"`
PartSize int `json:"recommendedPartSize"`
S3URI string `json:"s3ApiUrl"`
// Allowed holds the key's scope. Master keys carry an Allowed whose
// Buckets and Prefix are null rather than omitting the field.
Allowed *Allowed `json:"allowed"`
}
type UpdateBucketRequest ¶
type UpdateBucketRequest struct {
AccountID string `json:"accountId"`
BucketID string `json:"bucketId"`
Type string `json:"bucketType,omitempty"`
// A nil pointer omits bucketInfo; a pointer to an empty map sends {}.
Info *map[string]string `json:"bucketInfo,omitempty"`
// A nil pointer omits lifecycleRules (leave them unchanged); a pointer to an
// empty slice sends [] (remove them all).
LifecycleRules *[]LifecycleRule `json:"lifecycleRules,omitempty"`
IfRevisionIs int `json:"ifRevisionIs,omitempty"`
CORSRules []CORSRule `json:"corsRules,omitempty"`
DefaultRetention *Retention `json:"defaultRetention,omitempty"`
DefaultServerSideEncryption *ServerSideEncryption `json:"defaultServerSideEncryption,omitempty"`
FileLockEnabled bool `json:"fileLockEnabled,omitempty"`
ReplicationConfiguration *ReplicationConfiguration `json:"replicationConfiguration,omitempty"`
}
type UpdateBucketResponse ¶
type UpdateBucketResponse CreateBucketResponse
type UpdateFileLegalHoldRequest ¶ added in v0.9.0
type UpdateFileLegalHoldResponse ¶ added in v0.9.0
type UpdateFileLegalHoldResponse GetFileInfoResponse
type UpdateFileRetentionRequest ¶ added in v0.9.0
type UpdateFileRetentionRequest struct {
FileID string `json:"fileId"`
Name string `json:"fileName"`
Retention FileRetention `json:"fileRetention"`
BypassGovernance bool `json:"bypassGovernance"`
}
type UpdateFileRetentionResponse ¶ added in v0.9.0
type UpdateFileRetentionResponse GetFileInfoResponse
type UploadFileResponse ¶
type UploadFileResponse GetFileInfoResponse
type WebhookNotificationTarget ¶ added in v0.9.0
type WebhookNotificationTarget struct {
URL string `json:"url"`
CustomHeaders []NotificationCustomHeader `json:"customHeaders,omitempty"`
HMACSHA256SigningSecret string `json:"hmacSha256SigningSecret,omitempty"`
MaxEventsPerBatch int `json:"maxEventsPerBatch,omitempty"`
}
WebhookNotificationTarget is the configuration for a webhook notification target.