媒体处理 MPC-Go SDK:代码示例

时间:2024-07-30 16:48:27

代码示例

调用前请根据实际情况替换如下变量:"SDK_AK"、"SDK_SK"、{your endpoint string}以及{your project id}。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main

import (
    "fmt"
    "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/config"
    "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/httphandler"
    mpc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1"
    "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1/model"
    "net/http"
)

func RequestHandler(request http.Request) {
    fmt.Println(request)
}

func ResponseHandler(response http.Response) {
    fmt.Println(response)
}
ak := os.Getenv("SDK_AK")
sk := os.Getenv("SDK_SK")
projectId := os.Getenv("{your project id}")
func main() {
    client := mpc.NewMpcClient(
        mpc.MpcClientBuilder().
            WithEndpoint("{your endpoint}").
            WithCredential(
                basic.NewCredentialsBuilder().
                    WithAk(ak).
                    WithSk(sk).
                    WithProjectId(projectId).
                    Build()).
            WithHttpConfig(config.DefaultHttpConfig().
                WithIgnoreSSLVerification(true).
                WithHttpHandler(httphandler.
                    NewHttpHandler().
                        AddRequestHandler(RequestHandler).
                        AddResponseHandler(ResponseHandler))).
            Build())

    request := &model.ListTranscodingTaskRequest{        
        TaskId:&[]int64{1900293},
    }
    response, err := client.ListTranscodingTask(request)
    if err == nil {
        fmt.Println("%+v\n",response)
    } else {
        fmt.Println(err)
    }
}
support.huaweicloud.com/sdkreference-mpc/mpc_05_0089.html