Querying Animated GIF Tasks

Notes

  • You can query animated GIF tasks by task ID, task status, time range, page number, or compound query.
  • In the query results, if the page number and maximum number of displayed records are not specified, but the number of records is greater than 10, 10 records are displayed by default on each page.

Query by Task ID

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// A maximum of 10 task IDs are supported.
QueryAnimatedGraphicsTaskReq queryAnimatedGraphicsTaskReq = new QueryAnimatedGraphicsTaskReq();
LinkedList<String> taskIds = new LinkedList<>();
taskIds.add("1234");
queryAnimatedGraphicsTaskReq.setTaskId(taskIds);

// Send a request to MPC.
QueryAnimatedGraphicsTaskRsp rsp = mpcClient.queryAnimatedGraphicsTask(queryAnimatedGraphicsTaskReq);
// Return a message.
System.out.println(new Gson().toJson(rsp));

Query by Page Number

1
2
3
4
5
6
7
8
// Set the page number and number of records on each page.
QueryAnimatedGraphicsTaskReq queryAnimatedGraphicsTaskReq = new QueryAnimatedGraphicsTaskReq();
queryAnimatedGraphicsTaskReq .setPage(1);
queryAnimatedGraphicsTaskReq .setSize(10);
// Send a request to MPC.
QueryAnimatedGraphicsTaskRsp rsp = mpcClient.queryAnimatedGraphicsTask(queryAnimatedGraphicsTaskReq);
// Return a message.
System.out.println(new Gson().toJson(rsp ));

Query by Time Range

1
2
3
4
5
6
7
8
// Set the start time and end time.
QueryAnimatedGraphicsTaskReq queryAnimatedGraphicsTaskReq = new QueryAnimatedGraphicsTaskReq();
queryAnimatedGraphicsTaskReq .setStartTime("20180520131400");
queryAnimatedGraphicsTaskReq .setEndTime("20180520141300");
// Send a request to MPC.
QueryAnimatedGraphicsTaskRsp rsp = mpcClient.queryAnimatedGraphicsTask(queryAnimatedGraphicsTaskReq);
// Return a message.
System.out.println(new Gson().toJson(rsp));

Query by Task Status

1
2
3
4
5
6
7
// Set the task status.
QueryAnimatedGraphicsTaskReq queryAnimatedGraphicsTaskReq = new QueryAnimatedGraphicsTaskReq();
queryAnimatedGraphicsTaskReq.setStatus(CommonTask.STATUS_SUCCEED);
// Send a request to MPC.
queryAnimatedGraphicsTaskReq rsp = mpcClient.queryAnimatedGraphicsTask(queryAnimatedGraphicsTaskReq);
// Return a message.
System.out.println(new Gson().toJson(rsp));

Compound Query

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// Set the following parameters:
QueryAnimatedGraphicsTaskReq queryAnimatedGraphicsTaskReq = new QueryAnimatedGraphicsTaskReq();
queryAnimatedGraphicsTaskReq .setPage(1);
queryAnimatedGraphicsTaskReq .setSize(10);
queryAnimatedGraphicsTaskReq .setStartTime("20180520131400");
queryAnimatedGraphicsTaskReq .setEndTime("20180520141300");
queryAnimatedGraphicsTaskReq.setStatus(CommonTask.STATUS_SUCCEED);
// Send a request to MPC.
queryAnimatedGraphicsTaskReq rsp = mpcClient.queryAnimatedGraphicsTask(queryAnimatedGraphicsTaskReq);
// Return a message.
System.out.println(new Gson().toJson(rsp));

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
package com.huawei.mpc;

import com.google.gson.Gson;
import com.huawei.mpc.client.MpcClient;
import com.huawei.mpc.client.MpcConfig;
import com.huawei.mpc.model.CommonTask;
import com.huawei.mpc.model.animated.QueryAnimatedGraphicsTaskReq;
import com.huawei.mpc.model.animated.QueryAnimatedGraphicsTaskRsp;

import java.util.LinkedList;

public class AnimatedQueryTest {
    public void queryAnimatedTask() {
        Gson gson = new Gson();

       // Initialize the client.
        MpcConfig mpcConfig = new MpcConfig();
        mpcConfig.setEndPoint("mpc.cn-north-4.myhuaweicloud.com");
        mpcConfig.setProjectId("Your project ID");
        mpcConfig.setAk("*************");
        mpcConfig.setSk("*****************************");

        MpcClient mpcClient = new MpcClient(mpcConfig);

        // Create a query instance.
        QueryAnimatedGraphicsTaskReq queryAnimatedGraphicsTaskReq = new QueryAnimatedGraphicsTaskReq();
        LinkedList<String> taskIds = new LinkedList<>();
        taskIds.add("1234");
        queryAnimatedGraphicsTaskReq.setStartTime("20180520131400");
        queryAnimatedGraphicsTaskReq.setEndTime("20180520141300");
        queryAnimatedGraphicsTaskReq.setPage(1);
        queryAnimatedGraphicsTaskReq.setSize(10);
        queryAnimatedGraphicsTaskReq.setTaskId(taskIds);
        queryAnimatedGraphicsTaskReq.setStatus(CommonTask.STATUS_SUCCEED);

        QueryAnimatedGraphicsTaskRsp queryResponse = mpcClient.queryAnimatedGraphicsTask(queryAnimatedGraphicsTaskReq);
       // Print the query results.
        System.out.println(gson.toJson(queryResponse));
    }
}