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