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-06-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-06-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-06-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-06-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-06-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) Start(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (result StreamingEndpointsStartFuture, err error) {
524 if tracing.IsEnabled() {
525 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Start")
526 defer func() {
527 sc := -1
528 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
529 sc = result.FutureAPI.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", "Start", err.Error())
540 }
541
542 req, err := client.StartPreparer(ctx, resourceGroupName, accountName, streamingEndpointName)
543 if err != nil {
544 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Start", nil, "Failure preparing request")
545 return
546 }
547
548 result, err = client.StartSender(req)
549 if err != nil {
550 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Start", result.Response(), "Failure sending request")
551 return
552 }
553
554 return
555 }
556
557
558 func (client StreamingEndpointsClient) StartPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (*http.Request, error) {
559 pathParameters := map[string]interface{}{
560 "accountName": autorest.Encode("path", accountName),
561 "resourceGroupName": autorest.Encode("path", resourceGroupName),
562 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
563 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
564 }
565
566 const APIVersion = "2021-06-01"
567 queryParameters := map[string]interface{}{
568 "api-version": APIVersion,
569 }
570
571 preparer := autorest.CreatePreparer(
572 autorest.AsPost(),
573 autorest.WithBaseURL(client.BaseURI),
574 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/start", pathParameters),
575 autorest.WithQueryParameters(queryParameters))
576 return preparer.Prepare((&http.Request{}).WithContext(ctx))
577 }
578
579
580
581 func (client StreamingEndpointsClient) StartSender(req *http.Request) (future StreamingEndpointsStartFuture, err error) {
582 var resp *http.Response
583 future.FutureAPI = &azure.Future{}
584 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
585 if err != nil {
586 return
587 }
588 var azf azure.Future
589 azf, err = azure.NewFutureFromResponse(resp)
590 future.FutureAPI = &azf
591 future.Result = future.result
592 return
593 }
594
595
596
597 func (client StreamingEndpointsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
598 err = autorest.Respond(
599 resp,
600 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
601 autorest.ByClosing())
602 result.Response = resp
603 return
604 }
605
606
607
608
609
610
611 func (client StreamingEndpointsClient) Stop(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (result StreamingEndpointsStopFuture, err error) {
612 if tracing.IsEnabled() {
613 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Stop")
614 defer func() {
615 sc := -1
616 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
617 sc = result.FutureAPI.Response().StatusCode
618 }
619 tracing.EndSpan(ctx, sc, err)
620 }()
621 }
622 if err := validation.Validate([]validation.Validation{
623 {TargetValue: streamingEndpointName,
624 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
625 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
626 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
627 return result, validation.NewError("media.StreamingEndpointsClient", "Stop", err.Error())
628 }
629
630 req, err := client.StopPreparer(ctx, resourceGroupName, accountName, streamingEndpointName)
631 if err != nil {
632 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Stop", nil, "Failure preparing request")
633 return
634 }
635
636 result, err = client.StopSender(req)
637 if err != nil {
638 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Stop", result.Response(), "Failure sending request")
639 return
640 }
641
642 return
643 }
644
645
646 func (client StreamingEndpointsClient) StopPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string) (*http.Request, error) {
647 pathParameters := map[string]interface{}{
648 "accountName": autorest.Encode("path", accountName),
649 "resourceGroupName": autorest.Encode("path", resourceGroupName),
650 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
651 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
652 }
653
654 const APIVersion = "2021-06-01"
655 queryParameters := map[string]interface{}{
656 "api-version": APIVersion,
657 }
658
659 preparer := autorest.CreatePreparer(
660 autorest.AsPost(),
661 autorest.WithBaseURL(client.BaseURI),
662 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}/stop", pathParameters),
663 autorest.WithQueryParameters(queryParameters))
664 return preparer.Prepare((&http.Request{}).WithContext(ctx))
665 }
666
667
668
669 func (client StreamingEndpointsClient) StopSender(req *http.Request) (future StreamingEndpointsStopFuture, err error) {
670 var resp *http.Response
671 future.FutureAPI = &azure.Future{}
672 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
673 if err != nil {
674 return
675 }
676 var azf azure.Future
677 azf, err = azure.NewFutureFromResponse(resp)
678 future.FutureAPI = &azf
679 future.Result = future.result
680 return
681 }
682
683
684
685 func (client StreamingEndpointsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) {
686 err = autorest.Respond(
687 resp,
688 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
689 autorest.ByClosing())
690 result.Response = resp
691 return
692 }
693
694
695
696
697
698
699
700 func (client StreamingEndpointsClient) Update(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint) (result StreamingEndpointsUpdateFuture, err error) {
701 if tracing.IsEnabled() {
702 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingEndpointsClient.Update")
703 defer func() {
704 sc := -1
705 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
706 sc = result.FutureAPI.Response().StatusCode
707 }
708 tracing.EndSpan(ctx, sc, err)
709 }()
710 }
711 if err := validation.Validate([]validation.Validation{
712 {TargetValue: streamingEndpointName,
713 Constraints: []validation.Constraint{{Target: "streamingEndpointName", Name: validation.MaxLength, Rule: 24, Chain: nil},
714 {Target: "streamingEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil},
715 {Target: "streamingEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
716 return result, validation.NewError("media.StreamingEndpointsClient", "Update", err.Error())
717 }
718
719 req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, streamingEndpointName, parameters)
720 if err != nil {
721 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Update", nil, "Failure preparing request")
722 return
723 }
724
725 result, err = client.UpdateSender(req)
726 if err != nil {
727 err = autorest.NewErrorWithError(err, "media.StreamingEndpointsClient", "Update", result.Response(), "Failure sending request")
728 return
729 }
730
731 return
732 }
733
734
735 func (client StreamingEndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, streamingEndpointName string, parameters StreamingEndpoint) (*http.Request, error) {
736 pathParameters := map[string]interface{}{
737 "accountName": autorest.Encode("path", accountName),
738 "resourceGroupName": autorest.Encode("path", resourceGroupName),
739 "streamingEndpointName": autorest.Encode("path", streamingEndpointName),
740 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
741 }
742
743 const APIVersion = "2021-06-01"
744 queryParameters := map[string]interface{}{
745 "api-version": APIVersion,
746 }
747
748 parameters.SystemData = nil
749 preparer := autorest.CreatePreparer(
750 autorest.AsContentType("application/json; charset=utf-8"),
751 autorest.AsPatch(),
752 autorest.WithBaseURL(client.BaseURI),
753 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/streamingEndpoints/{streamingEndpointName}", pathParameters),
754 autorest.WithJSON(parameters),
755 autorest.WithQueryParameters(queryParameters))
756 return preparer.Prepare((&http.Request{}).WithContext(ctx))
757 }
758
759
760
761 func (client StreamingEndpointsClient) UpdateSender(req *http.Request) (future StreamingEndpointsUpdateFuture, err error) {
762 var resp *http.Response
763 future.FutureAPI = &azure.Future{}
764 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
765 if err != nil {
766 return
767 }
768 var azf azure.Future
769 azf, err = azure.NewFutureFromResponse(resp)
770 future.FutureAPI = &azf
771 future.Result = future.result
772 return
773 }
774
775
776
777 func (client StreamingEndpointsClient) UpdateResponder(resp *http.Response) (result StreamingEndpoint, err error) {
778 err = autorest.Respond(
779 resp,
780 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
781 autorest.ByUnmarshallingJSON(&result),
782 autorest.ByClosing())
783 result.Response = autorest.Response{Response: resp}
784 return
785 }
786
View as plain text