forked from aws/aws-sdk-go-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
376 lines (324 loc) · 12.9 KB
/
api.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package kinesisvideomedia
import (
"io"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
"github.com/aws/aws-sdk-go-v2/private/protocol"
)
const opGetMedia = "GetMedia"
// GetMediaRequest is a API request type for the GetMedia API operation.
type GetMediaRequest struct {
*aws.Request
Input *GetMediaInput
Copy func(*GetMediaInput) GetMediaRequest
}
// Send marshals and sends the GetMedia API request.
func (r GetMediaRequest) Send() (*GetMediaOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*GetMediaOutput), nil
}
// GetMediaRequest returns a request value for making API operation for
// Amazon Kinesis Video Streams Media.
//
// Use this API to retrieve media content from a Kinesis video stream. In the
// request, you identify stream name or stream Amazon Resource Name (ARN), and
// the starting chunk. Kinesis Video Streams then returns a stream of chunks
// in order by fragment number.
//
// You must first call the GetDataEndpoint API to get an endpoint to which you
// can then send the GetMedia requests.
//
// When you put media data (fragments) on a stream, Kinesis Video Streams stores
// each incoming fragment and related metadata in what is called a "chunk."
// For more information, see . The GetMedia API returns a stream of these chunks
// starting from the chunk that you specify in the request.
//
// The following limits apply when using the GetMedia API:
//
// * A client can call GetMedia up to five times per second per stream.
//
// * Kinesis Video Streams sends media data at a rate of up to 25 megabytes
// per second (or 200 megabits per second) during a GetMedia session.
//
// // Example sending a request using the GetMediaRequest method.
// req := client.GetMediaRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesis-video-media-2017-09-30/GetMedia
func (c *KinesisVideoMedia) GetMediaRequest(input *GetMediaInput) GetMediaRequest {
op := &aws.Operation{
Name: opGetMedia,
HTTPMethod: "POST",
HTTPPath: "/getMedia",
}
if input == nil {
input = &GetMediaInput{}
}
output := &GetMediaOutput{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}
return GetMediaRequest{Request: req, Input: input, Copy: c.GetMediaRequest}
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesis-video-media-2017-09-30/GetMediaInput
type GetMediaInput struct {
_ struct{} `type:"structure"`
// Identifies the starting chunk to get from the specified stream.
//
// StartSelector is a required field
StartSelector *StartSelector `type:"structure" required:"true"`
// The ARN of the stream from where you want to get the media content. If you
// don't specify the streamARN, you must specify the streamName.
StreamARN *string `min:"1" type:"string"`
// The Kinesis video stream name from where you want to get the media content.
// If you don't specify the streamName, you must specify the streamARN.
StreamName *string `min:"1" type:"string"`
}
// String returns the string representation
func (s GetMediaInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s GetMediaInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *GetMediaInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "GetMediaInput"}
if s.StartSelector == nil {
invalidParams.Add(aws.NewErrParamRequired("StartSelector"))
}
if s.StreamARN != nil && len(*s.StreamARN) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("StreamARN", 1))
}
if s.StreamName != nil && len(*s.StreamName) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("StreamName", 1))
}
if s.StartSelector != nil {
if err := s.StartSelector.Validate(); err != nil {
invalidParams.AddNested("StartSelector", err.(aws.ErrInvalidParams))
}
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s GetMediaInput) MarshalFields(e protocol.FieldEncoder) error {
if s.StartSelector != nil {
v := s.StartSelector
metadata := protocol.Metadata{}
e.SetFields(protocol.BodyTarget, "StartSelector", v, metadata)
}
if s.StreamARN != nil {
v := *s.StreamARN
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "StreamARN", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.StreamName != nil {
v := *s.StreamName
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "StreamName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesis-video-media-2017-09-30/GetMediaOutput
type GetMediaOutput struct {
_ struct{} `type:"structure" payload:"Payload"`
responseMetadata aws.Response
// The content type of the requested media.
ContentType *string `location:"header" locationName:"Content-Type" min:"1" type:"string"`
// The payload Kinesis Video Streams returns is a sequence of chunks from the
// specified stream. For information about the chunks, see . The chunks that
// Kinesis Video Streams returns in the GetMedia call also include the following
// additional Matroska (MKV) tags:
//
// * AWS_KINESISVIDEO_CONTINUATION_TOKEN (UTF-8 string) - In the event your
// GetMedia call terminates, you can use this continuation token in your
// next request to get the next chunk where the last request terminated.
//
// * AWS_KINESISVIDEO_MILLIS_BEHIND_NOW (UTF-8 string) - Client applications
// can use this tag value to determine how far behind the chunk returned
// in the response is from the latest chunk on the stream.
//
// * AWS_KINESISVIDEO_FRAGMENT_NUMBER - Fragment number returned in the chunk.
//
// * AWS_KINESISVIDEO_SERVER_TIMESTAMP - Server time stamp of the fragment.
//
// * AWS_KINESISVIDEO_PRODUCER_TIMESTAMP - Producer time stamp of the fragment.
//
// The following tags will be present if an error occurs:
//
// * AWS_KINESISVIDEO_ERROR_CODE - String description of an error that caused
// GetMedia to stop.
//
// * AWS_KINESISVIDEO_ERROR_ID: Integer code of the error.
//
// The error codes are as follows:
//
// * 3002 - Error writing to the stream
//
// * 4000 - Requested fragment is not found
//
// * 4500 - Access denied for the stream's KMS key
//
// * 4501 - Stream's KMS key is disabled
//
// * 4502 - Validation error on the Stream's KMS key
//
// * 4503 - KMS key specified in the stream is unavailable
//
// * 4504 - Invalid usage of the KMS key specified in the stream
//
// * 4505 - Invalid state of the KMS key specified in the stream
//
// * 4506 - Unable to find the KMS key specified in the stream
//
// * 5000 - Internal error
Payload io.ReadCloser `type:"blob"`
}
// String returns the string representation
func (s GetMediaOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s GetMediaOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s GetMediaOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s GetMediaOutput) MarshalFields(e protocol.FieldEncoder) error {
if s.ContentType != nil {
v := *s.ContentType
metadata := protocol.Metadata{}
e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
// Skipping Payload Output type's body not valid.
return nil
}
// Identifies the chunk on the Kinesis video stream where you want the GetMedia
// API to start returning media data. You have the following options to identify
// the starting chunk:
//
// * Choose the latest (or oldest) chunk.
//
// * Identify a specific chunk. You can identify a specific chunk either
// by providing a fragment number or time stamp (server or producer).
//
// * Each chunk's metadata includes a continuation token as a Matroska (MKV)
// tag (AWS_KINESISVIDEO_CONTINUATION_TOKEN). If your previous GetMedia request
// terminated, you can use this tag value in your next GetMedia request.
// The API then starts returning chunks starting where the last API ended.
// Please also see https://docs.aws.amazon.com/goto/WebAPI/kinesis-video-media-2017-09-30/StartSelector
type StartSelector struct {
_ struct{} `type:"structure"`
// Specifies the fragment number from where you want the GetMedia API to start
// returning the fragments.
AfterFragmentNumber *string `min:"1" type:"string"`
// Continuation token that Kinesis Video Streams returned in the previous GetMedia
// response. The GetMedia API then starts with the chunk identified by the continuation
// token.
ContinuationToken *string `min:"1" type:"string"`
// Identifies the fragment on the Kinesis video stream where you want to start
// getting the data from.
//
// * NOW - Start with the latest chunk on the stream.
//
// * EARLIEST - Start with earliest available chunk on the stream.
//
// * FRAGMENT_NUMBER - Start with the chunk containing the specific fragment.
// You must also specify the StartFragmentNumber.
//
// * PRODUCER_TIMESTAMP or SERVER_TIMESTAMP - Start with the chunk containing
// a fragment with the specified producer or server time stamp. You specify
// the time stamp by adding StartTimestamp.
//
// * CONTINUATION_TOKEN - Read using the specified continuation token.
//
// If you choose the NOW, EARLIEST, or CONTINUATION_TOKEN as the startSelectorType,
// you don't provide any additional information in the startSelector.
//
// StartSelectorType is a required field
StartSelectorType StartSelectorType `type:"string" required:"true" enum:"true"`
// A time stamp value. This value is required if you choose the PRODUCER_TIMESTAMP
// or the SERVER_TIMESTAMP as the startSelectorType. The GetMedia API then starts
// with the chunk containing the fragment that has the specified time stamp.
StartTimestamp *time.Time `type:"timestamp" timestampFormat:"unix"`
}
// String returns the string representation
func (s StartSelector) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s StartSelector) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *StartSelector) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "StartSelector"}
if s.AfterFragmentNumber != nil && len(*s.AfterFragmentNumber) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("AfterFragmentNumber", 1))
}
if s.ContinuationToken != nil && len(*s.ContinuationToken) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("ContinuationToken", 1))
}
if len(s.StartSelectorType) == 0 {
invalidParams.Add(aws.NewErrParamRequired("StartSelectorType"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s StartSelector) MarshalFields(e protocol.FieldEncoder) error {
if s.AfterFragmentNumber != nil {
v := *s.AfterFragmentNumber
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "AfterFragmentNumber", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.ContinuationToken != nil {
v := *s.ContinuationToken
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "ContinuationToken", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if len(s.StartSelectorType) > 0 {
v := s.StartSelectorType
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "StartSelectorType", protocol.QuotedValue{ValueMarshaler: v}, metadata)
}
if s.StartTimestamp != nil {
v := *s.StartTimestamp
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "StartTimestamp", protocol.TimeValue{V: v, Format: protocol.UnixTimeFormat}, metadata)
}
return nil
}
type StartSelectorType string
// Enum values for StartSelectorType
const (
StartSelectorTypeFragmentNumber StartSelectorType = "FRAGMENT_NUMBER"
StartSelectorTypeServerTimestamp StartSelectorType = "SERVER_TIMESTAMP"
StartSelectorTypeProducerTimestamp StartSelectorType = "PRODUCER_TIMESTAMP"
StartSelectorTypeNow StartSelectorType = "NOW"
StartSelectorTypeEarliest StartSelectorType = "EARLIEST"
StartSelectorTypeContinuationToken StartSelectorType = "CONTINUATION_TOKEN"
)
func (enum StartSelectorType) MarshalValue() (string, error) {
return string(enum), nil
}
func (enum StartSelectorType) MarshalValueBuf(b []byte) ([]byte, error) {
b = b[0:0]
return append(b, enum...), nil
}