Skip to content

Commit

Permalink
Added COS Object SQL URL
Browse files Browse the repository at this point in the history
  • Loading branch information
testpod-source-p authored and hkantare committed Aug 5, 2021
1 parent f87de95 commit b45d9cd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/ibm-cos-bucket-object/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ data "ibm_cos_bucket_object" "object" {
| content\_length | Size of the object body, in bytes. | `integer` |
| content\_type | A standard MIME type describing the format of the object data. | `string` |
| etag | Computed MD5 hexdigest of the object content. | `string` |
| last\_modified | Last modified date of the object. A GMT formatted date. | `string` |
| last\_modified | Last modified date of the object. A GMT formatted date. | `string` |
| object_sql_url | Access the object using an SQL Query instance. | `string` |
5 changes: 5 additions & 0 deletions ibm/data_source_ibm_cos_bucket_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func dataSourceIBMCosBucketObject() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"object_sql_url": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -148,5 +152,6 @@ func dataSourceIBMCosBucketObjectRead(ctx context.Context, d *schema.ResourceDat
objectID := getObjectId(bucketCRN, objectKey, bucketLocation)
d.SetId(objectID)
d.Set("version_id", out.VersionId)
d.Set("object_sql_url", "cos://"+bucketLocation+"/"+bucketName+"/"+objectKey)
return nil
}
1 change: 1 addition & 0 deletions ibm/data_source_ibm_cos_bucket_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestAccIBMCOSBucketObjectDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("data.ibm_cos_bucket_object.testacc", "content_type"),
resource.TestCheckResourceAttrSet("data.ibm_cos_bucket_object.testacc", "etag"),
resource.TestCheckResourceAttrSet("data.ibm_cos_bucket_object.testacc", "last_modified"),
resource.TestCheckResourceAttrSet("data.ibm_cos_bucket_object.testacc", "object_sql_url"),
),
},
},
Expand Down
7 changes: 6 additions & 1 deletion ibm/resource_ibm_cos_bucket_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ func resourceIBMCOSBucketObject() *schema.Resource {
Default: true,
Description: "COS buckets need to be empty before they can be deleted. force_delete option empty the bucket and delete it.",
},
"object_sql_url": {
Type: schema.TypeString,
Computed: true,
Description: "Access the object using an SQL Query instance.The reference url is used to perform queries against objects storing structured data.",
},
},
}
}
Expand Down Expand Up @@ -274,7 +279,7 @@ func resourceIBMCOSBucketObjectRead(ctx context.Context, d *schema.ResourceData,

d.Set("key", objectKey)
d.Set("version_id", out.VersionId)

d.Set("object_sql_url", "cos://"+bucketLocation+"/"+bucketName+"/"+objectKey)
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions ibm/resource_ibm_cos_bucket_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestAccIBMCOSBucketObject_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "content_type"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "etag"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "last_modified"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "object_sql_url"),
resource.TestCheckResourceAttr("ibm_cos_bucket_object.testacc", "body", objectBody),
),
},
Expand All @@ -44,6 +45,7 @@ func TestAccIBMCOSBucketObject_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "content_type"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "etag"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "last_modified"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "object_sql_url"),
resource.TestCheckResourceAttr("ibm_cos_bucket_object.testacc", "body", objectBody),
),
},
Expand All @@ -56,6 +58,7 @@ func TestAccIBMCOSBucketObject_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "content_type"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "etag"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "last_modified"),
resource.TestCheckResourceAttrSet("ibm_cos_bucket_object.testacc", "object_sql_url"),
resource.TestCheckResourceAttr("ibm_cos_bucket_object.testacc", "body", string(objectFileBody)),
),
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/cos_bucket_object.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ In addition to all argument reference list, you can access the following attribu
- `content_type` - (String) A standard MIME type describing the format of an object data.
- `etag` - (String) Computed MD5 hexdigest of an object content.
- `last_modified` - (Timestamp) Last modified date of the object. A GMT formatted date.
- `object_sql_url` - (String) Access the object using an SQL Query instance. The SQL URL is a reference url used inside of an SQL statement. The reference url is used to perform queries against objects storing structured data.
1 change: 1 addition & 0 deletions website/docs/r/cos_bucket_object.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ In addition to all argument reference list, you can access the following attribu
- `content_type` - (String) A standard MIME type describing the format of an object data.
- `etag` - (String) Computed MD5 hexdigest of an object content.
- `last_modified` - (Timestamp) Last modified date of an object. A GMT formatted date.
- `object_sql_url` - (String) Access the object using an SQL Query instance. The SQL URL is a reference url used inside of an SQL statement. The reference url is used to perform queries against objects storing structured data.

## Import

Expand Down

0 comments on commit b45d9cd

Please sign in to comment.