Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COS: Added Object SQL URL #2934

Merged
merged 1 commit into from Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/ibm-cos-bucket-object/README.md
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
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
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
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
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
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
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