Skip to content

Commit d0d1bdb

Browse files
parrneetjotruon
authored andcommitted
Add ocid to object storage bucket
1 parent d5e204c commit d0d1bdb

7 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
## 3.55.0 (Unreleased)
22

33
### Added
4-
- Support Etag for ListObjects
4+
- Support Etag in `oci_objectstorage_objects` resource
55
- Support for Network Security Groups in `oci_file_storage_mount_target` resource
66
- Support for multi-attach for block storage
77
- Support for cache control and control-disposition headers in `oci_objectstorage_object`
8+
- Support for OCID in Bucket Resource
89

910
## 3.54.0 (November 27, 2019)
1011

oci/objectstorage_bucket_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ func (s *ObjectStorageBucketDataSourceCrud) SetData() error {
101101

102102
s.D.Set("freeform_tags", s.Res.FreeformTags)
103103

104+
if s.Res.Id != nil {
105+
s.D.Set("bucket_id", *s.Res.Id)
106+
}
107+
104108
if s.Res.KmsKeyId != nil {
105109
s.D.Set("kms_key_id", *s.Res.KmsKeyId)
106110
}

oci/objectstorage_bucket_resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ func ObjectStorageBucketResource() *schema.Resource {
9393
Type: schema.TypeString,
9494
Computed: true,
9595
},
96+
"bucket_id": {
97+
Type: schema.TypeString,
98+
Computed: true,
99+
},
96100
"created_by": {
97101
Type: schema.TypeString,
98102
Computed: true,
@@ -342,6 +346,8 @@ func (s *ObjectStorageBucketResourceCrud) Delete() error {
342346

343347
func (s *ObjectStorageBucketResourceCrud) SetData() error {
344348

349+
s.D.Set("bucket_id", *s.Res.Id)
350+
345351
bucket, namespace, err := parseBucketCompositeId(s.D.Id())
346352
if err == nil {
347353
s.D.Set("bucket", &bucket)

oci/objectstorage_bucket_summaries_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func ObjectStorageBucketsDataSource() *schema.Resource {
2525
"bucket_summaries": {
2626
Type: schema.TypeList,
2727
Computed: true,
28-
Elem: ObjectStorageBucketResource(),
28+
Elem: GetDataSourceItemSchema(ObjectStorageBucketResource()),
2929
},
3030
},
3131
}

oci/objectstorage_bucket_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
9191
Config: config + compartmentIdVariableStr + BucketResourceDependencies +
9292
generateResourceFromRepresentationMap("oci_objectstorage_bucket", "test_bucket", Required, Create, bucketRepresentation),
9393
Check: resource.ComposeAggregateTestCheckFunc(
94+
resource.TestCheckResourceAttrSet(resourceName, "bucket_id"),
9495
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
9596
resource.TestCheckResourceAttr(resourceName, "name", testBucketName),
9697
resource.TestCheckResourceAttrSet(resourceName, "namespace"),
@@ -112,6 +113,7 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
112113
generateResourceFromRepresentationMap("oci_objectstorage_bucket", "test_bucket", Optional, Create, bucketRepresentation),
113114
Check: resource.ComposeAggregateTestCheckFunc(
114115
resource.TestCheckResourceAttr(resourceName, "access_type", "NoPublicAccess"),
116+
resource.TestCheckResourceAttrSet(resourceName, "bucket_id"),
115117
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
116118
resource.TestCheckResourceAttrSet(resourceName, "created_by"),
117119
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
@@ -155,6 +157,7 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
155157
generateResourceFromRepresentationMap("oci_objectstorage_bucket", "test_bucket", Optional, Create, bucketRepresentation),
156158
Check: resource.ComposeAggregateTestCheckFunc(
157159
resource.TestCheckResourceAttr(resourceName, "access_type", "NoPublicAccess"),
160+
resource.TestCheckResourceAttrSet(resourceName, "bucket_id"),
158161
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId2),
159162
resource.TestCheckResourceAttrSet(resourceName, "created_by"),
160163
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
@@ -183,6 +186,7 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
183186
generateResourceFromRepresentationMap("oci_objectstorage_bucket", "test_bucket", Optional, Update, bucketRepresentation),
184187
Check: resource.ComposeAggregateTestCheckFunc(
185188
resource.TestCheckResourceAttr(resourceName, "access_type", "ObjectRead"),
189+
resource.TestCheckResourceAttrSet(resourceName, "bucket_id"),
186190
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
187191
resource.TestCheckResourceAttrSet(resourceName, "created_by"),
188192
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
@@ -239,11 +243,13 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
239243
resource.TestCheckResourceAttr(singularDatasourceName, "access_type", "ObjectRead"),
240244
resource.TestCheckResourceAttrSet(singularDatasourceName, "approximate_count"),
241245
resource.TestCheckResourceAttrSet(singularDatasourceName, "approximate_size"),
246+
resource.TestCheckResourceAttrSet(singularDatasourceName, "bucket_id"),
242247
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
243248
resource.TestCheckResourceAttrSet(singularDatasourceName, "created_by"),
244249
resource.TestCheckResourceAttr(singularDatasourceName, "defined_tags.%", "1"),
245250
resource.TestCheckResourceAttrSet(singularDatasourceName, "etag"),
246251
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
252+
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
247253
resource.TestCheckResourceAttr(singularDatasourceName, "metadata.%", "1"),
248254
resource.TestCheckResourceAttr(singularDatasourceName, "name", testBucketName2),
249255
resource.TestCheckResourceAttrSet(singularDatasourceName, "namespace"),
@@ -253,8 +259,6 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
253259
resource.TestCheckResourceAttr(singularDatasourceName, "object_events_enabled", "true"),
254260
resource.TestCheckResourceAttr(singularDatasourceName, "storage_tier", "Standard"),
255261
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
256-
resource.TestCheckResourceAttrSet(singularDatasourceName, "approximate_count"),
257-
resource.TestCheckResourceAttrSet(singularDatasourceName, "approximate_size"),
258262
),
259263
},
260264
// remove singular datasource from previous step so that it doesn't conflict with import tests

website/docs/d/objectstorage_bucket.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The following attributes are exported:
3838
* `access_type` - The type of public access enabled on this bucket. A bucket is set to `NoPublicAccess` by default, which only allows an authenticated caller to access the bucket and its contents. When `ObjectRead` is enabled on the bucket, public access is allowed for the `GetObject`, `HeadObject`, and `ListObjects` operations. When `ObjectReadWithoutList` is enabled on the bucket, public access is allowed for the `GetObject` and `HeadObject` operations.
3939
* `approximate_count` - The approximate number of objects in the bucket. Count statistics are reported periodically. You will see a lag between what is displayed and the actual object count.
4040
* `approximate_size` - The approximate total size in bytes of all objects in the bucket. Size statistics are reported periodically. You will see a lag between what is displayed and the actual size of the bucket.
41+
* `bucket_id` - The OCID of the bucket which is a Oracle assigned unique identifier for this resource type (bucket). `bucket_id` cannot be used for bucket lookup.
4142
* `compartment_id` - The compartment ID in which the bucket is authorized.
4243
* `created_by` - The OCID of the user who created the bucket.
4344
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`

website/docs/r/objectstorage_bucket.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The following attributes are exported:
6060
* `access_type` - The type of public access enabled on this bucket. A bucket is set to `NoPublicAccess` by default, which only allows an authenticated caller to access the bucket and its contents. When `ObjectRead` is enabled on the bucket, public access is allowed for the `GetObject`, `HeadObject`, and `ListObjects` operations. When `ObjectReadWithoutList` is enabled on the bucket, public access is allowed for the `GetObject` and `HeadObject` operations.
6161
* `approximate_count` - The approximate number of objects in the bucket. Count statistics are reported periodically. You will see a lag between what is displayed and the actual object count.
6262
* `approximate_size` - The approximate total size in bytes of all objects in the bucket. Size statistics are reported periodically. You will see a lag between what is displayed and the actual size of the bucket.
63+
* `bucket_id` - The OCID of the bucket which is a Oracle assigned unique identifier for this resource type (bucket). `bucket_id` cannot be used for bucket lookup.
6364
* `compartment_id` - The compartment ID in which the bucket is authorized.
6465
* `created_by` - The OCID of the user who created the bucket.
6566
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`

0 commit comments

Comments
 (0)