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 LiveOutputsClient struct {
20 BaseClient
21 }
22
23
24 func NewLiveOutputsClient(subscriptionID string) LiveOutputsClient {
25 return NewLiveOutputsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewLiveOutputsClientWithBaseURI(baseURI string, subscriptionID string) LiveOutputsClient {
31 return LiveOutputsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40
41 func (client LiveOutputsClient) Create(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, parameters LiveOutput) (result LiveOutputsCreateFuture, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/LiveOutputsClient.Create")
44 defer func() {
45 sc := -1
46 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
47 sc = result.FutureAPI.Response().StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 if err := validation.Validate([]validation.Validation{
53 {TargetValue: liveEventName,
54 Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
55 {Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
56 {Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}},
57 {TargetValue: liveOutputName,
58 Constraints: []validation.Constraint{{Target: "liveOutputName", Name: validation.MaxLength, Rule: 256, Chain: nil},
59 {Target: "liveOutputName", Name: validation.MinLength, Rule: 1, Chain: nil},
60 {Target: "liveOutputName", Name: validation.Pattern, Rule: `^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$`, Chain: nil}}},
61 {TargetValue: parameters,
62 Constraints: []validation.Constraint{{Target: "parameters.LiveOutputProperties", Name: validation.Null, Rule: false,
63 Chain: []validation.Constraint{{Target: "parameters.LiveOutputProperties.AssetName", Name: validation.Null, Rule: true, Chain: nil},
64 {Target: "parameters.LiveOutputProperties.ArchiveWindowLength", Name: validation.Null, Rule: true, Chain: nil},
65 }}}}}); err != nil {
66 return result, validation.NewError("media.LiveOutputsClient", "Create", err.Error())
67 }
68
69 req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, liveEventName, liveOutputName, parameters)
70 if err != nil {
71 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "Create", nil, "Failure preparing request")
72 return
73 }
74
75 result, err = client.CreateSender(req)
76 if err != nil {
77 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "Create", result.Response(), "Failure sending request")
78 return
79 }
80
81 return
82 }
83
84
85 func (client LiveOutputsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, parameters LiveOutput) (*http.Request, error) {
86 pathParameters := map[string]interface{}{
87 "accountName": autorest.Encode("path", accountName),
88 "liveEventName": autorest.Encode("path", liveEventName),
89 "liveOutputName": autorest.Encode("path", liveOutputName),
90 "resourceGroupName": autorest.Encode("path", resourceGroupName),
91 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
92 }
93
94 const APIVersion = "2018-06-01-preview"
95 queryParameters := map[string]interface{}{
96 "api-version": APIVersion,
97 }
98
99 preparer := autorest.CreatePreparer(
100 autorest.AsContentType("application/json; charset=utf-8"),
101 autorest.AsPut(),
102 autorest.WithBaseURL(client.BaseURI),
103 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}", pathParameters),
104 autorest.WithJSON(parameters),
105 autorest.WithQueryParameters(queryParameters))
106 return preparer.Prepare((&http.Request{}).WithContext(ctx))
107 }
108
109
110
111 func (client LiveOutputsClient) CreateSender(req *http.Request) (future LiveOutputsCreateFuture, err error) {
112 var resp *http.Response
113 future.FutureAPI = &azure.Future{}
114 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
115 if err != nil {
116 return
117 }
118 var azf azure.Future
119 azf, err = azure.NewFutureFromResponse(resp)
120 future.FutureAPI = &azf
121 future.Result = future.result
122 return
123 }
124
125
126
127 func (client LiveOutputsClient) CreateResponder(resp *http.Response) (result LiveOutput, err error) {
128 err = autorest.Respond(
129 resp,
130 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
131 autorest.ByUnmarshallingJSON(&result),
132 autorest.ByClosing())
133 result.Response = autorest.Response{Response: resp}
134 return
135 }
136
137
138
139
140
141
142
143 func (client LiveOutputsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string) (result LiveOutputsDeleteFuture, err error) {
144 if tracing.IsEnabled() {
145 ctx = tracing.StartSpan(ctx, fqdn+"/LiveOutputsClient.Delete")
146 defer func() {
147 sc := -1
148 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
149 sc = result.FutureAPI.Response().StatusCode
150 }
151 tracing.EndSpan(ctx, sc, err)
152 }()
153 }
154 if err := validation.Validate([]validation.Validation{
155 {TargetValue: liveEventName,
156 Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
157 {Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
158 {Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}},
159 {TargetValue: liveOutputName,
160 Constraints: []validation.Constraint{{Target: "liveOutputName", Name: validation.MaxLength, Rule: 256, Chain: nil},
161 {Target: "liveOutputName", Name: validation.MinLength, Rule: 1, Chain: nil},
162 {Target: "liveOutputName", Name: validation.Pattern, Rule: `^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
163 return result, validation.NewError("media.LiveOutputsClient", "Delete", err.Error())
164 }
165
166 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, liveEventName, liveOutputName)
167 if err != nil {
168 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "Delete", nil, "Failure preparing request")
169 return
170 }
171
172 result, err = client.DeleteSender(req)
173 if err != nil {
174 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "Delete", result.Response(), "Failure sending request")
175 return
176 }
177
178 return
179 }
180
181
182 func (client LiveOutputsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string) (*http.Request, error) {
183 pathParameters := map[string]interface{}{
184 "accountName": autorest.Encode("path", accountName),
185 "liveEventName": autorest.Encode("path", liveEventName),
186 "liveOutputName": autorest.Encode("path", liveOutputName),
187 "resourceGroupName": autorest.Encode("path", resourceGroupName),
188 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
189 }
190
191 const APIVersion = "2018-06-01-preview"
192 queryParameters := map[string]interface{}{
193 "api-version": APIVersion,
194 }
195
196 preparer := autorest.CreatePreparer(
197 autorest.AsDelete(),
198 autorest.WithBaseURL(client.BaseURI),
199 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}", pathParameters),
200 autorest.WithQueryParameters(queryParameters))
201 return preparer.Prepare((&http.Request{}).WithContext(ctx))
202 }
203
204
205
206 func (client LiveOutputsClient) DeleteSender(req *http.Request) (future LiveOutputsDeleteFuture, err error) {
207 var resp *http.Response
208 future.FutureAPI = &azure.Future{}
209 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
210 if err != nil {
211 return
212 }
213 var azf azure.Future
214 azf, err = azure.NewFutureFromResponse(resp)
215 future.FutureAPI = &azf
216 future.Result = future.result
217 return
218 }
219
220
221
222 func (client LiveOutputsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
223 err = autorest.Respond(
224 resp,
225 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
226 autorest.ByClosing())
227 result.Response = resp
228 return
229 }
230
231
232
233
234
235
236
237 func (client LiveOutputsClient) Get(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string) (result LiveOutput, err error) {
238 if tracing.IsEnabled() {
239 ctx = tracing.StartSpan(ctx, fqdn+"/LiveOutputsClient.Get")
240 defer func() {
241 sc := -1
242 if result.Response.Response != nil {
243 sc = result.Response.Response.StatusCode
244 }
245 tracing.EndSpan(ctx, sc, err)
246 }()
247 }
248 if err := validation.Validate([]validation.Validation{
249 {TargetValue: liveEventName,
250 Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
251 {Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
252 {Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}},
253 {TargetValue: liveOutputName,
254 Constraints: []validation.Constraint{{Target: "liveOutputName", Name: validation.MaxLength, Rule: 256, Chain: nil},
255 {Target: "liveOutputName", Name: validation.MinLength, Rule: 1, Chain: nil},
256 {Target: "liveOutputName", Name: validation.Pattern, Rule: `^([a-zA-Z0-9])+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
257 return result, validation.NewError("media.LiveOutputsClient", "Get", err.Error())
258 }
259
260 req, err := client.GetPreparer(ctx, resourceGroupName, accountName, liveEventName, liveOutputName)
261 if err != nil {
262 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "Get", nil, "Failure preparing request")
263 return
264 }
265
266 resp, err := client.GetSender(req)
267 if err != nil {
268 result.Response = autorest.Response{Response: resp}
269 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "Get", resp, "Failure sending request")
270 return
271 }
272
273 result, err = client.GetResponder(resp)
274 if err != nil {
275 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "Get", resp, "Failure responding to request")
276 return
277 }
278
279 return
280 }
281
282
283 func (client LiveOutputsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string) (*http.Request, error) {
284 pathParameters := map[string]interface{}{
285 "accountName": autorest.Encode("path", accountName),
286 "liveEventName": autorest.Encode("path", liveEventName),
287 "liveOutputName": autorest.Encode("path", liveOutputName),
288 "resourceGroupName": autorest.Encode("path", resourceGroupName),
289 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
290 }
291
292 const APIVersion = "2018-06-01-preview"
293 queryParameters := map[string]interface{}{
294 "api-version": APIVersion,
295 }
296
297 preparer := autorest.CreatePreparer(
298 autorest.AsGet(),
299 autorest.WithBaseURL(client.BaseURI),
300 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}", pathParameters),
301 autorest.WithQueryParameters(queryParameters))
302 return preparer.Prepare((&http.Request{}).WithContext(ctx))
303 }
304
305
306
307 func (client LiveOutputsClient) GetSender(req *http.Request) (*http.Response, error) {
308 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
309 }
310
311
312
313 func (client LiveOutputsClient) GetResponder(resp *http.Response) (result LiveOutput, err error) {
314 err = autorest.Respond(
315 resp,
316 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
317 autorest.ByUnmarshallingJSON(&result),
318 autorest.ByClosing())
319 result.Response = autorest.Response{Response: resp}
320 return
321 }
322
323
324
325
326
327
328 func (client LiveOutputsClient) List(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (result LiveOutputListResultPage, err error) {
329 if tracing.IsEnabled() {
330 ctx = tracing.StartSpan(ctx, fqdn+"/LiveOutputsClient.List")
331 defer func() {
332 sc := -1
333 if result.lolr.Response.Response != nil {
334 sc = result.lolr.Response.Response.StatusCode
335 }
336 tracing.EndSpan(ctx, sc, err)
337 }()
338 }
339 if err := validation.Validate([]validation.Validation{
340 {TargetValue: liveEventName,
341 Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
342 {Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
343 {Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
344 return result, validation.NewError("media.LiveOutputsClient", "List", err.Error())
345 }
346
347 result.fn = client.listNextResults
348 req, err := client.ListPreparer(ctx, resourceGroupName, accountName, liveEventName)
349 if err != nil {
350 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "List", nil, "Failure preparing request")
351 return
352 }
353
354 resp, err := client.ListSender(req)
355 if err != nil {
356 result.lolr.Response = autorest.Response{Response: resp}
357 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "List", resp, "Failure sending request")
358 return
359 }
360
361 result.lolr, err = client.ListResponder(resp)
362 if err != nil {
363 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "List", resp, "Failure responding to request")
364 return
365 }
366 if result.lolr.hasNextLink() && result.lolr.IsEmpty() {
367 err = result.NextWithContext(ctx)
368 return
369 }
370
371 return
372 }
373
374
375 func (client LiveOutputsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (*http.Request, error) {
376 pathParameters := map[string]interface{}{
377 "accountName": autorest.Encode("path", accountName),
378 "liveEventName": autorest.Encode("path", liveEventName),
379 "resourceGroupName": autorest.Encode("path", resourceGroupName),
380 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
381 }
382
383 const APIVersion = "2018-06-01-preview"
384 queryParameters := map[string]interface{}{
385 "api-version": APIVersion,
386 }
387
388 preparer := autorest.CreatePreparer(
389 autorest.AsGet(),
390 autorest.WithBaseURL(client.BaseURI),
391 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs", pathParameters),
392 autorest.WithQueryParameters(queryParameters))
393 return preparer.Prepare((&http.Request{}).WithContext(ctx))
394 }
395
396
397
398 func (client LiveOutputsClient) ListSender(req *http.Request) (*http.Response, error) {
399 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
400 }
401
402
403
404 func (client LiveOutputsClient) ListResponder(resp *http.Response) (result LiveOutputListResult, err error) {
405 err = autorest.Respond(
406 resp,
407 azure.WithErrorUnlessStatusCode(http.StatusOK),
408 autorest.ByUnmarshallingJSON(&result),
409 autorest.ByClosing())
410 result.Response = autorest.Response{Response: resp}
411 return
412 }
413
414
415 func (client LiveOutputsClient) listNextResults(ctx context.Context, lastResults LiveOutputListResult) (result LiveOutputListResult, err error) {
416 req, err := lastResults.liveOutputListResultPreparer(ctx)
417 if err != nil {
418 return result, autorest.NewErrorWithError(err, "media.LiveOutputsClient", "listNextResults", nil, "Failure preparing next results request")
419 }
420 if req == nil {
421 return
422 }
423 resp, err := client.ListSender(req)
424 if err != nil {
425 result.Response = autorest.Response{Response: resp}
426 return result, autorest.NewErrorWithError(err, "media.LiveOutputsClient", "listNextResults", resp, "Failure sending next results request")
427 }
428 result, err = client.ListResponder(resp)
429 if err != nil {
430 err = autorest.NewErrorWithError(err, "media.LiveOutputsClient", "listNextResults", resp, "Failure responding to next results request")
431 }
432 return
433 }
434
435
436 func (client LiveOutputsClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (result LiveOutputListResultIterator, err error) {
437 if tracing.IsEnabled() {
438 ctx = tracing.StartSpan(ctx, fqdn+"/LiveOutputsClient.List")
439 defer func() {
440 sc := -1
441 if result.Response().Response.Response != nil {
442 sc = result.page.Response().Response.Response.StatusCode
443 }
444 tracing.EndSpan(ctx, sc, err)
445 }()
446 }
447 result.page, err = client.List(ctx, resourceGroupName, accountName, liveEventName)
448 return
449 }
450
View as plain text