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