diff --git a/.gitignore b/.gitignore
index 7da6873..8d1693a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,8 @@
# Folders
_obj
_test
+.idea
+.DS_Store
# Architecture specific extensions/prefixes
*.[568vq]
@@ -26,4 +28,4 @@ dist/
cover.html
cover.out
covprofile
-coverage.html
\ No newline at end of file
+coverage.html
diff --git a/ci_media.go b/ci_media.go
index 9a10c61..971ba7b 100644
--- a/ci_media.go
+++ b/ci_media.go
@@ -112,6 +112,7 @@ type CreateMediaJobsOptions struct {
Input *JobInput `xml:"Input,omitempty"`
Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`
QueueId string `xml:"QueueId,omitempty"`
+ CallBack string `xml:"CallBack,omitempty"`
}
type MediaProcessJobDetail struct {
@@ -150,7 +151,7 @@ type DescribeMediaProcessJobResult struct {
NonExistJobIds string `xml:"NonExistJobIds,omitempty"`
}
-func (s *CIService) DescribeMediaJobs(ctx context.Context, jobid string) (*DescribeMediaProcessJobResult, *Response, error) {
+func (s *CIService) DescribeMediaJob(ctx context.Context, jobid string) (*DescribeMediaProcessJobResult, *Response, error) {
var res DescribeMediaProcessJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
@@ -162,7 +163,7 @@ func (s *CIService) DescribeMediaJobs(ctx context.Context, jobid string) (*Descr
return &res, resp, err
}
-type DescribeMediaProcessJobsOptions struct {
+type DescribeMediaJobsOptions struct {
QueueId string `url:"queueId,omitempty"`
Tag string `url:"tag,omitempty"`
OrderByTime string `url:"orderByTime,omitempty"`
@@ -173,14 +174,14 @@ type DescribeMediaProcessJobsOptions struct {
EndCreationTime string `url:"endCreationTime,omitempty"`
}
-type DescribeMediaProcessJobsResult struct {
+type DescribeMediaJobsResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail []DocProcessJobDetail `xml:"JobsDetail,omitempty"`
NextToken string `xml:"NextToken,omitempty"`
}
-func (s *CIService) DescribeMediaProcessJobs(ctx context.Context, opt *DescribeMediaProcessJobsOptions) (*DescribeMediaProcessJobsResult, *Response, error) {
- var res DescribeMediaProcessJobsResult
+func (s *CIService) DescribeMediaJobs(ctx context.Context, opt *DescribeMediaJobsOptions) (*DescribeMediaJobsResult, *Response, error) {
+ var res DescribeMediaJobsResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/jobs",
diff --git a/ci_media_test.go b/ci_media_test.go
new file mode 100644
index 0000000..26b1167
--- /dev/null
+++ b/ci_media_test.go
@@ -0,0 +1,170 @@
+package cos
+
+import (
+ "context"
+ "net/http"
+ "testing"
+)
+
+func TestCIService_CreateMediaJobs(t *testing.T) {
+ setup()
+ defer teardown()
+
+ wantBody := "Animation" +
+ "" +
+ "t1460606b9752148c4ab182f55163ba7cd" +
+ "p893bcda225bf4945a378da6662e81a89" +
+ "https://www.callback.com"
+
+ mux.HandleFunc("/jobs", func(w http.ResponseWriter, r *http.Request) {
+ testMethod(t, r, http.MethodPost)
+ testHeader(t, r, "Content-Type", "application/xml")
+ testBody(t, r, wantBody)
+ })
+
+ opt := &CreateMediaJobsOptions{
+ Tag: "Animation",
+ Input: &JobInput{
+ Object: "test.mp4",
+ },
+ Operation: &MediaProcessJobOperation{
+ Output: &JobOutput{
+ Region: "ap-beijing",
+ Bucket: "abc-1250000000",
+ Object: "test-trans.gif",
+ },
+ TemplateId: "t1460606b9752148c4ab182f55163ba7cd",
+ },
+ QueueId: "p893bcda225bf4945a378da6662e81a89",
+ CallBack: "https://www.callback.com",
+ }
+
+ _, _, err := client.CI.CreateMediaJobs(context.Background(), opt)
+ if err != nil {
+ t.Fatalf("CI.CreateMediaJobs returned errors: %v", err)
+ }
+}
+
+func TestCIService_DescribeMediaJob(t *testing.T) {
+ setup()
+ defer teardown()
+
+ jobID := "jabcsdssfeipplsdfwe"
+ mux.HandleFunc("/jobs/"+jobID, func(w http.ResponseWriter, r *http.Request) {
+ testMethod(t, r, http.MethodGet)
+ })
+
+ _, _, err := client.CI.DescribeMediaJob(context.Background(), jobID)
+ if err != nil {
+ t.Fatalf("CI.DescribeMediaJob returned error: %v", err)
+ }
+}
+
+func TestCIService_DescribeMediaJobs(t *testing.T) {
+ setup()
+ defer teardown()
+
+ queueId := "aaaaaaaaaaa"
+ tag := "Animation"
+
+ mux.HandleFunc("/jobs", func(w http.ResponseWriter, r *http.Request) {
+ testMethod(t, r, http.MethodGet)
+ v := values{
+ "queueId": queueId,
+ "tag": tag,
+ }
+ testFormValues(t, r, v)
+ })
+
+ opt := &DescribeMediaJobsOptions{
+ QueueId: queueId,
+ Tag: tag,
+ }
+
+ _, _, err := client.CI.DescribeMediaJobs(context.Background(), opt)
+ if err != nil {
+ t.Fatalf("CI.DescribeMediaJobs returned error: %v", err)
+ }
+}
+
+func TestCIService_DescribeMediaProcessQueues(t *testing.T) {
+ setup()
+ defer teardown()
+
+ queueIds := "A,B,C"
+ mux.HandleFunc("/queue", func(w http.ResponseWriter, r *http.Request) {
+ testMethod(t, r, http.MethodGet)
+ v := values{
+ "queueIds": queueIds,
+ }
+ testFormValues(t, r, v)
+ })
+
+ opt := &DescribeMediaProcessQueuesOptions{
+ QueueIds: queueIds,
+ }
+
+ _, _, err := client.CI.DescribeMediaProcessQueues(context.Background(), opt)
+ if err != nil {
+ t.Fatalf("CI.DescribeMediaProcessQueues returned error: %v", err)
+ }
+}
+
+func TestCIService_UpdateMediaProcessQueue(t *testing.T) {
+ setup()
+ defer teardown()
+
+ queueID := "p8eb46b8cc1a94bc09512d16c5c4f4d3a"
+ wantBody := "QueueName" + queueID + "Active" +
+ "test.comOnUrlTransCodingFinish" +
+ ""
+ mux.HandleFunc("/queue/"+queueID, func(w http.ResponseWriter, r *http.Request) {
+ testMethod(t, r, http.MethodPut)
+ testHeader(t, r, "Content-Type", "application/xml")
+ testBody(t, r, wantBody)
+ })
+
+ opt := &UpdateMediaProcessQueueOptions{
+ Name: "QueueName",
+ QueueID: queueID,
+ State: "Active",
+ NotifyConfig: &MediaProcessQueueNotifyConfig{
+ Url: "test.com",
+ State: "On",
+ Type: "Url",
+ Event: "TransCodingFinish",
+ },
+ }
+
+ _, _, err := client.CI.UpdateMediaProcessQueue(context.Background(), opt)
+ if err != nil {
+ t.Fatalf("CI.UpdateMediaProcessQueue returned error: %v", err)
+ }
+}
+
+func TestCIService_DescribeMediaProcessBuckets(t *testing.T) {
+ setup()
+ defer teardown()
+
+ regions := "ap-shanghai,ap-gaungzhou"
+ bucketName := "testbucket-1250000000"
+ mux.HandleFunc("/mediabucket", func(w http.ResponseWriter, r *http.Request) {
+ testMethod(t, r, http.MethodGet)
+ v := values{
+ "regions": regions,
+ "bucketName": bucketName,
+ }
+ testFormValues(t, r, v)
+ })
+
+ opt := &DescribeMediaProcessBucketsOptions{
+ Regions: regions,
+ BucketName: bucketName,
+ }
+
+ _, _, err := client.CI.DescribeMediaProcessBuckets(context.Background(), opt)
+ if err != nil {
+ t.Fatalf("CI.DescribeMediaProcessBuckets returned error: %v", err)
+ }
+}