1package videoanalyzer
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
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// VideosClient is the azure Video Analyzer ARM Client
19type VideosClient struct {
20	BaseClient
21}
22
23// NewVideosClient creates an instance of the VideosClient client.
24func NewVideosClient(subscriptionID string) VideosClient {
25	return NewVideosClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewVideosClientWithBaseURI creates an instance of the VideosClient client using a custom endpoint.  Use this when
29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewVideosClientWithBaseURI(baseURI string, subscriptionID string) VideosClient {
31	return VideosClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdate creates a new video resource or updates an existing one in an account.
35// Parameters:
36// resourceGroupName - the name of the resource group. The name is case insensitive.
37// accountName - the Azure Video Analyzer account name.
38// videoName - the name of the video to create or update.
39// parameters - the request parameters
40func (client VideosClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity) (result VideoEntity, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/VideosClient.CreateOrUpdate")
43		defer func() {
44			sc := -1
45			if result.Response.Response != nil {
46				sc = result.Response.Response.StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: client.SubscriptionID,
53			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
54		{TargetValue: resourceGroupName,
55			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
56				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
57				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
58		{TargetValue: parameters,
59			Constraints: []validation.Constraint{{Target: "parameters.VideoProperties", Name: validation.Null, Rule: false,
60				Chain: []validation.Constraint{{Target: "parameters.VideoProperties.Flags", Name: validation.Null, Rule: false,
61					Chain: []validation.Constraint{{Target: "parameters.VideoProperties.Flags.CanStream", Name: validation.Null, Rule: true, Chain: nil},
62						{Target: "parameters.VideoProperties.Flags.HasData", Name: validation.Null, Rule: true, Chain: nil},
63						{Target: "parameters.VideoProperties.Flags.IsRecording", Name: validation.Null, Rule: true, Chain: nil},
64					}},
65				}}}}}); err != nil {
66		return result, validation.NewError("videoanalyzer.VideosClient", "CreateOrUpdate", err.Error())
67	}
68
69	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, videoName, parameters)
70	if err != nil {
71		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "CreateOrUpdate", nil, "Failure preparing request")
72		return
73	}
74
75	resp, err := client.CreateOrUpdateSender(req)
76	if err != nil {
77		result.Response = autorest.Response{Response: resp}
78		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "CreateOrUpdate", resp, "Failure sending request")
79		return
80	}
81
82	result, err = client.CreateOrUpdateResponder(resp)
83	if err != nil {
84		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "CreateOrUpdate", resp, "Failure responding to request")
85		return
86	}
87
88	return
89}
90
91// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
92func (client VideosClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity) (*http.Request, error) {
93	pathParameters := map[string]interface{}{
94		"accountName":       autorest.Encode("path", accountName),
95		"resourceGroupName": autorest.Encode("path", resourceGroupName),
96		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
97		"videoName":         autorest.Encode("path", videoName),
98	}
99
100	const APIVersion = "2021-05-01-preview"
101	queryParameters := map[string]interface{}{
102		"api-version": APIVersion,
103	}
104
105	parameters.SystemData = nil
106	preparer := autorest.CreatePreparer(
107		autorest.AsContentType("application/json; charset=utf-8"),
108		autorest.AsPut(),
109		autorest.WithBaseURL(client.BaseURI),
110		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}", pathParameters),
111		autorest.WithJSON(parameters),
112		autorest.WithQueryParameters(queryParameters))
113	return preparer.Prepare((&http.Request{}).WithContext(ctx))
114}
115
116// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
117// http.Response Body if it receives an error.
118func (client VideosClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
119	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
120}
121
122// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
123// closes the http.Response Body.
124func (client VideosClient) CreateOrUpdateResponder(resp *http.Response) (result VideoEntity, err error) {
125	err = autorest.Respond(
126		resp,
127		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
128		autorest.ByUnmarshallingJSON(&result),
129		autorest.ByClosing())
130	result.Response = autorest.Response{Response: resp}
131	return
132}
133
134// Delete deletes an existing video resource and its underlying data. This operation is irreversible.
135// Parameters:
136// resourceGroupName - the name of the resource group. The name is case insensitive.
137// accountName - the Azure Video Analyzer account name.
138// videoName - the name of the video to delete.
139func (client VideosClient) Delete(ctx context.Context, resourceGroupName string, accountName string, videoName string) (result autorest.Response, err error) {
140	if tracing.IsEnabled() {
141		ctx = tracing.StartSpan(ctx, fqdn+"/VideosClient.Delete")
142		defer func() {
143			sc := -1
144			if result.Response != nil {
145				sc = result.Response.StatusCode
146			}
147			tracing.EndSpan(ctx, sc, err)
148		}()
149	}
150	if err := validation.Validate([]validation.Validation{
151		{TargetValue: client.SubscriptionID,
152			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
153		{TargetValue: resourceGroupName,
154			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
155				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
156				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
157		return result, validation.NewError("videoanalyzer.VideosClient", "Delete", err.Error())
158	}
159
160	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, videoName)
161	if err != nil {
162		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Delete", nil, "Failure preparing request")
163		return
164	}
165
166	resp, err := client.DeleteSender(req)
167	if err != nil {
168		result.Response = resp
169		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Delete", resp, "Failure sending request")
170		return
171	}
172
173	result, err = client.DeleteResponder(resp)
174	if err != nil {
175		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Delete", resp, "Failure responding to request")
176		return
177	}
178
179	return
180}
181
182// DeletePreparer prepares the Delete request.
183func (client VideosClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, videoName string) (*http.Request, error) {
184	pathParameters := map[string]interface{}{
185		"accountName":       autorest.Encode("path", accountName),
186		"resourceGroupName": autorest.Encode("path", resourceGroupName),
187		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
188		"videoName":         autorest.Encode("path", videoName),
189	}
190
191	const APIVersion = "2021-05-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/videoAnalyzers/{accountName}/videos/{videoName}", pathParameters),
200		autorest.WithQueryParameters(queryParameters))
201	return preparer.Prepare((&http.Request{}).WithContext(ctx))
202}
203
204// DeleteSender sends the Delete request. The method will close the
205// http.Response Body if it receives an error.
206func (client VideosClient) DeleteSender(req *http.Request) (*http.Response, error) {
207	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
208}
209
210// DeleteResponder handles the response to the Delete request. The method always
211// closes the http.Response Body.
212func (client VideosClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
213	err = autorest.Respond(
214		resp,
215		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
216		autorest.ByClosing())
217	result.Response = resp
218	return
219}
220
221// Get retrieves an existing video resource within an account with a given name.
222// Parameters:
223// resourceGroupName - the name of the resource group. The name is case insensitive.
224// accountName - the Azure Video Analyzer account name.
225// videoName - the name of the video to retrieve.
226func (client VideosClient) Get(ctx context.Context, resourceGroupName string, accountName string, videoName string) (result VideoEntity, err error) {
227	if tracing.IsEnabled() {
228		ctx = tracing.StartSpan(ctx, fqdn+"/VideosClient.Get")
229		defer func() {
230			sc := -1
231			if result.Response.Response != nil {
232				sc = result.Response.Response.StatusCode
233			}
234			tracing.EndSpan(ctx, sc, err)
235		}()
236	}
237	if err := validation.Validate([]validation.Validation{
238		{TargetValue: client.SubscriptionID,
239			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
240		{TargetValue: resourceGroupName,
241			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
242				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
243				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
244		return result, validation.NewError("videoanalyzer.VideosClient", "Get", err.Error())
245	}
246
247	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, videoName)
248	if err != nil {
249		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Get", nil, "Failure preparing request")
250		return
251	}
252
253	resp, err := client.GetSender(req)
254	if err != nil {
255		result.Response = autorest.Response{Response: resp}
256		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Get", resp, "Failure sending request")
257		return
258	}
259
260	result, err = client.GetResponder(resp)
261	if err != nil {
262		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Get", resp, "Failure responding to request")
263		return
264	}
265
266	return
267}
268
269// GetPreparer prepares the Get request.
270func (client VideosClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, videoName string) (*http.Request, error) {
271	pathParameters := map[string]interface{}{
272		"accountName":       autorest.Encode("path", accountName),
273		"resourceGroupName": autorest.Encode("path", resourceGroupName),
274		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
275		"videoName":         autorest.Encode("path", videoName),
276	}
277
278	const APIVersion = "2021-05-01-preview"
279	queryParameters := map[string]interface{}{
280		"api-version": APIVersion,
281	}
282
283	preparer := autorest.CreatePreparer(
284		autorest.AsGet(),
285		autorest.WithBaseURL(client.BaseURI),
286		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}", pathParameters),
287		autorest.WithQueryParameters(queryParameters))
288	return preparer.Prepare((&http.Request{}).WithContext(ctx))
289}
290
291// GetSender sends the Get request. The method will close the
292// http.Response Body if it receives an error.
293func (client VideosClient) GetSender(req *http.Request) (*http.Response, error) {
294	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
295}
296
297// GetResponder handles the response to the Get request. The method always
298// closes the http.Response Body.
299func (client VideosClient) GetResponder(resp *http.Response) (result VideoEntity, err error) {
300	err = autorest.Respond(
301		resp,
302		azure.WithErrorUnlessStatusCode(http.StatusOK),
303		autorest.ByUnmarshallingJSON(&result),
304		autorest.ByClosing())
305	result.Response = autorest.Response{Response: resp}
306	return
307}
308
309// List list all existing video resources in the specified account.
310// Parameters:
311// resourceGroupName - the name of the resource group. The name is case insensitive.
312// accountName - the Azure Video Analyzer account name.
313// top - specifies a non-negative integer n that limits the number of items returned from a collection. The
314// service returns the number of available items up to but not greater than the specified value n.
315func (client VideosClient) List(ctx context.Context, resourceGroupName string, accountName string, top *int32) (result VideoEntityCollectionPage, err error) {
316	if tracing.IsEnabled() {
317		ctx = tracing.StartSpan(ctx, fqdn+"/VideosClient.List")
318		defer func() {
319			sc := -1
320			if result.vec.Response.Response != nil {
321				sc = result.vec.Response.Response.StatusCode
322			}
323			tracing.EndSpan(ctx, sc, err)
324		}()
325	}
326	if err := validation.Validate([]validation.Validation{
327		{TargetValue: client.SubscriptionID,
328			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
329		{TargetValue: resourceGroupName,
330			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
331				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
332				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
333		return result, validation.NewError("videoanalyzer.VideosClient", "List", err.Error())
334	}
335
336	result.fn = client.listNextResults
337	req, err := client.ListPreparer(ctx, resourceGroupName, accountName, top)
338	if err != nil {
339		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "List", nil, "Failure preparing request")
340		return
341	}
342
343	resp, err := client.ListSender(req)
344	if err != nil {
345		result.vec.Response = autorest.Response{Response: resp}
346		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "List", resp, "Failure sending request")
347		return
348	}
349
350	result.vec, err = client.ListResponder(resp)
351	if err != nil {
352		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "List", resp, "Failure responding to request")
353		return
354	}
355	if result.vec.hasNextLink() && result.vec.IsEmpty() {
356		err = result.NextWithContext(ctx)
357		return
358	}
359
360	return
361}
362
363// ListPreparer prepares the List request.
364func (client VideosClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, top *int32) (*http.Request, error) {
365	pathParameters := map[string]interface{}{
366		"accountName":       autorest.Encode("path", accountName),
367		"resourceGroupName": autorest.Encode("path", resourceGroupName),
368		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
369	}
370
371	const APIVersion = "2021-05-01-preview"
372	queryParameters := map[string]interface{}{
373		"api-version": APIVersion,
374	}
375	if top != nil {
376		queryParameters["$top"] = autorest.Encode("query", *top)
377	}
378
379	preparer := autorest.CreatePreparer(
380		autorest.AsGet(),
381		autorest.WithBaseURL(client.BaseURI),
382		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos", pathParameters),
383		autorest.WithQueryParameters(queryParameters))
384	return preparer.Prepare((&http.Request{}).WithContext(ctx))
385}
386
387// ListSender sends the List request. The method will close the
388// http.Response Body if it receives an error.
389func (client VideosClient) ListSender(req *http.Request) (*http.Response, error) {
390	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
391}
392
393// ListResponder handles the response to the List request. The method always
394// closes the http.Response Body.
395func (client VideosClient) ListResponder(resp *http.Response) (result VideoEntityCollection, err error) {
396	err = autorest.Respond(
397		resp,
398		azure.WithErrorUnlessStatusCode(http.StatusOK),
399		autorest.ByUnmarshallingJSON(&result),
400		autorest.ByClosing())
401	result.Response = autorest.Response{Response: resp}
402	return
403}
404
405// listNextResults retrieves the next set of results, if any.
406func (client VideosClient) listNextResults(ctx context.Context, lastResults VideoEntityCollection) (result VideoEntityCollection, err error) {
407	req, err := lastResults.videoEntityCollectionPreparer(ctx)
408	if err != nil {
409		return result, autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "listNextResults", nil, "Failure preparing next results request")
410	}
411	if req == nil {
412		return
413	}
414	resp, err := client.ListSender(req)
415	if err != nil {
416		result.Response = autorest.Response{Response: resp}
417		return result, autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "listNextResults", resp, "Failure sending next results request")
418	}
419	result, err = client.ListResponder(resp)
420	if err != nil {
421		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "listNextResults", resp, "Failure responding to next results request")
422	}
423	return
424}
425
426// ListComplete enumerates all values, automatically crossing page boundaries as required.
427func (client VideosClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string, top *int32) (result VideoEntityCollectionIterator, err error) {
428	if tracing.IsEnabled() {
429		ctx = tracing.StartSpan(ctx, fqdn+"/VideosClient.List")
430		defer func() {
431			sc := -1
432			if result.Response().Response.Response != nil {
433				sc = result.page.Response().Response.Response.StatusCode
434			}
435			tracing.EndSpan(ctx, sc, err)
436		}()
437	}
438	result.page, err = client.List(ctx, resourceGroupName, accountName, top)
439	return
440}
441
442// ListStreamingToken generates a streaming token used for authenticating video playback.
443// Parameters:
444// resourceGroupName - the name of the resource group. The name is case insensitive.
445// accountName - the Azure Video Analyzer account name.
446// videoName - the name of the video to generate a token for playback.
447func (client VideosClient) ListStreamingToken(ctx context.Context, resourceGroupName string, accountName string, videoName string) (result VideoStreamingToken, err error) {
448	if tracing.IsEnabled() {
449		ctx = tracing.StartSpan(ctx, fqdn+"/VideosClient.ListStreamingToken")
450		defer func() {
451			sc := -1
452			if result.Response.Response != nil {
453				sc = result.Response.Response.StatusCode
454			}
455			tracing.EndSpan(ctx, sc, err)
456		}()
457	}
458	if err := validation.Validate([]validation.Validation{
459		{TargetValue: client.SubscriptionID,
460			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
461		{TargetValue: resourceGroupName,
462			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
463				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
464				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
465		return result, validation.NewError("videoanalyzer.VideosClient", "ListStreamingToken", err.Error())
466	}
467
468	req, err := client.ListStreamingTokenPreparer(ctx, resourceGroupName, accountName, videoName)
469	if err != nil {
470		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "ListStreamingToken", nil, "Failure preparing request")
471		return
472	}
473
474	resp, err := client.ListStreamingTokenSender(req)
475	if err != nil {
476		result.Response = autorest.Response{Response: resp}
477		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "ListStreamingToken", resp, "Failure sending request")
478		return
479	}
480
481	result, err = client.ListStreamingTokenResponder(resp)
482	if err != nil {
483		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "ListStreamingToken", resp, "Failure responding to request")
484		return
485	}
486
487	return
488}
489
490// ListStreamingTokenPreparer prepares the ListStreamingToken request.
491func (client VideosClient) ListStreamingTokenPreparer(ctx context.Context, resourceGroupName string, accountName string, videoName string) (*http.Request, error) {
492	pathParameters := map[string]interface{}{
493		"accountName":       autorest.Encode("path", accountName),
494		"resourceGroupName": autorest.Encode("path", resourceGroupName),
495		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
496		"videoName":         autorest.Encode("path", videoName),
497	}
498
499	const APIVersion = "2021-05-01-preview"
500	queryParameters := map[string]interface{}{
501		"api-version": APIVersion,
502	}
503
504	preparer := autorest.CreatePreparer(
505		autorest.AsPost(),
506		autorest.WithBaseURL(client.BaseURI),
507		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}/listStreamingToken", pathParameters),
508		autorest.WithQueryParameters(queryParameters))
509	return preparer.Prepare((&http.Request{}).WithContext(ctx))
510}
511
512// ListStreamingTokenSender sends the ListStreamingToken request. The method will close the
513// http.Response Body if it receives an error.
514func (client VideosClient) ListStreamingTokenSender(req *http.Request) (*http.Response, error) {
515	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
516}
517
518// ListStreamingTokenResponder handles the response to the ListStreamingToken request. The method always
519// closes the http.Response Body.
520func (client VideosClient) ListStreamingTokenResponder(resp *http.Response) (result VideoStreamingToken, err error) {
521	err = autorest.Respond(
522		resp,
523		azure.WithErrorUnlessStatusCode(http.StatusOK),
524		autorest.ByUnmarshallingJSON(&result),
525		autorest.ByClosing())
526	result.Response = autorest.Response{Response: resp}
527	return
528}
529
530// Update updates individual properties of an existing video resource.
531// Parameters:
532// resourceGroupName - the name of the resource group. The name is case insensitive.
533// accountName - the Azure Video Analyzer account name.
534// videoName - the name of the video to update.
535// parameters - the request parameters
536func (client VideosClient) Update(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity) (result VideoEntity, err error) {
537	if tracing.IsEnabled() {
538		ctx = tracing.StartSpan(ctx, fqdn+"/VideosClient.Update")
539		defer func() {
540			sc := -1
541			if result.Response.Response != nil {
542				sc = result.Response.Response.StatusCode
543			}
544			tracing.EndSpan(ctx, sc, err)
545		}()
546	}
547	if err := validation.Validate([]validation.Validation{
548		{TargetValue: client.SubscriptionID,
549			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
550		{TargetValue: resourceGroupName,
551			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
552				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
553				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
554		return result, validation.NewError("videoanalyzer.VideosClient", "Update", err.Error())
555	}
556
557	req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, videoName, parameters)
558	if err != nil {
559		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Update", nil, "Failure preparing request")
560		return
561	}
562
563	resp, err := client.UpdateSender(req)
564	if err != nil {
565		result.Response = autorest.Response{Response: resp}
566		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Update", resp, "Failure sending request")
567		return
568	}
569
570	result, err = client.UpdateResponder(resp)
571	if err != nil {
572		err = autorest.NewErrorWithError(err, "videoanalyzer.VideosClient", "Update", resp, "Failure responding to request")
573		return
574	}
575
576	return
577}
578
579// UpdatePreparer prepares the Update request.
580func (client VideosClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity) (*http.Request, error) {
581	pathParameters := map[string]interface{}{
582		"accountName":       autorest.Encode("path", accountName),
583		"resourceGroupName": autorest.Encode("path", resourceGroupName),
584		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
585		"videoName":         autorest.Encode("path", videoName),
586	}
587
588	const APIVersion = "2021-05-01-preview"
589	queryParameters := map[string]interface{}{
590		"api-version": APIVersion,
591	}
592
593	parameters.SystemData = nil
594	preparer := autorest.CreatePreparer(
595		autorest.AsContentType("application/json; charset=utf-8"),
596		autorest.AsPatch(),
597		autorest.WithBaseURL(client.BaseURI),
598		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}", pathParameters),
599		autorest.WithJSON(parameters),
600		autorest.WithQueryParameters(queryParameters))
601	return preparer.Prepare((&http.Request{}).WithContext(ctx))
602}
603
604// UpdateSender sends the Update request. The method will close the
605// http.Response Body if it receives an error.
606func (client VideosClient) UpdateSender(req *http.Request) (*http.Response, error) {
607	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
608}
609
610// UpdateResponder handles the response to the Update request. The method always
611// closes the http.Response Body.
612func (client VideosClient) UpdateResponder(resp *http.Response) (result VideoEntity, err error) {
613	err = autorest.Respond(
614		resp,
615		azure.WithErrorUnlessStatusCode(http.StatusOK),
616		autorest.ByUnmarshallingJSON(&result),
617		autorest.ByClosing())
618	result.Response = autorest.Response{Response: resp}
619	return
620}
621