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