File: b2types.go

package info (click to toggle)
golang-github-backblaze-blazer 0.6.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 612 kB
  • sloc: makefile: 5
file content (283 lines) | stat: -rw-r--r-- 8,734 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// Copyright 2016, the Blazer authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package b2types implements internal types common to the B2 API.
package b2types

// You know what would be amazing?  If I could autogen this from like a JSON
// file.  Wouldn't that be amazing?  That would be amazing.

const (
	V1api = "/b2api/v1/"
)

type ErrorMessage struct {
	Status int    `json:"status"`
	Code   string `json:"code"`
	Msg    string `json:"message"`
}

type AuthorizeAccountResponse struct {
	AccountID      string    `json:"accountId"`
	AuthToken      string    `json:"authorizationToken"`
	URI            string    `json:"apiUrl"`
	DownloadURI    string    `json:"downloadUrl"`
	MinPartSize    int       `json:"minimumPartSize"`
	PartSize       int       `json:"recommendedPartSize"`
	AbsMinPartSize int       `json:"absoluteMinimumPartSize"`
	Allowed        Allowance `json:"allowed"`
}

type Allowance struct {
	Capabilities []string `json:"capabilities"`
	Bucket       string   `json:"bucketId"`
	Prefix       string   `json:"namePrefix"`
}

type LifecycleRule struct {
	DaysHiddenUntilDeleted int    `json:"daysFromHidingToDeleting,omitempty"`
	DaysNewUntilHidden     int    `json:"daysFromUploadingToHiding,omitempty"`
	Prefix                 string `json:"fileNamePrefix"`
}

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"`
}

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"`
}

type DeleteBucketRequest struct {
	AccountID string `json:"accountId"`
	BucketID  string `json:"bucketId"`
}

type ListBucketsRequest struct {
	AccountID string `json:"accountId"`
	Bucket    string `json:"bucketId,omitempty"`
	Name      string `json:"bucketName,omitempty"`
}

type ListBucketsResponse struct {
	Buckets []CreateBucketResponse `json:"buckets"`
}

type UpdateBucketRequest struct {
	AccountID      string            `json:"accountId"`
	BucketID       string            `json:"bucketId"`
	Type           string            `json:"bucketType,omitempty"`
	Info           map[string]string `json:"bucketInfo,omitempty"`
	LifecycleRules []LifecycleRule   `json:"lifecycleRules,omitempty"`
	IfRevisionIs   int               `json:"ifRevisionIs,omitempty"`
}

type UpdateBucketResponse CreateBucketResponse

type GetUploadURLRequest struct {
	BucketID string `json:"bucketId"`
}

type GetUploadURLResponse struct {
	URI   string `json:"uploadUrl"`
	Token string `json:"authorizationToken"`
}

type UploadFileResponse GetFileInfoResponse

type DeleteFileVersionRequest struct {
	Name   string `json:"fileName"`
	FileID string `json:"fileId"`
}

type StartLargeFileRequest struct {
	BucketID    string            `json:"bucketId"`
	Name        string            `json:"fileName"`
	ContentType string            `json:"contentType"`
	Info        map[string]string `json:"fileInfo,omitempty"`
}

type StartLargeFileResponse struct {
	ID string `json:"fileId"`
}

type CancelLargeFileRequest struct {
	ID string `json:"fileId"`
}

type ListPartsRequest struct {
	ID    string `json:"fileId"`
	Start int    `json:"startPartNumber"`
	Count int    `json:"maxPartCount"`
}

type ListPartsResponse struct {
	Next  int `json:"nextPartNumber"`
	Parts []struct {
		ID     string `json:"fileId"`
		Number int    `json:"partNumber"`
		SHA1   string `json:"contentSha1"`
		Size   int64  `json:"contentLength"`
	} `json:"parts"`
}

type getUploadPartURLRequest struct {
	ID string `json:"fileId"`
}

type getUploadPartURLResponse struct {
	URL   string `json:"uploadUrl"`
	Token string `json:"authorizationToken"`
}

type FinishLargeFileRequest struct {
	ID     string   `json:"fileId"`
	Hashes []string `json:"partSha1Array"`
}

type FinishLargeFileResponse struct {
	Name      string `json:"fileName"`
	FileID    string `json:"fileId"`
	Timestamp int64  `json:"uploadTimestamp"`
	Action    string `json:"action"`
}

type ListFileNamesRequest struct {
	BucketID     string `json:"bucketId"`
	Count        int    `json:"maxFileCount"`
	Continuation string `json:"startFileName,omitempty"`
	Prefix       string `json:"prefix,omitempty"`
	Delimiter    string `json:"delimiter,omitempty"`
}

type ListFileNamesResponse struct {
	Continuation string                `json:"nextFileName"`
	Files        []GetFileInfoResponse `json:"files"`
}

type ListFileVersionsRequest struct {
	BucketID  string `json:"bucketId"`
	Count     int    `json:"maxFileCount"`
	StartName string `json:"startFileName,omitempty"`
	StartID   string `json:"startFileId,omitempty"`
	Prefix    string `json:"prefix,omitempty"`
	Delimiter string `json:"delimiter,omitempty"`
}

type ListFileVersionsResponse struct {
	NextName string                `json:"nextFileName"`
	NextID   string                `json:"nextFileId"`
	Files    []GetFileInfoResponse `json:"files"`
}

type HideFileRequest struct {
	BucketID string `json:"bucketId"`
	File     string `json:"fileName"`
}

type HideFileResponse struct {
	ID        string `json:"fileId"`
	Timestamp int64  `json:"uploadTimestamp"`
	Action    string `json:"action"`
}

type GetFileInfoRequest struct {
	ID string `json:"fileId"`
}

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"`
}

type GetDownloadAuthorizationRequest struct {
	BucketID           string `json:"bucketId"`
	Prefix             string `json:"fileNamePrefix"`
	Valid              int    `json:"validDurationInSeconds"`
	ContentDisposition string `json:"b2ContentDisposition,omitempty"`
}

type GetDownloadAuthorizationResponse struct {
	BucketID string `json:"bucketId"`
	Prefix   string `json:"fileNamePrefix"`
	Token    string `json:"authorizationToken"`
}

type ListUnfinishedLargeFilesRequest struct {
	BucketID     string `json:"bucketId"`
	Continuation string `json:"startFileId,omitempty"`
	Count        int    `json:"maxFileCount,omitempty"`
}

type ListUnfinishedLargeFilesResponse struct {
	Files        []GetFileInfoResponse `json:"files"`
	Continuation string                `json:"nextFileId"`
}

type CreateKeyRequest 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"`
}

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"`
	Prefix       string   `json:"namePrefix"`
}

type CreateKeyResponse Key

type DeleteKeyRequest struct {
	KeyID string `json:"applicationKeyId"`
}

type DeleteKeyResponse Key

type ListKeysRequest struct {
	AccountID string `json:"accountId"`
	Max       int    `json:"maxKeyCount,omitempty"`
	Next      string `json:"startApplicationKeyId,omitempty"`
}

type ListKeysResponse struct {
	Keys []Key  `json:"keys"`
	Next string `json:"nextApplicationKeyId"`
}