Skip to content

Commit

Permalink
feat:support operation
Browse files Browse the repository at this point in the history
  • Loading branch information
lyu571 committed Sep 28, 2023
1 parent 36d1566 commit d92eaaf
Show file tree
Hide file tree
Showing 7 changed files with 1,131 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tencentcloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,9 @@ Media Processing Service(MPS)
tencentcloud_mps_adaptive_dynamic_streaming_template
tencentcloud_mps_person_sample
tencentcloud_mps_withdraws_watermark_operation
tencentcloud_mps_parse_live_stream_process_notify_operation
tencentcloud_mps_edit_media_operation
tencentcloud_mps_describe_media_metadata_operation
Cloud HDFS(CHDFS)
Data Source
Expand Down Expand Up @@ -3031,6 +3034,9 @@ func Provider() *schema.Provider {
"tencentcloud_mps_adaptive_dynamic_streaming_template": resourceTencentCloudMpsAdaptiveDynamicStreamingTemplate(),
"tencentcloud_mps_person_sample": resourceTencentCloudMpsPersonSample(),
"tencentcloud_mps_withdraws_watermark_operation": resourceTencentCloudMpsWithdrawsWatermarkOperation(),
"tencentcloud_mps_parse_live_stream_process_notify_operation": resourceTencentCloudMpsParseLiveStreamProcessNotifyOperation(),
"tencentcloud_mps_edit_media_operation": resourceTencentCloudMpsEditMediaOperation(),
"tencentcloud_mps_describe_media_metadata_operation": resourceTencentCloudMpsDescribeMediaMetadataOperation(),
"tencentcloud_cbs_disk_backup": resourceTencentCloudCbsDiskBackup(),
"tencentcloud_cbs_snapshot_share_permission": resourceTencentCloudCbsSnapshotSharePermission(),
"tencentcloud_cbs_disk_backup_rollback_operation": resourceTencentCloudCbsDiskBackupRollbackOperation(),
Expand Down
243 changes: 243 additions & 0 deletions tencentcloud/resource_tc_mps_describe_media_metadata_operation.go
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
}
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 = ""
}
}
}
`
Loading

0 comments on commit d92eaaf

Please sign in to comment.