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

     1  package streams
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags"
     7  )
     8  
     9  type CreateStreamOpts struct {
    10  	// Name of the stream.
    11  	// The stream name can contain 1 to 64 characters, including letters, digits, underscores (_), and hyphens (-).
    12  	// Maximum: 64
    13  	StreamName string `json:"stream_name"`
    14  	// Number of partitions. Partitions are the base throughput unit of a DIS stream.
    15  	PartitionCount int `json:"partition_count"`
    16  	// Stream type.
    17  	// COMMON: a common stream. The bandwidth is 1 MB/s.
    18  	// ADVANCED: an advanced stream. The bandwidth is 5 MB/s.
    19  	// Enumeration values:
    20  	// COMMON
    21  	// ADVANCED
    22  	StreamType string `json:"stream_type,omitempty"`
    23  	// Source data type.
    24  	// BLOB: a set of binary data stored in a database management system.
    25  	// Default value: BLOB
    26  	// Enumeration values:
    27  	// BLOB
    28  	DataType string `json:"data_type,omitempty"`
    29  	// Period of time for which data is retained in the stream.
    30  	// Value range: 24-72
    31  	// Unit: hour
    32  	// Default value: 24
    33  	// If this parameter is left blank, the default value is used.
    34  	// Maximum: 7
    35  	// Default: 24
    36  	DataDuration *int `json:"data_duration,omitempty"`
    37  	// Specifies whether to enable auto-scaling.
    38  	// true: Auto scaling is enabled.
    39  	// false: Auto scaling is disabled.
    40  	// This function is disabled by default.
    41  	// Default: false
    42  	AutoScaleEnabled *bool `json:"auto_scale_enabled,omitempty"`
    43  	// Minimum number of partitions for automatic scale-down when auto-scaling is enabled.
    44  	// Minimum: 1
    45  	AutoScaleMinPartitionCount *int `json:"auto_scale_min_partition_count,omitempty"`
    46  	// Maximum number of partitions for automatic scale-up when auto-scaling is enabled.
    47  	AutoScaleMaxPartitionCount *int `json:"auto_scale_max_partition_count,omitempty"`
    48  	// Source data structure that defines JSON and CSV formats.
    49  	// It is described in the syntax of the Avro schema.
    50  	DataSchema string `json:"data_schema,omitempty"`
    51  	// Attributes of data in CSV format, such as delimiter.
    52  	CsvProperties CsvProperties `json:"csv_properties,omitempty"`
    53  	// Compression type of data. Currently, the value can be:
    54  	// snappy
    55  	// gzip
    56  	// zip
    57  	// Data is not compressed by default.
    58  	// Enumeration values:
    59  	// snappy
    60  	// gzip
    61  	// zip
    62  	CompressionFormat string `json:"compression_format,omitempty"`
    63  	// List of stream tags.
    64  	Tags []tags.ResourceTag `json:"tags,omitempty"`
    65  }
    66  
    67  type CsvProperties struct {
    68  	// Data separator.
    69  	Delimiter string `json:"delimiter,omitempty"`
    70  }
    71  
    72  func CreateStream(client *golangsdk.ServiceClient, opts CreateStreamOpts) error {
    73  	b, err := build.RequestBody(opts, "")
    74  	if err != nil {
    75  		return err
    76  	}
    77  
    78  	// POST /v2/{project_id}/streams
    79  	_, err = client.Post(client.ServiceURL("streams"), b, nil, &golangsdk.RequestOpts{
    80  		OkCodes: []int{201},
    81  	})
    82  	return err
    83  }