Use Alibaba Cloud CLI to manage ApsaraVideo Live resources

Updated at:
Copy as MD

Alibaba Cloud CLI is a general-purpose command-line tool built on OpenAPI. You can use it to automate management and maintenance of ApsaraVideo Live resources. This topic walks through calling the DescribeLiveUserDomains operation to query streaming domain names as an example of using Alibaba Cloud CLI with ApsaraVideo Live.

Before you begin

Familiarize yourself with Alibaba Cloud CLI. For more information, see What is Alibaba Cloud CLI?

Step 1: Install Alibaba Cloud CLI

Install Alibaba Cloud CLI on your device. Select the installation package that matches your operating system:

  • Windows operating system: Windows

  • Linux operating system: Linux

  • macOS operating system: macOS

Alternatively, you can debug CLI commands in Cloud Shell, which has Alibaba Cloud CLI built in and keeps it up to date. For more information, see What is Cloud Shell?.

Step 2: Configure Alibaba Cloud CLI

Important

An Alibaba Cloud account has full access to all service APIs, which poses security risks. We recommend that you create a Resource Access Management (RAM) identity, grant only the required permissions based on the principle of least privilege, and then use the RAM identity to call API operations. For more information about the policies supported by ApsaraVideo Live, see ApsaraVideo Live system policies and ApsaraVideo Live custom policies.

Before you use Alibaba Cloud CLI, configure identity credentials and a region ID. Alibaba Cloud CLI supports various credential types. For more information, see Credential types. This example uses AccessKey pairs.

  1. Create a RAM user and create an AccessKey pair for the RAM user to configure identity credentials. For more information, see Create a RAM user and Create an AccessKey pair.

  2. Grant the required permissions to the RAM user. In this example, attach the AliyunLiveReadOnlyAccess policy to the RAM user. The policy grants the RAM user the read-only permissions on ApsaraVideo Live. For more information, see Grant permissions to a RAM user.

  3. Obtain the region ID for your API calls. For more information about the available regions of ApsaraVideo Live, see Endpoints.

    Note

    You can use the --region option to run a command in a specific region. This option overrides the region in the default credential configuration and environment variables. For more information, see Command line options for API calls.

  4. Use the AccessKey pair of the RAM user to configure AccessKey credentials in the profile named AkProfile. For more information, see Configuration examples.

Step 3: Generate a CLI command

  1. In OpenAPI Explorer, go to the DescribeLiveUserDomains debugging page.

  2. On the Parameters tab, configure the parameters. Then, click the CLI Example tab to view the generated sample CLI command.

  3. Copy the CLI command or debug the CLI command in Cloud Shell.

    • Click the image icon to start Cloud Shell and debug the CLI command in Cloud Shell.

    • Click the image icon to copy the CLI command to the clipboard. You can also paste the CLI command into your on-premises shell to run the command.

    Note

    When you paste the CLI command into your local shell, make sure the parameter formats match the requirements. For more information, see Parameter formats.

    OpenAPI Explorer adds the --region option to the generated CLI command by default. This option overrides the region in the default credential configuration and environment variables. You can remove it if you want to use the default region.

Step 4: Call the API operations of ApsaraVideo Live

Example 1: Query the supported API operations of ApsaraVideo Live by using Alibaba Cloud CLI

Run the --help option to list all supported API operations of ApsaraVideo Live. You can also view the supported API operations in List of operations by function.

  1. Run the following command:

    aliyun live --help
  2. View the command output.

    Product: live (ApsaraVideo Live)
    Version: 2016-11-01
    Available Api List:
        AddCasterComponent            Adds a component to a caster.
        AddCasterEpisode              Adds an episode to a caster.
        AddCasterEpisodeGroup         Adds an episode group.
        AddCasterEpisodeGroupContent  Adds content to an episode group.
        AddCasterLayout               Adds a layout to a caster.
        AddCasterProgram              Adds a program to a caster.
        AddCasterVideoResource        Adds a video resource. The number of video resources is limited by the caster inputs.
        AddCustomLiveStreamTranscode  Adds a custom transcoding configuration.
        AddLiveAIProduceRules
        AddLiveAISubtitle
        AddLiveAppRecordConfig        Configures application-based recording and saves the output to OSS.
        AddLiveAppSnapshotConfig      Configures snapshot capturing. The configuration takes effect after you restart streaming.
        AddLiveAudioAuditConfig       Adds a configuration for audio moderation.
        AddLiveAudioAuditNotifyConfig Adds a callback configuration for audio moderation.
        AddLiveCenterTransfer         Adds a stream relay configuration in Live Center.
        AddLiveDetectNotifyConfig     Adds a callback URL for content moderation.
        AddLiveDomain                 Adds a domain name. You can add only one domain name at a time.
        AddLiveDomainMapping          Adds a mapping between a streaming domain and an ingest domain.
        AddLiveDomainPlayMapping      Adds a mapping between a primary streaming domain and a secondary streaming domain.

Example 2: Query all domain names of ApsaraVideo Live within the account

Call the DescribeUserDomains operation of ApsaraVideo Live to query all streaming domain names in your account.

  1. Run the following command:

    aliyun live DescribeLiveUserDomains --LiveDomainType liveVideo
  2. View the command output.

    {
      "Domains": {
        "PageData": [
          {
            "Cname": "learn.developer.aliyundoc.com",
            "Description": "test",
            "DomainName": "demo.aliyundoc.com",
            "GmtCreated": "2017-08-29T12:15:36Z",
            "GmtModified": "2017-12-29T12:15:36Z",
            "LiveDomainStatus": "online",
            "LiveDomainType": "liveVideo",
            "RegionName": "cn-beijing",
            "ResourceGroupId": ""
          }
        ]
      },
      "PageNumber": 1,
      "PageSize": 100,
      "RequestId": "E4EBD2BF-5EB0-4476-8829-9D94E1B15267",
      "TotalCount": 1
    }
    Note

    If an error is returned when you call an API operation of ApsaraVideo Live, verify the input parameters and values against the error code.

    You can also copy the RequestId from the response or the SDK error message and use the OpenAPI Diagnostic Platform for self-service diagnostics.