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