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 StreamingLocatorsClient struct {
20 BaseClient
21 }
22
23
24 func NewStreamingLocatorsClient(subscriptionID string) StreamingLocatorsClient {
25 return NewStreamingLocatorsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewStreamingLocatorsClientWithBaseURI(baseURI string, subscriptionID string) StreamingLocatorsClient {
32 return StreamingLocatorsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41 func (client StreamingLocatorsClient) Create(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string, parameters StreamingLocator) (result StreamingLocator, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingLocatorsClient.Create")
44 defer func() {
45 sc := -1
46 if result.Response.Response != nil {
47 sc = result.Response.Response.StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 if err := validation.Validate([]validation.Validation{
53 {TargetValue: parameters,
54 Constraints: []validation.Constraint{{Target: "parameters.StreamingLocatorProperties", Name: validation.Null, Rule: false,
55 Chain: []validation.Constraint{{Target: "parameters.StreamingLocatorProperties.AssetName", Name: validation.Null, Rule: true, Chain: nil},
56 {Target: "parameters.StreamingLocatorProperties.StreamingPolicyName", Name: validation.Null, Rule: true, Chain: nil},
57 }}}}}); err != nil {
58 return result, validation.NewError("media.StreamingLocatorsClient", "Create", err.Error())
59 }
60
61 req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, streamingLocatorName, parameters)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Create", nil, "Failure preparing request")
64 return
65 }
66
67 resp, err := client.CreateSender(req)
68 if err != nil {
69 result.Response = autorest.Response{Response: resp}
70 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Create", resp, "Failure sending request")
71 return
72 }
73
74 result, err = client.CreateResponder(resp)
75 if err != nil {
76 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Create", resp, "Failure responding to request")
77 return
78 }
79
80 return
81 }
82
83
84 func (client StreamingLocatorsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string, parameters StreamingLocator) (*http.Request, error) {
85 pathParameters := map[string]interface{}{
86 "accountName": autorest.Encode("path", accountName),
87 "resourceGroupName": autorest.Encode("path", resourceGroupName),
88 "streamingLocatorName": autorest.Encode("path", streamingLocatorName),
89 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
90 }
91
92 const APIVersion = "2020-05-01"
93 queryParameters := map[string]interface{}{
94 "api-version": APIVersion,
95 }
96
97 parameters.SystemData = nil
98 preparer := autorest.CreatePreparer(
99 autorest.AsContentType("application/json; charset=utf-8"),
100 autorest.AsPut(),
101 autorest.WithBaseURL(client.BaseURI),
102 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}", pathParameters),
103 autorest.WithJSON(parameters),
104 autorest.WithQueryParameters(queryParameters))
105 return preparer.Prepare((&http.Request{}).WithContext(ctx))
106 }
107
108
109
110 func (client StreamingLocatorsClient) CreateSender(req *http.Request) (*http.Response, error) {
111 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
112 }
113
114
115
116 func (client StreamingLocatorsClient) CreateResponder(resp *http.Response) (result StreamingLocator, err error) {
117 err = autorest.Respond(
118 resp,
119 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
120 autorest.ByUnmarshallingJSON(&result),
121 autorest.ByClosing())
122 result.Response = autorest.Response{Response: resp}
123 return
124 }
125
126
127
128
129
130
131 func (client StreamingLocatorsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string) (result autorest.Response, err error) {
132 if tracing.IsEnabled() {
133 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingLocatorsClient.Delete")
134 defer func() {
135 sc := -1
136 if result.Response != nil {
137 sc = result.Response.StatusCode
138 }
139 tracing.EndSpan(ctx, sc, err)
140 }()
141 }
142 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, streamingLocatorName)
143 if err != nil {
144 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Delete", nil, "Failure preparing request")
145 return
146 }
147
148 resp, err := client.DeleteSender(req)
149 if err != nil {
150 result.Response = resp
151 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Delete", resp, "Failure sending request")
152 return
153 }
154
155 result, err = client.DeleteResponder(resp)
156 if err != nil {
157 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Delete", resp, "Failure responding to request")
158 return
159 }
160
161 return
162 }
163
164
165 func (client StreamingLocatorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string) (*http.Request, error) {
166 pathParameters := map[string]interface{}{
167 "accountName": autorest.Encode("path", accountName),
168 "resourceGroupName": autorest.Encode("path", resourceGroupName),
169 "streamingLocatorName": autorest.Encode("path", streamingLocatorName),
170 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
171 }
172
173 const APIVersion = "2020-05-01"
174 queryParameters := map[string]interface{}{
175 "api-version": APIVersion,
176 }
177
178 preparer := autorest.CreatePreparer(
179 autorest.AsDelete(),
180 autorest.WithBaseURL(client.BaseURI),
181 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}", pathParameters),
182 autorest.WithQueryParameters(queryParameters))
183 return preparer.Prepare((&http.Request{}).WithContext(ctx))
184 }
185
186
187
188 func (client StreamingLocatorsClient) DeleteSender(req *http.Request) (*http.Response, error) {
189 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
190 }
191
192
193
194 func (client StreamingLocatorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
195 err = autorest.Respond(
196 resp,
197 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
198 autorest.ByClosing())
199 result.Response = resp
200 return
201 }
202
203
204
205
206
207
208 func (client StreamingLocatorsClient) Get(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string) (result StreamingLocator, err error) {
209 if tracing.IsEnabled() {
210 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingLocatorsClient.Get")
211 defer func() {
212 sc := -1
213 if result.Response.Response != nil {
214 sc = result.Response.Response.StatusCode
215 }
216 tracing.EndSpan(ctx, sc, err)
217 }()
218 }
219 req, err := client.GetPreparer(ctx, resourceGroupName, accountName, streamingLocatorName)
220 if err != nil {
221 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Get", nil, "Failure preparing request")
222 return
223 }
224
225 resp, err := client.GetSender(req)
226 if err != nil {
227 result.Response = autorest.Response{Response: resp}
228 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Get", resp, "Failure sending request")
229 return
230 }
231
232 result, err = client.GetResponder(resp)
233 if err != nil {
234 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "Get", resp, "Failure responding to request")
235 return
236 }
237
238 return
239 }
240
241
242 func (client StreamingLocatorsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string) (*http.Request, error) {
243 pathParameters := map[string]interface{}{
244 "accountName": autorest.Encode("path", accountName),
245 "resourceGroupName": autorest.Encode("path", resourceGroupName),
246 "streamingLocatorName": autorest.Encode("path", streamingLocatorName),
247 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
248 }
249
250 const APIVersion = "2020-05-01"
251 queryParameters := map[string]interface{}{
252 "api-version": APIVersion,
253 }
254
255 preparer := autorest.CreatePreparer(
256 autorest.AsGet(),
257 autorest.WithBaseURL(client.BaseURI),
258 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}", pathParameters),
259 autorest.WithQueryParameters(queryParameters))
260 return preparer.Prepare((&http.Request{}).WithContext(ctx))
261 }
262
263
264
265 func (client StreamingLocatorsClient) GetSender(req *http.Request) (*http.Response, error) {
266 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
267 }
268
269
270
271 func (client StreamingLocatorsClient) GetResponder(resp *http.Response) (result StreamingLocator, err error) {
272 err = autorest.Respond(
273 resp,
274 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
275 autorest.ByUnmarshallingJSON(&result),
276 autorest.ByClosing())
277 result.Response = autorest.Response{Response: resp}
278 return
279 }
280
281
282
283
284
285
286
287
288
289 func (client StreamingLocatorsClient) List(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (result StreamingLocatorCollectionPage, err error) {
290 if tracing.IsEnabled() {
291 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingLocatorsClient.List")
292 defer func() {
293 sc := -1
294 if result.slc.Response.Response != nil {
295 sc = result.slc.Response.Response.StatusCode
296 }
297 tracing.EndSpan(ctx, sc, err)
298 }()
299 }
300 result.fn = client.listNextResults
301 req, err := client.ListPreparer(ctx, resourceGroupName, accountName, filter, top, orderby)
302 if err != nil {
303 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "List", nil, "Failure preparing request")
304 return
305 }
306
307 resp, err := client.ListSender(req)
308 if err != nil {
309 result.slc.Response = autorest.Response{Response: resp}
310 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "List", resp, "Failure sending request")
311 return
312 }
313
314 result.slc, err = client.ListResponder(resp)
315 if err != nil {
316 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "List", resp, "Failure responding to request")
317 return
318 }
319 if result.slc.hasNextLink() && result.slc.IsEmpty() {
320 err = result.NextWithContext(ctx)
321 return
322 }
323
324 return
325 }
326
327
328 func (client StreamingLocatorsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (*http.Request, error) {
329 pathParameters := map[string]interface{}{
330 "accountName": autorest.Encode("path", accountName),
331 "resourceGroupName": autorest.Encode("path", resourceGroupName),
332 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
333 }
334
335 const APIVersion = "2020-05-01"
336 queryParameters := map[string]interface{}{
337 "api-version": APIVersion,
338 }
339 if len(filter) > 0 {
340 queryParameters["$filter"] = autorest.Encode("query", filter)
341 }
342 if top != nil {
343 queryParameters["$top"] = autorest.Encode("query", *top)
344 }
345 if len(orderby) > 0 {
346 queryParameters["$orderby"] = autorest.Encode("query", orderby)
347 }
348
349 preparer := autorest.CreatePreparer(
350 autorest.AsGet(),
351 autorest.WithBaseURL(client.BaseURI),
352 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators", pathParameters),
353 autorest.WithQueryParameters(queryParameters))
354 return preparer.Prepare((&http.Request{}).WithContext(ctx))
355 }
356
357
358
359 func (client StreamingLocatorsClient) ListSender(req *http.Request) (*http.Response, error) {
360 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
361 }
362
363
364
365 func (client StreamingLocatorsClient) ListResponder(resp *http.Response) (result StreamingLocatorCollection, err error) {
366 err = autorest.Respond(
367 resp,
368 azure.WithErrorUnlessStatusCode(http.StatusOK),
369 autorest.ByUnmarshallingJSON(&result),
370 autorest.ByClosing())
371 result.Response = autorest.Response{Response: resp}
372 return
373 }
374
375
376 func (client StreamingLocatorsClient) listNextResults(ctx context.Context, lastResults StreamingLocatorCollection) (result StreamingLocatorCollection, err error) {
377 req, err := lastResults.streamingLocatorCollectionPreparer(ctx)
378 if err != nil {
379 return result, autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "listNextResults", nil, "Failure preparing next results request")
380 }
381 if req == nil {
382 return
383 }
384 resp, err := client.ListSender(req)
385 if err != nil {
386 result.Response = autorest.Response{Response: resp}
387 return result, autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "listNextResults", resp, "Failure sending next results request")
388 }
389 result, err = client.ListResponder(resp)
390 if err != nil {
391 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "listNextResults", resp, "Failure responding to next results request")
392 }
393 return
394 }
395
396
397 func (client StreamingLocatorsClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (result StreamingLocatorCollectionIterator, err error) {
398 if tracing.IsEnabled() {
399 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingLocatorsClient.List")
400 defer func() {
401 sc := -1
402 if result.Response().Response.Response != nil {
403 sc = result.page.Response().Response.Response.StatusCode
404 }
405 tracing.EndSpan(ctx, sc, err)
406 }()
407 }
408 result.page, err = client.List(ctx, resourceGroupName, accountName, filter, top, orderby)
409 return
410 }
411
412
413
414
415
416
417 func (client StreamingLocatorsClient) ListContentKeys(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string) (result ListContentKeysResponse, err error) {
418 if tracing.IsEnabled() {
419 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingLocatorsClient.ListContentKeys")
420 defer func() {
421 sc := -1
422 if result.Response.Response != nil {
423 sc = result.Response.Response.StatusCode
424 }
425 tracing.EndSpan(ctx, sc, err)
426 }()
427 }
428 req, err := client.ListContentKeysPreparer(ctx, resourceGroupName, accountName, streamingLocatorName)
429 if err != nil {
430 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "ListContentKeys", nil, "Failure preparing request")
431 return
432 }
433
434 resp, err := client.ListContentKeysSender(req)
435 if err != nil {
436 result.Response = autorest.Response{Response: resp}
437 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "ListContentKeys", resp, "Failure sending request")
438 return
439 }
440
441 result, err = client.ListContentKeysResponder(resp)
442 if err != nil {
443 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "ListContentKeys", resp, "Failure responding to request")
444 return
445 }
446
447 return
448 }
449
450
451 func (client StreamingLocatorsClient) ListContentKeysPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string) (*http.Request, error) {
452 pathParameters := map[string]interface{}{
453 "accountName": autorest.Encode("path", accountName),
454 "resourceGroupName": autorest.Encode("path", resourceGroupName),
455 "streamingLocatorName": autorest.Encode("path", streamingLocatorName),
456 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
457 }
458
459 const APIVersion = "2020-05-01"
460 queryParameters := map[string]interface{}{
461 "api-version": APIVersion,
462 }
463
464 preparer := autorest.CreatePreparer(
465 autorest.AsPost(),
466 autorest.WithBaseURL(client.BaseURI),
467 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listContentKeys", pathParameters),
468 autorest.WithQueryParameters(queryParameters))
469 return preparer.Prepare((&http.Request{}).WithContext(ctx))
470 }
471
472
473
474 func (client StreamingLocatorsClient) ListContentKeysSender(req *http.Request) (*http.Response, error) {
475 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
476 }
477
478
479
480 func (client StreamingLocatorsClient) ListContentKeysResponder(resp *http.Response) (result ListContentKeysResponse, err error) {
481 err = autorest.Respond(
482 resp,
483 azure.WithErrorUnlessStatusCode(http.StatusOK),
484 autorest.ByUnmarshallingJSON(&result),
485 autorest.ByClosing())
486 result.Response = autorest.Response{Response: resp}
487 return
488 }
489
490
491
492
493
494
495 func (client StreamingLocatorsClient) ListPaths(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string) (result ListPathsResponse, err error) {
496 if tracing.IsEnabled() {
497 ctx = tracing.StartSpan(ctx, fqdn+"/StreamingLocatorsClient.ListPaths")
498 defer func() {
499 sc := -1
500 if result.Response.Response != nil {
501 sc = result.Response.Response.StatusCode
502 }
503 tracing.EndSpan(ctx, sc, err)
504 }()
505 }
506 req, err := client.ListPathsPreparer(ctx, resourceGroupName, accountName, streamingLocatorName)
507 if err != nil {
508 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "ListPaths", nil, "Failure preparing request")
509 return
510 }
511
512 resp, err := client.ListPathsSender(req)
513 if err != nil {
514 result.Response = autorest.Response{Response: resp}
515 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "ListPaths", resp, "Failure sending request")
516 return
517 }
518
519 result, err = client.ListPathsResponder(resp)
520 if err != nil {
521 err = autorest.NewErrorWithError(err, "media.StreamingLocatorsClient", "ListPaths", resp, "Failure responding to request")
522 return
523 }
524
525 return
526 }
527
528
529 func (client StreamingLocatorsClient) ListPathsPreparer(ctx context.Context, resourceGroupName string, accountName string, streamingLocatorName string) (*http.Request, error) {
530 pathParameters := map[string]interface{}{
531 "accountName": autorest.Encode("path", accountName),
532 "resourceGroupName": autorest.Encode("path", resourceGroupName),
533 "streamingLocatorName": autorest.Encode("path", streamingLocatorName),
534 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
535 }
536
537 const APIVersion = "2020-05-01"
538 queryParameters := map[string]interface{}{
539 "api-version": APIVersion,
540 }
541
542 preparer := autorest.CreatePreparer(
543 autorest.AsPost(),
544 autorest.WithBaseURL(client.BaseURI),
545 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listPaths", pathParameters),
546 autorest.WithQueryParameters(queryParameters))
547 return preparer.Prepare((&http.Request{}).WithContext(ctx))
548 }
549
550
551
552 func (client StreamingLocatorsClient) ListPathsSender(req *http.Request) (*http.Response, error) {
553 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
554 }
555
556
557
558 func (client StreamingLocatorsClient) ListPathsResponder(resp *http.Response) (result ListPathsResponse, err error) {
559 err = autorest.Respond(
560 resp,
561 azure.WithErrorUnlessStatusCode(http.StatusOK),
562 autorest.ByUnmarshallingJSON(&result),
563 autorest.ByClosing())
564 result.Response = autorest.Response{Response: resp}
565 return
566 }
567
View as plain text