Updated on 2024-10-21 GMT+08:00

Querying Details of a Stream

Function

This API is used to query details about a specified stream.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/streams/{stream_name}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

stream_name

Yes

String

Name of the stream to be queried

Maximum: 60

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

start_partitionId

No

String

Name of the partition to start the partition list with. The returned partition list does not contain this partition.

limit_partitions

No

Integer

Max. number of partitions to list in a single API call.

Minimum: 1

Maximum: 1000

Default: 100

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

stream_name

String

Stream name

create_time

Long

Time when the stream is created. The value is a 13-bit timestamp.

last_modified_time

Long

Time when a stream is the most recently modified. The value is a 13-bit timestamp.

status

String

Current status of the stream.

  • CREATING

  • RUNNING

  • TERMINATING

  • TERMINATED

Enumeration values:

  • CREATING

  • RUNNING

  • TERMINATING

  • FROZEN

stream_type

String

Stream type

  • COMMON: a common stream with a bandwidth of 1 Mbit/s

  • ADVANCED: an advanced stream with a bandwidth of 5 Mbit/s

Enumeration values:

  • COMMON

  • ADVANCED

partitions

Array of PartitionResult objects

Partition list of the stream

has_more_partitions

Boolean

Whether there are more matching partitions.

  • true: yes

  • false: no

retention_period

Integer

Period for storing data in units of hours

stream_id

String

Unique identifier of the stream

data_type

String

Source data type.

  • BLOB: a collection of binary data stored as a single entity in a database management system

  • JSON: an open-standard file format that uses human-readable text to transmit data objects consisting of attribute-value pairs and array data types

  • CSV: a simple text format for storing tabular data in a plain text file. Commas are used as delimiters.

Default value: BLOB

Enumeration values:

  • BLOB

  • JSON

  • CSV

data_schema

String

Source data structure that defines JSON and CSV formats. It is described in the syntax of the Avro schema. For details about Avro, go to http://avro.apache.org/docs/current/#schemas.

compression_format

String

Data compression type. Currently, the following compression types are supported:

  • snappy

  • gzip

  • zip

By default, data is not compressed.

Enumeration values:

  • snappy

  • gzip

  • zip

csv_properties

CSVProperties object

Attributes of data in CSV format, such as delimiter

writable_partition_count

Integer

Total number of writable partitions (including partitions in ACTIVE state only)

readable_partition_count

Integer

Total number of readable partitions (including partitions in ACTIVE and DELETED state).

update_partition_counts

Array of UpdatePartitionCount objects

List of scaling operation records

tags

Array of Tag objects

List of stream tags

sys_tags

Array of SysTag objects

Enterprise project of a stream

auto_scale_enabled

Boolean

Whether to enable auto scaling.

  • true: Auto scaling is enabled.

  • false: Auto scaling is disabled.

By default, auto scaling is disabled.

auto_scale_min_partition_count

Integer

Minimum number of partitions for automatic scale-down when auto scaling is enabled.

auto_scale_max_partition_count

Integer

Maximum number of partitions for automatic scale-up when auto scaling is enabled.

Table 5 PartitionResult

Parameter

Type

Description

status

String

Current status of the partition

  • CREATING

  • ACTIVE

  • DELETED

  • EXPIRED

Enumeration values:

  • CREATING

  • ACTIVE

  • DELETED

  • EXPIRED

partition_id

String

Unique identifier of the partition

hash_range

String

Possible value range of the hash key used by the partition

sequence_number_range

String

Sequence number range of the partition

parent_partitions

String

Parent partition

Table 6 CSVProperties

Parameter

Type

Description

delimiter

String

Data separator

Table 7 UpdatePartitionCount

Parameter

Type

Description

create_timestamp

Long

Scaling execution timestamp, which is a 13-digit timestamp.

src_partition_count

Integer

Number of partitions before scaling

target_partition_count

Integer

Number of partitions after scaling

result_code

Integer

Response code of the scaling operation

result_msg

Integer

Response to the scaling operation

auto_scale

Boolean

Whether the scaling operation is automatic

  • true: auto scaling

  • false: manual scaling

Table 8 Tag

Parameter

Type

Description

key

String

Tag key.

  • It cannot be left blank.

  • It must be unique for each resource.

  • It can contain uppercase and lowercase letters, digits, hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF).

Minimum: 1

Maximum: 36

value

String

Value.

  • It can contain a maximum of 43 characters.

  • It can contain uppercase and lowercase letters, digits, periods (.), hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF).

  • It can only contain digits, letters, hyphens (-), and underscores (_).

Minimum: 0

Maximum: 43

Table 9 SysTag

Parameter

Type

Description

key

String

Tag key.

  • It cannot be left blank.

  • Its value must be _sys_enterprise_project_id.

status

String

Enumeration values:

  • _sys_enterprise_project_id

value

String

Value.

The value is the enterprise project ID, which needs to be obtained on the enterprise management page.

  • It is a 36-digit UUID.

Example Requests

Querying Details of a Stream

GET https://{Endpoint}/v2/{project_id}/streams/{stream_name}

Example Responses

Status code: 200

Normal response

{
  "stream_id" : "8QM3Nt9YTLOwtUVYJhO",
  "stream_name" : "newstream",
  "create_time" : 1593569685875,
  "last_modified_time" : "1599050091026,",
  "retention_period" : 24,
  "status" : "RUNNING",
  "stream_type" : "COMMON",
  "data_type" : "BLOB",
  "writable_partition_count" : 1,
  "readable_partition_count" : 1,
  "tags" : [ ],
  "auto_scale_enabled" : false,
  "auto_scale_min_partition_count" : 0,
  "auto_scale_max_partition_count" : 0,
  "partitions" : [ {
    "status" : "ACTIVE",
    "partition_id" : "shardId-0000000000",
    "hash_range" : "[0 : 9223372036854775807]",
    "sequence_number_range" : "[289911 : 289927]"
  } ],
  "has_more_partitions" : false
}

SDK Sample Code

The SDK sample code is as follows.

Java

 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.dis.v2.region.DisRegion;
import com.huaweicloud.sdk.dis.v2.*;
import com.huaweicloud.sdk.dis.v2.model.*;


public class ShowStreamSolution {

    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");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        DisClient client = DisClient.newBuilder()
                .withCredential(auth)
                .withRegion(DisRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowStreamRequest request = new ShowStreamRequest();
        request.withStartPartitionId("<start_partitionId>");
        request.withLimitPartitions(<limit_partitions>);
        try {
            ShowStreamResponse response = client.showStream(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());
        }
    }
}

Python

 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdis.v2.region.dis_region import DisRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdis.v2 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"]

    credentials = BasicCredentials(ak, sk)

    client = DisClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DisRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ShowStreamRequest()
        request.start_partition_id = "<start_partitionId>"
        request.limit_partitions = <limit_partitions>
        response = client.show_stream(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dis "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/v2/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")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := dis.NewDisClient(
        dis.DisClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ShowStreamRequest{}
	startPartitionIdRequest:= "<start_partitionId>"
	request.StartPartitionId = &startPartitionIdRequest
	limitPartitionsRequest:= int32(<limit_partitions>)
	request.LimitPartitions = &limitPartitionsRequest
	response, err := client.ShowStream(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

More

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Normal response

Error Codes

See Error Codes.