1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package kinesis
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Creates a Kinesis data stream. A stream captures and transports data records
14// that are continuously emitted from different data sources or producers.
15// Scale-out within a stream is explicitly supported by means of shards, which are
16// uniquely identified groups of data records in a stream. You specify and control
17// the number of shards that a stream is composed of. Each shard can support reads
18// up to five transactions per second, up to a maximum data read total of 2 MiB per
19// second. Each shard can support writes up to 1,000 records per second, up to a
20// maximum data write total of 1 MiB per second. If the amount of data input
21// increases or decreases, you can add or remove shards. The stream name identifies
22// the stream. The name is scoped to the AWS account used by the application. It is
23// also scoped by AWS Region. That is, two streams in two different accounts can
24// have the same name, and two streams in the same account, but in two different
25// Regions, can have the same name. CreateStream is an asynchronous operation. Upon
26// receiving a CreateStream request, Kinesis Data Streams immediately returns and
27// sets the stream status to CREATING. After the stream is created, Kinesis Data
28// Streams sets the stream status to ACTIVE. You should perform read and write
29// operations only on an ACTIVE stream. You receive a LimitExceededException when
30// making a CreateStream request when you try to do one of the following:
31//
32// * Have
33// more than five streams in the CREATING state at any point in time.
34//
35// * Create
36// more shards than are authorized for your account.
37//
38// For the default shard limit
39// for an AWS account, see Amazon Kinesis Data Streams Limits
40// (https://docs.aws.amazon.com/kinesis/latest/dev/service-sizes-and-limits.html)
41// in the Amazon Kinesis Data Streams Developer Guide. To increase this limit,
42// contact AWS Support
43// (https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html). You can
44// use DescribeStream to check the stream status, which is returned in
45// StreamStatus. CreateStream has a limit of five transactions per second per
46// account.
47func (c *Client) CreateStream(ctx context.Context, params *CreateStreamInput, optFns ...func(*Options)) (*CreateStreamOutput, error) {
48	if params == nil {
49		params = &CreateStreamInput{}
50	}
51
52	result, metadata, err := c.invokeOperation(ctx, "CreateStream", params, optFns, addOperationCreateStreamMiddlewares)
53	if err != nil {
54		return nil, err
55	}
56
57	out := result.(*CreateStreamOutput)
58	out.ResultMetadata = metadata
59	return out, nil
60}
61
62// Represents the input for CreateStream.
63type CreateStreamInput struct {
64
65	// The number of shards that the stream will use. The throughput of the stream is a
66	// function of the number of shards; more shards are required for greater
67	// provisioned throughput.
68	//
69	// This member is required.
70	ShardCount *int32
71
72	// A name to identify the stream. The stream name is scoped to the AWS account used
73	// by the application that creates the stream. It is also scoped by AWS Region.
74	// That is, two streams in two different AWS accounts can have the same name. Two
75	// streams in the same AWS account but in two different Regions can also have the
76	// same name.
77	//
78	// This member is required.
79	StreamName *string
80}
81
82type CreateStreamOutput struct {
83	// Metadata pertaining to the operation's result.
84	ResultMetadata middleware.Metadata
85}
86
87func addOperationCreateStreamMiddlewares(stack *middleware.Stack, options Options) (err error) {
88	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateStream{}, middleware.After)
89	if err != nil {
90		return err
91	}
92	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateStream{}, middleware.After)
93	if err != nil {
94		return err
95	}
96	if err = addSetLoggerMiddleware(stack, options); err != nil {
97		return err
98	}
99	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
100		return err
101	}
102	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
103		return err
104	}
105	if err = addResolveEndpointMiddleware(stack, options); err != nil {
106		return err
107	}
108	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
109		return err
110	}
111	if err = addRetryMiddlewares(stack, options); err != nil {
112		return err
113	}
114	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
115		return err
116	}
117	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
118		return err
119	}
120	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
121		return err
122	}
123	if err = addClientUserAgent(stack); err != nil {
124		return err
125	}
126	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
127		return err
128	}
129	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addOpCreateStreamValidationMiddleware(stack); err != nil {
133		return err
134	}
135	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateStream(options.Region), middleware.Before); err != nil {
136		return err
137	}
138	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
139		return err
140	}
141	if err = addResponseErrorMiddleware(stack); err != nil {
142		return err
143	}
144	if err = addRequestResponseLogging(stack, options); err != nil {
145		return err
146	}
147	return nil
148}
149
150func newServiceMetadataMiddleware_opCreateStream(region string) *awsmiddleware.RegisterServiceMetadata {
151	return &awsmiddleware.RegisterServiceMetadata{
152		Region:        region,
153		ServiceID:     ServiceID,
154		SigningName:   "kinesis",
155		OperationName: "CreateStream",
156	}
157}
158