更新时间:2021-06-28 GMT+08:00
分享

删除水印模板

通过指定水印模板ID删除用户自定义的水印模板。

核心代码

1
2
3
4
5
// 发送删除水印配置模板请求给媒体处理服务
DeleteWatermarkTemplateRequest req = new DeleteWatermarkTemplateRequest().withTemplateId(215728);
DeleteWatermarkTemplateResponse rsp = initMpcClient().deleteWatermarkTemplate(req);
// 打印返回消息
System.out.println("httpCode=" + rsp.getHttpStatusCode() + ", rsp=" + JsonUtils.toJSON(rsp));

代码示例

 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
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ClientRequestException;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.http.HttpConfig;
import com.huaweicloud.sdk.core.utils.JsonUtils;
import com.huaweicloud.sdk.mpc.v1.MpcClient;
import com.huaweicloud.sdk.mpc.v1.model.DeleteWatermarkTemplateRequest;
import com.huaweicloud.sdk.mpc.v1.model.DeleteWatermarkTemplateResponse;
import com.obs.services.internal.ServiceException;

public class TestDeleteWatermarkTemplate {
    /**
     * 初始化 MpcClient
     * @return
     */
    public static MpcClient initMpcClient() {
        HttpConfig httpConfig = HttpConfig.getDefaultHttpConfig().withIgnoreSSLVerification(true).withTimeout(3);
        //http代理设置,请根据实际情况设置
        //httpConfig.withProxyHost("xxxxxx").withProxyPort(xxxxxx).withProxyUsername("xxxxxx").
        //        withProxyPassword("xxxxxx");
        //根据实际填写ak,sk,华为云控制台账号名下“我的凭证”>访问密钥上创建和查看您的AK/SK
        String ak = "xxxxxx";
        String sk = "xxxxxx";
        //根据实际填写项目ID,华为云控制台账号名下“我的凭证”>API凭证下查看您的项目ID
        String projectId = "xxxxxx";
        //根据实际填写所需endpoint,这里以华东2为例
        String endpoint = "https://mpc.cn-east-2.myhuaweicloud.com";
        BasicCredentials auth = new BasicCredentials().withAk(ak).withSk(sk).withProjectId(projectId);
        return MpcClient.newBuilder()
                .withHttpConfig(httpConfig)
                .withCredential(auth)
                .withEndpoint(endpoint)
                .build();
    }

    /**
     * 删除水印模板任务
     * @param args
     */
    public static void main(String[] args) {
        DeleteWatermarkTemplateRequest req = new DeleteWatermarkTemplateRequest().withTemplateId(215728);
        try {
            DeleteWatermarkTemplateResponse rsp = initMpcClient().deleteWatermarkTemplate(req);
            System.out.println("httpCode=" + rsp.getHttpStatusCode() + ", rsp=" + JsonUtils.toJSON(rsp));
        } catch (ClientRequestException | ConnectionException | RequestTimeoutException | ServiceException e) {
            System.out.println(e);
        }
    }
}
分享:

    相关文档

    相关产品