diff --git a/storage/bucket.go b/storage/bucket.go index 602c8512856..f2a59f3b3d1 100644 --- a/storage/bucket.go +++ b/storage/bucket.go @@ -337,6 +337,10 @@ type BucketAttrs struct { // Typical values are "multi-region", "region" and "dual-region". // This field is read-only. LocationType string + + // The project number of the project the bucket belongs to. + // This field is read-only. + ProjectNumber uint64 } // BucketPolicyOnly is an alias for UniformBucketLevelAccess. @@ -597,6 +601,7 @@ func newBucket(b *raw.Bucket) (*BucketAttrs, error) { PublicAccessPrevention: toPublicAccessPrevention(b.IamConfiguration), Etag: b.Etag, LocationType: b.LocationType, + ProjectNumber: b.ProjectNumber, }, nil } diff --git a/storage/bucket_test.go b/storage/bucket_test.go index 4ff5f5cc5ed..3919853e731 100644 --- a/storage/bucket_test.go +++ b/storage/bucket_test.go @@ -642,10 +642,11 @@ func TestNewBucket(t *testing.T) { Acl: []*raw.BucketAccessControl{ {Bucket: "name", Role: "READER", Email: "joe@example.com", Entity: "allUsers"}, }, - LocationType: "dual-region", - Encryption: &raw.BucketEncryption{DefaultKmsKeyName: "key"}, - Logging: &raw.BucketLogging{LogBucket: "lb", LogObjectPrefix: "p"}, - Website: &raw.BucketWebsite{MainPageSuffix: "mps", NotFoundPage: "404"}, + LocationType: "dual-region", + Encryption: &raw.BucketEncryption{DefaultKmsKeyName: "key"}, + Logging: &raw.BucketLogging{LogBucket: "lb", LogObjectPrefix: "p"}, + Website: &raw.BucketWebsite{MainPageSuffix: "mps", NotFoundPage: "404"}, + ProjectNumber: 123231313, } want := &BucketAttrs{ Name: "name", @@ -695,6 +696,7 @@ func TestNewBucket(t *testing.T) { ACL: []ACLRule{{Entity: "allUsers", Role: RoleReader, Email: "joe@example.com"}}, DefaultObjectACL: nil, LocationType: "dual-region", + ProjectNumber: 123231313, } got, err := newBucket(rb) if err != nil { diff --git a/storage/integration_test.go b/storage/integration_test.go index f90f15322e3..e608034fb10 100644 --- a/storage/integration_test.go +++ b/storage/integration_test.go @@ -265,6 +265,9 @@ func TestIntegration_BucketMethods(t *testing.T) { if attrs.LocationType == "" { t.Error("got an empty LocationType") } + if attrs.ProjectNumber == 0 { + t.Errorf("got a zero ProjectNumber") + } h.mustDeleteBucket(b) // Test Create and Delete with attributes. @@ -331,6 +334,9 @@ func TestIntegration_BucketMethods(t *testing.T) { if attrs.LocationType == "" { t.Error("got an empty LocationType") } + if attrs.ProjectNumber == 0 { + t.Errorf("got a zero ProjectNumber") + } h.mustDeleteBucket(b) }