All Products
Search
Document Center

ApsaraVideo Media Processing:Manage MPS queues

Last Updated:Aug 28, 2023

This topic provides examples on how to call API operations that are encapsulated in ApsaraVideo Media Processing (MPS) SDK for PHP to manage MPS queues.

Create an MPS queue

You can call the AddPipeline operation to create an MPS queue.

<?php
require_once './aliyun-php-sdk-core/Config.php'; 
use Mts\Request\V20140618 as Mts;

function initMtsClient($accessKeyId, $accessKeySecret) {
    $regionId = 'cn-shanghai';  // The ID of the region in which your MPS service is deployed.
    $profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret);
    return new DefaultAcsClient($profile);
}


try {
    $client = initMtsClient(getenv('ALIBABA_CLOUD_ACCESS_KEY_ID'), getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'));
    $response = addPipeline($client);
    print_r($response);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

function addPipeline($client) {
    $request = new Mts\AddPipelineRequest();
    $request->setName("test-pipeline");
    $request->setSpeed('Standard');
    return $client->getAcsResponse($request);
}

Search for MPS queues

You can call the SearchPipeline operation to search for MPS queues in specific state.

<?php
require_once './aliyun-php-sdk-core/Config.php'; 
use Mts\Request\V20140618 as Mts;

function initMtsClient($accessKeyId, $accessKeySecret) {
    $regionId = 'cn-shanghai';  // The ID of the region in which your MPS service is deployed.
    $profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret);
    return new DefaultAcsClient($profile);
}


try {
    $client = initMtsClient(getenv('ALIBABA_CLOUD_ACCESS_KEY_ID'), getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'));
    $response = searchPipeline($client);
    print_r($response);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

function searchPipeline($client) {
    $request = new Mts\SearchPipelineRequest();
    $request->setState("Paused");
    $request->setAcceptFormat('JSON');
    return $client->getAcsResponse($request);
}

Query one or more MPS queues

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

<?php
require_once './aliyun-php-sdk-core/Config.php'; 
use Mts\Request\V20140618 as Mts;

function initMtsClient($accessKeyId, $accessKeySecret) {
    $regionId = 'cn-shanghai';  // The ID of the region in which your MPS service is deployed.
    $profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret);
    return new DefaultAcsClient($profile);
}


try {
    $client = initMtsClient(getenv('ALIBABA_CLOUD_ACCESS_KEY_ID'), getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'));
    $response = queryPipelineList($client);
    print_r($response);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

function queryPipelineList($client) {
    $request = new Mts\QueryPipelineListRequest();
    # The ID of the MPS queue. Separate multiple queue IDs with commas (,).
    $request->setPipelineIds("0ba6fb1ab75271a2e1293******");
    return $client->getAcsResponse($request);
}

Update an MPS queue

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

<?php
require_once './aliyun-php-sdk-core/Config.php'; 
use Mts\Request\V20140618 as Mts;

function initMtsClient($accessKeyId, $accessKeySecret) {
    $regionId = 'cn-shanghai';  // The ID of the region in which your MPS service is deployed.
    $profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret);
    return new DefaultAcsClient($profile);
}


try {
    $client = initMtsClient(getenv('ALIBABA_CLOUD_ACCESS_KEY_ID'), getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'));
    $response = updatePipeline($client);
    print_r($response);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

function updatePipeline($client) {
    $request = new Mts\UpdatePipelineRequest();
    $request->setPipelineId("0ba6fb15271a2e1293*******");
    $request->setName("update name");
    $request->setState("Paused");
    return $client->getAcsResponse($request);
}

Delete an MPS queue

You can call the DeletePipeline operation to delete an MPS queue.

<?php
require_once './aliyun-php-sdk-core/Config.php'; 
use Mts\Request\V20140618 as Mts;

function initMtsClient($accessKeyId, $accessKeySecret) {
    $regionId = 'cn-shanghai';  // The ID of the region in which your MPS service is deployed.
    $profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret);
    return new DefaultAcsClient($profile);
}


try {
    $client = initMtsClient(getenv('ALIBABA_CLOUD_ACCESS_KEY_ID'), getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'));
    $response = deletePipeline($client);
    print_r($response);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

function deletePipeline($client) {
    $request = new Mts\DeletePipelineRequest();
    $request->setPipelineId("0ba6fb1ab771a2e1293******");
    return $client->getAcsResponse($request);
}