1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package iot
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/aws-sdk-go-v2/service/iot/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a stream for delivering one or more large files in chunks over MQTT. A
15// stream transports data bytes in chunks or blocks packaged as MQTT messages from
16// a source like S3. You can have one or more files associated with a stream.
17// Requires permission to access the CreateStream
18// (https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions)
19// action.
20func (c *Client) CreateStream(ctx context.Context, params *CreateStreamInput, optFns ...func(*Options)) (*CreateStreamOutput, error) {
21	if params == nil {
22		params = &CreateStreamInput{}
23	}
24
25	result, metadata, err := c.invokeOperation(ctx, "CreateStream", params, optFns, c.addOperationCreateStreamMiddlewares)
26	if err != nil {
27		return nil, err
28	}
29
30	out := result.(*CreateStreamOutput)
31	out.ResultMetadata = metadata
32	return out, nil
33}
34
35type CreateStreamInput struct {
36
37	// The files to stream.
38	//
39	// This member is required.
40	Files []types.StreamFile
41
42	// An IAM role that allows the IoT service principal assumes to access your S3
43	// files.
44	//
45	// This member is required.
46	RoleArn *string
47
48	// The stream ID.
49	//
50	// This member is required.
51	StreamId *string
52
53	// A description of the stream.
54	Description *string
55
56	// Metadata which can be used to manage streams.
57	Tags []types.Tag
58
59	noSmithyDocumentSerde
60}
61
62type CreateStreamOutput struct {
63
64	// A description of the stream.
65	Description *string
66
67	// The stream ARN.
68	StreamArn *string
69
70	// The stream ID.
71	StreamId *string
72
73	// The version of the stream.
74	StreamVersion *int32
75
76	// Metadata pertaining to the operation's result.
77	ResultMetadata middleware.Metadata
78
79	noSmithyDocumentSerde
80}
81
82func (c *Client) addOperationCreateStreamMiddlewares(stack *middleware.Stack, options Options) (err error) {
83	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateStream{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateStream{}, middleware.After)
88	if err != nil {
89		return err
90	}
91	if err = addSetLoggerMiddleware(stack, options); err != nil {
92		return err
93	}
94	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
95		return err
96	}
97	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
98		return err
99	}
100	if err = addResolveEndpointMiddleware(stack, options); err != nil {
101		return err
102	}
103	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
104		return err
105	}
106	if err = addRetryMiddlewares(stack, options); err != nil {
107		return err
108	}
109	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
110		return err
111	}
112	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
113		return err
114	}
115	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
116		return err
117	}
118	if err = addClientUserAgent(stack); err != nil {
119		return err
120	}
121	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
122		return err
123	}
124	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
125		return err
126	}
127	if err = addOpCreateStreamValidationMiddleware(stack); err != nil {
128		return err
129	}
130	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateStream(options.Region), middleware.Before); err != nil {
131		return err
132	}
133	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
134		return err
135	}
136	if err = addResponseErrorMiddleware(stack); err != nil {
137		return err
138	}
139	if err = addRequestResponseLogging(stack, options); err != nil {
140		return err
141	}
142	return nil
143}
144
145func newServiceMetadataMiddleware_opCreateStream(region string) *awsmiddleware.RegisterServiceMetadata {
146	return &awsmiddleware.RegisterServiceMetadata{
147		Region:        region,
148		ServiceID:     ServiceID,
149		SigningName:   "execute-api",
150		OperationName: "CreateStream",
151	}
152}
153