-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
243 changes: 243 additions & 0 deletions
243
tencentcloud/resource_tc_mps_describe_media_metadata_operation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
/* | ||
Provides a resource to create a mps describe_media_metadata_operation | ||
Example Usage | ||
```hcl | ||
resource "tencentcloud_mps_describe_media_metadata_operation" "describe_media_metadata_operation" { | ||
input_info { | ||
type = "" | ||
cos_input_info { | ||
bucket = "" | ||
region = "" | ||
object = "" | ||
} | ||
url_input_info { | ||
url = "" | ||
} | ||
s3_input_info { | ||
s3_bucket = "" | ||
s3_region = "" | ||
s3_object = "" | ||
s3_secret_id = "" | ||
s3_secret_key = "" | ||
} | ||
} | ||
} | ||
``` | ||
Import | ||
mps describe_media_metadata_operation can be imported using the id, e.g. | ||
``` | ||
terraform import tencentcloud_mps_describe_media_metadata_operation.describe_media_metadata_operation describe_media_metadata_operation_id | ||
``` | ||
*/ | ||
package tencentcloud | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
mps "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mps/v20190612" | ||
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" | ||
"log" | ||
) | ||
|
||
func resourceTencentCloudMpsDescribeMediaMetadataOperation() *schema.Resource { | ||
return &schema.Resource{ | ||
Create: resourceTencentCloudMpsDescribeMediaMetadataOperationCreate, | ||
Read: resourceTencentCloudMpsDescribeMediaMetadataOperationRead, | ||
Delete: resourceTencentCloudMpsDescribeMediaMetadataOperationDelete, | ||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
"input_info": { | ||
Required: true, | ||
ForceNew: true, | ||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Description: "Input information of file for metadata getting.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"type": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The input type. Valid values:<li>`COS`: A COS bucket address.</li><li> `URL`: A URL.</li><li> `AWS-S3`: An AWS S3 bucket address. Currently, this type is only supported for transcoding tasks.</li>.", | ||
}, | ||
"cos_input_info": { | ||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Optional: true, | ||
Description: "The information of the COS object to process. This parameter is valid and required when `Type` is `COS`.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"bucket": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The COS bucket of the object to process, such as `TopRankVideo-125xxx88`.", | ||
}, | ||
"region": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The region of the COS bucket, such as `ap-chongqing`.", | ||
}, | ||
"object": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The path of the object to process, such as `/movie/201907/WildAnimal.mov`.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
"url_input_info": { | ||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Optional: true, | ||
Description: "The URL of the object to process. This parameter is valid and required when `Type` is `URL`.Note: This field may return null, indicating that no valid value can be obtained.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"url": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "URL of a video.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
"s3_input_info": { | ||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Optional: true, | ||
Description: "The information of the AWS S3 object processed. This parameter is required if `Type` is `AWS-S3`.Note: This field may return null, indicating that no valid value can be obtained.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"s3_bucket": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The AWS S3 bucket.", | ||
}, | ||
"s3_region": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The region of the AWS S3 bucket.", | ||
}, | ||
"s3_object": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The path of the AWS S3 object.", | ||
}, | ||
"s3_secret_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The key ID required to access the AWS S3 object.", | ||
}, | ||
"s3_secret_key": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The key required to access the AWS S3 object.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func resourceTencentCloudMpsDescribeMediaMetadataOperationCreate(d *schema.ResourceData, meta interface{}) error { | ||
defer logElapsed("resource.tencentcloud_mps_describe_media_metadata_operation.create")() | ||
defer inconsistentCheck(d, meta)() | ||
|
||
logId := getLogId(contextNil) | ||
|
||
var ( | ||
request = mps.NewDescribeMediaMetaDataRequest() | ||
response = mps.NewDescribeMediaMetaDataResponse() | ||
inputInfo uint64 | ||
) | ||
if dMap, ok := helper.InterfacesHeadMap(d, "input_info"); ok { | ||
mediaInputInfo := mps.MediaInputInfo{} | ||
if v, ok := dMap["type"]; ok { | ||
mediaInputInfo.Type = helper.String(v.(string)) | ||
} | ||
if cosInputInfoMap, ok := helper.InterfaceToMap(dMap, "cos_input_info"); ok { | ||
cosInputInfo := mps.CosInputInfo{} | ||
if v, ok := cosInputInfoMap["bucket"]; ok { | ||
cosInputInfo.Bucket = helper.String(v.(string)) | ||
} | ||
if v, ok := cosInputInfoMap["region"]; ok { | ||
cosInputInfo.Region = helper.String(v.(string)) | ||
} | ||
if v, ok := cosInputInfoMap["object"]; ok { | ||
cosInputInfo.Object = helper.String(v.(string)) | ||
} | ||
mediaInputInfo.CosInputInfo = &cosInputInfo | ||
} | ||
if urlInputInfoMap, ok := helper.InterfaceToMap(dMap, "url_input_info"); ok { | ||
urlInputInfo := mps.UrlInputInfo{} | ||
if v, ok := urlInputInfoMap["url"]; ok { | ||
urlInputInfo.Url = helper.String(v.(string)) | ||
} | ||
mediaInputInfo.UrlInputInfo = &urlInputInfo | ||
} | ||
if s3InputInfoMap, ok := helper.InterfaceToMap(dMap, "s3_input_info"); ok { | ||
s3InputInfo := mps.S3InputInfo{} | ||
if v, ok := s3InputInfoMap["s3_bucket"]; ok { | ||
s3InputInfo.S3Bucket = helper.String(v.(string)) | ||
} | ||
if v, ok := s3InputInfoMap["s3_region"]; ok { | ||
s3InputInfo.S3Region = helper.String(v.(string)) | ||
} | ||
if v, ok := s3InputInfoMap["s3_object"]; ok { | ||
s3InputInfo.S3Object = helper.String(v.(string)) | ||
} | ||
if v, ok := s3InputInfoMap["s3_secret_id"]; ok { | ||
s3InputInfo.S3SecretId = helper.String(v.(string)) | ||
} | ||
if v, ok := s3InputInfoMap["s3_secret_key"]; ok { | ||
s3InputInfo.S3SecretKey = helper.String(v.(string)) | ||
} | ||
mediaInputInfo.S3InputInfo = &s3InputInfo | ||
} | ||
request.InputInfo = &mediaInputInfo | ||
} | ||
|
||
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { | ||
result, e := meta.(*TencentCloudClient).apiV3Conn.UseMpsClient().DescribeMediaMetaData(request) | ||
if e != nil { | ||
return retryError(e) | ||
} else { | ||
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) | ||
} | ||
response = result | ||
return nil | ||
}) | ||
if err != nil { | ||
log.Printf("[CRITAL]%s operate mps describeMediaMetadataOperation failed, reason:%+v", logId, err) | ||
return err | ||
} | ||
|
||
inputInfo = *response.Response.InputInfo | ||
d.SetId(helper.UInt64ToStr(inputInfo)) | ||
|
||
return resourceTencentCloudMpsDescribeMediaMetadataOperationRead(d, meta) | ||
} | ||
|
||
func resourceTencentCloudMpsDescribeMediaMetadataOperationRead(d *schema.ResourceData, meta interface{}) error { | ||
defer logElapsed("resource.tencentcloud_mps_describe_media_metadata_operation.read")() | ||
defer inconsistentCheck(d, meta)() | ||
|
||
return nil | ||
} | ||
|
||
func resourceTencentCloudMpsDescribeMediaMetadataOperationDelete(d *schema.ResourceData, meta interface{}) error { | ||
defer logElapsed("resource.tencentcloud_mps_describe_media_metadata_operation.delete")() | ||
defer inconsistentCheck(d, meta)() | ||
|
||
return nil | ||
} |
53 changes: 53 additions & 0 deletions
53
tencentcloud/resource_tc_mps_describe_media_metadata_operation_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package tencentcloud | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"testing" | ||
) | ||
|
||
func TestAccTencentCloudMpsDescribeMediaMetadataOperationResource_basic(t *testing.T) { | ||
t.Parallel() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
}, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccMpsDescribeMediaMetadataOperation, | ||
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_mps_describe_media_metadata_operation.describe_media_metadata_operation", "id")), | ||
}, | ||
{ | ||
ResourceName: "tencentcloud_mps_describe_media_metadata_operation.describe_media_metadata_operation", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccMpsDescribeMediaMetadataOperation = ` | ||
resource "tencentcloud_mps_describe_media_metadata_operation" "describe_media_metadata_operation" { | ||
input_info { | ||
type = "" | ||
cos_input_info { | ||
bucket = "" | ||
region = "" | ||
object = "" | ||
} | ||
url_input_info { | ||
url = "" | ||
} | ||
s3_input_info { | ||
s3_bucket = "" | ||
s3_region = "" | ||
s3_object = "" | ||
s3_secret_id = "" | ||
s3_secret_key = "" | ||
} | ||
} | ||
} | ||
` |
Oops, something went wrong.