1// +build go1.13
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// Code generated by Microsoft (R) AutoRest Code Generator.
6// Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
8package armcompute
9
10import (
11	"context"
12	"errors"
13	"fmt"
14	"github.com/Azure/azure-sdk-for-go/sdk/armcore"
15	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
16	"net/http"
17	"net/url"
18	"strings"
19	"time"
20)
21
22// GalleryApplicationsClient contains the methods for the GalleryApplications group.
23// Don't use this type directly, use NewGalleryApplicationsClient() instead.
24type GalleryApplicationsClient struct {
25	con            *armcore.Connection
26	subscriptionID string
27}
28
29// NewGalleryApplicationsClient creates a new instance of GalleryApplicationsClient with the specified values.
30func NewGalleryApplicationsClient(con *armcore.Connection, subscriptionID string) *GalleryApplicationsClient {
31	return &GalleryApplicationsClient{con: con, subscriptionID: subscriptionID}
32}
33
34// BeginCreateOrUpdate - Create or update a gallery Application Definition.
35// If the operation fails it returns the *CloudError error type.
36func (client *GalleryApplicationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, galleryApplication GalleryApplication, options *GalleryApplicationsBeginCreateOrUpdateOptions) (GalleryApplicationPollerResponse, error) {
37	resp, err := client.createOrUpdate(ctx, resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options)
38	if err != nil {
39		return GalleryApplicationPollerResponse{}, err
40	}
41	result := GalleryApplicationPollerResponse{
42		RawResponse: resp.Response,
43	}
44	pt, err := armcore.NewLROPoller("GalleryApplicationsClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError)
45	if err != nil {
46		return GalleryApplicationPollerResponse{}, err
47	}
48	poller := &galleryApplicationPoller{
49		pt: pt,
50	}
51	result.Poller = poller
52	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GalleryApplicationResponse, error) {
53		return poller.pollUntilDone(ctx, frequency)
54	}
55	return result, nil
56}
57
58// ResumeCreateOrUpdate creates a new GalleryApplicationPoller from the specified resume token.
59// token - The value must come from a previous call to GalleryApplicationPoller.ResumeToken().
60func (client *GalleryApplicationsClient) ResumeCreateOrUpdate(ctx context.Context, token string) (GalleryApplicationPollerResponse, error) {
61	pt, err := armcore.NewLROPollerFromResumeToken("GalleryApplicationsClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError)
62	if err != nil {
63		return GalleryApplicationPollerResponse{}, err
64	}
65	poller := &galleryApplicationPoller{
66		pt: pt,
67	}
68	resp, err := poller.Poll(ctx)
69	if err != nil {
70		return GalleryApplicationPollerResponse{}, err
71	}
72	result := GalleryApplicationPollerResponse{
73		RawResponse: resp,
74	}
75	result.Poller = poller
76	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GalleryApplicationResponse, error) {
77		return poller.pollUntilDone(ctx, frequency)
78	}
79	return result, nil
80}
81
82// CreateOrUpdate - Create or update a gallery Application Definition.
83// If the operation fails it returns the *CloudError error type.
84func (client *GalleryApplicationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, galleryApplication GalleryApplication, options *GalleryApplicationsBeginCreateOrUpdateOptions) (*azcore.Response, error) {
85	req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options)
86	if err != nil {
87		return nil, err
88	}
89	resp, err := client.con.Pipeline().Do(req)
90	if err != nil {
91		return nil, err
92	}
93	if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) {
94		return nil, client.createOrUpdateHandleError(resp)
95	}
96	return resp, nil
97}
98
99// createOrUpdateCreateRequest creates the CreateOrUpdate request.
100func (client *GalleryApplicationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, galleryApplication GalleryApplication, options *GalleryApplicationsBeginCreateOrUpdateOptions) (*azcore.Request, error) {
101	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"
102	if client.subscriptionID == "" {
103		return nil, errors.New("parameter client.subscriptionID cannot be empty")
104	}
105	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
106	if resourceGroupName == "" {
107		return nil, errors.New("parameter resourceGroupName cannot be empty")
108	}
109	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
110	if galleryName == "" {
111		return nil, errors.New("parameter galleryName cannot be empty")
112	}
113	urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName))
114	if galleryApplicationName == "" {
115		return nil, errors.New("parameter galleryApplicationName cannot be empty")
116	}
117	urlPath = strings.ReplaceAll(urlPath, "{galleryApplicationName}", url.PathEscape(galleryApplicationName))
118	req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))
119	if err != nil {
120		return nil, err
121	}
122	req.Telemetry(telemetryInfo)
123	reqQP := req.URL.Query()
124	reqQP.Set("api-version", "2020-09-30")
125	req.URL.RawQuery = reqQP.Encode()
126	req.Header.Set("Accept", "application/json")
127	return req, req.MarshalAsJSON(galleryApplication)
128}
129
130// createOrUpdateHandleError handles the CreateOrUpdate error response.
131func (client *GalleryApplicationsClient) createOrUpdateHandleError(resp *azcore.Response) error {
132	body, err := resp.Payload()
133	if err != nil {
134		return azcore.NewResponseError(err, resp.Response)
135	}
136	errType := CloudError{raw: string(body)}
137	if err := resp.UnmarshalAsJSON(&errType); err != nil {
138		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
139	}
140	return azcore.NewResponseError(&errType, resp.Response)
141}
142
143// BeginDelete - Delete a gallery Application.
144// If the operation fails it returns the *CloudError error type.
145func (client *GalleryApplicationsClient) BeginDelete(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, options *GalleryApplicationsBeginDeleteOptions) (HTTPPollerResponse, error) {
146	resp, err := client.deleteOperation(ctx, resourceGroupName, galleryName, galleryApplicationName, options)
147	if err != nil {
148		return HTTPPollerResponse{}, err
149	}
150	result := HTTPPollerResponse{
151		RawResponse: resp.Response,
152	}
153	pt, err := armcore.NewLROPoller("GalleryApplicationsClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError)
154	if err != nil {
155		return HTTPPollerResponse{}, err
156	}
157	poller := &httpPoller{
158		pt: pt,
159	}
160	result.Poller = poller
161	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) {
162		return poller.pollUntilDone(ctx, frequency)
163	}
164	return result, nil
165}
166
167// ResumeDelete creates a new HTTPPoller from the specified resume token.
168// token - The value must come from a previous call to HTTPPoller.ResumeToken().
169func (client *GalleryApplicationsClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) {
170	pt, err := armcore.NewLROPollerFromResumeToken("GalleryApplicationsClient.Delete", token, client.con.Pipeline(), client.deleteHandleError)
171	if err != nil {
172		return HTTPPollerResponse{}, err
173	}
174	poller := &httpPoller{
175		pt: pt,
176	}
177	resp, err := poller.Poll(ctx)
178	if err != nil {
179		return HTTPPollerResponse{}, err
180	}
181	result := HTTPPollerResponse{
182		RawResponse: resp,
183	}
184	result.Poller = poller
185	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) {
186		return poller.pollUntilDone(ctx, frequency)
187	}
188	return result, nil
189}
190
191// Delete - Delete a gallery Application.
192// If the operation fails it returns the *CloudError error type.
193func (client *GalleryApplicationsClient) deleteOperation(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, options *GalleryApplicationsBeginDeleteOptions) (*azcore.Response, error) {
194	req, err := client.deleteCreateRequest(ctx, resourceGroupName, galleryName, galleryApplicationName, options)
195	if err != nil {
196		return nil, err
197	}
198	resp, err := client.con.Pipeline().Do(req)
199	if err != nil {
200		return nil, err
201	}
202	if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) {
203		return nil, client.deleteHandleError(resp)
204	}
205	return resp, nil
206}
207
208// deleteCreateRequest creates the Delete request.
209func (client *GalleryApplicationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, options *GalleryApplicationsBeginDeleteOptions) (*azcore.Request, error) {
210	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"
211	if client.subscriptionID == "" {
212		return nil, errors.New("parameter client.subscriptionID cannot be empty")
213	}
214	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
215	if resourceGroupName == "" {
216		return nil, errors.New("parameter resourceGroupName cannot be empty")
217	}
218	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
219	if galleryName == "" {
220		return nil, errors.New("parameter galleryName cannot be empty")
221	}
222	urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName))
223	if galleryApplicationName == "" {
224		return nil, errors.New("parameter galleryApplicationName cannot be empty")
225	}
226	urlPath = strings.ReplaceAll(urlPath, "{galleryApplicationName}", url.PathEscape(galleryApplicationName))
227	req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))
228	if err != nil {
229		return nil, err
230	}
231	req.Telemetry(telemetryInfo)
232	reqQP := req.URL.Query()
233	reqQP.Set("api-version", "2020-09-30")
234	req.URL.RawQuery = reqQP.Encode()
235	req.Header.Set("Accept", "application/json")
236	return req, nil
237}
238
239// deleteHandleError handles the Delete error response.
240func (client *GalleryApplicationsClient) deleteHandleError(resp *azcore.Response) error {
241	body, err := resp.Payload()
242	if err != nil {
243		return azcore.NewResponseError(err, resp.Response)
244	}
245	errType := CloudError{raw: string(body)}
246	if err := resp.UnmarshalAsJSON(&errType); err != nil {
247		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
248	}
249	return azcore.NewResponseError(&errType, resp.Response)
250}
251
252// Get - Retrieves information about a gallery Application Definition.
253// If the operation fails it returns the *CloudError error type.
254func (client *GalleryApplicationsClient) Get(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, options *GalleryApplicationsGetOptions) (GalleryApplicationResponse, error) {
255	req, err := client.getCreateRequest(ctx, resourceGroupName, galleryName, galleryApplicationName, options)
256	if err != nil {
257		return GalleryApplicationResponse{}, err
258	}
259	resp, err := client.con.Pipeline().Do(req)
260	if err != nil {
261		return GalleryApplicationResponse{}, err
262	}
263	if !resp.HasStatusCode(http.StatusOK) {
264		return GalleryApplicationResponse{}, client.getHandleError(resp)
265	}
266	return client.getHandleResponse(resp)
267}
268
269// getCreateRequest creates the Get request.
270func (client *GalleryApplicationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, options *GalleryApplicationsGetOptions) (*azcore.Request, error) {
271	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"
272	if client.subscriptionID == "" {
273		return nil, errors.New("parameter client.subscriptionID cannot be empty")
274	}
275	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
276	if resourceGroupName == "" {
277		return nil, errors.New("parameter resourceGroupName cannot be empty")
278	}
279	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
280	if galleryName == "" {
281		return nil, errors.New("parameter galleryName cannot be empty")
282	}
283	urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName))
284	if galleryApplicationName == "" {
285		return nil, errors.New("parameter galleryApplicationName cannot be empty")
286	}
287	urlPath = strings.ReplaceAll(urlPath, "{galleryApplicationName}", url.PathEscape(galleryApplicationName))
288	req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))
289	if err != nil {
290		return nil, err
291	}
292	req.Telemetry(telemetryInfo)
293	reqQP := req.URL.Query()
294	reqQP.Set("api-version", "2020-09-30")
295	req.URL.RawQuery = reqQP.Encode()
296	req.Header.Set("Accept", "application/json")
297	return req, nil
298}
299
300// getHandleResponse handles the Get response.
301func (client *GalleryApplicationsClient) getHandleResponse(resp *azcore.Response) (GalleryApplicationResponse, error) {
302	var val *GalleryApplication
303	if err := resp.UnmarshalAsJSON(&val); err != nil {
304		return GalleryApplicationResponse{}, err
305	}
306	return GalleryApplicationResponse{RawResponse: resp.Response, GalleryApplication: val}, nil
307}
308
309// getHandleError handles the Get error response.
310func (client *GalleryApplicationsClient) getHandleError(resp *azcore.Response) error {
311	body, err := resp.Payload()
312	if err != nil {
313		return azcore.NewResponseError(err, resp.Response)
314	}
315	errType := CloudError{raw: string(body)}
316	if err := resp.UnmarshalAsJSON(&errType); err != nil {
317		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
318	}
319	return azcore.NewResponseError(&errType, resp.Response)
320}
321
322// ListByGallery - List gallery Application Definitions in a gallery.
323// If the operation fails it returns the *CloudError error type.
324func (client *GalleryApplicationsClient) ListByGallery(resourceGroupName string, galleryName string, options *GalleryApplicationsListByGalleryOptions) GalleryApplicationListPager {
325	return &galleryApplicationListPager{
326		pipeline: client.con.Pipeline(),
327		requester: func(ctx context.Context) (*azcore.Request, error) {
328			return client.listByGalleryCreateRequest(ctx, resourceGroupName, galleryName, options)
329		},
330		responder: client.listByGalleryHandleResponse,
331		errorer:   client.listByGalleryHandleError,
332		advancer: func(ctx context.Context, resp GalleryApplicationListResponse) (*azcore.Request, error) {
333			return azcore.NewRequest(ctx, http.MethodGet, *resp.GalleryApplicationList.NextLink)
334		},
335		statusCodes: []int{http.StatusOK},
336	}
337}
338
339// listByGalleryCreateRequest creates the ListByGallery request.
340func (client *GalleryApplicationsClient) listByGalleryCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, options *GalleryApplicationsListByGalleryOptions) (*azcore.Request, error) {
341	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications"
342	if client.subscriptionID == "" {
343		return nil, errors.New("parameter client.subscriptionID cannot be empty")
344	}
345	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
346	if resourceGroupName == "" {
347		return nil, errors.New("parameter resourceGroupName cannot be empty")
348	}
349	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
350	if galleryName == "" {
351		return nil, errors.New("parameter galleryName cannot be empty")
352	}
353	urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName))
354	req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))
355	if err != nil {
356		return nil, err
357	}
358	req.Telemetry(telemetryInfo)
359	reqQP := req.URL.Query()
360	reqQP.Set("api-version", "2020-09-30")
361	req.URL.RawQuery = reqQP.Encode()
362	req.Header.Set("Accept", "application/json")
363	return req, nil
364}
365
366// listByGalleryHandleResponse handles the ListByGallery response.
367func (client *GalleryApplicationsClient) listByGalleryHandleResponse(resp *azcore.Response) (GalleryApplicationListResponse, error) {
368	var val *GalleryApplicationList
369	if err := resp.UnmarshalAsJSON(&val); err != nil {
370		return GalleryApplicationListResponse{}, err
371	}
372	return GalleryApplicationListResponse{RawResponse: resp.Response, GalleryApplicationList: val}, nil
373}
374
375// listByGalleryHandleError handles the ListByGallery error response.
376func (client *GalleryApplicationsClient) listByGalleryHandleError(resp *azcore.Response) error {
377	body, err := resp.Payload()
378	if err != nil {
379		return azcore.NewResponseError(err, resp.Response)
380	}
381	errType := CloudError{raw: string(body)}
382	if err := resp.UnmarshalAsJSON(&errType); err != nil {
383		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
384	}
385	return azcore.NewResponseError(&errType, resp.Response)
386}
387
388// BeginUpdate - Update a gallery Application Definition.
389// If the operation fails it returns the *CloudError error type.
390func (client *GalleryApplicationsClient) BeginUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, galleryApplication GalleryApplicationUpdate, options *GalleryApplicationsBeginUpdateOptions) (GalleryApplicationPollerResponse, error) {
391	resp, err := client.update(ctx, resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options)
392	if err != nil {
393		return GalleryApplicationPollerResponse{}, err
394	}
395	result := GalleryApplicationPollerResponse{
396		RawResponse: resp.Response,
397	}
398	pt, err := armcore.NewLROPoller("GalleryApplicationsClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError)
399	if err != nil {
400		return GalleryApplicationPollerResponse{}, err
401	}
402	poller := &galleryApplicationPoller{
403		pt: pt,
404	}
405	result.Poller = poller
406	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GalleryApplicationResponse, error) {
407		return poller.pollUntilDone(ctx, frequency)
408	}
409	return result, nil
410}
411
412// ResumeUpdate creates a new GalleryApplicationPoller from the specified resume token.
413// token - The value must come from a previous call to GalleryApplicationPoller.ResumeToken().
414func (client *GalleryApplicationsClient) ResumeUpdate(ctx context.Context, token string) (GalleryApplicationPollerResponse, error) {
415	pt, err := armcore.NewLROPollerFromResumeToken("GalleryApplicationsClient.Update", token, client.con.Pipeline(), client.updateHandleError)
416	if err != nil {
417		return GalleryApplicationPollerResponse{}, err
418	}
419	poller := &galleryApplicationPoller{
420		pt: pt,
421	}
422	resp, err := poller.Poll(ctx)
423	if err != nil {
424		return GalleryApplicationPollerResponse{}, err
425	}
426	result := GalleryApplicationPollerResponse{
427		RawResponse: resp,
428	}
429	result.Poller = poller
430	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GalleryApplicationResponse, error) {
431		return poller.pollUntilDone(ctx, frequency)
432	}
433	return result, nil
434}
435
436// Update - Update a gallery Application Definition.
437// If the operation fails it returns the *CloudError error type.
438func (client *GalleryApplicationsClient) update(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, galleryApplication GalleryApplicationUpdate, options *GalleryApplicationsBeginUpdateOptions) (*azcore.Response, error) {
439	req, err := client.updateCreateRequest(ctx, resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options)
440	if err != nil {
441		return nil, err
442	}
443	resp, err := client.con.Pipeline().Do(req)
444	if err != nil {
445		return nil, err
446	}
447	if !resp.HasStatusCode(http.StatusOK) {
448		return nil, client.updateHandleError(resp)
449	}
450	return resp, nil
451}
452
453// updateCreateRequest creates the Update request.
454func (client *GalleryApplicationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, galleryApplicationName string, galleryApplication GalleryApplicationUpdate, options *GalleryApplicationsBeginUpdateOptions) (*azcore.Request, error) {
455	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}"
456	if client.subscriptionID == "" {
457		return nil, errors.New("parameter client.subscriptionID cannot be empty")
458	}
459	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
460	if resourceGroupName == "" {
461		return nil, errors.New("parameter resourceGroupName cannot be empty")
462	}
463	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
464	if galleryName == "" {
465		return nil, errors.New("parameter galleryName cannot be empty")
466	}
467	urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName))
468	if galleryApplicationName == "" {
469		return nil, errors.New("parameter galleryApplicationName cannot be empty")
470	}
471	urlPath = strings.ReplaceAll(urlPath, "{galleryApplicationName}", url.PathEscape(galleryApplicationName))
472	req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath))
473	if err != nil {
474		return nil, err
475	}
476	req.Telemetry(telemetryInfo)
477	reqQP := req.URL.Query()
478	reqQP.Set("api-version", "2020-09-30")
479	req.URL.RawQuery = reqQP.Encode()
480	req.Header.Set("Accept", "application/json")
481	return req, req.MarshalAsJSON(galleryApplication)
482}
483
484// updateHandleError handles the Update error response.
485func (client *GalleryApplicationsClient) updateHandleError(resp *azcore.Response) error {
486	body, err := resp.Payload()
487	if err != nil {
488		return azcore.NewResponseError(err, resp.Response)
489	}
490	errType := CloudError{raw: string(body)}
491	if err := resp.UnmarshalAsJSON(&errType); err != nil {
492		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
493	}
494	return azcore.NewResponseError(&errType, resp.Response)
495}
496