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// GalleriesClient contains the methods for the Galleries group.
23// Don't use this type directly, use NewGalleriesClient() instead.
24type GalleriesClient struct {
25	con            *armcore.Connection
26	subscriptionID string
27}
28
29// NewGalleriesClient creates a new instance of GalleriesClient with the specified values.
30func NewGalleriesClient(con *armcore.Connection, subscriptionID string) *GalleriesClient {
31	return &GalleriesClient{con: con, subscriptionID: subscriptionID}
32}
33
34// BeginCreateOrUpdate - Create or update a Shared Image Gallery.
35// If the operation fails it returns the *CloudError error type.
36func (client *GalleriesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, gallery Gallery, options *GalleriesBeginCreateOrUpdateOptions) (GalleryPollerResponse, error) {
37	resp, err := client.createOrUpdate(ctx, resourceGroupName, galleryName, gallery, options)
38	if err != nil {
39		return GalleryPollerResponse{}, err
40	}
41	result := GalleryPollerResponse{
42		RawResponse: resp.Response,
43	}
44	pt, err := armcore.NewLROPoller("GalleriesClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError)
45	if err != nil {
46		return GalleryPollerResponse{}, err
47	}
48	poller := &galleryPoller{
49		pt: pt,
50	}
51	result.Poller = poller
52	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GalleryResponse, error) {
53		return poller.pollUntilDone(ctx, frequency)
54	}
55	return result, nil
56}
57
58// ResumeCreateOrUpdate creates a new GalleryPoller from the specified resume token.
59// token - The value must come from a previous call to GalleryPoller.ResumeToken().
60func (client *GalleriesClient) ResumeCreateOrUpdate(ctx context.Context, token string) (GalleryPollerResponse, error) {
61	pt, err := armcore.NewLROPollerFromResumeToken("GalleriesClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError)
62	if err != nil {
63		return GalleryPollerResponse{}, err
64	}
65	poller := &galleryPoller{
66		pt: pt,
67	}
68	resp, err := poller.Poll(ctx)
69	if err != nil {
70		return GalleryPollerResponse{}, err
71	}
72	result := GalleryPollerResponse{
73		RawResponse: resp,
74	}
75	result.Poller = poller
76	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GalleryResponse, error) {
77		return poller.pollUntilDone(ctx, frequency)
78	}
79	return result, nil
80}
81
82// CreateOrUpdate - Create or update a Shared Image Gallery.
83// If the operation fails it returns the *CloudError error type.
84func (client *GalleriesClient) createOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, gallery Gallery, options *GalleriesBeginCreateOrUpdateOptions) (*azcore.Response, error) {
85	req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, galleryName, gallery, 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 *GalleriesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, gallery Gallery, options *GalleriesBeginCreateOrUpdateOptions) (*azcore.Request, error) {
101	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"
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	req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))
115	if err != nil {
116		return nil, err
117	}
118	req.Telemetry(telemetryInfo)
119	reqQP := req.URL.Query()
120	reqQP.Set("api-version", "2020-09-30")
121	req.URL.RawQuery = reqQP.Encode()
122	req.Header.Set("Accept", "application/json")
123	return req, req.MarshalAsJSON(gallery)
124}
125
126// createOrUpdateHandleError handles the CreateOrUpdate error response.
127func (client *GalleriesClient) createOrUpdateHandleError(resp *azcore.Response) error {
128	body, err := resp.Payload()
129	if err != nil {
130		return azcore.NewResponseError(err, resp.Response)
131	}
132	errType := CloudError{raw: string(body)}
133	if err := resp.UnmarshalAsJSON(&errType); err != nil {
134		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
135	}
136	return azcore.NewResponseError(&errType, resp.Response)
137}
138
139// BeginDelete - Delete a Shared Image Gallery.
140// If the operation fails it returns the *CloudError error type.
141func (client *GalleriesClient) BeginDelete(ctx context.Context, resourceGroupName string, galleryName string, options *GalleriesBeginDeleteOptions) (HTTPPollerResponse, error) {
142	resp, err := client.deleteOperation(ctx, resourceGroupName, galleryName, options)
143	if err != nil {
144		return HTTPPollerResponse{}, err
145	}
146	result := HTTPPollerResponse{
147		RawResponse: resp.Response,
148	}
149	pt, err := armcore.NewLROPoller("GalleriesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError)
150	if err != nil {
151		return HTTPPollerResponse{}, err
152	}
153	poller := &httpPoller{
154		pt: pt,
155	}
156	result.Poller = poller
157	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) {
158		return poller.pollUntilDone(ctx, frequency)
159	}
160	return result, nil
161}
162
163// ResumeDelete creates a new HTTPPoller from the specified resume token.
164// token - The value must come from a previous call to HTTPPoller.ResumeToken().
165func (client *GalleriesClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) {
166	pt, err := armcore.NewLROPollerFromResumeToken("GalleriesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError)
167	if err != nil {
168		return HTTPPollerResponse{}, err
169	}
170	poller := &httpPoller{
171		pt: pt,
172	}
173	resp, err := poller.Poll(ctx)
174	if err != nil {
175		return HTTPPollerResponse{}, err
176	}
177	result := HTTPPollerResponse{
178		RawResponse: resp,
179	}
180	result.Poller = poller
181	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) {
182		return poller.pollUntilDone(ctx, frequency)
183	}
184	return result, nil
185}
186
187// Delete - Delete a Shared Image Gallery.
188// If the operation fails it returns the *CloudError error type.
189func (client *GalleriesClient) deleteOperation(ctx context.Context, resourceGroupName string, galleryName string, options *GalleriesBeginDeleteOptions) (*azcore.Response, error) {
190	req, err := client.deleteCreateRequest(ctx, resourceGroupName, galleryName, options)
191	if err != nil {
192		return nil, err
193	}
194	resp, err := client.con.Pipeline().Do(req)
195	if err != nil {
196		return nil, err
197	}
198	if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) {
199		return nil, client.deleteHandleError(resp)
200	}
201	return resp, nil
202}
203
204// deleteCreateRequest creates the Delete request.
205func (client *GalleriesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, options *GalleriesBeginDeleteOptions) (*azcore.Request, error) {
206	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"
207	if client.subscriptionID == "" {
208		return nil, errors.New("parameter client.subscriptionID cannot be empty")
209	}
210	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
211	if resourceGroupName == "" {
212		return nil, errors.New("parameter resourceGroupName cannot be empty")
213	}
214	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
215	if galleryName == "" {
216		return nil, errors.New("parameter galleryName cannot be empty")
217	}
218	urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName))
219	req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))
220	if err != nil {
221		return nil, err
222	}
223	req.Telemetry(telemetryInfo)
224	reqQP := req.URL.Query()
225	reqQP.Set("api-version", "2020-09-30")
226	req.URL.RawQuery = reqQP.Encode()
227	req.Header.Set("Accept", "application/json")
228	return req, nil
229}
230
231// deleteHandleError handles the Delete error response.
232func (client *GalleriesClient) deleteHandleError(resp *azcore.Response) error {
233	body, err := resp.Payload()
234	if err != nil {
235		return azcore.NewResponseError(err, resp.Response)
236	}
237	errType := CloudError{raw: string(body)}
238	if err := resp.UnmarshalAsJSON(&errType); err != nil {
239		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
240	}
241	return azcore.NewResponseError(&errType, resp.Response)
242}
243
244// Get - Retrieves information about a Shared Image Gallery.
245// If the operation fails it returns the *CloudError error type.
246func (client *GalleriesClient) Get(ctx context.Context, resourceGroupName string, galleryName string, options *GalleriesGetOptions) (GalleryResponse, error) {
247	req, err := client.getCreateRequest(ctx, resourceGroupName, galleryName, options)
248	if err != nil {
249		return GalleryResponse{}, err
250	}
251	resp, err := client.con.Pipeline().Do(req)
252	if err != nil {
253		return GalleryResponse{}, err
254	}
255	if !resp.HasStatusCode(http.StatusOK) {
256		return GalleryResponse{}, client.getHandleError(resp)
257	}
258	return client.getHandleResponse(resp)
259}
260
261// getCreateRequest creates the Get request.
262func (client *GalleriesClient) getCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, options *GalleriesGetOptions) (*azcore.Request, error) {
263	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"
264	if client.subscriptionID == "" {
265		return nil, errors.New("parameter client.subscriptionID cannot be empty")
266	}
267	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
268	if resourceGroupName == "" {
269		return nil, errors.New("parameter resourceGroupName cannot be empty")
270	}
271	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
272	if galleryName == "" {
273		return nil, errors.New("parameter galleryName cannot be empty")
274	}
275	urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName))
276	req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))
277	if err != nil {
278		return nil, err
279	}
280	req.Telemetry(telemetryInfo)
281	reqQP := req.URL.Query()
282	reqQP.Set("api-version", "2020-09-30")
283	if options != nil && options.Select != nil {
284		reqQP.Set("$select", string(*options.Select))
285	}
286	req.URL.RawQuery = reqQP.Encode()
287	req.Header.Set("Accept", "application/json")
288	return req, nil
289}
290
291// getHandleResponse handles the Get response.
292func (client *GalleriesClient) getHandleResponse(resp *azcore.Response) (GalleryResponse, error) {
293	var val *Gallery
294	if err := resp.UnmarshalAsJSON(&val); err != nil {
295		return GalleryResponse{}, err
296	}
297	return GalleryResponse{RawResponse: resp.Response, Gallery: val}, nil
298}
299
300// getHandleError handles the Get error response.
301func (client *GalleriesClient) getHandleError(resp *azcore.Response) error {
302	body, err := resp.Payload()
303	if err != nil {
304		return azcore.NewResponseError(err, resp.Response)
305	}
306	errType := CloudError{raw: string(body)}
307	if err := resp.UnmarshalAsJSON(&errType); err != nil {
308		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
309	}
310	return azcore.NewResponseError(&errType, resp.Response)
311}
312
313// List - List galleries under a subscription.
314// If the operation fails it returns the *CloudError error type.
315func (client *GalleriesClient) List(options *GalleriesListOptions) GalleryListPager {
316	return &galleryListPager{
317		pipeline: client.con.Pipeline(),
318		requester: func(ctx context.Context) (*azcore.Request, error) {
319			return client.listCreateRequest(ctx, options)
320		},
321		responder: client.listHandleResponse,
322		errorer:   client.listHandleError,
323		advancer: func(ctx context.Context, resp GalleryListResponse) (*azcore.Request, error) {
324			return azcore.NewRequest(ctx, http.MethodGet, *resp.GalleryList.NextLink)
325		},
326		statusCodes: []int{http.StatusOK},
327	}
328}
329
330// listCreateRequest creates the List request.
331func (client *GalleriesClient) listCreateRequest(ctx context.Context, options *GalleriesListOptions) (*azcore.Request, error) {
332	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries"
333	if client.subscriptionID == "" {
334		return nil, errors.New("parameter client.subscriptionID cannot be empty")
335	}
336	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
337	req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))
338	if err != nil {
339		return nil, err
340	}
341	req.Telemetry(telemetryInfo)
342	reqQP := req.URL.Query()
343	reqQP.Set("api-version", "2020-09-30")
344	req.URL.RawQuery = reqQP.Encode()
345	req.Header.Set("Accept", "application/json")
346	return req, nil
347}
348
349// listHandleResponse handles the List response.
350func (client *GalleriesClient) listHandleResponse(resp *azcore.Response) (GalleryListResponse, error) {
351	var val *GalleryList
352	if err := resp.UnmarshalAsJSON(&val); err != nil {
353		return GalleryListResponse{}, err
354	}
355	return GalleryListResponse{RawResponse: resp.Response, GalleryList: val}, nil
356}
357
358// listHandleError handles the List error response.
359func (client *GalleriesClient) listHandleError(resp *azcore.Response) error {
360	body, err := resp.Payload()
361	if err != nil {
362		return azcore.NewResponseError(err, resp.Response)
363	}
364	errType := CloudError{raw: string(body)}
365	if err := resp.UnmarshalAsJSON(&errType); err != nil {
366		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
367	}
368	return azcore.NewResponseError(&errType, resp.Response)
369}
370
371// ListByResourceGroup - List galleries under a resource group.
372// If the operation fails it returns the *CloudError error type.
373func (client *GalleriesClient) ListByResourceGroup(resourceGroupName string, options *GalleriesListByResourceGroupOptions) GalleryListPager {
374	return &galleryListPager{
375		pipeline: client.con.Pipeline(),
376		requester: func(ctx context.Context) (*azcore.Request, error) {
377			return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options)
378		},
379		responder: client.listByResourceGroupHandleResponse,
380		errorer:   client.listByResourceGroupHandleError,
381		advancer: func(ctx context.Context, resp GalleryListResponse) (*azcore.Request, error) {
382			return azcore.NewRequest(ctx, http.MethodGet, *resp.GalleryList.NextLink)
383		},
384		statusCodes: []int{http.StatusOK},
385	}
386}
387
388// listByResourceGroupCreateRequest creates the ListByResourceGroup request.
389func (client *GalleriesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *GalleriesListByResourceGroupOptions) (*azcore.Request, error) {
390	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries"
391	if client.subscriptionID == "" {
392		return nil, errors.New("parameter client.subscriptionID cannot be empty")
393	}
394	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
395	if resourceGroupName == "" {
396		return nil, errors.New("parameter resourceGroupName cannot be empty")
397	}
398	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
399	req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))
400	if err != nil {
401		return nil, err
402	}
403	req.Telemetry(telemetryInfo)
404	reqQP := req.URL.Query()
405	reqQP.Set("api-version", "2020-09-30")
406	req.URL.RawQuery = reqQP.Encode()
407	req.Header.Set("Accept", "application/json")
408	return req, nil
409}
410
411// listByResourceGroupHandleResponse handles the ListByResourceGroup response.
412func (client *GalleriesClient) listByResourceGroupHandleResponse(resp *azcore.Response) (GalleryListResponse, error) {
413	var val *GalleryList
414	if err := resp.UnmarshalAsJSON(&val); err != nil {
415		return GalleryListResponse{}, err
416	}
417	return GalleryListResponse{RawResponse: resp.Response, GalleryList: val}, nil
418}
419
420// listByResourceGroupHandleError handles the ListByResourceGroup error response.
421func (client *GalleriesClient) listByResourceGroupHandleError(resp *azcore.Response) error {
422	body, err := resp.Payload()
423	if err != nil {
424		return azcore.NewResponseError(err, resp.Response)
425	}
426	errType := CloudError{raw: string(body)}
427	if err := resp.UnmarshalAsJSON(&errType); err != nil {
428		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
429	}
430	return azcore.NewResponseError(&errType, resp.Response)
431}
432
433// BeginUpdate - Update a Shared Image Gallery.
434// If the operation fails it returns the *CloudError error type.
435func (client *GalleriesClient) BeginUpdate(ctx context.Context, resourceGroupName string, galleryName string, gallery GalleryUpdate, options *GalleriesBeginUpdateOptions) (GalleryPollerResponse, error) {
436	resp, err := client.update(ctx, resourceGroupName, galleryName, gallery, options)
437	if err != nil {
438		return GalleryPollerResponse{}, err
439	}
440	result := GalleryPollerResponse{
441		RawResponse: resp.Response,
442	}
443	pt, err := armcore.NewLROPoller("GalleriesClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError)
444	if err != nil {
445		return GalleryPollerResponse{}, err
446	}
447	poller := &galleryPoller{
448		pt: pt,
449	}
450	result.Poller = poller
451	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GalleryResponse, error) {
452		return poller.pollUntilDone(ctx, frequency)
453	}
454	return result, nil
455}
456
457// ResumeUpdate creates a new GalleryPoller from the specified resume token.
458// token - The value must come from a previous call to GalleryPoller.ResumeToken().
459func (client *GalleriesClient) ResumeUpdate(ctx context.Context, token string) (GalleryPollerResponse, error) {
460	pt, err := armcore.NewLROPollerFromResumeToken("GalleriesClient.Update", token, client.con.Pipeline(), client.updateHandleError)
461	if err != nil {
462		return GalleryPollerResponse{}, err
463	}
464	poller := &galleryPoller{
465		pt: pt,
466	}
467	resp, err := poller.Poll(ctx)
468	if err != nil {
469		return GalleryPollerResponse{}, err
470	}
471	result := GalleryPollerResponse{
472		RawResponse: resp,
473	}
474	result.Poller = poller
475	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GalleryResponse, error) {
476		return poller.pollUntilDone(ctx, frequency)
477	}
478	return result, nil
479}
480
481// Update - Update a Shared Image Gallery.
482// If the operation fails it returns the *CloudError error type.
483func (client *GalleriesClient) update(ctx context.Context, resourceGroupName string, galleryName string, gallery GalleryUpdate, options *GalleriesBeginUpdateOptions) (*azcore.Response, error) {
484	req, err := client.updateCreateRequest(ctx, resourceGroupName, galleryName, gallery, options)
485	if err != nil {
486		return nil, err
487	}
488	resp, err := client.con.Pipeline().Do(req)
489	if err != nil {
490		return nil, err
491	}
492	if !resp.HasStatusCode(http.StatusOK) {
493		return nil, client.updateHandleError(resp)
494	}
495	return resp, nil
496}
497
498// updateCreateRequest creates the Update request.
499func (client *GalleriesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, gallery GalleryUpdate, options *GalleriesBeginUpdateOptions) (*azcore.Request, error) {
500	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}"
501	if client.subscriptionID == "" {
502		return nil, errors.New("parameter client.subscriptionID cannot be empty")
503	}
504	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
505	if resourceGroupName == "" {
506		return nil, errors.New("parameter resourceGroupName cannot be empty")
507	}
508	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
509	if galleryName == "" {
510		return nil, errors.New("parameter galleryName cannot be empty")
511	}
512	urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName))
513	req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath))
514	if err != nil {
515		return nil, err
516	}
517	req.Telemetry(telemetryInfo)
518	reqQP := req.URL.Query()
519	reqQP.Set("api-version", "2020-09-30")
520	req.URL.RawQuery = reqQP.Encode()
521	req.Header.Set("Accept", "application/json")
522	return req, req.MarshalAsJSON(gallery)
523}
524
525// updateHandleError handles the Update error response.
526func (client *GalleriesClient) updateHandleError(resp *azcore.Response) error {
527	body, err := resp.Payload()
528	if err != nil {
529		return azcore.NewResponseError(err, resp.Response)
530	}
531	errType := CloudError{raw: string(body)}
532	if err := resp.UnmarshalAsJSON(&errType); err != nil {
533		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
534	}
535	return azcore.NewResponseError(&errType, resp.Response)
536}
537