Querying Watermark Templates
Notes
- You can query watermark templates by template ID or page number.
- A maximum of 10 template IDs can be queried at a time.
- The page number and maximum number of templates on each page must be specified for pagination query. If no parameters are specified, page is 0 and size is 10.
Core Code
- Create a query request.
1 2
// Create a request for querying a watermark template. QueryWatermarkTemplateRequest queryWatermarkTemplateRequest = new QueryWatermarkTemplateRequest();
- Set query parameters.
- Query by template ID
1 2
String[] templateIdArray = new String[]{"template_id1", "template_id2", "template_id3"}; queryWatermarkTemplateRequest.setTemplateIds(templateIdArray);
- Query by page number
1 2 3
// 2. Set the page number and number of records on each page. queryWatermarkTemplateRequest.setPage(2); queryWatermarkTemplateRequest.setSize(10);
- Query by template ID
- Send a query request and return a message.
1 2 3 4 5
// Send a request to MPC. QueryWatermarkTemplateResponse queryWatermarkTemplateResponse = mpcClient.queryWatermarkTemplate(queryWatermarkTemplateRequest); // Return a message. System.out.println(new Gson().toJson(queryWatermarkTemplateResponse));
Full Code
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 51 52 53 54 55 56 57 58 |
import com.google.gson.Gson;
import com.huawei.mpc.client.ClientConfig;
import com.huawei.mpc.client.MpcClient;
import com.huawei.mpc.client.MpcConfig;
import com.huawei.mpc.model.watermark.QueryWatermarkTemplateRequest;
import com.huawei.mpc.model.watermark.QueryWatermarkTemplateResponse;
// Set the method for constructing MPC configuration items.
MpcConfig mpcConfig = new MpcConfig();
// Mandatory. Set the endpoint of MPC. For details, see section "Obtaining Key Parameters."
mpcConfig.setEndPoint(endPoint);
// Mandatory. Set the user's project ID. For details, see section "Obtaining Key Parameters."
mpcConfig.setProjectId(projectId);
// Mandatory. Set the SK. For details, see section "Obtaining Key Parameters."
mpcConfig.setSk(sk);
// Mandatory. Set the AK. For details, see section "Obtaining Key Parameters."
mpcConfig.setAk(ak);
/*if you need proxy*/
// Optional. Set the proxy if necessary.
/*
ClientConfig clientConfig = new ClientConfig();
// Set the IP address of the proxy server.
clientConfig.setProxyHost(proxyHost);
// Set the port number of the proxy server.
clientConfig.setProxyPort(Integer.parseInt(proxyPort));
// Set the username for accessing the proxy server.
clientConfig.setProxyUserName(proxyUserName);
// Set the password for accessing the proxy server.
clientConfig.setProxyPassword(proxyPassword);
*/
// MPC construction method
MpcClient mpcClient = new MpcClient(mpcConfig);
// If a proxy needs to be set, use this constructor to initialize MpcClient.
//MpcClient mpcClient =new MpcClient(mpcConfig, clientConfig);
// Set request parameters.
QueryWatermarkTemplateRequest queryWatermarkTemplateRequest = new QueryWatermarkTemplateRequest();
// 1. Query by template ID
String[] templateIdArray = new String[]{"template_id1", "template_id2", "template_id3"};
queryWatermarkTemplateRequest.setTemplateIds(templateIdArray);
// 2. Set the page number and number of records on each page.
// queryWatermarkTemplateRequest.setPage(2);
// queryWatermarkTemplateRequest.setSize(10);
// Send a request to MPC.
QueryWatermarkTemplateResponse queryWatermarkTemplateResponse = mpcClient.queryWatermarkTemplate(queryWatermarkTemplateRequest);
// Return a message.
System.out.println(new Gson().toJson(queryWatermarkTemplateResponse));
|
Last Article: Modifying a Watermark Template
Next Article: Deleting a Watermark Template
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.