All Products
Search
Document Center

ApsaraVideo Media Processing:Manage MPS queues

Last Updated:Apr 07, 2024

An ApsaraVideo Media Processing (MPS) queue is a queue for processing jobs. After you submit asynchronous jobs, the jobs are queued for running based on the job priorities and the sequence in which the jobs are submitted. This topic provides examples on how to use the API operations that are encapsulated in MPS SDK for Python to manage MPS queues, such as creating, updating, deleting, and querying an MPS queue.

Query MPS queues in a specific state

You can call the SearchPipeline operation to query MPS queues in a specific state.

import os
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkmts.request.v20140618.SearchPipelineRequest import SearchPipelineRequest

# Obtain the AccessKey ID and AccessKey secret from environment variables.
credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'], os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'])
# The region_id parameter specifies the ID of the region in which your MPS service is deployed. For information about supported regions, visit https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/service-regions.
client = AcsClient(region_id = 'cn-shanghai', credential = credentials)

request = SearchPipelineRequest()
request.set_accept_format('json')

response = client.do_action_with_exception(request);
# Display the response.
print(str(response, encoding='utf-8'))

Query MPS queues based on queue IDs

You can call the QueryPipelineList operation to query one or more MPS queues based on the MPS queue IDs.

import os
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkmts.request.v20140618.QueryPipelineListRequest import QueryPipelineListRequest

# Obtain the AccessKey ID and AccessKey secret from environment variables.
credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'], os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'])
# The region_id parameter specifies the ID of the region in which your MPS service is deployed. For information about supported regions, visit https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/service-regions.
client = AcsClient(region_id = 'cn-shanghai', credential = credentials)

request = QueryPipelineListRequest()
request.set_PipelineIds('9bad3801a2c3d2c4df9c6****')
request.set_accept_format('json')

response = client.do_action_with_exception(request);
# Display the response.
print(str(response, encoding='utf-8'))

Update an MPS queue

You can call the UpdatePipeline operation to update an MPS queue, such as modifying the name and status of an MPS queue. The states of an MPS queue include Active and Paused.

import os

from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkmts.request.v20140618.UpdatePipelineRequest import UpdatePipelineRequest

# Obtain the AccessKey ID and AccessKey secret from environment variables.
credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'], os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'])
# The region_id parameter specifies the ID of the region in which your MPS service is deployed. For information about supported regions, visit https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/service-regions.
client = AcsClient(region_id = 'cn-shanghai', credential = credentials)

request = UpdatePipelineRequest()
request.set_PipelineId('91c22c4df9c6****')
request.set_Name('update name')
request.set_State('Active')

response = client.do_action_with_exception(request);
# Display the response.
print(str(response, encoding='utf-8'))

References