1 package media
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type StreamingEndpointsClient struct {
20 BaseClient
21 }
22
23
24 func NewStreamingEndpointsClient(subscriptionID string) StreamingEndpointsClient {
25 return NewStreamingEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewStreamingEndpointsClientWithBaseURI(baseURI string, subscriptionID string) StreamingEndpointsClient {
32 return StreamingEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41
42 func (client StreamingEndpointsClient) Create(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint, autoStart *bool) (result StreamingEndpointsCreateFuture, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Create")
45 defer func() {
46 sc := -1
47 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
48 sc = result.FutureAPI.Response().StatusCode
49 }
50 tracing.EndSpan(ctx, sc, err)
51 }()
52 }
53 if err := validation.Validate([]validation.Validation{
54 {TargetValue: streamingEndpointName,
55 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
56 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
57 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}},
58 {TargetValue: parameters,
59 Constraints: []validation.Constraint{{Target: "parameters.StreamingEndpointProperties", Name: validation.Null, Rule: false,
60 Chain: []validation.Constraint{{Target: "parameters.StreamingEndpointProperties.ScaleUnits", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
61 return result, validation.NewError("media.StreamingEndpointsClient", "Create", err.Error())
62 }
63
64 req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, streamingEndpointName, parameters, autoStart)
65 if err != nil {
66 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Create", nil, "Failure preparing request")
67 return
68 }
69
70 result, err = client.CreateSender(req)
71 if err != nil {
72 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Create", result.Response(), "Failure sending request")
73 return
74 }
75
76 return
77 }
78
79
80 func (client StreamingEndpointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint, autoStart *bool) (*http.Request, error) {
81 pathParameters := map[string]interface{}{
82 "accountName": autorest.Encode("path", accountName),
83 "resourceGroupName": autorest.Encode("path", resourceGroupName),
84 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
85 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
86 }
87
88 const APIVersion = "2021-11-01"
89 queryParameters := map[string]interface{}{
90 "api-version": APIVersion,
91 }
92 if autoStart != nil {
93 queryParameters["autoStart"] = autorest.Encode("query", *autoStart)
94 }
95
96 parameters.SystemData = nil
97 preparer := autorest.CreatePreparer(
98 autorest.AsContentType("application/json; charset=utf-8"),
99 autorest.AsPut(),
100 autorest.WithBaseURL(client.BaseURI),
101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", pathParameters),
102 autorest.WithJSON(parameters),
103 autorest.WithQueryParameters(queryParameters))
104 return preparer.Prepare((&http.Request{}).WithContext(ctx))
105 }
106
107
108
109 func (client StreamingEndpointsClient) CreateSender(req *http.Request) (future StreamingEndpointsCreateFuture, err error) {
110 var resp *http.Response
111 future.FutureAPI = &azure.Future{}
112 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
113 if err != nil {
114 return
115 }
116 var azf azure.Future
117 azf, err = azure.NewFutureFromResponse(resp)
118 future.FutureAPI = &azf
119 future.Result = future.result
120 return
121 }
122
123
124
125 func (client StreamingEndpointsClient) CreateResponder(resp *http.Response) (result StreamingEndpoint, err error) {
126 err = autorest.Respond(
127 resp,
128 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
129 autorest.ByUnmarshallingJSON(&result),
130 autorest.ByClosing())
131 result.Response = autorest.Response{Response: resp}
132 return
133 }
134
135
136
137
138
139
140 func (client StreamingEndpointsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (result StreamingEndpointsDeleteFuture, err error) {
141 if tracing.IsEnabled() {
142 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Delete")
143 defer func() {
144 sc := -1
145 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
146 sc = result.FutureAPI.Response().StatusCode
147 }
148 tracing.EndSpan(ctx, sc, err)
149 }()
150 }
151 if err := validation.Validate([]validation.Validation{
152 {TargetValue: streamingEndpointName,
153 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
154 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
155 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
156 return result, validation.NewError("media.StreamingEndpointsClient", "Delete", err.Error())
157 }
158
159 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, streamingEndpointName)
160 if err != nil {
161 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Delete", nil, "Failure preparing request")
162 return
163 }
164
165 result, err = client.DeleteSender(req)
166 if err != nil {
167 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Delete", result.Response(), "Failure sending request")
168 return
169 }
170
171 return
172 }
173
174
175 func (client StreamingEndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (*http.Request, error) {
176 pathParameters := map[string]interface{}{
177 "accountName": autorest.Encode("path", accountName),
178 "resourceGroupName": autorest.Encode("path", resourceGroupName),
179 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
180 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
181 }
182
183 const APIVersion = "2021-11-01"
184 queryParameters := map[string]interface{}{
185 "api-version": APIVersion,
186 }
187
188 preparer := autorest.CreatePreparer(
189 autorest.AsDelete(),
190 autorest.WithBaseURL(client.BaseURI),
191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", pathParameters),
192 autorest.WithQueryParameters(queryParameters))
193 return preparer.Prepare((&http.Request{}).WithContext(ctx))
194 }
195
196
197
198 func (client StreamingEndpointsClient) DeleteSender(req *http.Request) (future StreamingEndpointsDeleteFuture, err error) {
199 var resp *http.Response
200 future.FutureAPI = &azure.Future{}
201 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
202 if err != nil {
203 return
204 }
205 var azf azure.Future
206 azf, err = azure.NewFutureFromResponse(resp)
207 future.FutureAPI = &azf
208 future.Result = future.result
209 return
210 }
211
212
213
214 func (client StreamingEndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
215 err = autorest.Respond(
216 resp,
217 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
218 autorest.ByClosing())
219 result.Response = resp
220 return
221 }
222
223
224
225
226
227
228 func (client StreamingEndpointsClient) Get(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (result StreamingEndpoint, err error) {
229 if tracing.IsEnabled() {
230 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Get")
231 defer func() {
232 sc := -1
233 if result.Response.Response != nil {
234 sc = result.Response.Response.StatusCode
235 }
236 tracing.EndSpan(ctx, sc, err)
237 }()
238 }
239 if err := validation.Validate([]validation.Validation{
240 {TargetValue: streamingEndpointName,
241 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
242 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
243 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
244 return result, validation.NewError("media.StreamingEndpointsClient", "Get", err.Error())
245 }
246
247 req, err := client.GetPreparer(ctx, resourceGroupName, accountName, streamingEndpointName)
248 if err != nil {
249 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Get", nil, "Failure preparing request")
250 return
251 }
252
253 resp, err := client.GetSender(req)
254 if err != nil {
255 result.Response = autorest.Response{Response: resp}
256 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Get", resp, "Failure sending request")
257 return
258 }
259
260 result, err = client.GetResponder(resp)
261 if err != nil {
262 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Get", resp, "Failure responding to request")
263 return
264 }
265
266 return
267 }
268
269
270 func (client StreamingEndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (*http.Request, error) {
271 pathParameters := map[string]interface{}{
272 "accountName": autorest.Encode("path", accountName),
273 "resourceGroupName": autorest.Encode("path", resourceGroupName),
274 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
275 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
276 }
277
278 const APIVersion = "2021-11-01"
279 queryParameters := map[string]interface{}{
280 "api-version": APIVersion,
281 }
282
283 preparer := autorest.CreatePreparer(
284 autorest.AsGet(),
285 autorest.WithBaseURL(client.BaseURI),
286 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", pathParameters),
287 autorest.WithQueryParameters(queryParameters))
288 return preparer.Prepare((&http.Request{}).WithContext(ctx))
289 }
290
291
292
293 func (client StreamingEndpointsClient) GetSender(req *http.Request) (*http.Response, error) {
294 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
295 }
296
297
298
299 func (client StreamingEndpointsClient) GetResponder(resp *http.Response) (result StreamingEndpoint, err error) {
300 err = autorest.Respond(
301 resp,
302 azure.WithErrorUnlessStatusCode(http.StatusOK),
303 autorest.ByUnmarshallingJSON(&result),
304 autorest.ByClosing())
305 result.Response = autorest.Response{Response: resp}
306 return
307 }
308
309
310
311
312
313 func (client StreamingEndpointsClient) List(ctx context.Context, resourceGroupName string, accountName string) (result StreamingEndpointListResultPage, err error) {
314 if tracing.IsEnabled() {
315 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.List")
316 defer func() {
317 sc := -1
318 if result.selr.Response.Response != nil {
319 sc = result.selr.Response.Response.StatusCode
320 }
321 tracing.EndSpan(ctx, sc, err)
322 }()
323 }
324 result.fn = client.listNextResults
325 req, err := client.ListPreparer(ctx, resourceGroupName, accountName)
326 if err != nil {
327 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "List", nil, "Failure preparing request")
328 return
329 }
330
331 resp, err := client.ListSender(req)
332 if err != nil {
333 result.selr.Response = autorest.Response{Response: resp}
334 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "List", resp, "Failure sending request")
335 return
336 }
337
338 result.selr, err = client.ListResponder(resp)
339 if err != nil {
340 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "List", resp, "Failure responding to request")
341 return
342 }
343 if result.selr.hasNextLink() && result.selr.IsEmpty() {
344 err = result.NextWithContext(ctx)
345 return
346 }
347
348 return
349 }
350
351
352 func (client StreamingEndpointsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
353 pathParameters := map[string]interface{}{
354 "accountName": autorest.Encode("path", accountName),
355 "resourceGroupName": autorest.Encode("path", resourceGroupName),
356 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
357 }
358
359 const APIVersion = "2021-11-01"
360 queryParameters := map[string]interface{}{
361 "api-version": APIVersion,
362 }
363
364 preparer := autorest.CreatePreparer(
365 autorest.AsGet(),
366 autorest.WithBaseURL(client.BaseURI),
367 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints", pathParameters),
368 autorest.WithQueryParameters(queryParameters))
369 return preparer.Prepare((&http.Request{}).WithContext(ctx))
370 }
371
372
373
374 func (client StreamingEndpointsClient) ListSender(req *http.Request) (*http.Response, error) {
375 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
376 }
377
378
379
380 func (client StreamingEndpointsClient) ListResponder(resp *http.Response) (result StreamingEndpointListResult, err error) {
381 err = autorest.Respond(
382 resp,
383 azure.WithErrorUnlessStatusCode(http.StatusOK),
384 autorest.ByUnmarshallingJSON(&result),
385 autorest.ByClosing())
386 result.Response = autorest.Response{Response: resp}
387 return
388 }
389
390
391 func (client StreamingEndpointsClient) listNextResults(ctx context.Context, lastResults StreamingEndpointListResult) (result StreamingEndpointListResult, err error) {
392 req, err := lastResults.streamingEndpointListResultPreparer(ctx)
393 if err != nil {
394 return result, autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "listNextResults", nil, "Failure preparing next results request")
395 }
396 if req == nil {
397 return
398 }
399 resp, err := client.ListSender(req)
400 if err != nil {
401 result.Response = autorest.Response{Response: resp}
402 return result, autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "listNextResults", resp, "Failure sending next results request")
403 }
404 result, err = client.ListResponder(resp)
405 if err != nil {
406 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "listNextResults", resp, "Failure responding to next results request")
407 }
408 return
409 }
410
411
412 func (client StreamingEndpointsClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string) (result StreamingEndpointListResultIterator, err error) {
413 if tracing.IsEnabled() {
414 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.List")
415 defer func() {
416 sc := -1
417 if result.Response().Response.Response != nil {
418 sc = result.page.Response().Response.Response.StatusCode
419 }
420 tracing.EndSpan(ctx, sc, err)
421 }()
422 }
423 result.page, err = client.List(ctx, resourceGroupName, accountName)
424 return
425 }
426
427
428
429
430
431
432
433 func (client StreamingEndpointsClient) Scale(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEntityScaleUnit) (result StreamingEndpointsScaleFuture, err error) {
434 if tracing.IsEnabled() {
435 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Scale")
436 defer func() {
437 sc := -1
438 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
439 sc = result.FutureAPI.Response().StatusCode
440 }
441 tracing.EndSpan(ctx, sc, err)
442 }()
443 }
444 if err := validation.Validate([]validation.Validation{
445 {TargetValue: streamingEndpointName,
446 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
447 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
448 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
449 return result, validation.NewError("media.StreamingEndpointsClient", "Scale", err.Error())
450 }
451
452 req, err := client.ScalePreparer(ctx, resourceGroupName, accountName, streamingEndpointName, parameters)
453 if err != nil {
454 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Scale", nil, "Failure preparing request")
455 return
456 }
457
458 result, err = client.ScaleSender(req)
459 if err != nil {
460 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Scale", result.Response(), "Failure sending request")
461 return
462 }
463
464 return
465 }
466
467
468 func (client StreamingEndpointsClient) ScalePreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEntityScaleUnit) (*http.Request, error) {
469 pathParameters := map[string]interface{}{
470 "accountName": autorest.Encode("path", accountName),
471 "resourceGroupName": autorest.Encode("path", resourceGroupName),
472 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
473 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
474 }
475
476 const APIVersion = "2021-11-01"
477 queryParameters := map[string]interface{}{
478 "api-version": APIVersion,
479 }
480
481 preparer := autorest.CreatePreparer(
482 autorest.AsContentType("application/json; charset=utf-8"),
483 autorest.AsPost(),
484 autorest.WithBaseURL(client.BaseURI),
485 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/scale", pathParameters),
486 autorest.WithJSON(parameters),
487 autorest.WithQueryParameters(queryParameters))
488 return preparer.Prepare((&http.Request{}).WithContext(ctx))
489 }
490
491
492
493 func (client StreamingEndpointsClient) ScaleSender(req *http.Request) (future StreamingEndpointsScaleFuture, err error) {
494 var resp *http.Response
495 future.FutureAPI = &azure.Future{}
496 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
497 if err != nil {
498 return
499 }
500 var azf azure.Future
501 azf, err = azure.NewFutureFromResponse(resp)
502 future.FutureAPI = &azf
503 future.Result = future.result
504 return
505 }
506
507
508
509 func (client StreamingEndpointsClient) ScaleResponder(resp *http.Response) (result autorest.Response, err error) {
510 err = autorest.Respond(
511 resp,
512 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
513 autorest.ByClosing())
514 result.Response = resp
515 return
516 }
517
518
519
520
521
522
523 func (client StreamingEndpointsClient) Skus(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (result StreamingEndpointSkuInfoListResult, err error) {
524 if tracing.IsEnabled() {
525 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Skus")
526 defer func() {
527 sc := -1
528 if result.Response.Response != nil {
529 sc = result.Response.Response.StatusCode
530 }
531 tracing.EndSpan(ctx, sc, err)
532 }()
533 }
534 if err := validation.Validate([]validation.Validation{
535 {TargetValue: streamingEndpointName,
536 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
537 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
538 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
539 return result, validation.NewError("media.StreamingEndpointsClient", "Skus", err.Error())
540 }
541
542 req, err := client.SkusPreparer(ctx, resourceGroupName, accountName, streamingEndpointName)
543 if err != nil {
544 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Skus", nil, "Failure preparing request")
545 return
546 }
547
548 resp, err := client.SkusSender(req)
549 if err != nil {
550 result.Response = autorest.Response{Response: resp}
551 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Skus", resp, "Failure sending request")
552 return
553 }
554
555 result, err = client.SkusResponder(resp)
556 if err != nil {
557 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Skus", resp, "Failure responding to request")
558 return
559 }
560
561 return
562 }
563
564
565 func (client StreamingEndpointsClient) SkusPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (*http.Request, error) {
566 pathParameters := map[string]interface{}{
567 "accountName": autorest.Encode("path", accountName),
568 "resourceGroupName": autorest.Encode("path", resourceGroupName),
569 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
570 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
571 }
572
573 const APIVersion = "2021-11-01"
574 queryParameters := map[string]interface{}{
575 "api-version": APIVersion,
576 }
577
578 preparer := autorest.CreatePreparer(
579 autorest.AsGet(),
580 autorest.WithBaseURL(client.BaseURI),
581 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/skus", pathParameters),
582 autorest.WithQueryParameters(queryParameters))
583 return preparer.Prepare((&http.Request{}).WithContext(ctx))
584 }
585
586
587
588 func (client StreamingEndpointsClient) SkusSender(req *http.Request) (*http.Response, error) {
589 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
590 }
591
592
593
594 func (client StreamingEndpointsClient) SkusResponder(resp *http.Response) (result StreamingEndpointSkuInfoListResult, err error) {
595 err = autorest.Respond(
596 resp,
597 azure.WithErrorUnlessStatusCode(http.StatusOK),
598 autorest.ByUnmarshallingJSON(&result),
599 autorest.ByClosing())
600 result.Response = autorest.Response{Response: resp}
601 return
602 }
603
604
605
606
607
608
609 func (client StreamingEndpointsClient) Start(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (result StreamingEndpointsStartFuture, err error) {
610 if tracing.IsEnabled() {
611 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Start")
612 defer func() {
613 sc := -1
614 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
615 sc = result.FutureAPI.Response().StatusCode
616 }
617 tracing.EndSpan(ctx, sc, err)
618 }()
619 }
620 if err := validation.Validate([]validation.Validation{
621 {TargetValue: streamingEndpointName,
622 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
623 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
624 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
625 return result, validation.NewError("media.StreamingEndpointsClient", "Start", err.Error())
626 }
627
628 req, err := client.StartPreparer(ctx, resourceGroupName, accountName, streamingEndpointName)
629 if err != nil {
630 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Start", nil, "Failure preparing request")
631 return
632 }
633
634 result, err = client.StartSender(req)
635 if err != nil {
636 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Start", result.Response(), "Failure sending request")
637 return
638 }
639
640 return
641 }
642
643
644 func (client StreamingEndpointsClient) StartPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (*http.Request, error) {
645 pathParameters := map[string]interface{}{
646 "accountName": autorest.Encode("path", accountName),
647 "resourceGroupName": autorest.Encode("path", resourceGroupName),
648 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
649 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
650 }
651
652 const APIVersion = "2021-11-01"
653 queryParameters := map[string]interface{}{
654 "api-version": APIVersion,
655 }
656
657 preparer := autorest.CreatePreparer(
658 autorest.AsPost(),
659 autorest.WithBaseURL(client.BaseURI),
660 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start", pathParameters),
661 autorest.WithQueryParameters(queryParameters))
662 return preparer.Prepare((&http.Request{}).WithContext(ctx))
663 }
664
665
666
667 func (client StreamingEndpointsClient) StartSender(req *http.Request) (future StreamingEndpointsStartFuture, err error) {
668 var resp *http.Response
669 future.FutureAPI = &azure.Future{}
670 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
671 if err != nil {
672 return
673 }
674 var azf azure.Future
675 azf, err = azure.NewFutureFromResponse(resp)
676 future.FutureAPI = &azf
677 future.Result = future.result
678 return
679 }
680
681
682
683 func (client StreamingEndpointsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
684 err = autorest.Respond(
685 resp,
686 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
687 autorest.ByClosing())
688 result.Response = resp
689 return
690 }
691
692
693
694
695
696
697 func (client StreamingEndpointsClient) Stop(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (result StreamingEndpointsStopFuture, err error) {
698 if tracing.IsEnabled() {
699 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Stop")
700 defer func() {
701 sc := -1
702 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
703 sc = result.FutureAPI.Response().StatusCode
704 }
705 tracing.EndSpan(ctx, sc, err)
706 }()
707 }
708 if err := validation.Validate([]validation.Validation{
709 {TargetValue: streamingEndpointName,
710 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
711 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
712 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
713 return result, validation.NewError("media.StreamingEndpointsClient", "Stop", err.Error())
714 }
715
716 req, err := client.StopPreparer(ctx, resourceGroupName, accountName, streamingEndpointName)
717 if err != nil {
718 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Stop", nil, "Failure preparing request")
719 return
720 }
721
722 result, err = client.StopSender(req)
723 if err != nil {
724 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Stop", result.Response(), "Failure sending request")
725 return
726 }
727
728 return
729 }
730
731
732 func (client StreamingEndpointsClient) StopPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (*http.Request, error) {
733 pathParameters := map[string]interface{}{
734 "accountName": autorest.Encode("path", accountName),
735 "resourceGroupName": autorest.Encode("path", resourceGroupName),
736 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
737 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
738 }
739
740 const APIVersion = "2021-11-01"
741 queryParameters := map[string]interface{}{
742 "api-version": APIVersion,
743 }
744
745 preparer := autorest.CreatePreparer(
746 autorest.AsPost(),
747 autorest.WithBaseURL(client.BaseURI),
748 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop", pathParameters),
749 autorest.WithQueryParameters(queryParameters))
750 return preparer.Prepare((&http.Request{}).WithContext(ctx))
751 }
752
753
754
755 func (client StreamingEndpointsClient) StopSender(req *http.Request) (future StreamingEndpointsStopFuture, err error) {
756 var resp *http.Response
757 future.FutureAPI = &azure.Future{}
758 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
759 if err != nil {
760 return
761 }
762 var azf azure.Future
763 azf, err = azure.NewFutureFromResponse(resp)
764 future.FutureAPI = &azf
765 future.Result = future.result
766 return
767 }
768
769
770
771 func (client StreamingEndpointsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) {
772 err = autorest.Respond(
773 resp,
774 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
775 autorest.ByClosing())
776 result.Response = resp
777 return
778 }
779
780
781
782
783
784
785
786 func (client StreamingEndpointsClient) Update(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint) (result StreamingEndpointsUpdateFuture, err error) {
787 if tracing.IsEnabled() {
788 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Update")
789 defer func() {
790 sc := -1
791 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
792 sc = result.FutureAPI.Response().StatusCode
793 }
794 tracing.EndSpan(ctx, sc, err)
795 }()
796 }
797 if err := validation.Validate([]validation.Validation{
798 {TargetValue: streamingEndpointName,
799 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
800 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
801 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
802 return result, validation.NewError("media.StreamingEndpointsClient", "Update", err.Error())
803 }
804
805 req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, streamingEndpointName, parameters)
806 if err != nil {
807 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Update", nil, "Failure preparing request")
808 return
809 }
810
811 result, err = client.UpdateSender(req)
812 if err != nil {
813 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Update", result.Response(), "Failure sending request")
814 return
815 }
816
817 return
818 }
819
820
821 func (client StreamingEndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint) (*http.Request, error) {
822 pathParameters := map[string]interface{}{
823 "accountName": autorest.Encode("path", accountName),
824 "resourceGroupName": autorest.Encode("path", resourceGroupName),
825 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
826 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
827 }
828
829 const APIVersion = "2021-11-01"
830 queryParameters := map[string]interface{}{
831 "api-version": APIVersion,
832 }
833
834 parameters.SystemData = nil
835 preparer := autorest.CreatePreparer(
836 autorest.AsContentType("application/json; charset=utf-8"),
837 autorest.AsPatch(),
838 autorest.WithBaseURL(client.BaseURI),
839 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", pathParameters),
840 autorest.WithJSON(parameters),
841 autorest.WithQueryParameters(queryParameters))
842 return preparer.Prepare((&http.Request{}).WithContext(ctx))
843 }
844
845
846
847 func (client StreamingEndpointsClient) UpdateSender(req *http.Request) (future StreamingEndpointsUpdateFuture, err error) {
848 var resp *http.Response
849 future.FutureAPI = &azure.Future{}
850 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
851 if err != nil {
852 return
853 }
854 var azf azure.Future
855 azf, err = azure.NewFutureFromResponse(resp)
856 future.FutureAPI = &azf
857 future.Result = future.result
858 return
859 }
860
861
862
863 func (client StreamingEndpointsClient) UpdateResponder(resp *http.Response) (result StreamingEndpoint, err error) {
864 err = autorest.Respond(
865 resp,
866 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
867 autorest.ByUnmarshallingJSON(&result),
868 autorest.ByClosing())
869 result.Response = autorest.Response{Response: resp}
870 return
871 }
872
View as plain text