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