Skip to content

Commit 392df9c

Browse files
committed
Add support for Enabling Event Notifications on bucket resource
1 parent d7c3dad commit 392df9c

7 files changed

+47
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## 3.44.1 (Unreleased)
1+
## 3.45.0 (Unreleased)
2+
3+
### Added
4+
5+
- Support for Event Notifications on `oci_objectstorage_bucket`
6+
27
## 3.44.0 (September 18, 2019)
38

49
### Added

oci/objectstorage_bucket_data_source.go

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

108108
s.D.Set("metadata", s.Res.Metadata)
109109

110+
if s.Res.ObjectEventsEnabled != nil {
111+
s.D.Set("object_events_enabled", *s.Res.ObjectEventsEnabled)
112+
}
113+
110114
if s.Res.ObjectLifecyclePolicyEtag != nil {
111115
s.D.Set("object_lifecycle_policy_etag", *s.Res.ObjectLifecyclePolicyEtag)
112116
}

oci/objectstorage_bucket_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ func ObjectStorageBucketResource() *schema.Resource {
7272
Optional: true,
7373
Elem: schema.TypeString,
7474
},
75+
"object_events_enabled": {
76+
Type: schema.TypeBool,
77+
Optional: true,
78+
Computed: true,
79+
},
7580
"storage_tier": {
7681
Type: schema.TypeString,
7782
Optional: true,
@@ -196,6 +201,11 @@ func (s *ObjectStorageBucketResourceCrud) Create() error {
196201
request.NamespaceName = &tmp
197202
}
198203

204+
if objectEventsEnabled, ok := s.D.GetOkExists("object_events_enabled"); ok {
205+
tmp := objectEventsEnabled.(bool)
206+
request.ObjectEventsEnabled = &tmp
207+
}
208+
199209
if storageTier, ok := s.D.GetOkExists("storage_tier"); ok {
200210
request.StorageTier = oci_object_storage.CreateBucketDetailsStorageTierEnum(storageTier.(string))
201211
}
@@ -287,6 +297,11 @@ func (s *ObjectStorageBucketResourceCrud) Update() error {
287297
request.NamespaceName = &tmp
288298
}
289299

300+
if objectEventsEnabled, ok := s.D.GetOkExists("object_events_enabled"); ok {
301+
tmp := objectEventsEnabled.(bool)
302+
request.ObjectEventsEnabled = &tmp
303+
}
304+
290305
// @CODEGEN 2/2018: This should be used to change the name of a bucket, but the "namespace" field
291306
// is already being used to identify the bucket. Should have a new field for this.
292307
// Existing provider omits this, so we will omit it for now to avoid a potential breaking change.
@@ -379,6 +394,10 @@ func (s *ObjectStorageBucketResourceCrud) SetData() error {
379394
s.D.Set("namespace", *s.Res.Namespace)
380395
}
381396

397+
if s.Res.ObjectEventsEnabled != nil {
398+
s.D.Set("object_events_enabled", *s.Res.ObjectEventsEnabled)
399+
}
400+
382401
if s.Res.ObjectLifecyclePolicyEtag != nil {
383402
s.D.Set("object_lifecycle_policy_etag", *s.Res.ObjectLifecyclePolicyEtag)
384403
}

oci/objectstorage_bucket_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ var (
4242
}
4343

4444
bucketRepresentation = map[string]interface{}{
45-
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
46-
"name": Representation{repType: Required, create: testBucketName, update: testBucketName2},
47-
"namespace": Representation{repType: Required, create: `${data.oci_objectstorage_namespace.t.namespace}`},
48-
"access_type": Representation{repType: Optional, create: `NoPublicAccess`, update: `ObjectRead`},
49-
"defined_tags": Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
50-
"freeform_tags": Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
51-
"kms_key_id": Representation{repType: Optional, create: `${lookup(data.oci_kms_keys.test_keys_dependency.keys[0], "id")}`},
52-
"metadata": Representation{repType: Optional, create: map[string]string{"content-type": "text/plain"}, update: map[string]string{"content-type": "text/xml"}},
53-
"storage_tier": Representation{repType: Optional, create: `Standard`},
45+
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
46+
"name": Representation{repType: Required, create: testBucketName, update: testBucketName2},
47+
"namespace": Representation{repType: Required, create: `${data.oci_objectstorage_namespace.t.namespace}`},
48+
"access_type": Representation{repType: Optional, create: `NoPublicAccess`, update: `ObjectRead`},
49+
"defined_tags": Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
50+
"freeform_tags": Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
51+
"kms_key_id": Representation{repType: Optional, create: `${lookup(data.oci_kms_keys.test_keys_dependency.keys[0], "id")}`},
52+
"metadata": Representation{repType: Optional, create: map[string]string{"content-type": "text/plain"}, update: map[string]string{"content-type": "text/xml"}},
53+
"object_events_enabled": Representation{repType: Optional, create: `false`, update: `true`},
54+
"storage_tier": Representation{repType: Optional, create: `Standard`},
5455
}
5556

5657
BucketResourceDependencies = DefinedTagsDependencies + KeyResourceDependencyConfig + `
@@ -120,6 +121,7 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
120121
resource.TestCheckResourceAttr(resourceName, "metadata.%", "1"),
121122
resource.TestCheckResourceAttr(resourceName, "name", testBucketName),
122123
resource.TestCheckResourceAttrSet(resourceName, "namespace"),
124+
resource.TestCheckResourceAttr(resourceName, "object_events_enabled", "false"),
123125
resource.TestCheckResourceAttr(resourceName, "storage_tier", "Standard"),
124126
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
125127

@@ -185,6 +187,7 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
185187
resource.TestCheckResourceAttr(resourceName, "metadata.%", "1"),
186188
resource.TestCheckResourceAttr(resourceName, "name", testBucketName2),
187189
resource.TestCheckResourceAttrSet(resourceName, "namespace"),
190+
resource.TestCheckResourceAttr(resourceName, "object_events_enabled", "true"),
188191
resource.TestCheckResourceAttr(resourceName, "storage_tier", "Standard"),
189192
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
190193

@@ -242,6 +245,7 @@ func TestObjectStorageBucketResource_basic(t *testing.T) {
242245
// This is difficult to test because TF is eager in creating the datasource and gives stale results.
243246
// If a depends_on is added, we get an error like "After applying this step and refreshing, the plan was not empty:"
244247
//resource.TestCheckResourceAttrSet(singularDatasourceName, "object_lifecycle_policy_etag"),
248+
resource.TestCheckResourceAttr(singularDatasourceName, "object_events_enabled", "true"),
245249
resource.TestCheckResourceAttr(singularDatasourceName, "storage_tier", "Standard"),
246250
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
247251
resource.TestCheckResourceAttrSet(singularDatasourceName, "approximate_count"),

website/docs/d/objectstorage_bucket.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The following attributes are exported:
4646
* `metadata` - Arbitrary string keys and values for user-defined metadata.
4747
* `name` - The name of the bucket. Avoid entering confidential information. Example: my-new-bucket1
4848
* `namespace` - The Object Storage namespace in which the bucket lives.
49+
* `object_events_enabled` - A property that determines whether events will be generated for operations on objects in this bucket. This is false by default.
4950
* `object_lifecycle_policy_etag` - The entity tag (ETag) for the live object lifecycle policy on the bucket.
5051
* `storage_tier` - The storage tier type assigned to the bucket. A bucket is set to 'Standard' tier by default, which means objects uploaded or copied to the bucket will be in the standard storage tier. When the 'Archive' tier type is set explicitly for a bucket, objects uploaded or copied to the bucket will be stored in archive storage. The 'storageTier' property is immutable after bucket is created.
5152
* `time_created` - The date and time the bucket was created, as described in [RFC 2616](https://tools.ietf.org/rfc/rfc2616), section 14.29.

website/docs/d/objectstorage_bucket_summaries.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ The following attributes are exported:
5757
* `metadata` - Arbitrary string keys and values for user-defined metadata.
5858
* `name` - The name of the bucket. Avoid entering confidential information. Example: my-new-bucket1
5959
* `namespace` - The Object Storage namespace in which the bucket lives.
60+
* `object_events_enabled` - A property that determines whether events will be generated for operations on objects in this bucket. This is false by default.
6061
* `object_lifecycle_policy_etag` - The entity tag (ETag) for the live object lifecycle policy on the bucket.
6162
* `storage_tier` - The storage tier type assigned to the bucket. A bucket is set to 'Standard' tier by default, which means objects uploaded or copied to the bucket will be in the standard storage tier. When the 'Archive' tier type is set explicitly for a bucket, objects uploaded or copied to the bucket will be stored in archive storage. The 'storageTier' property is immutable after bucket is created.
6263
* `time_created` - The date and time the bucket was created, as described in [RFC 2616](https://tools.ietf.org/rfc/rfc2616), section 14.29.

website/docs/r/objectstorage_bucket.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ resource "oci_objectstorage_bucket" "test_bucket" {
2828
freeform_tags = {"Department"= "Finance"}
2929
kms_key_id = "${oci_objectstorage_kms_key.test_kms_key.id}"
3030
metadata = "${var.bucket_metadata}"
31+
object_events_enabled = "${var.bucket_object_events_enabled}"
3132
storage_tier = "${var.bucket_storage_tier}"
3233
}
3334
```
@@ -44,6 +45,7 @@ The following arguments are supported:
4445
* `metadata` - (Optional) (Updatable) Arbitrary string, up to 4KB, of keys and values for user-defined metadata.
4546
* `name` - (Required) The name of the bucket. Valid characters are uppercase or lowercase letters, numbers, and dashes. Bucket names must be unique within an Object Storage namespace. Avoid entering confidential information. example: Example: my-new-bucket1
4647
* `namespace` - (Required) The Object Storage namespace used for the request.
48+
* `object_events_enabled` - (Optional) (Updatable) A property that determines whether events will be generated for operations on objects in this bucket. This is false by default.
4749
* `storage_tier` - (Optional) The type of storage tier of this bucket. A bucket is set to 'Standard' tier by default, which means the bucket will be put in the standard storage tier. When 'Archive' tier type is set explicitly, the bucket is put in the Archive Storage tier. The 'storageTier' property is immutable after bucket is created.
4850

4951

@@ -66,6 +68,7 @@ The following attributes are exported:
6668
* `metadata` - Arbitrary string keys and values for user-defined metadata.
6769
* `name` - The name of the bucket. Avoid entering confidential information. Example: my-new-bucket1
6870
* `namespace` - The Object Storage namespace in which the bucket lives.
71+
* `object_events_enabled` - A property that determines whether events will be generated for operations on objects in this bucket. This is false by default.
6972
* `object_lifecycle_policy_etag` - The entity tag (ETag) for the live object lifecycle policy on the bucket.
7073
* `storage_tier` - The storage tier type assigned to the bucket. A bucket is set to 'Standard' tier by default, which means objects uploaded or copied to the bucket will be in the standard storage tier. When the 'Archive' tier type is set explicitly for a bucket, objects uploaded or copied to the bucket will be stored in archive storage. The 'storageTier' property is immutable after bucket is created.
7174
* `time_created` - The date and time the bucket was created, as described in [RFC 2616](https://tools.ietf.org/rfc/rfc2616), section 14.29.

0 commit comments

Comments
 (0)