forked from Azure/azure-sdk-for-go
/
zm_blob_request_options.go
339 lines (282 loc) · 11.7 KB
/
zm_blob_request_options.go
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package azblob
import (
"net/url"
"strings"
)
// DeleteBlobOptions provides set of configurations for Delete blob operation
type DeleteBlobOptions struct {
// Required if the blob has associated snapshots. Specify one of the following two options: include: Delete the base blob
// and all of its snapshots. only: Delete only the blob's snapshots and not the blob itself
DeleteSnapshots *DeleteSnapshotsOptionType
BlobAccessConditions *BlobAccessConditions
}
func (o *DeleteBlobOptions) pointers() (*BlobDeleteOptions, *LeaseAccessConditions, *ModifiedAccessConditions) {
if o == nil {
return nil, nil, nil
}
basics := BlobDeleteOptions{
DeleteSnapshots: o.DeleteSnapshots,
}
if o.BlobAccessConditions == nil {
return &basics, nil, nil
}
return &basics, o.BlobAccessConditions.LeaseAccessConditions, o.BlobAccessConditions.ModifiedAccessConditions
}
// DownloadBlobOptions provides set of configurations for Download blob operation
type DownloadBlobOptions struct {
// When set to true and specified together with the Range, the service returns the MD5 hash for the range, as long as the
// range is less than or equal to 4 MB in size.
RangeGetContentMD5 *bool
// Optional, you can specify whether a particular range of the blob is read
Offset *int64
Count *int64
BlobAccessConditions *BlobAccessConditions
CpkInfo *CpkInfo
CpkScopeInfo *CpkScopeInfo
}
func (o *DownloadBlobOptions) pointers() (blobDownloadOptions *BlobDownloadOptions,
leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, modifiedAccessConditions *ModifiedAccessConditions) {
if o == nil {
return nil, nil, nil, nil
}
offset := int64(0)
count := int64(CountToEnd)
if o.Offset != nil {
offset = *o.Offset
}
if o.Count != nil {
count = *o.Count
}
basics := BlobDownloadOptions{
RangeGetContentMD5: o.RangeGetContentMD5,
Range: HttpRange{
Offset: offset,
Count: count,
}.pointers(),
}
leaseAccessConditions, modifiedAccessConditions = o.BlobAccessConditions.pointers()
return &basics, leaseAccessConditions, o.CpkInfo, modifiedAccessConditions
}
// SetTierOptions provides set of configurations for SetTier on blob operation
type SetTierOptions struct {
// Optional: Indicates the priority with which to rehydrate an archived blob.
RehydratePriority *RehydratePriority
LeaseAccessConditions *LeaseAccessConditions
ModifiedAccessConditions *ModifiedAccessConditions
}
func (o *SetTierOptions) pointers() (blobSetTierOptions *BlobSetTierOptions,
leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) {
if o == nil {
return nil, nil, nil
}
basics := BlobSetTierOptions{RehydratePriority: o.RehydratePriority}
return &basics, o.LeaseAccessConditions, o.ModifiedAccessConditions
}
// GetBlobPropertiesOptions provides set of configurations for GetProperties blob operation
type GetBlobPropertiesOptions struct {
BlobAccessConditions *BlobAccessConditions
CpkInfo *CpkInfo
}
func (o *GetBlobPropertiesOptions) pointers() (blobGetPropertiesOptions *BlobGetPropertiesOptions,
leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo, modifiedAccessConditions *ModifiedAccessConditions) {
if o == nil {
return nil, nil, nil, nil
}
leaseAccessConditions, modifiedAccessConditions = o.BlobAccessConditions.pointers()
return nil, leaseAccessConditions, o.CpkInfo, modifiedAccessConditions
}
// SetBlobHTTPHeadersOptions provides set of configurations for SetHTTPHeaders on blob operation
type SetBlobHTTPHeadersOptions struct {
LeaseAccessConditions *LeaseAccessConditions
ModifiedAccessConditions *ModifiedAccessConditions
}
func (o *SetBlobHTTPHeadersOptions) pointers() (blobSetHttpHeadersOptions *BlobSetHTTPHeadersOptions,
leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) {
if o == nil {
return nil, nil, nil
}
return nil, o.LeaseAccessConditions, o.ModifiedAccessConditions
}
// SetBlobMetadataOptions provides set of configurations for SetMetatdata on blob operation
type SetBlobMetadataOptions struct {
LeaseAccessConditions *LeaseAccessConditions
CpkInfo *CpkInfo
CpkScopeInfo *CpkScopeInfo
ModifiedAccessConditions *ModifiedAccessConditions
}
func (o *SetBlobMetadataOptions) pointers() (leaseAccessConditions *LeaseAccessConditions, cpkInfo *CpkInfo,
cpkScopeInfo *CpkScopeInfo, modifiedAccessConditions *ModifiedAccessConditions) {
if o == nil {
return nil, nil, nil, nil
}
return o.LeaseAccessConditions, o.CpkInfo, o.CpkScopeInfo, o.ModifiedAccessConditions
}
// CreateBlobSnapshotOptions provides set of configurations for CreateSnapshot of blob operation
type CreateBlobSnapshotOptions struct {
Metadata map[string]string
LeaseAccessConditions *LeaseAccessConditions
CpkInfo *CpkInfo
CpkScopeInfo *CpkScopeInfo
ModifiedAccessConditions *ModifiedAccessConditions
}
func (o *CreateBlobSnapshotOptions) pointers() (blobSetMetadataOptions *BlobCreateSnapshotOptions, cpkInfo *CpkInfo,
cpkScopeInfo *CpkScopeInfo, modifiedAccessConditions *ModifiedAccessConditions, leaseAccessConditions *LeaseAccessConditions) {
if o == nil {
return nil, nil, nil, nil, nil
}
basics := BlobCreateSnapshotOptions{
Metadata: o.Metadata,
}
return &basics, o.CpkInfo, o.CpkScopeInfo, o.ModifiedAccessConditions, o.LeaseAccessConditions
}
// StartCopyBlobOptions provides set of configurations for StartCopyFromURL blob operation
type StartCopyBlobOptions struct {
// Optional. Used to set blob tags in various blob operations.
TagsMap map[string]string
// Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the
// operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs
// are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source
// blob or file. Note that beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers.
// See Naming and Referencing Containers, Blobs, and Metadata for more information.
Metadata map[string]string
// Optional: Indicates the priority with which to rehydrate an archived blob.
RehydratePriority *RehydratePriority
// Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer.
SealBlob *bool
// Optional. Indicates the tier to be set on the blob.
Tier *AccessTier
SourceModifiedAccessConditions *SourceModifiedAccessConditions
ModifiedAccessConditions *ModifiedAccessConditions
LeaseAccessConditions *LeaseAccessConditions
}
func (o *StartCopyBlobOptions) pointers() (blobStartCopyFromUrlOptions *BlobStartCopyFromURLOptions,
sourceModifiedAccessConditions *SourceModifiedAccessConditions, modifiedAccessConditions *ModifiedAccessConditions, leaseAccessConditions *LeaseAccessConditions) {
if o == nil {
return nil, nil, nil, nil
}
basics := BlobStartCopyFromURLOptions{
BlobTagsString: serializeBlobTagsToStrPtr(o.TagsMap),
Metadata: o.Metadata,
RehydratePriority: o.RehydratePriority,
SealBlob: o.SealBlob,
Tier: o.Tier,
}
return &basics, o.SourceModifiedAccessConditions, o.ModifiedAccessConditions, o.LeaseAccessConditions
}
// AbortCopyBlobOptions provides set of configurations for AbortCopyFromURL operation
type AbortCopyBlobOptions struct {
LeaseAccessConditions *LeaseAccessConditions
}
func (o *AbortCopyBlobOptions) pointers() (blobAbortCopyFromUrlOptions *BlobAbortCopyFromURLOptions,
leaseAccessConditions *LeaseAccessConditions) {
if o == nil {
return nil, nil
}
return nil, o.LeaseAccessConditions
}
func serializeBlobTagsToStrPtr(tagsMap map[string]string) *string {
if tagsMap == nil {
return nil
}
tags := make([]string, 0)
for key, val := range tagsMap {
tags = append(tags, url.QueryEscape(key)+"="+url.QueryEscape(val))
}
//tags = tags[:len(tags)-1]
blobTagsString := strings.Join(tags, "&")
return &blobTagsString
}
func serializeBlobTags(tagsMap map[string]string) *BlobTags {
if tagsMap == nil {
return nil
}
blobTagSet := make([]*BlobTag, 0)
for key, val := range tagsMap {
newKey, newVal := key, val
blobTagSet = append(blobTagSet, &BlobTag{Key: &newKey, Value: &newVal})
}
return &BlobTags{BlobTagSet: blobTagSet}
}
// SetTagsBlobOptions provides set of configurations for SetTags operation
type SetTagsBlobOptions struct {
// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
RequestID *string
// The timeout parameter is expressed in seconds.
Timeout *int32
// The version id parameter is an opaque DateTime value that, when present,
// specifies the version of the blob to operate on. It's for service version 2019-10-10 and newer.
VersionID *string
// Optional header, Specifies the transactional crc64 for the body, to be validated by the service.
TransactionalContentCRC64 []byte
// Optional header, Specifies the transactional md5 for the body, to be validated by the service.
TransactionalContentMD5 []byte
TagsMap map[string]string
ModifiedAccessConditions *ModifiedAccessConditions
LeaseAccessConditions *LeaseAccessConditions
}
func (o *SetTagsBlobOptions) pointers() (*BlobSetTagsOptions, *LeaseAccessConditions, *ModifiedAccessConditions) {
if o == nil {
return nil, nil, nil
}
options := &BlobSetTagsOptions{
RequestID: o.RequestID,
Tags: serializeBlobTags(o.TagsMap),
Timeout: o.Timeout,
TransactionalContentMD5: o.TransactionalContentMD5,
TransactionalContentCRC64: o.TransactionalContentCRC64,
VersionID: o.VersionID,
}
return options, o.LeaseAccessConditions, o.ModifiedAccessConditions
}
// GetTagsBlobOptions provides set of configurations for GetTags operation
type GetTagsBlobOptions struct {
// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
RequestID *string
// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve.
Snapshot *string
// The timeout parameter is expressed in seconds.
Timeout *int32
// The version id parameter is an opaque DateTime value that, when present, specifies the version of the blob to operate on.
// It's for service version 2019-10-10 and newer.
VersionID *string
ModifiedAccessConditions *ModifiedAccessConditions
}
func (o *GetTagsBlobOptions) pointers() (*BlobGetTagsOptions, *ModifiedAccessConditions) {
if o == nil {
return nil, nil
}
options := &BlobGetTagsOptions{
RequestID: o.RequestID,
Snapshot: o.Snapshot,
Timeout: o.Timeout,
VersionID: o.VersionID,
}
return options, o.ModifiedAccessConditions
}
// ObjectReplicationRules struct
type ObjectReplicationRules struct {
RuleId string
Status string
}
// ObjectReplicationPolicy are deserialized attributes
type ObjectReplicationPolicy struct {
PolicyId *string
Rules *[]ObjectReplicationRules
}
// GetBlobPropertiesResponse reformat the GetPropertiesResponse object for easy consumption
type GetBlobPropertiesResponse struct {
BlobGetPropertiesResponse
// deserialized attributes
ObjectReplicationRules []ObjectReplicationPolicy
}
func (bgpr *BlobGetPropertiesResponse) deserializeAttributes() GetBlobPropertiesResponse {
getResp := GetBlobPropertiesResponse{}
if bgpr == nil {
return getResp
}
getResp.BlobGetPropertiesResponse = *bgpr
getResp.ObjectReplicationRules = deserializeORSPolicies(bgpr.ObjectReplicationRules)
return getResp
}