github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dis/v2/streams/GetStream.go (about)

     1  package streams
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags"
     7  )
     8  
     9  type GetStreamOpts struct {
    10  	// Stream to be queried.
    11  	// Maximum: 60
    12  	StreamName string
    13  	// Name of the partition to start the partition list with. The returned partition list does not contain this partition.
    14  	StartPartitionId string `q:"start_partitionId,omitempty"`
    15  	// Maximum number of partitions to list in a single API call. Value range: 1-1,000 Default value: 100
    16  	// Minimum: 1
    17  	// Maximum: 1000
    18  	// Default: 100
    19  	LimitPartitions *int `q:"limit_partitions,omitempty"`
    20  }
    21  
    22  func GetStream(client *golangsdk.ServiceClient, opts GetStreamOpts) (*DescribeStreamResponse, error) {
    23  	url, err := golangsdk.NewURLBuilder().WithEndpoints("streams", opts.StreamName).WithQueryParams(&opts).Build()
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	// GET /v2/{project_id}/streams/{stream_name}
    29  	raw, err := client.Get(client.ServiceURL(url.String()), nil,
    30  		&golangsdk.RequestOpts{
    31  			MoreHeaders: map[string]string{"Content-Type": "application/json"}, JSONBody: nil,
    32  		})
    33  	if err != nil {
    34  		return nil, err
    35  	}
    36  
    37  	var res DescribeStreamResponse
    38  	err = extract.Into(raw.Body, &res)
    39  	return &res, err
    40  }
    41  
    42  type DescribeStreamResponse struct {
    43  	// Name of the stream.
    44  	StreamName string `json:"stream_name,omitempty"`
    45  	// Time when a stream is created. The value is a 13-bit timestamp.
    46  	CreatedAt *int64 `json:"create_time,omitempty"`
    47  	// Time when a stream is the most recently modified. The value is a 13-bit timestamp.
    48  	LastModifiedTime *int64 `json:"last_modified_time,omitempty"`
    49  	// Current status of the stream. Possible values:
    50  	// CREATING: The stream is being created.
    51  	// RUNNING: The stream is running.
    52  	// TERMINATING: The stream is being deleted.
    53  	// TERMINATED: The stream has been deleted.
    54  	// Enumeration values:
    55  	// CREATING
    56  	// RUNNING
    57  	// TERMINATING
    58  	// FROZEN
    59  	Status string `json:"status,omitempty"`
    60  	// Stream type.
    61  	// COMMON: a common stream. The bandwidth is 1 MB/s.
    62  	// ADVANCED: an advanced stream. The bandwidth is 5 MB/s.
    63  	// Enumeration values:
    64  	// COMMON
    65  	// ADVANCED
    66  	StreamType string `json:"stream_type,omitempty"`
    67  	// A list of partitions that comprise the DIS stream.
    68  	Partitions []PartitionResult `json:"partitions,omitempty"`
    69  	// Specifies whether there are more matching partitions of the DIS stream to list.
    70  	// true: yes
    71  	// false: no
    72  	HasMorePartitions *bool `json:"has_more_partitions,omitempty"`
    73  	// Period for storing data in units of hours.
    74  	RetentionPeriod *int `json:"retention_period,omitempty"`
    75  	// Unique identifier of the stream.
    76  	StreamId string `json:"stream_id,omitempty"`
    77  	// Source data type
    78  	// BLOB: a set of binary data stored in a database management system.
    79  	// Default value: BLOB
    80  	// Enumeration values:
    81  	// BLOB
    82  	DataType string `json:"data_type,omitempty"`
    83  	// Source data structure that defines JSON and CSV formats.
    84  	// It is described in the syntax of the Avro schema.
    85  	// For details about Avro,
    86  	// go to http://avro.apache.org/docs/current/
    87  	DataSchema string `json:"data_schema,omitempty"`
    88  	// Compression type of data. Currently, the value can be:
    89  	// snappy
    90  	// gzip
    91  	// zip
    92  	// Data is not compressed by default.
    93  	// Enumeration values:
    94  	// snappy
    95  	// gzip
    96  	// zip
    97  	CompressionFormat string `json:"compression_format,omitempty"`
    98  	// Attributes of data in CSV format, such as delimiter.
    99  	CsvProperties CsvProperties `json:"csv_properties,omitempty"`
   100  	// Total number of writable partitions (including partitions in ACTIVE state only).
   101  	WritablePartitionCount *int `json:"writable_partition_count,omitempty"`
   102  	// Total number of readable partitions (including partitions in ACTIVE and DELETED state).
   103  	ReadablePartitionCount *int `json:"readable_partition_count,omitempty"`
   104  	// List of scaling operation records.
   105  	UpdatePartitionCounts []UpdatePartitionCountResponse `json:"update_partition_counts,omitempty"`
   106  	// List of stream tags.
   107  	Tags []tags.ResourceTag `json:"tags,omitempty"`
   108  	// Specifies whether to enable auto-scaling.
   109  	// true: auto-scaling is enabled.
   110  	// false: auto-scaling is disabled.
   111  	// This function is disabled by default.
   112  	AutoScaleEnabled *bool `json:"auto_scale_enabled,omitempty"`
   113  	// Minimum number of partitions for automatic scale-down when auto-scaling is enabled.
   114  	AutoScaleMinPartitionCount *int `json:"auto_scale_min_partition_count,omitempty"`
   115  	// Maximum number of partitions for automatic scale-up when auto-scaling is enabled.
   116  	AutoScaleMaxPartitionCount *int `json:"auto_scale_max_partition_count,omitempty"`
   117  }
   118  
   119  type PartitionResult struct {
   120  	// Current status of the partition. Possible values:
   121  	// CREATING: The stream is being created.
   122  	// ACTIVE: The stream is available.
   123  	// DELETED: The stream is being deleted.
   124  	// EXPIRED: The stream has expired.
   125  	// Enumeration values:
   126  	// CREATING
   127  	// ACTIVE
   128  	// DELETED
   129  	// EXPIRED
   130  	Status string `json:"status,omitempty"`
   131  	// Unique identifier of the partition.
   132  	PartitionId string `json:"partition_id,omitempty"`
   133  	// Possible value range of the hash key used by the partition.
   134  	HashRange string `json:"hash_range,omitempty"`
   135  	// Sequence number range of the partition.
   136  	SequenceNumberRange string `json:"sequence_number_range,omitempty"`
   137  	// Parent partition.
   138  	ParentPartitions string `json:"parent_partitions,omitempty"`
   139  }
   140  
   141  type UpdatePartitionCountResponse struct {
   142  	// Scaling execution timestamp, which is a 13-digit timestamp.
   143  	CreatedAt *int64 `json:"create_timestamp,omitempty"`
   144  	// Number of partitions before scaling.
   145  	SrcPartitionCount *int `json:"src_partition_count,omitempty"`
   146  	// Number of partitions after scaling.
   147  	TargetPartitionCount *int `json:"target_partition_count,omitempty"`
   148  	// Response code of the scaling operation.
   149  	ResultCode *int `json:"result_code,omitempty"`
   150  	// Response to the scaling operation.
   151  	ResultMsg *int `json:"result_msg,omitempty"`
   152  	// Specifies whether the scaling operation is automatic.
   153  	// true: Auto scaling is enabled.
   154  	// false: Manual scaling is enabled.
   155  	AutoScale *bool `json:"auto_scale,omitempty"`
   156  }