/
index.yml
2959 lines (2890 loc) · 147 KB
/
index.yml
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### YamlMime:UniversalReference
items:
- uid: cloud.google.com/go/storage
name: cloud.google.com/go/storage
id: storage
summary: "<p>\nPackage storage provides an easy way to work with Google Cloud Storage.\nGoogle
Cloud Storage stores data in named objects, which are grouped into buckets.\n</p>\n<p>\nMore
information about Google Cloud Storage is available at\n<a href=\"https://cloud.google.com/storage/docs\">https://cloud.google.com/storage/docs</a>.\n</p>\n<p>\nSee
<a href=\"https://godoc.org/cloud.google.com/go\">https://godoc.org/cloud.google.com/go</a>
for authentication, timeouts,\nconnection pooling and similar aspects of this
package.\n</p>\n<p>\nAll of the methods of this package use exponential backoff
to retry calls that fail\nwith certain errors, as described in\n<a href=\"https://cloud.google.com/storage/docs/exponential-backoff\">https://cloud.google.com/storage/docs/exponential-backoff</a>.
Retrying continues\nindefinitely unless the controlling context is canceled or
the client is closed. See\ncontext.WithTimeout and context.WithCancel.\n</p>\n<h3
id=\"hdr-Creating_a_Client\">Creating a Client</h3>\n<p>\nTo start working with
this package, create a client:\n</p>\n<pre>ctx := context.Background()\nclient,
err := storage.NewClient(ctx)\nif err != nil {\n // TODO: Handle error.\n}\n</pre>\n<p>\nThe
client will use your default application credentials. Clients should be\nreused
instead of created as needed. The methods of Client are safe for\nconcurrent use
by multiple goroutines.\n</p>\n<p>\nIf you only wish to access public data, you
can create\nan unauthenticated client with\n</p>\n<pre>client, err := storage.NewClient(ctx,
option.WithoutAuthentication())\n</pre>\n<h3 id=\"hdr-Buckets\">Buckets</h3>\n<p>\nA
Google Cloud Storage bucket is a collection of objects. To work with a\nbucket,
make a bucket handle:\n</p>\n<pre>bkt := client.Bucket(bucketName)\n</pre>\n<p>\nA
handle is a reference to a bucket. You can have a handle even if the\nbucket doesn't
exist yet. To create a bucket in Google Cloud Storage,\ncall Create on the handle:\n</p>\n<pre>if
err := bkt.Create(ctx, projectID, nil); err != nil {\n // TODO: Handle error.\n}\n</pre>\n<p>\nNote
that although buckets are associated with projects, bucket names are\nglobal across
all projects.\n</p>\n<p>\nEach bucket has associated metadata, represented in
this package by\nBucketAttrs. The third argument to BucketHandle.Create allows
you to set\nthe initial BucketAttrs of a bucket. To retrieve a bucket's attributes,
use\nAttrs:\n</p>\n<pre>attrs, err := bkt.Attrs(ctx)\nif err != nil {\n //
TODO: Handle error.\n}\nfmt.Printf("bucket %s, created at %s, is located in
%s with storage class %s\\n",\n attrs.Name, attrs.Created, attrs.Location,
attrs.StorageClass)\n</pre>\n<h3 id=\"hdr-Objects\">Objects</h3>\n<p>\nAn object
holds arbitrary data as a sequence of bytes, like a file. You\nrefer to objects
using a handle, just as with buckets, but unlike buckets\nyou don't explicitly
create an object. Instead, the first time you write\nto an object it will be created.
You can use the standard Go io.Reader\nand io.Writer interfaces to read and write
object data:\n</p>\n<pre>obj := bkt.Object("data")\n// Write something
to obj.\n// w implements io.Writer.\nw := obj.NewWriter(ctx)\n// Write some text
to obj. This will either create the object or overwrite whatever is there already.\nif
_, err := fmt.Fprintf(w, "This object contains text.\\n"); err != nil
{\n // TODO: Handle error.\n}\n// Close, just like writing a file.\nif err
:= w.Close(); err != nil {\n // TODO: Handle error.\n}\n\n// Read it back.\nr,
err := obj.NewReader(ctx)\nif err != nil {\n // TODO: Handle error.\n}\ndefer
r.Close()\nif _, err := io.Copy(os.Stdout, r); err != nil {\n // TODO: Handle
error.\n}\n// Prints "This object contains text."\n</pre>\n<p>\nObjects
also have attributes, which you can fetch with Attrs:\n</p>\n<pre>objAttrs, err
:= obj.Attrs(ctx)\nif err != nil {\n // TODO: Handle error.\n}\nfmt.Printf("object
%s has size %d and can be read using %s\\n",\n objAttrs.Name, objAttrs.Size,
objAttrs.MediaLink)\n</pre>\n<h3 id=\"hdr-Listing_objects\">Listing objects</h3>\n<p>\nListing
objects in a bucket is done with the Bucket.Objects method:\n</p>\n<pre>query
:= &storage.Query{Prefix: ""}\n\nvar names []string\nit := bkt.Objects(ctx,
query)\nfor {\n attrs, err := it.Next()\n if err == iterator.Done {\n break\n
\ }\n if err != nil {\n log.Fatal(err)\n }\n names = append(names,
attrs.Name)\n}\n</pre>\n<p>\nIf only a subset of object attributes is needed when
listing, specifying this\nsubset using Query.SetAttrSelection may speed up the
listing process:\n</p>\n<pre>query := &storage.Query{Prefix: ""}\nquery.SetAttrSelection([]string{"Name"})\n\n//
... as before\n</pre>\n<h3 id=\"hdr-ACLs\">ACLs</h3>\n<p>\nBoth objects and buckets
have ACLs (Access Control Lists). An ACL is a list of\nACLRules, each of which
specifies the role of a user, group or project. ACLs\nare suitable for fine-grained
control, but you may prefer using IAM to control\naccess at the project level
(see\n<a href=\"https://cloud.google.com/storage/docs/access-control/iam\">https://cloud.google.com/storage/docs/access-control/iam</a>).\n</p>\n<p>\nTo
list the ACLs of a bucket or object, obtain an ACLHandle and call its List method:\n</p>\n<pre>acls,
err := obj.ACL().List(ctx)\nif err != nil {\n // TODO: Handle error.\n}\nfor
_, rule := range acls {\n fmt.Printf("%s has role %s\\n", rule.Entity,
rule.Role)\n}\n</pre>\n<p>\nYou can also set and delete ACLs.\n</p>\n<h3 id=\"hdr-Conditions\">Conditions</h3>\n<p>\nEvery
object has a generation and a metageneration. The generation changes\nwhenever
the content changes, and the metageneration changes whenever the\nmetadata changes.
Conditions let you check these values before an operation;\nthe operation only
executes if the conditions match. You can use conditions to\nprevent race conditions
in read-modify-write operations.\n</p>\n<p>\nFor example, say you've read
an object's metadata into objAttrs. Now\nyou want to write to that object,
but only if its contents haven't changed\nsince you read it. Here is how to
express that:\n</p>\n<pre>w = obj.If(storage.Conditions{GenerationMatch: objAttrs.Generation}).NewWriter(ctx)\n//
Proceed with writing as above.\n</pre>\n<h3 id=\"hdr-Signed_URLs\">Signed URLs</h3>\n<p>\nYou
can obtain a URL that lets anyone read or write an object for a limited time.\nYou
don't need to create a client to do this. See the documentation of\nSignedURL
for details.\n</p>\n<pre>url, err := storage.SignedURL(bucketName, "shared-object",
opts)\nif err != nil {\n // TODO: Handle error.\n}\nfmt.Println(url)\n</pre>\n<h3
id=\"hdr-Post_Policy_V4_Signed_Request\">Post Policy V4 Signed Request</h3>\n<p>\nA
type of signed request that allows uploads through HTML forms directly to Cloud
Storage with\ntemporary permission. Conditions can be applied to restrict how
the HTML form is used and exercised\nby a user.\n</p>\n<p>\nFor more information,
please see <a href=\"https://cloud.google.com/storage/docs/xml-api/post-object\">https://cloud.google.com/storage/docs/xml-api/post-object</a>
as well\nas the documentation of GenerateSignedPostPolicyV4.\n</p>\n<pre>pv4,
err := storage.GenerateSignedPostPolicyV4(bucketName, objectName, opts)\nif err
!= nil {\n // TODO: Handle error.\n}\nfmt.Printf("URL: %s\\nFields; %v\\n",
pv4.URL, pv4.Fields)\n</pre>\n<h3 id=\"hdr-Errors\">Errors</h3>\n<p>\nErrors returned
by this client are often of the type [`googleapi.Error`](<a href=\"https://godoc.org/google.golang.org/api/googleapi#Error\">https://godoc.org/google.golang.org/api/googleapi#Error</a>).\nThese
errors can be introspected for more information by type asserting to the richer
`googleapi.Error` type. For example:\n</p>\n<pre>if e, ok := err.(*googleapi.Error);
ok {\n\t if e.Code == 409 { ... }\n}\n</pre>\n"
type: package
langs:
- go
children:
- cloud.google.com/go/storage.DeleteAction,SetStorageClassAction
- cloud.google.com/go/storage.NoPayload,JSONPayload
- cloud.google.com/go/storage.ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent
- cloud.google.com/go/storage.ScopeFullControl,ScopeReadOnly,ScopeReadWrite
- cloud.google.com/go/storage.ErrBucketNotExist,ErrObjectNotExist
- cloud.google.com/go/storage.ACLEntity
- cloud.google.com/go/storage.AllUsers,AllAuthenticatedUsers
- cloud.google.com/go/storage.ACLHandle
- cloud.google.com/go/storage.ACLHandle.Delete
- cloud.google.com/go/storage.ACLHandle.List
- cloud.google.com/go/storage.ACLHandle.Set
- cloud.google.com/go/storage.ACLRole
- cloud.google.com/go/storage.RoleOwner,RoleReader,RoleWriter
- cloud.google.com/go/storage.ACLRule
- cloud.google.com/go/storage.BucketAttrs
- cloud.google.com/go/storage.BucketAttrsToUpdate
- cloud.google.com/go/storage.BucketAttrsToUpdate.DeleteLabel
- cloud.google.com/go/storage.BucketAttrsToUpdate.SetLabel
- cloud.google.com/go/storage.BucketConditions
- cloud.google.com/go/storage.BucketEncryption
- cloud.google.com/go/storage.BucketHandle
- cloud.google.com/go/storage.BucketHandle.ACL
- cloud.google.com/go/storage.BucketHandle.AddNotification
- cloud.google.com/go/storage.BucketHandle.Attrs
- cloud.google.com/go/storage.BucketHandle.Create
- cloud.google.com/go/storage.BucketHandle.DefaultObjectACL
- cloud.google.com/go/storage.BucketHandle.Delete
- cloud.google.com/go/storage.BucketHandle.DeleteNotification
- cloud.google.com/go/storage.BucketHandle.IAM
- cloud.google.com/go/storage.BucketHandle.If
- cloud.google.com/go/storage.BucketHandle.LockRetentionPolicy
- cloud.google.com/go/storage.BucketHandle.Notifications
- cloud.google.com/go/storage.BucketHandle.Object
- cloud.google.com/go/storage.BucketHandle.Objects
- cloud.google.com/go/storage.BucketHandle.Update
- cloud.google.com/go/storage.BucketHandle.UserProject
- cloud.google.com/go/storage.BucketIterator
- cloud.google.com/go/storage.BucketIterator.Next
- cloud.google.com/go/storage.BucketIterator.PageInfo
- cloud.google.com/go/storage.BucketLogging
- cloud.google.com/go/storage.BucketPolicyOnly
- cloud.google.com/go/storage.BucketWebsite
- cloud.google.com/go/storage.CORS
- cloud.google.com/go/storage.Client
- cloud.google.com/go/storage.Client.NewClient
- cloud.google.com/go/storage.Client.Bucket
- cloud.google.com/go/storage.Client.Buckets
- cloud.google.com/go/storage.Client.Close
- cloud.google.com/go/storage.Client.CreateHMACKey
- cloud.google.com/go/storage.Client.HMACKeyHandle
- cloud.google.com/go/storage.Client.ListHMACKeys
- cloud.google.com/go/storage.Client.ServiceAccount
- cloud.google.com/go/storage.Composer
- cloud.google.com/go/storage.Composer.Run
- cloud.google.com/go/storage.Conditions
- cloud.google.com/go/storage.Copier
- cloud.google.com/go/storage.Copier.Run
- cloud.google.com/go/storage.HMACKey
- cloud.google.com/go/storage.HMACKeyAttrsToUpdate
- cloud.google.com/go/storage.HMACKeyHandle
- cloud.google.com/go/storage.HMACKeyHandle.Delete
- cloud.google.com/go/storage.HMACKeyHandle.Get
- cloud.google.com/go/storage.HMACKeyHandle.Update
- cloud.google.com/go/storage.HMACKeyOption
- cloud.google.com/go/storage.HMACKeyOption.ForHMACKeyServiceAccountEmail
- cloud.google.com/go/storage.HMACKeyOption.ShowDeletedHMACKeys
- cloud.google.com/go/storage.HMACKeyOption.UserProjectForHMACKeys
- cloud.google.com/go/storage.HMACKeysIterator
- cloud.google.com/go/storage.HMACKeysIterator.Next
- cloud.google.com/go/storage.HMACKeysIterator.PageInfo
- cloud.google.com/go/storage.HMACState
- cloud.google.com/go/storage.Active,Inactive,Deleted
- cloud.google.com/go/storage.Lifecycle
- cloud.google.com/go/storage.LifecycleAction
- cloud.google.com/go/storage.LifecycleCondition
- cloud.google.com/go/storage.LifecycleRule
- cloud.google.com/go/storage.Liveness
- cloud.google.com/go/storage.LiveAndArchived,Live,Archived
- cloud.google.com/go/storage.Notification
- cloud.google.com/go/storage.ObjectAttrs
- cloud.google.com/go/storage.ObjectAttrsToUpdate
- cloud.google.com/go/storage.ObjectHandle
- cloud.google.com/go/storage.ObjectHandle.ACL
- cloud.google.com/go/storage.ObjectHandle.Attrs
- cloud.google.com/go/storage.ObjectHandle.BucketName
- cloud.google.com/go/storage.ObjectHandle.ComposerFrom
- cloud.google.com/go/storage.ObjectHandle.CopierFrom
- cloud.google.com/go/storage.ObjectHandle.Delete
- cloud.google.com/go/storage.ObjectHandle.Generation
- cloud.google.com/go/storage.ObjectHandle.If
- cloud.google.com/go/storage.ObjectHandle.Key
- cloud.google.com/go/storage.ObjectHandle.NewRangeReader
- cloud.google.com/go/storage.ObjectHandle.NewReader
- cloud.google.com/go/storage.ObjectHandle.NewWriter
- cloud.google.com/go/storage.ObjectHandle.ObjectName
- cloud.google.com/go/storage.ObjectHandle.ReadCompressed
- cloud.google.com/go/storage.ObjectHandle.Update
- cloud.google.com/go/storage.ObjectIterator
- cloud.google.com/go/storage.ObjectIterator.Next
- cloud.google.com/go/storage.ObjectIterator.PageInfo
- cloud.google.com/go/storage.PolicyV4Fields
- cloud.google.com/go/storage.PostPolicyV4
- cloud.google.com/go/storage.PostPolicyV4.GenerateSignedPostPolicyV4
- cloud.google.com/go/storage.PostPolicyV4Condition
- cloud.google.com/go/storage.PostPolicyV4Condition.ConditionContentLengthRange
- cloud.google.com/go/storage.PostPolicyV4Condition.ConditionStartsWith
- cloud.google.com/go/storage.PostPolicyV4Options
- cloud.google.com/go/storage.ProjectTeam
- cloud.google.com/go/storage.Query
- cloud.google.com/go/storage.Query.SetAttrSelection
- cloud.google.com/go/storage.Reader
- cloud.google.com/go/storage.Reader.CacheControl
- cloud.google.com/go/storage.Reader.Close
- cloud.google.com/go/storage.Reader.ContentEncoding
- cloud.google.com/go/storage.Reader.ContentType
- cloud.google.com/go/storage.Reader.LastModified
- cloud.google.com/go/storage.Reader.Read
- cloud.google.com/go/storage.Reader.Remain
- cloud.google.com/go/storage.Reader.Size
- cloud.google.com/go/storage.ReaderObjectAttrs
- cloud.google.com/go/storage.RetentionPolicy
- cloud.google.com/go/storage.SignedURLOptions
- cloud.google.com/go/storage.SigningScheme
- cloud.google.com/go/storage.SigningSchemeDefault,SigningSchemeV2,SigningSchemeV4
- cloud.google.com/go/storage.URLStyle
- cloud.google.com/go/storage.URLStyle.BucketBoundHostname
- cloud.google.com/go/storage.URLStyle.PathStyle
- cloud.google.com/go/storage.URLStyle.VirtualHostedStyle
- cloud.google.com/go/storage.UniformBucketLevelAccess
- cloud.google.com/go/storage.Writer
- cloud.google.com/go/storage.Writer.Attrs
- cloud.google.com/go/storage.Writer.Close
- cloud.google.com/go/storage.Writer.CloseWithError
- cloud.google.com/go/storage.Writer.Write
- cloud.google.com/go/storage.SignedURL
alt_link: https://pkg.go.dev/cloud.google.com/go/storage
- uid: cloud.google.com/go/storage.DeleteAction,SetStorageClassAction
name: DeleteAction, SetStorageClassAction
id: DeleteAction,SetStorageClassAction
parent: cloud.google.com/go/storage
type: const
langs:
- go
syntax:
content: "const (\n\n\t// DeleteAction is a lifecycle action that deletes a live
and/or archived\n\t// objects. Takes precedence over SetStorageClass actions.\n\tDeleteAction
= \"Delete\"\n\n\t// SetStorageClassAction changes the storage class of live
and/or archived\n\t// objects.\n\tSetStorageClassAction = \"SetStorageClass\"\n)"
- uid: cloud.google.com/go/storage.NoPayload,JSONPayload
name: NoPayload, JSONPayload
id: NoPayload,JSONPayload
summary: |
Values for Notification.PayloadFormat.
parent: cloud.google.com/go/storage
type: const
langs:
- go
syntax:
content: "const (\n\t// Send no payload with notification messages.\n\tNoPayload
= \"NONE\"\n\n\t// Send object metadata as JSON with notification messages.\n\tJSONPayload
= \"JSON_API_V1\"\n)"
- uid: cloud.google.com/go/storage.ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent
name: ObjectFinalizeEvent, ObjectMetadataUpdateEvent, ObjectDeleteEvent, ObjectArchiveEvent
id: ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent
summary: |
Values for Notification.EventTypes.
parent: cloud.google.com/go/storage
type: const
langs:
- go
syntax:
content: "const (\n\t// Event that occurs when an object is successfully created.\n\tObjectFinalizeEvent
= \"OBJECT_FINALIZE\"\n\n\t// Event that occurs when the metadata of an existing
object changes.\n\tObjectMetadataUpdateEvent = \"OBJECT_METADATA_UPDATE\"\n\n\t//
Event that occurs when an object is permanently deleted.\n\tObjectDeleteEvent
= \"OBJECT_DELETE\"\n\n\t// Event that occurs when the live version of an object
becomes an\n\t// archived version.\n\tObjectArchiveEvent = \"OBJECT_ARCHIVE\"\n)"
- uid: cloud.google.com/go/storage.ScopeFullControl,ScopeReadOnly,ScopeReadWrite
name: ScopeFullControl, ScopeReadOnly, ScopeReadWrite
id: ScopeFullControl,ScopeReadOnly,ScopeReadWrite
parent: cloud.google.com/go/storage
type: const
langs:
- go
syntax:
content: "const (\n\t// ScopeFullControl grants permissions to manage your\n\t//
data and permissions in Google Cloud Storage.\n\tScopeFullControl = raw.DevstorageFullControlScope\n\n\t//
ScopeReadOnly grants permissions to\n\t// view your data in Google Cloud Storage.\n\tScopeReadOnly
= raw.DevstorageReadOnlyScope\n\n\t// ScopeReadWrite grants permissions to manage
your\n\t// data in Google Cloud Storage.\n\tScopeReadWrite = raw.DevstorageReadWriteScope\n)"
- uid: cloud.google.com/go/storage.ErrBucketNotExist,ErrObjectNotExist
name: ErrBucketNotExist, ErrObjectNotExist
id: ErrBucketNotExist,ErrObjectNotExist
parent: cloud.google.com/go/storage
type: variable
langs:
- go
syntax:
content: "var (\n\t// ErrBucketNotExist indicates that the bucket does not exist.\n\tErrBucketNotExist
= errors.New(\"storage: bucket doesn't exist\")\n\t// ErrObjectNotExist indicates
that the object does not exist.\n\tErrObjectNotExist = errors.New(\"storage:
object doesn't exist\")\n)"
- uid: cloud.google.com/go/storage.ACLEntity
name: ACLEntity
id: ACLEntity
summary: |
ACLEntity refers to a user or group.
They are sometimes referred to as grantees.
It could be in the form of:
"user-<userId>", "user-<email>", "group-<groupId>", "group-<email>",
"domain-<domain>" and "project-team-<projectId>".
Or one of the predefined constants: AllUsers, AllAuthenticatedUsers.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: type ACLEntity string
- uid: cloud.google.com/go/storage.AllUsers,AllAuthenticatedUsers
name: AllUsers, AllAuthenticatedUsers
id: AllUsers,AllAuthenticatedUsers
parent: cloud.google.com/go/storage.ACLEntity
type: const
langs:
- go
syntax:
content: "const (\n\tAllUsers ACLEntity = \"allUsers\"\n\tAllAuthenticatedUsers
ACLEntity = \"allAuthenticatedUsers\"\n)"
- uid: cloud.google.com/go/storage.ACLHandle
name: ACLHandle
id: ACLHandle
summary: |
ACLHandle provides operations on an access control list for a Google Cloud Storage bucket or object.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type ACLHandle struct {\n\t// contains filtered or unexported fields\n}"
- uid: cloud.google.com/go/storage.ACLHandle.Delete
name: |
func (*ACLHandle) Delete
id: Delete
summary: |
Delete permanently deletes the ACL entry for the given entity.
parent: cloud.google.com/go/storage.ACLHandle
type: method
langs:
- go
syntax:
content: func (a *ACLHandle) Delete(ctx context.Context, entity ACLEntity) (err
error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// No longer grant access to
the bucket to everyone on the Internet.\n\tif err := client.Bucket(\"my-bucket\").ACL().Delete(ctx,
storage.AllUsers); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n"
- uid: cloud.google.com/go/storage.ACLHandle.List
name: |
func (*ACLHandle) List
id: List
summary: |
List retrieves ACL entries.
parent: cloud.google.com/go/storage.ACLHandle
type: method
langs:
- go
syntax:
content: func (a *ACLHandle) List(ctx context.Context) (rules []ACLRule, err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// List the default object
ACLs for my-bucket.\n\taclRules, err := client.Bucket(\"my-bucket\").DefaultObjectACL().List(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(aclRules)\n}\n"
- uid: cloud.google.com/go/storage.ACLHandle.Set
name: |
func (*ACLHandle) Set
id: Set
summary: |
Set sets the role for the given entity.
parent: cloud.google.com/go/storage.ACLHandle
type: method
langs:
- go
syntax:
content: func (a *ACLHandle) Set(ctx context.Context, entity ACLEntity, role ACLRole)
(err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Let any authenticated user
read my-bucket/my-object.\n\tobj := client.Bucket(\"my-bucket\").Object(\"my-object\")\n\tif
err := obj.ACL().Set(ctx, storage.AllAuthenticatedUsers, storage.RoleReader);
err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n"
- uid: cloud.google.com/go/storage.ACLRole
name: ACLRole
id: ACLRole
summary: |
ACLRole is the level of access to grant.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: type ACLRole string
- uid: cloud.google.com/go/storage.RoleOwner,RoleReader,RoleWriter
name: RoleOwner, RoleReader, RoleWriter
id: RoleOwner,RoleReader,RoleWriter
parent: cloud.google.com/go/storage.ACLRole
type: const
langs:
- go
syntax:
content: "const (\n\tRoleOwner ACLRole = \"OWNER\"\n\tRoleReader ACLRole = \"READER\"\n\tRoleWriter
ACLRole = \"WRITER\"\n)"
- uid: cloud.google.com/go/storage.ACLRule
name: ACLRule
id: ACLRule
summary: |
ACLRule represents a grant for a role to an entity (user, group or team) for a
Google Cloud Storage object or bucket.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type ACLRule struct {\n\tEntity ACLEntity\n\tEntityID string\n\tRole
\ ACLRole\n\tDomain string\n\tEmail string\n\tProjectTeam *ProjectTeam\n}"
- uid: cloud.google.com/go/storage.BucketAttrs
name: BucketAttrs
id: BucketAttrs
summary: |
BucketAttrs represents the metadata for a Google Cloud Storage bucket.
Read-only fields are ignored by BucketHandle.Create.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketAttrs struct {\n\t// Name is the name of the bucket.\n\t//
This field is read-only.\n\tName string\n\n\t// ACL is the list of access control
rules on the bucket.\n\tACL []ACLRule\n\n\t// BucketPolicyOnly is an alias for
UniformBucketLevelAccess. Use of\n\t// UniformBucketLevelAccess is recommended
above the use of this field.\n\t// Setting BucketPolicyOnly.Enabled OR UniformBucketLevelAccess.Enabled
to\n\t// true, will enable UniformBucketLevelAccess.\n\tBucketPolicyOnly BucketPolicyOnly\n\n\t//
UniformBucketLevelAccess configures access checks to use only bucket-level IAM\n\t//
policies and ignore any ACL rules for the bucket.\n\t// See https://cloud.google.com/storage/docs/uniform-bucket-level-access\n\t//
for more information.\n\tUniformBucketLevelAccess UniformBucketLevelAccess\n\n\t//
DefaultObjectACL is the list of access controls to\n\t// apply to new objects
when no object ACL is provided.\n\tDefaultObjectACL []ACLRule\n\n\t// DefaultEventBasedHold
is the default value for event-based hold on\n\t// newly created objects in
this bucket. It defaults to false.\n\tDefaultEventBasedHold bool\n\n\t// If
not empty, applies a predefined set of access controls. It should be set\n\t//
only when creating a bucket.\n\t// It is always empty for BucketAttrs returned
from the service.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/insert\n\t//
for valid values.\n\tPredefinedACL string\n\n\t// If not empty, applies a predefined
set of default object access controls.\n\t// It should be set only when creating
a bucket.\n\t// It is always empty for BucketAttrs returned from the service.\n\t//
See https://cloud.google.com/storage/docs/json_api/v1/buckets/insert\n\t// for
valid values.\n\tPredefinedDefaultObjectACL string\n\n\t// Location is the location
of the bucket. It defaults to \"US\".\n\tLocation string\n\n\t// MetaGeneration
is the metadata generation of the bucket.\n\t// This field is read-only.\n\tMetaGeneration
int64\n\n\t// StorageClass is the default storage class of the bucket. This
defines\n\t// how objects in the bucket are stored and determines the SLA\n\t//
and the cost of storage. Typical values are \"STANDARD\", \"NEARLINE\",\n\t//
\"COLDLINE\" and \"ARCHIVE\". Defaults to \"STANDARD\".\n\t// See https://cloud.google.com/storage/docs/storage-classes
for all\n\t// valid values.\n\tStorageClass string\n\n\t// Created is the creation
time of the bucket.\n\t// This field is read-only.\n\tCreated time.Time\n\n\t//
VersioningEnabled reports whether this bucket has versioning enabled.\n\tVersioningEnabled
bool\n\n\t// Labels are the bucket's labels.\n\tLabels map[string]string\n\n\t//
RequesterPays reports whether the bucket is a Requester Pays bucket.\n\t// Clients
performing operations on Requester Pays buckets must provide\n\t// a user project
(see BucketHandle.UserProject), which will be billed\n\t// for the operations.\n\tRequesterPays
bool\n\n\t// Lifecycle is the lifecycle configuration for objects in the bucket.\n\tLifecycle
Lifecycle\n\n\t// Retention policy enforces a minimum retention time for all
objects\n\t// contained in the bucket. A RetentionPolicy of nil implies the
bucket\n\t// has no minimum data retention.\n\t//\n\t// This feature is in private
alpha release. It is not currently available to\n\t// most customers. It might
be changed in backwards-incompatible ways and is not\n\t// subject to any SLA
or deprecation policy.\n\tRetentionPolicy *RetentionPolicy\n\n\t// The bucket's
Cross-Origin Resource Sharing (CORS) configuration.\n\tCORS []CORS\n\n\t// The
encryption configuration used by default for newly inserted objects.\n\tEncryption
*BucketEncryption\n\n\t// The logging configuration.\n\tLogging *BucketLogging\n\n\t//
The website configuration.\n\tWebsite *BucketWebsite\n\n\t// Etag is the HTTP/1.1
Entity tag for the bucket.\n\t// This field is read-only.\n\tEtag string\n\n\t//
LocationType describes how data is stored and replicated.\n\t// Typical values
are \"multi-region\", \"region\" and \"dual-region\".\n\t// This field is read-only.\n\tLocationType
string\n}"
- uid: cloud.google.com/go/storage.BucketAttrsToUpdate
name: BucketAttrsToUpdate
id: BucketAttrsToUpdate
summary: |
BucketAttrsToUpdate define the attributes to update during an Update call.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketAttrsToUpdate struct {\n\t// If set, updates whether the
bucket uses versioning.\n\tVersioningEnabled optional.Bool\n\n\t// If set, updates
whether the bucket is a Requester Pays bucket.\n\tRequesterPays optional.Bool\n\n\t//
DefaultEventBasedHold is the default value for event-based hold on\n\t// newly
created objects in this bucket.\n\tDefaultEventBasedHold optional.Bool\n\n\t//
BucketPolicyOnly is an alias for UniformBucketLevelAccess. Use of\n\t// UniformBucketLevelAccess
is recommended above the use of this field.\n\t// Setting BucketPolicyOnly.Enabled
OR UniformBucketLevelAccess.Enabled to\n\t// true, will enable UniformBucketLevelAccess.
If both BucketPolicyOnly and\n\t// UniformBucketLevelAccess are set, the value
of UniformBucketLevelAccess\n\t// will take precedence.\n\tBucketPolicyOnly
*BucketPolicyOnly\n\n\t// UniformBucketLevelAccess configures access checks
to use only bucket-level IAM\n\t// policies and ignore any ACL rules for the
bucket.\n\t// See https://cloud.google.com/storage/docs/uniform-bucket-level-access\n\t//
for more information.\n\tUniformBucketLevelAccess *UniformBucketLevelAccess\n\n\t//
If set, updates the retention policy of the bucket. Using\n\t// RetentionPolicy.RetentionPeriod
= 0 will delete the existing policy.\n\t//\n\t// This feature is in private
alpha release. It is not currently available to\n\t// most customers. It might
be changed in backwards-incompatible ways and is not\n\t// subject to any SLA
or deprecation policy.\n\tRetentionPolicy *RetentionPolicy\n\n\t// If set, replaces
the CORS configuration with a new configuration.\n\t// An empty (rather than
nil) slice causes all CORS policies to be removed.\n\tCORS []CORS\n\n\t// If
set, replaces the encryption configuration of the bucket. Using\n\t// BucketEncryption.DefaultKMSKeyName
= \"\" will delete the existing\n\t// configuration.\n\tEncryption *BucketEncryption\n\n\t//
If set, replaces the lifecycle configuration of the bucket.\n\tLifecycle *Lifecycle\n\n\t//
If set, replaces the logging configuration of the bucket.\n\tLogging *BucketLogging\n\n\t//
If set, replaces the website configuration of the bucket.\n\tWebsite *BucketWebsite\n\n\t//
If not empty, applies a predefined set of access controls.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/patch.\n\tPredefinedACL
string\n\n\t// If not empty, applies a predefined set of default object access
controls.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/patch.\n\tPredefinedDefaultObjectACL
string\n\t// contains filtered or unexported fields\n}"
- uid: cloud.google.com/go/storage.BucketAttrsToUpdate.DeleteLabel
name: |
func (*BucketAttrsToUpdate) DeleteLabel
id: DeleteLabel
summary: |
DeleteLabel causes a label to be deleted when ua is used in a
call to Bucket.Update.
parent: cloud.google.com/go/storage.BucketAttrsToUpdate
type: method
langs:
- go
syntax:
content: func (ua *BucketAttrsToUpdate) DeleteLabel(name string)
- uid: cloud.google.com/go/storage.BucketAttrsToUpdate.SetLabel
name: |
func (*BucketAttrsToUpdate) SetLabel
id: SetLabel
summary: |
SetLabel causes a label to be added or modified when ua is used
in a call to Bucket.Update.
parent: cloud.google.com/go/storage.BucketAttrsToUpdate
type: method
langs:
- go
syntax:
content: func (ua *BucketAttrsToUpdate) SetLabel(name, value string)
- uid: cloud.google.com/go/storage.BucketConditions
name: BucketConditions
id: BucketConditions
summary: |
BucketConditions constrain bucket methods to act on specific metagenerations.
The zero value is an empty set of constraints.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketConditions struct {\n\t// MetagenerationMatch specifies that
the bucket must have the given\n\t// metageneration for the operation to occur.\n\t//
If MetagenerationMatch is zero, it has no effect.\n\tMetagenerationMatch int64\n\n\t//
MetagenerationNotMatch specifies that the bucket must not have the given\n\t//
metageneration for the operation to occur.\n\t// If MetagenerationNotMatch is
zero, it has no effect.\n\tMetagenerationNotMatch int64\n}"
- uid: cloud.google.com/go/storage.BucketEncryption
name: BucketEncryption
id: BucketEncryption
summary: |
BucketEncryption is a bucket's encryption configuration.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketEncryption struct {\n\t// A Cloud KMS key name, in the form\n\t//
projects/P/locations/L/keyRings/R/cryptoKeys/K, that will be used to encrypt\n\t//
objects inserted into this bucket, if no encryption method is specified.\n\t//
The key's location must be the same as the bucket's.\n\tDefaultKMSKeyName string\n}"
- uid: cloud.google.com/go/storage.BucketHandle
name: BucketHandle
id: BucketHandle
summary: |
BucketHandle provides operations on a Google Cloud Storage bucket.
Use Client.Bucket to get a handle.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketHandle struct {\n\t// contains filtered or unexported fields\n}"
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\tattrs, err := client.Bucket(\"my-bucket\").Attrs(ctx)\n\tif
err == storage.ErrBucketNotExist {\n\t\tfmt.Println(\"The bucket does not exist\")\n\t\treturn\n\t}\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Printf(\"The bucket exists
and has attributes: %#v\\n\", attrs)\n}\n"
name: exists
- uid: cloud.google.com/go/storage.BucketHandle.ACL
name: |
func (*BucketHandle) ACL
id: ACL
summary: |
ACL returns an ACLHandle, which provides access to the bucket's access control list.
This controls who can list, create or overwrite the objects in a bucket.
This call does not perform any network operations.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) ACL() *ACLHandle
- uid: cloud.google.com/go/storage.BucketHandle.AddNotification
name: |
func (*BucketHandle) AddNotification
id: AddNotification
summary: |
AddNotification adds a notification to b. You must set n's TopicProjectID, TopicID
and PayloadFormat, and must not set its ID. The other fields are all optional. The
returned Notification's ID can be used to refer to it.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) AddNotification(ctx context.Context, n *Notification)
(ret *Notification, err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\tn,
err := b.AddNotification(ctx, &storage.Notification{\n\t\tTopicProjectID: \"my-project\",\n\t\tTopicID:
\ \"my-topic\",\n\t\tPayloadFormat: storage.JSONPayload,\n\t})\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(n.ID)\n}\n"
- uid: cloud.google.com/go/storage.BucketHandle.Attrs
name: |
func (*BucketHandle) Attrs
id: Attrs
summary: |
Attrs returns the metadata for the bucket.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) Attrs(ctx context.Context) (attrs *BucketAttrs,
err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tattrs, err := client.Bucket(\"my-bucket\").Attrs(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(attrs)\n}\n"
- uid: cloud.google.com/go/storage.BucketHandle.Create
name: |
func (*BucketHandle) Create
id: Create
summary: |
Create creates the Bucket in the project.
If attrs is nil the API defaults will be used.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) Create(ctx context.Context, projectID string,
attrs *BucketAttrs) (err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tif err := client.Bucket(\"my-bucket\").Create(ctx,
\"my-project\", nil); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n"
- uid: cloud.google.com/go/storage.BucketHandle.DefaultObjectACL
name: |
func (*BucketHandle) DefaultObjectACL
id: DefaultObjectACL
summary: |
DefaultObjectACL returns an ACLHandle, which provides access to the bucket's default object ACLs.
These ACLs are applied to newly created objects in this bucket that do not have a defined ACL.
This call does not perform any network operations.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) DefaultObjectACL() *ACLHandle
- uid: cloud.google.com/go/storage.BucketHandle.Delete
name: |
func (*BucketHandle) Delete
id: Delete
summary: |
Delete deletes the Bucket.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) Delete(ctx context.Context) (err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tif err := client.Bucket(\"my-bucket\").Delete(ctx);
err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n"
- uid: cloud.google.com/go/storage.BucketHandle.DeleteNotification
name: |
func (*BucketHandle) DeleteNotification
id: DeleteNotification
summary: |
DeleteNotification deletes the notification with the given ID.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) DeleteNotification(ctx context.Context, id string)
(err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nvar
notificationID string\n\nfunc main() {\n\tctx := context.Background()\n\tclient,
err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb
:= client.Bucket(\"my-bucket\")\n\t// TODO: Obtain notificationID from BucketHandle.AddNotification\n\t//
or BucketHandle.Notifications.\n\terr = b.DeleteNotification(ctx, notificationID)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n"
- uid: cloud.google.com/go/storage.BucketHandle.IAM
name: |
func (*BucketHandle) IAM
id: IAM
summary: |
IAM provides access to IAM access control for the bucket.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) IAM() *iam.Handle
- uid: cloud.google.com/go/storage.BucketHandle.If
name: |
func (*BucketHandle) If
id: If
summary: |
If returns a new BucketHandle that applies a set of preconditions.
Preconditions already set on the BucketHandle are ignored.
Operations on the new handle will return an error if the preconditions are not
satisfied. The only valid preconditions for buckets are MetagenerationMatch
and MetagenerationNotMatch.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) If(conds BucketConditions) *BucketHandle
- uid: cloud.google.com/go/storage.BucketHandle.LockRetentionPolicy
name: |
func (*BucketHandle) LockRetentionPolicy
id: LockRetentionPolicy
summary: |
LockRetentionPolicy locks a bucket's retention policy until a previously-configured
RetentionPeriod past the EffectiveTime. Note that if RetentionPeriod is set to less
than a day, the retention policy is treated as a development configuration and locking
will have no effect. The BucketHandle must have a metageneration condition that
matches the bucket's metageneration. See BucketHandle.If.
This feature is in private alpha release. It is not currently available to
most customers. It might be changed in backwards-incompatible ways and is not
subject to any SLA or deprecation policy.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) LockRetentionPolicy(ctx context.Context) error
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\tattrs,
err := b.Attrs(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t//
Note that locking the bucket without first attaching a RetentionPolicy\n\t//
that's at least 1 day is a no-op\n\terr = b.If(storage.BucketConditions{MetagenerationMatch:
attrs.MetaGeneration}).LockRetentionPolicy(ctx)\n\tif err != nil {\n\t\t// TODO:
handle err\n\t}\n}\n"
- uid: cloud.google.com/go/storage.BucketHandle.Notifications
name: |
func (*BucketHandle) Notifications
id: Notifications
summary: |
Notifications returns all the Notifications configured for this bucket, as a map
indexed by notification ID.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) Notifications(ctx context.Context) (n map[string]*Notification,
err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\tns,
err := b.Notifications(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfor
id, n := range ns {\n\t\tfmt.Printf(\"%s: %+v\\n\", id, n)\n\t}\n}\n"
- uid: cloud.google.com/go/storage.BucketHandle.Object
name: |
func (*BucketHandle) Object
id: Object
summary: |
Object returns an ObjectHandle, which provides operations on the named object.
This call does not perform any network operations.
name must consist entirely of valid UTF-8-encoded runes. The full specification
for valid object names can be found at:
https://cloud.google.com/storage/docs/bucket-naming
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) Object(name string) *ObjectHandle
- uid: cloud.google.com/go/storage.BucketHandle.Objects
name: |
func (*BucketHandle) Objects
id: Objects
summary: |
Objects returns an iterator over the objects in the bucket that match the Query q.
If q is nil, no filtering is done.
Note: The returned iterator is not safe for concurrent operations without explicit synchronization.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) Objects(ctx context.Context, q *Query) *ObjectIterator
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tit := client.Bucket(\"my-bucket\").Objects(ctx,
nil)\n\t_ = it // TODO: iterate using Next or iterator.Pager.\n}\n"
- uid: cloud.google.com/go/storage.BucketHandle.Update
name: |
func (*BucketHandle) Update
id: Update
summary: |
Update updates a bucket's attributes.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) Update(ctx context.Context, uattrs BucketAttrsToUpdate)
(attrs *BucketAttrs, err error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Enable versioning in the
bucket, regardless of its previous value.\n\tattrs, err := client.Bucket(\"my-bucket\").Update(ctx,\n\t\tstorage.BucketAttrsToUpdate{VersioningEnabled:
true})\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(attrs)\n}\n"
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\tattrs,
err := b.Attrs(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tvar
au storage.BucketAttrsToUpdate\n\tau.SetLabel(\"lab\", attrs.Labels[\"lab\"]+\"-more\")\n\tif
attrs.Labels[\"delete-me\"] == \"yes\" {\n\t\tau.DeleteLabel(\"delete-me\")\n\t}\n\tattrs,
err = b.\n\t\tIf(storage.BucketConditions{MetagenerationMatch: attrs.MetaGeneration}).\n\t\tUpdate(ctx,
au)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(attrs)\n}\n"
name: readModifyWrite
- uid: cloud.google.com/go/storage.BucketHandle.UserProject
name: |
func (*BucketHandle) UserProject
id: UserProject
summary: |
UserProject returns a new BucketHandle that passes the project ID as the user
project for all subsequent calls. Calls with a user project will be billed to that
project rather than to the bucket's owning project.
A user project is required for all operations on Requester Pays buckets.
parent: cloud.google.com/go/storage.BucketHandle
type: method
langs:
- go
syntax:
content: func (b *BucketHandle) UserProject(projectID string) *BucketHandle
- uid: cloud.google.com/go/storage.BucketIterator
name: BucketIterator
id: BucketIterator
summary: |
A BucketIterator is an iterator over BucketAttrs.
Note: This iterator is not safe for concurrent operations without explicit synchronization.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketIterator struct {\n\t// Prefix restricts the iterator to
buckets whose names begin with it.\n\tPrefix string\n\t// contains filtered
or unexported fields\n}"
- uid: cloud.google.com/go/storage.BucketIterator.Next
name: |
func (*BucketIterator) Next
id: Next
summary: |
Next returns the next result. Its second return value is iterator.Done if
there are no more results. Once Next returns iterator.Done, all subsequent
calls will return iterator.Done.
Note: This method is not safe for concurrent operations without explicit synchronization.
parent: cloud.google.com/go/storage.BucketIterator
type: method
langs:
- go
syntax:
content: func (it *BucketIterator) Next() (*BucketAttrs, error)
codeexamples:
- content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc
main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif
err != nil {\n\t\t// TODO: handle error.\n\t}\n\tit := client.Buckets(ctx, \"my-project\")\n\tfor
{\n\t\tbucketAttrs, err := it.Next()\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif
err != nil {\n\t\t\t// TODO: Handle error.\n\t\t}\n\t\tfmt.Println(bucketAttrs)\n\t}\n}\n"
- uid: cloud.google.com/go/storage.BucketIterator.PageInfo
name: |
func (*BucketIterator) PageInfo
id: PageInfo
summary: |
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
Note: This method is not safe for concurrent operations without explicit synchronization.
parent: cloud.google.com/go/storage.BucketIterator
type: method
langs:
- go
syntax:
content: func (it *BucketIterator) PageInfo() *iterator.PageInfo
- uid: cloud.google.com/go/storage.BucketLogging
name: BucketLogging
id: BucketLogging
summary: |
BucketLogging holds the bucket's logging configuration, which defines the
destination bucket and optional name prefix for the current bucket's
logs.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketLogging struct {\n\t// The destination bucket where the current
bucket's logs\n\t// should be placed.\n\tLogBucket string\n\n\t// A prefix for
log object names.\n\tLogObjectPrefix string\n}"
- uid: cloud.google.com/go/storage.BucketPolicyOnly
name: BucketPolicyOnly
id: BucketPolicyOnly
summary: |
BucketPolicyOnly is an alias for UniformBucketLevelAccess.
Use of UniformBucketLevelAccess is preferred above BucketPolicyOnly.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketPolicyOnly struct {\n\t// Enabled specifies whether access
checks use only bucket-level IAM\n\t// policies. Enabled may be disabled until
the locked time.\n\tEnabled bool\n\t// LockedTime specifies the deadline for
changing Enabled from true to\n\t// false.\n\tLockedTime time.Time\n}"
- uid: cloud.google.com/go/storage.BucketWebsite
name: BucketWebsite
id: BucketWebsite
summary: |
BucketWebsite holds the bucket's website configuration, controlling how the
service behaves when accessing bucket contents as a web site. See
https://cloud.google.com/storage/docs/static-website for more information.
parent: cloud.google.com/go/storage
type: type
langs:
- go
syntax:
content: "type BucketWebsite struct {\n\t// If the requested object path is missing,
the service will ensure the path has\n\t// a trailing '/', append this suffix,
and attempt to retrieve the resulting\n\t// object. This allows the creation
of index.html objects to represent directory\n\t// pages.\n\tMainPageSuffix
string\n\n\t// If the requested object path is missing, and any mainPageSuffix
object is\n\t// missing, if applicable, the service will return the named object
from this\n\t// bucket as the content for a 404 Not Found result.\n\tNotFoundPage
string\n}"
- uid: cloud.google.com/go/storage.CORS
name: CORS
id: CORS
summary: |
CORS is the bucket's Cross-Origin Resource Sharing (CORS) configuration.
parent: cloud.google.com/go/storage
type: type
langs:
- go