/
blob.go
421 lines (375 loc) · 19.6 KB
/
blob.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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package storage
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages a Blob within a Storage Container.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v4/go/azure/storage"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
// Location: pulumi.String("West Europe"),
// })
// if err != nil {
// return err
// }
// exampleAccount, err := storage.NewAccount(ctx, "exampleAccount", &storage.AccountArgs{
// ResourceGroupName: exampleResourceGroup.Name,
// Location: exampleResourceGroup.Location,
// AccountTier: pulumi.String("Standard"),
// AccountReplicationType: pulumi.String("LRS"),
// })
// if err != nil {
// return err
// }
// exampleContainer, err := storage.NewContainer(ctx, "exampleContainer", &storage.ContainerArgs{
// StorageAccountName: exampleAccount.Name,
// ContainerAccessType: pulumi.String("private"),
// })
// if err != nil {
// return err
// }
// _, err = storage.NewBlob(ctx, "exampleBlob", &storage.BlobArgs{
// StorageAccountName: exampleAccount.Name,
// StorageContainerName: exampleContainer.Name,
// Type: pulumi.String("Block"),
// Source: pulumi.NewFileAsset("some-local-file.zip"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Storage Blob's can be imported using the `resource id`, e.g.
//
// ```sh
// $ pulumi import azure:storage/blob:Blob blob1 https://example.blob.core.windows.net/container/blob.vhd
// ```
type Blob struct {
pulumi.CustomResourceState
// The access tier of the storage blob. Possible values are `Archive`, `Cool` and `Hot`.
AccessTier pulumi.StringOutput `pulumi:"accessTier"`
// Controls the [cache control header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) content of the response when blob is requested .
CacheControl pulumi.StringPtrOutput `pulumi:"cacheControl"`
// The MD5 sum of the blob contents. Cannot be defined if `sourceUri` is defined, or if blob type is Append or Page. Changing this forces a new resource to be created.
ContentMd5 pulumi.StringPtrOutput `pulumi:"contentMd5"`
// The content type of the storage blob. Cannot be defined if `sourceUri` is defined. Defaults to `application/octet-stream`.
ContentType pulumi.StringPtrOutput `pulumi:"contentType"`
// A map of custom blob metadata.
Metadata pulumi.StringMapOutput `pulumi:"metadata"`
// The name of the storage blob. Must be unique within the storage container the blob is located.
Name pulumi.StringOutput `pulumi:"name"`
// The number of workers per CPU core to run for concurrent uploads. Defaults to `8`.
Parallelism pulumi.IntPtrOutput `pulumi:"parallelism"`
// Used only for `page` blobs to specify the size in bytes of the blob to be created. Must be a multiple of 512. Defaults to 0.
Size pulumi.IntPtrOutput `pulumi:"size"`
// An absolute path to a file on the local system. This field cannot be specified for Append blobs and cannot be specified if `sourceContent` or `sourceUri` is specified.
Source pulumi.AssetOrArchiveOutput `pulumi:"source"`
// The content for this blob which should be defined inline. This field can only be specified for Block blobs and cannot be specified if `source` or `sourceUri` is specified.
SourceContent pulumi.StringPtrOutput `pulumi:"sourceContent"`
// The URI of an existing blob, or a file in the Azure File service, to use as the source contents
// for the blob to be created. Changing this forces a new resource to be created. This field cannot be specified for Append blobs and cannot be specified if `source` or `sourceContent` is specified.
SourceUri pulumi.StringPtrOutput `pulumi:"sourceUri"`
// Specifies the storage account in which to create the storage container.
// Changing this forces a new resource to be created.
StorageAccountName pulumi.StringOutput `pulumi:"storageAccountName"`
// The name of the storage container in which this blob should be created.
StorageContainerName pulumi.StringOutput `pulumi:"storageContainerName"`
// The type of the storage blob to be created. Possible values are `Append`, `Block` or `Page`. Changing this forces a new resource to be created.
Type pulumi.StringOutput `pulumi:"type"`
// The URL of the blob
Url pulumi.StringOutput `pulumi:"url"`
}
// NewBlob registers a new resource with the given unique name, arguments, and options.
func NewBlob(ctx *pulumi.Context,
name string, args *BlobArgs, opts ...pulumi.ResourceOption) (*Blob, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.StorageAccountName == nil {
return nil, errors.New("invalid value for required argument 'StorageAccountName'")
}
if args.StorageContainerName == nil {
return nil, errors.New("invalid value for required argument 'StorageContainerName'")
}
if args.Type == nil {
return nil, errors.New("invalid value for required argument 'Type'")
}
var resource Blob
err := ctx.RegisterResource("azure:storage/blob:Blob", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetBlob gets an existing Blob resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetBlob(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *BlobState, opts ...pulumi.ResourceOption) (*Blob, error) {
var resource Blob
err := ctx.ReadResource("azure:storage/blob:Blob", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Blob resources.
type blobState struct {
// The access tier of the storage blob. Possible values are `Archive`, `Cool` and `Hot`.
AccessTier *string `pulumi:"accessTier"`
// Controls the [cache control header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) content of the response when blob is requested .
CacheControl *string `pulumi:"cacheControl"`
// The MD5 sum of the blob contents. Cannot be defined if `sourceUri` is defined, or if blob type is Append or Page. Changing this forces a new resource to be created.
ContentMd5 *string `pulumi:"contentMd5"`
// The content type of the storage blob. Cannot be defined if `sourceUri` is defined. Defaults to `application/octet-stream`.
ContentType *string `pulumi:"contentType"`
// A map of custom blob metadata.
Metadata map[string]string `pulumi:"metadata"`
// The name of the storage blob. Must be unique within the storage container the blob is located.
Name *string `pulumi:"name"`
// The number of workers per CPU core to run for concurrent uploads. Defaults to `8`.
Parallelism *int `pulumi:"parallelism"`
// Used only for `page` blobs to specify the size in bytes of the blob to be created. Must be a multiple of 512. Defaults to 0.
Size *int `pulumi:"size"`
// An absolute path to a file on the local system. This field cannot be specified for Append blobs and cannot be specified if `sourceContent` or `sourceUri` is specified.
Source pulumi.AssetOrArchive `pulumi:"source"`
// The content for this blob which should be defined inline. This field can only be specified for Block blobs and cannot be specified if `source` or `sourceUri` is specified.
SourceContent *string `pulumi:"sourceContent"`
// The URI of an existing blob, or a file in the Azure File service, to use as the source contents
// for the blob to be created. Changing this forces a new resource to be created. This field cannot be specified for Append blobs and cannot be specified if `source` or `sourceContent` is specified.
SourceUri *string `pulumi:"sourceUri"`
// Specifies the storage account in which to create the storage container.
// Changing this forces a new resource to be created.
StorageAccountName *string `pulumi:"storageAccountName"`
// The name of the storage container in which this blob should be created.
StorageContainerName *string `pulumi:"storageContainerName"`
// The type of the storage blob to be created. Possible values are `Append`, `Block` or `Page`. Changing this forces a new resource to be created.
Type *string `pulumi:"type"`
// The URL of the blob
Url *string `pulumi:"url"`
}
type BlobState struct {
// The access tier of the storage blob. Possible values are `Archive`, `Cool` and `Hot`.
AccessTier pulumi.StringPtrInput
// Controls the [cache control header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) content of the response when blob is requested .
CacheControl pulumi.StringPtrInput
// The MD5 sum of the blob contents. Cannot be defined if `sourceUri` is defined, or if blob type is Append or Page. Changing this forces a new resource to be created.
ContentMd5 pulumi.StringPtrInput
// The content type of the storage blob. Cannot be defined if `sourceUri` is defined. Defaults to `application/octet-stream`.
ContentType pulumi.StringPtrInput
// A map of custom blob metadata.
Metadata pulumi.StringMapInput
// The name of the storage blob. Must be unique within the storage container the blob is located.
Name pulumi.StringPtrInput
// The number of workers per CPU core to run for concurrent uploads. Defaults to `8`.
Parallelism pulumi.IntPtrInput
// Used only for `page` blobs to specify the size in bytes of the blob to be created. Must be a multiple of 512. Defaults to 0.
Size pulumi.IntPtrInput
// An absolute path to a file on the local system. This field cannot be specified for Append blobs and cannot be specified if `sourceContent` or `sourceUri` is specified.
Source pulumi.AssetOrArchiveInput
// The content for this blob which should be defined inline. This field can only be specified for Block blobs and cannot be specified if `source` or `sourceUri` is specified.
SourceContent pulumi.StringPtrInput
// The URI of an existing blob, or a file in the Azure File service, to use as the source contents
// for the blob to be created. Changing this forces a new resource to be created. This field cannot be specified for Append blobs and cannot be specified if `source` or `sourceContent` is specified.
SourceUri pulumi.StringPtrInput
// Specifies the storage account in which to create the storage container.
// Changing this forces a new resource to be created.
StorageAccountName pulumi.StringPtrInput
// The name of the storage container in which this blob should be created.
StorageContainerName pulumi.StringPtrInput
// The type of the storage blob to be created. Possible values are `Append`, `Block` or `Page`. Changing this forces a new resource to be created.
Type pulumi.StringPtrInput
// The URL of the blob
Url pulumi.StringPtrInput
}
func (BlobState) ElementType() reflect.Type {
return reflect.TypeOf((*blobState)(nil)).Elem()
}
type blobArgs struct {
// The access tier of the storage blob. Possible values are `Archive`, `Cool` and `Hot`.
AccessTier *string `pulumi:"accessTier"`
// Controls the [cache control header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) content of the response when blob is requested .
CacheControl *string `pulumi:"cacheControl"`
// The MD5 sum of the blob contents. Cannot be defined if `sourceUri` is defined, or if blob type is Append or Page. Changing this forces a new resource to be created.
ContentMd5 *string `pulumi:"contentMd5"`
// The content type of the storage blob. Cannot be defined if `sourceUri` is defined. Defaults to `application/octet-stream`.
ContentType *string `pulumi:"contentType"`
// A map of custom blob metadata.
Metadata map[string]string `pulumi:"metadata"`
// The name of the storage blob. Must be unique within the storage container the blob is located.
Name *string `pulumi:"name"`
// The number of workers per CPU core to run for concurrent uploads. Defaults to `8`.
Parallelism *int `pulumi:"parallelism"`
// Used only for `page` blobs to specify the size in bytes of the blob to be created. Must be a multiple of 512. Defaults to 0.
Size *int `pulumi:"size"`
// An absolute path to a file on the local system. This field cannot be specified for Append blobs and cannot be specified if `sourceContent` or `sourceUri` is specified.
Source pulumi.AssetOrArchive `pulumi:"source"`
// The content for this blob which should be defined inline. This field can only be specified for Block blobs and cannot be specified if `source` or `sourceUri` is specified.
SourceContent *string `pulumi:"sourceContent"`
// The URI of an existing blob, or a file in the Azure File service, to use as the source contents
// for the blob to be created. Changing this forces a new resource to be created. This field cannot be specified for Append blobs and cannot be specified if `source` or `sourceContent` is specified.
SourceUri *string `pulumi:"sourceUri"`
// Specifies the storage account in which to create the storage container.
// Changing this forces a new resource to be created.
StorageAccountName string `pulumi:"storageAccountName"`
// The name of the storage container in which this blob should be created.
StorageContainerName string `pulumi:"storageContainerName"`
// The type of the storage blob to be created. Possible values are `Append`, `Block` or `Page`. Changing this forces a new resource to be created.
Type string `pulumi:"type"`
}
// The set of arguments for constructing a Blob resource.
type BlobArgs struct {
// The access tier of the storage blob. Possible values are `Archive`, `Cool` and `Hot`.
AccessTier pulumi.StringPtrInput
// Controls the [cache control header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) content of the response when blob is requested .
CacheControl pulumi.StringPtrInput
// The MD5 sum of the blob contents. Cannot be defined if `sourceUri` is defined, or if blob type is Append or Page. Changing this forces a new resource to be created.
ContentMd5 pulumi.StringPtrInput
// The content type of the storage blob. Cannot be defined if `sourceUri` is defined. Defaults to `application/octet-stream`.
ContentType pulumi.StringPtrInput
// A map of custom blob metadata.
Metadata pulumi.StringMapInput
// The name of the storage blob. Must be unique within the storage container the blob is located.
Name pulumi.StringPtrInput
// The number of workers per CPU core to run for concurrent uploads. Defaults to `8`.
Parallelism pulumi.IntPtrInput
// Used only for `page` blobs to specify the size in bytes of the blob to be created. Must be a multiple of 512. Defaults to 0.
Size pulumi.IntPtrInput
// An absolute path to a file on the local system. This field cannot be specified for Append blobs and cannot be specified if `sourceContent` or `sourceUri` is specified.
Source pulumi.AssetOrArchiveInput
// The content for this blob which should be defined inline. This field can only be specified for Block blobs and cannot be specified if `source` or `sourceUri` is specified.
SourceContent pulumi.StringPtrInput
// The URI of an existing blob, or a file in the Azure File service, to use as the source contents
// for the blob to be created. Changing this forces a new resource to be created. This field cannot be specified for Append blobs and cannot be specified if `source` or `sourceContent` is specified.
SourceUri pulumi.StringPtrInput
// Specifies the storage account in which to create the storage container.
// Changing this forces a new resource to be created.
StorageAccountName pulumi.StringInput
// The name of the storage container in which this blob should be created.
StorageContainerName pulumi.StringInput
// The type of the storage blob to be created. Possible values are `Append`, `Block` or `Page`. Changing this forces a new resource to be created.
Type pulumi.StringInput
}
func (BlobArgs) ElementType() reflect.Type {
return reflect.TypeOf((*blobArgs)(nil)).Elem()
}
type BlobInput interface {
pulumi.Input
ToBlobOutput() BlobOutput
ToBlobOutputWithContext(ctx context.Context) BlobOutput
}
func (*Blob) ElementType() reflect.Type {
return reflect.TypeOf((**Blob)(nil)).Elem()
}
func (i *Blob) ToBlobOutput() BlobOutput {
return i.ToBlobOutputWithContext(context.Background())
}
func (i *Blob) ToBlobOutputWithContext(ctx context.Context) BlobOutput {
return pulumi.ToOutputWithContext(ctx, i).(BlobOutput)
}
// BlobArrayInput is an input type that accepts BlobArray and BlobArrayOutput values.
// You can construct a concrete instance of `BlobArrayInput` via:
//
// BlobArray{ BlobArgs{...} }
type BlobArrayInput interface {
pulumi.Input
ToBlobArrayOutput() BlobArrayOutput
ToBlobArrayOutputWithContext(context.Context) BlobArrayOutput
}
type BlobArray []BlobInput
func (BlobArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Blob)(nil)).Elem()
}
func (i BlobArray) ToBlobArrayOutput() BlobArrayOutput {
return i.ToBlobArrayOutputWithContext(context.Background())
}
func (i BlobArray) ToBlobArrayOutputWithContext(ctx context.Context) BlobArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(BlobArrayOutput)
}
// BlobMapInput is an input type that accepts BlobMap and BlobMapOutput values.
// You can construct a concrete instance of `BlobMapInput` via:
//
// BlobMap{ "key": BlobArgs{...} }
type BlobMapInput interface {
pulumi.Input
ToBlobMapOutput() BlobMapOutput
ToBlobMapOutputWithContext(context.Context) BlobMapOutput
}
type BlobMap map[string]BlobInput
func (BlobMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Blob)(nil)).Elem()
}
func (i BlobMap) ToBlobMapOutput() BlobMapOutput {
return i.ToBlobMapOutputWithContext(context.Background())
}
func (i BlobMap) ToBlobMapOutputWithContext(ctx context.Context) BlobMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(BlobMapOutput)
}
type BlobOutput struct{ *pulumi.OutputState }
func (BlobOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Blob)(nil)).Elem()
}
func (o BlobOutput) ToBlobOutput() BlobOutput {
return o
}
func (o BlobOutput) ToBlobOutputWithContext(ctx context.Context) BlobOutput {
return o
}
type BlobArrayOutput struct{ *pulumi.OutputState }
func (BlobArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Blob)(nil)).Elem()
}
func (o BlobArrayOutput) ToBlobArrayOutput() BlobArrayOutput {
return o
}
func (o BlobArrayOutput) ToBlobArrayOutputWithContext(ctx context.Context) BlobArrayOutput {
return o
}
func (o BlobArrayOutput) Index(i pulumi.IntInput) BlobOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Blob {
return vs[0].([]*Blob)[vs[1].(int)]
}).(BlobOutput)
}
type BlobMapOutput struct{ *pulumi.OutputState }
func (BlobMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Blob)(nil)).Elem()
}
func (o BlobMapOutput) ToBlobMapOutput() BlobMapOutput {
return o
}
func (o BlobMapOutput) ToBlobMapOutputWithContext(ctx context.Context) BlobMapOutput {
return o
}
func (o BlobMapOutput) MapIndex(k pulumi.StringInput) BlobOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Blob {
return vs[0].(map[string]*Blob)[vs[1].(string)]
}).(BlobOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*BlobInput)(nil)).Elem(), &Blob{})
pulumi.RegisterInputType(reflect.TypeOf((*BlobArrayInput)(nil)).Elem(), BlobArray{})
pulumi.RegisterInputType(reflect.TypeOf((*BlobMapInput)(nil)).Elem(), BlobMap{})
pulumi.RegisterOutputType(BlobOutput{})
pulumi.RegisterOutputType(BlobArrayOutput{})
pulumi.RegisterOutputType(BlobMapOutput{})
}