查询直播拉流转推任务 - ListPullTasks
功能介绍
查询直播拉流转推任务。
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,需具备如下身份策略权限。
授权项
访问级别
资源类型(*为必须)
条件键
别名
依赖的授权项
live:stream:listPullTask
Read
-
-
-
-
URI
GET /v1/{project_id}/pull/stream/task
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| project_id | 是 | String | 项目ID,获取方法请参考获取项目ID。 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| region | 否 | String | 参数解释: 任务所在区域 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| offset | 否 | Integer | 参数解释: 偏移量 约束限制: 不涉及 默认取值: 不涉及 取值范围: 0~2147483647 |
| limit | 否 | Integer | 参数解释: 每页记录数 约束限制: 不涉及 默认取值: 不涉及 取值范围: 1~100 |
| task_id | 否 | String | 参数解释: 任务ID 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| X-Auth-Token | 否 | String | 用户Token,使用Token鉴权方式时必填。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| task_infos | Array of LivePullTaskInfo objects | 参数解释: 直播拉流任务列表 |
| request_id | String | 参数解释: 请求ID 取值范围: 不涉及 |
| total | Integer | 参数解释: 总条目数 取值范围: 0~10000 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| task_id | String | 参数解释: 任务ID 取值范围: 不涉及 |
| status | String | 参数解释: 任务状态 取值范围: 不涉及 |
| create_time | String | 参数解释: 创建时间 取值范围: 不涉及 |
| region | String | 参数解释: 任务执行区域 取值范围: 不涉及 |
| source_type | String | 参数解释: 拉流源类型 取值范围: |
| source_urls | Array of strings | 参数解释: 拉流源URL |
| domain | String | 参数解释: 直播推流域名 取值范围: 字符长度为[1-255]位 |
| app_name | String | 参数解释: 应用名称 取值范围: 字符长度为[1-128]位 |
| stream_name | String | 参数解释: 流名称 取值范围: 字符长度为[1-512]位 |
| push_args | String | 参数解释: 推流参数 取值范围: 不涉及 |
| destination_url | String | 参数解释: 完整的目标URL。 取值范围: |
| start_time | String | 参数解释: 任务启动时间,时间格式:"2006-01-02T15:04:05Z"。 取值范围: 不涉及 |
| end_time | String | 参数解释: 任务结束时间,时间格式:"2006-01-02T15:04:05Z"。 取值范围: 不涉及 |
| callback_events | Array of strings | 参数解释: 要回调的事件列表(不填则回调全部) |
| callback_url | String | 参数解释: 回调接收地址 取值范围: 不涉及 |
| backup_source_type | String | 参数解释: 备源的类型 取值范围: PullLivePushLive:直播 |
| backup_source_urls | Array of strings | 参数解释: 备源URL。数组长度为[0,30],且仅当source_type为PullVodPushLive生效。 |
| vod_loop_time | String | 参数解释: 视频播放循环次数,仅当source_type为PullVodPushLive生效。 取值范围: |
| vod_start_video_index | Integer | 参数解释: 播放文件索引,从0开始表示第一个文件,最大值 len(source_urls)-1。仅当source_type为PullVodPushLive生效。 取值范围: 0~8192 |
| vod_start_video_time | Integer | 参数解释: 指定从上述指定文件的第几秒开始播放,仅当source_type为PullVodPushLive生效。 取值范围: 0~2100000000 |
| vod_refresh_type | String | 参数解释: 修改任务时文件切换方式 取值范围: |
状态码:400
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误码 |
| error_msg | String | 错误描述 |
| request_id | String | 请求id |
状态码:404
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误码 |
| error_msg | String | 错误描述 |
| request_id | String | 请求id |
请求示例
GET https://{endpoint}/v1/{project_id}/pull/stream/task?region=cn-north-4&task_id=xxxxxx 响应示例
状态码:200
查询直播拉流转推任务成功
{
"request_id" : "85968475-e92f-42db-a754-08e627b6d8dd",
"total" : 1,
"task_infos" : [ {
"task_id" : "7864b3dc-e92f-42db-a754-08e627b6d8dd",
"status" : "suspend",
"create_time" : "2018-05-19T10:00:00Z",
"region" : "cn-north-4",
"source_type" : "PullLivePushLive",
"source_urls" : [ "rtmp://play.example.huawei.com/live/stream1" ],
"domain" : "publish.example.huawei.com",
"app_name" : "live",
"stream_name" : "test",
"start_time" : "2018-05-19T18:00:00Z",
"end_time" : "2018-05-19T21:00:00Z",
"push_args" : "arg1=value1",
"destination_url" : "",
"callback_events" : [ "TaskStart", "TaskExit", "TaskAlarm" ],
"callback_url" : "callback.example.com",
"backup_source_type" : "PullLivePushLive",
"backup_source_urls" : [ "rtmp://play.example.huawei.com/live/stream1_bak" ]
} ]
} 状态码:400
查询直播拉流转推任务失败
{
"error_code" : "LIVE.100011001",
"error_msg" : "Request Illegal",
"request_id" : "85968475-e92f-42db-a754-08e627b6d8dd"
} 状态码:404
任务不存在
{
"error_code" : "LIVE.100011001",
"error_msg" : "Request Illegal",
"request_id" : "85968475-e92f-42db-a754-08e627b6d8dd"
} SDK代码示例
SDK代码示例如下。
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 | package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.live.v1.region.LiveRegion; import com.huaweicloud.sdk.live.v1.*; import com.huaweicloud.sdk.live.v1.model.*; public class ListPullTasksSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); LiveClient client = LiveClient.newBuilder() .withCredential(auth) .withRegion(LiveRegion.valueOf("<YOUR REGION>")) .build(); ListPullTasksRequest request = new ListPullTasksRequest(); try { ListPullTasksResponse response = client.listPullTasks(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
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 | # coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdklive.v1.region.live_region import LiveRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdklive.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = LiveClient.new_builder() \ .with_credentials(credentials) \ .with_region(LiveRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListPullTasksRequest() response = client.list_pull_tasks(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
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 | package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" live "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := live.LiveClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := live.NewLiveClient(hcClient) request := &model.ListPullTasksRequest{} response, err := client.ListPullTasks(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
| 状态码 | 描述 |
|---|---|
| 200 | 查询直播拉流转推任务成功 |
| 400 | 查询直播拉流转推任务失败 |
| 404 | 任务不存在 |
错误码
请参见错误码。