Skip to content

Commit e19a4ee

Browse files
Query parameters added to Get Object request in object_storage object resource
1 parent e38f47a commit e19a4ee

File tree

4 files changed

+87
-11
lines changed

4 files changed

+87
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## 3.95.0 (Unreleased)
2+
- Support for query parameters added to `object_storage` `object` resource
3+
24
## 3.94.0 (September 23, 2020)
35

46
### Added

oci/objectstorage_object_data_source.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ func ObjectStorageObjectDataSource() *schema.Resource {
2727
Type: schema.TypeString,
2828
Required: true,
2929
},
30+
"http_response_cache_control": {
31+
Type: schema.TypeString,
32+
Optional: true,
33+
},
34+
"http_response_content_disposition": {
35+
Type: schema.TypeString,
36+
Optional: true,
37+
},
38+
"http_response_content_encoding": {
39+
Type: schema.TypeString,
40+
Optional: true,
41+
},
42+
"http_response_content_language": {
43+
Type: schema.TypeString,
44+
Optional: true,
45+
},
46+
"http_response_content_type": {
47+
Type: schema.TypeString,
48+
Optional: true,
49+
},
50+
"http_response_expires": {
51+
Type: schema.TypeString,
52+
Optional: true,
53+
},
3054
"namespace": {
3155
Type: schema.TypeString,
3256
Required: true,
@@ -162,6 +186,36 @@ func (s *ObjectStorageObjectDataSourceCrud) Get() error {
162186
request.VersionId = &tmp
163187
}
164188

189+
if httpResponseCacheControl, ok := s.D.GetOkExists("http_response_cache_control"); ok {
190+
tmp := httpResponseCacheControl.(string)
191+
request.HttpResponseCacheControl = &tmp
192+
}
193+
194+
if httpResponseContentDisposition, ok := s.D.GetOkExists("http_response_content_disposition"); ok {
195+
tmp := httpResponseContentDisposition.(string)
196+
request.HttpResponseContentDisposition = &tmp
197+
}
198+
199+
if httpResponseContentEncoding, ok := s.D.GetOkExists("http_response_content_encoding"); ok {
200+
tmp := httpResponseContentEncoding.(string)
201+
request.HttpResponseContentEncoding = &tmp
202+
}
203+
204+
if httpResponseContentLanguage, ok := s.D.GetOkExists("http_response_content_language"); ok {
205+
tmp := httpResponseContentLanguage.(string)
206+
request.HttpResponseContentLanguage = &tmp
207+
}
208+
209+
if httpResponseContentType, ok := s.D.GetOkExists("http_response_content_type"); ok {
210+
tmp := httpResponseContentType.(string)
211+
request.HttpResponseContentType = &tmp
212+
}
213+
214+
if httpResponseExpires, ok := s.D.GetOkExists("http_response_expires"); ok {
215+
tmp := httpResponseExpires.(string)
216+
request.HttpResponseExpires = &tmp
217+
}
218+
165219
response, err := s.Client.GetObject(context.Background(), request)
166220
if err != nil {
167221
return err

oci/objectstorage_object_test.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"context"
88
"crypto/md5"
99
"encoding/base64"
10+
"time"
11+
1012
"encoding/hex"
1113
"fmt"
1214
"io/ioutil"
@@ -47,12 +49,18 @@ var (
4749
}
4850

4951
objectSingularDataSourceRepresentation = map[string]interface{}{
50-
"bucket": Representation{repType: Required, create: `${oci_objectstorage_bucket.test_bucket.name}`},
51-
"namespace": Representation{repType: Required, create: `${oci_objectstorage_bucket.test_bucket.namespace}`},
52-
"object": Representation{repType: Required, create: `my-test-object-3`},
53-
"content_length_limit": Representation{repType: Optional, create: `17`, update: `15`},
54-
"base64_encode_content": Representation{repType: Optional, create: `true`},
55-
"version_id": Representation{repType: Optional, create: `${oci_objectstorage_object.test_object.version_id}`},
52+
"bucket": Representation{repType: Required, create: `${oci_objectstorage_bucket.test_bucket.name}`},
53+
"namespace": Representation{repType: Required, create: `${oci_objectstorage_bucket.test_bucket.namespace}`},
54+
"object": Representation{repType: Required, create: `my-test-object-3`},
55+
"content_length_limit": Representation{repType: Optional, create: `17`, update: `20`},
56+
"base64_encode_content": Representation{repType: Optional, create: `true`},
57+
"version_id": Representation{repType: Optional, create: `${oci_objectstorage_object.test_object.version_id}`},
58+
"http_response_cache_control": Representation{repType: Optional, create: `no-cache`, update: `no-store`},
59+
"http_response_content_disposition": Representation{repType: Optional, create: `inline`, update: `inline`},
60+
"http_response_content_encoding": Representation{repType: Optional, create: `identity`, update: `identity`},
61+
"http_response_content_language": Representation{repType: Optional, create: `en-US`, update: `en-US`},
62+
"http_response_content_type": Representation{repType: Optional, create: `text/plain`, update: `text/plain`},
63+
"http_response_expires": Representation{repType: Optional, create: expirationTimeForPar.Format(time.RFC3339Nano), update: expirationTimeForPar.Format(time.RFC3339Nano)},
5664
}
5765

5866
objectRepresentation = map[string]interface{}{
@@ -288,16 +296,17 @@ func TestObjectStorageObjectResource_basic(t *testing.T) {
288296
Config: config + compartmentIdVariableStr + ObjectResourceDependencies +
289297
generateResourceFromRepresentationMap("oci_objectstorage_object", "test_object", Optional, Update,
290298
getUpdatedRepresentationCopy("object", Representation{repType: Required, create: `my-test-object-1`, update: `my-test-object-3`}, objectRepresentation)) +
291-
generateDataSourceFromRepresentationMap("oci_objectstorage_object", "test_object", Optional, Create, objectSingularDataSourceRepresentation),
299+
generateDataSourceFromRepresentationMap("oci_objectstorage_object", "test_object", Optional, Update, objectSingularDataSourceRepresentation),
292300
Check: resource.ComposeAggregateTestCheckFunc(
293301
resource.TestCheckResourceAttr(singularDatasourceName, "base64_encode_content", "true"),
294302
resource.TestCheckResourceAttr(singularDatasourceName, "cache_control", "no-store"),
295-
resource.TestCheckResourceAttr(singularDatasourceName, "content_disposition", "attachment; filename=\"filename.html\""),
303+
resource.TestCheckResourceAttr(singularDatasourceName, "content_disposition", "inline"),
296304
resource.TestCheckResourceAttr(singularDatasourceName, "content_encoding", "identity"),
297-
resource.TestCheckResourceAttr(singularDatasourceName, "content_language", "en-CA"),
305+
resource.TestCheckResourceAttr(singularDatasourceName, "content_language", "en-US"),
298306
resource.TestCheckResourceAttr(singularDatasourceName, "content_length", "16"),
299307
resource.TestCheckResourceAttr(singularDatasourceName, "content_md5", *md5B64Encode2),
300-
resource.TestCheckResourceAttr(singularDatasourceName, "content_type", "text/xml"),
308+
resource.TestCheckResourceAttr(singularDatasourceName, "content_type", "text/plain"),
309+
resource.TestCheckResourceAttr(singularDatasourceName, "http_response_expires", expirationTimeForPar.Format(time.RFC3339Nano)),
301310
resource.TestCheckResourceAttr(singularDatasourceName, "bucket", testBucketName),
302311
resource.TestCheckResourceAttrSet(singularDatasourceName, "content"),
303312
resource.TestCheckResourceAttr(singularDatasourceName, "content", base64.StdEncoding.EncodeToString([]byte("<a1>content</a1>"))),
@@ -330,7 +339,6 @@ func TestObjectStorageObjectResource_basic(t *testing.T) {
330339
Check: resource.ComposeAggregateTestCheckFunc(
331340
resource.TestCheckResourceAttr(datasourceName, "bucket", testBucketName),
332341
resource.TestCheckResourceAttrSet(datasourceName, "namespace"),
333-
334342
resource.TestCheckResourceAttr(datasourceName, "objects.#", "1"),
335343
resource.TestCheckResourceAttr(datasourceName, "delimiter", "/"),
336344
resource.TestCheckResourceAttr(datasourceName, "end", "x"),

website/docs/d/objectstorage_object.html.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ data "oci_objectstorage_object" "test_object" {
2323
object = var.object_object
2424
2525
#Optional
26+
http_response_cache_control = var.object_http_response_cache_control
27+
http_response_content_disposition = var.object_http_response_content_disposition
28+
http_response_content_encoding = var.object_http_response_content_encoding
29+
http_response_content_language = var.object_http_response_content_language
30+
http_response_content_type = var.object_http_response_content_type
31+
http_response_expires = var.object_http_response_expires
2632
version_id = oci_objectstorage_version.test_version.id
2733
}
2834
```
@@ -32,6 +38,12 @@ data "oci_objectstorage_object" "test_object" {
3238
The following arguments are supported:
3339

3440
* `bucket` - (Required) The name of the bucket. Avoid entering confidential information. Example: `my-new-bucket1`
41+
* `http_response_cache_control` - (Optional) This value will be used in Cache-Control header of the response.
42+
* `http_response_content_disposition` - (Optional) This value will be used in Content-Disposition header of the response.
43+
* `http_response_content_encoding` - (Optional) This value will be used in Content-Encoding header of the response
44+
* `http_response_content_language` - (Optional) This value will be used in Content-Language header of the response.
45+
* `http_response_content_type` - (Optional) This value will be used in Content-Type header of the response.
46+
* `http_response_expires` - (Optional) This value will be used in Expires header of the response
3547
* `namespace` - (Required) The Object Storage namespace used for the request.
3648
* `object` - (Required) The name of the object. Avoid entering confidential information. Example: `test/object1.log`
3749
* `content_length_limit` - (Optional) The limit of the content length of the object body to download from the object store. The default is 1Mb.

0 commit comments

Comments
 (0)