1package network
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/autorest/validation"
25	"github.com/Azure/go-autorest/tracing"
26	"net/http"
27)
28
29// PublicIPAddressesClient is the network Client
30type PublicIPAddressesClient struct {
31	BaseClient
32}
33
34// NewPublicIPAddressesClient creates an instance of the PublicIPAddressesClient client.
35func NewPublicIPAddressesClient(subscriptionID string) PublicIPAddressesClient {
36	return NewPublicIPAddressesClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewPublicIPAddressesClientWithBaseURI creates an instance of the PublicIPAddressesClient client using a custom
40// endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
41// stack).
42func NewPublicIPAddressesClientWithBaseURI(baseURI string, subscriptionID string) PublicIPAddressesClient {
43	return PublicIPAddressesClient{NewWithBaseURI(baseURI, subscriptionID)}
44}
45
46// CreateOrUpdate creates or updates a static or dynamic public IP address.
47// Parameters:
48// resourceGroupName - the name of the resource group.
49// publicIPAddressName - the name of the public IP address.
50// parameters - parameters supplied to the create or update public IP address operation.
51func (client PublicIPAddressesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress) (result PublicIPAddressesCreateOrUpdateFuture, err error) {
52	if tracing.IsEnabled() {
53		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.CreateOrUpdate")
54		defer func() {
55			sc := -1
56			if result.Response() != nil {
57				sc = result.Response().StatusCode
58			}
59			tracing.EndSpan(ctx, sc, err)
60		}()
61	}
62	if err := validation.Validate([]validation.Validation{
63		{TargetValue: parameters,
64			Constraints: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat", Name: validation.Null, Rule: false,
65				Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration", Name: validation.Null, Rule: false,
66					Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat", Name: validation.Null, Rule: false,
67						Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.PublicIPAddress", Name: validation.Null, Rule: false, Chain: nil}}},
68					}},
69				}}}}}); err != nil {
70		return result, validation.NewError("network.PublicIPAddressesClient", "CreateOrUpdate", err.Error())
71	}
72
73	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, publicIPAddressName, parameters)
74	if err != nil {
75		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", nil, "Failure preparing request")
76		return
77	}
78
79	result, err = client.CreateOrUpdateSender(req)
80	if err != nil {
81		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
82		return
83	}
84
85	return
86}
87
88// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
89func (client PublicIPAddressesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress) (*http.Request, error) {
90	pathParameters := map[string]interface{}{
91		"publicIpAddressName": autorest.Encode("path", publicIPAddressName),
92		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
93		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
94	}
95
96	const APIVersion = "2019-11-01"
97	queryParameters := map[string]interface{}{
98		"api-version": APIVersion,
99	}
100
101	parameters.Etag = nil
102	preparer := autorest.CreatePreparer(
103		autorest.AsContentType("application/json; charset=utf-8"),
104		autorest.AsPut(),
105		autorest.WithBaseURL(client.BaseURI),
106		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}", pathParameters),
107		autorest.WithJSON(parameters),
108		autorest.WithQueryParameters(queryParameters))
109	return preparer.Prepare((&http.Request{}).WithContext(ctx))
110}
111
112// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
113// http.Response Body if it receives an error.
114func (client PublicIPAddressesClient) CreateOrUpdateSender(req *http.Request) (future PublicIPAddressesCreateOrUpdateFuture, err error) {
115	var resp *http.Response
116	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
117	if err != nil {
118		return
119	}
120	future.Future, err = azure.NewFutureFromResponse(resp)
121	return
122}
123
124// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
125// closes the http.Response Body.
126func (client PublicIPAddressesClient) CreateOrUpdateResponder(resp *http.Response) (result PublicIPAddress, err error) {
127	err = autorest.Respond(
128		resp,
129		client.ByInspecting(),
130		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
131		autorest.ByUnmarshallingJSON(&result),
132		autorest.ByClosing())
133	result.Response = autorest.Response{Response: resp}
134	return
135}
136
137// Delete deletes the specified public IP address.
138// Parameters:
139// resourceGroupName - the name of the resource group.
140// publicIPAddressName - the name of the subnet.
141func (client PublicIPAddressesClient) Delete(ctx context.Context, resourceGroupName string, publicIPAddressName string) (result PublicIPAddressesDeleteFuture, err error) {
142	if tracing.IsEnabled() {
143		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.Delete")
144		defer func() {
145			sc := -1
146			if result.Response() != nil {
147				sc = result.Response().StatusCode
148			}
149			tracing.EndSpan(ctx, sc, err)
150		}()
151	}
152	req, err := client.DeletePreparer(ctx, resourceGroupName, publicIPAddressName)
153	if err != nil {
154		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", nil, "Failure preparing request")
155		return
156	}
157
158	result, err = client.DeleteSender(req)
159	if err != nil {
160		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", result.Response(), "Failure sending request")
161		return
162	}
163
164	return
165}
166
167// DeletePreparer prepares the Delete request.
168func (client PublicIPAddressesClient) DeletePreparer(ctx context.Context, resourceGroupName string, publicIPAddressName string) (*http.Request, error) {
169	pathParameters := map[string]interface{}{
170		"publicIpAddressName": autorest.Encode("path", publicIPAddressName),
171		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
172		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
173	}
174
175	const APIVersion = "2019-11-01"
176	queryParameters := map[string]interface{}{
177		"api-version": APIVersion,
178	}
179
180	preparer := autorest.CreatePreparer(
181		autorest.AsDelete(),
182		autorest.WithBaseURL(client.BaseURI),
183		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}", pathParameters),
184		autorest.WithQueryParameters(queryParameters))
185	return preparer.Prepare((&http.Request{}).WithContext(ctx))
186}
187
188// DeleteSender sends the Delete request. The method will close the
189// http.Response Body if it receives an error.
190func (client PublicIPAddressesClient) DeleteSender(req *http.Request) (future PublicIPAddressesDeleteFuture, err error) {
191	var resp *http.Response
192	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
193	if err != nil {
194		return
195	}
196	future.Future, err = azure.NewFutureFromResponse(resp)
197	return
198}
199
200// DeleteResponder handles the response to the Delete request. The method always
201// closes the http.Response Body.
202func (client PublicIPAddressesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
203	err = autorest.Respond(
204		resp,
205		client.ByInspecting(),
206		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
207		autorest.ByClosing())
208	result.Response = resp
209	return
210}
211
212// Get gets the specified public IP address in a specified resource group.
213// Parameters:
214// resourceGroupName - the name of the resource group.
215// publicIPAddressName - the name of the subnet.
216// expand - expands referenced resources.
217func (client PublicIPAddressesClient) Get(ctx context.Context, resourceGroupName string, publicIPAddressName string, expand string) (result PublicIPAddress, err error) {
218	if tracing.IsEnabled() {
219		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.Get")
220		defer func() {
221			sc := -1
222			if result.Response.Response != nil {
223				sc = result.Response.Response.StatusCode
224			}
225			tracing.EndSpan(ctx, sc, err)
226		}()
227	}
228	req, err := client.GetPreparer(ctx, resourceGroupName, publicIPAddressName, expand)
229	if err != nil {
230		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", nil, "Failure preparing request")
231		return
232	}
233
234	resp, err := client.GetSender(req)
235	if err != nil {
236		result.Response = autorest.Response{Response: resp}
237		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", resp, "Failure sending request")
238		return
239	}
240
241	result, err = client.GetResponder(resp)
242	if err != nil {
243		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", resp, "Failure responding to request")
244	}
245
246	return
247}
248
249// GetPreparer prepares the Get request.
250func (client PublicIPAddressesClient) GetPreparer(ctx context.Context, resourceGroupName string, publicIPAddressName string, expand string) (*http.Request, error) {
251	pathParameters := map[string]interface{}{
252		"publicIpAddressName": autorest.Encode("path", publicIPAddressName),
253		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
254		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
255	}
256
257	const APIVersion = "2019-11-01"
258	queryParameters := map[string]interface{}{
259		"api-version": APIVersion,
260	}
261	if len(expand) > 0 {
262		queryParameters["$expand"] = autorest.Encode("query", expand)
263	}
264
265	preparer := autorest.CreatePreparer(
266		autorest.AsGet(),
267		autorest.WithBaseURL(client.BaseURI),
268		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}", pathParameters),
269		autorest.WithQueryParameters(queryParameters))
270	return preparer.Prepare((&http.Request{}).WithContext(ctx))
271}
272
273// GetSender sends the Get request. The method will close the
274// http.Response Body if it receives an error.
275func (client PublicIPAddressesClient) GetSender(req *http.Request) (*http.Response, error) {
276	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
277}
278
279// GetResponder handles the response to the Get request. The method always
280// closes the http.Response Body.
281func (client PublicIPAddressesClient) GetResponder(resp *http.Response) (result PublicIPAddress, err error) {
282	err = autorest.Respond(
283		resp,
284		client.ByInspecting(),
285		azure.WithErrorUnlessStatusCode(http.StatusOK),
286		autorest.ByUnmarshallingJSON(&result),
287		autorest.ByClosing())
288	result.Response = autorest.Response{Response: resp}
289	return
290}
291
292// GetVirtualMachineScaleSetPublicIPAddress get the specified public IP address in a virtual machine scale set.
293// Parameters:
294// resourceGroupName - the name of the resource group.
295// virtualMachineScaleSetName - the name of the virtual machine scale set.
296// virtualmachineIndex - the virtual machine index.
297// networkInterfaceName - the name of the network interface.
298// IPConfigurationName - the name of the IP configuration.
299// publicIPAddressName - the name of the public IP Address.
300// expand - expands referenced resources.
301func (client PublicIPAddressesClient) GetVirtualMachineScaleSetPublicIPAddress(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string, publicIPAddressName string, expand string) (result PublicIPAddress, err error) {
302	if tracing.IsEnabled() {
303		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.GetVirtualMachineScaleSetPublicIPAddress")
304		defer func() {
305			sc := -1
306			if result.Response.Response != nil {
307				sc = result.Response.Response.StatusCode
308			}
309			tracing.EndSpan(ctx, sc, err)
310		}()
311	}
312	req, err := client.GetVirtualMachineScaleSetPublicIPAddressPreparer(ctx, resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, IPConfigurationName, publicIPAddressName, expand)
313	if err != nil {
314		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "GetVirtualMachineScaleSetPublicIPAddress", nil, "Failure preparing request")
315		return
316	}
317
318	resp, err := client.GetVirtualMachineScaleSetPublicIPAddressSender(req)
319	if err != nil {
320		result.Response = autorest.Response{Response: resp}
321		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "GetVirtualMachineScaleSetPublicIPAddress", resp, "Failure sending request")
322		return
323	}
324
325	result, err = client.GetVirtualMachineScaleSetPublicIPAddressResponder(resp)
326	if err != nil {
327		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "GetVirtualMachineScaleSetPublicIPAddress", resp, "Failure responding to request")
328	}
329
330	return
331}
332
333// GetVirtualMachineScaleSetPublicIPAddressPreparer prepares the GetVirtualMachineScaleSetPublicIPAddress request.
334func (client PublicIPAddressesClient) GetVirtualMachineScaleSetPublicIPAddressPreparer(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string, publicIPAddressName string, expand string) (*http.Request, error) {
335	pathParameters := map[string]interface{}{
336		"ipConfigurationName":        autorest.Encode("path", IPConfigurationName),
337		"networkInterfaceName":       autorest.Encode("path", networkInterfaceName),
338		"publicIpAddressName":        autorest.Encode("path", publicIPAddressName),
339		"resourceGroupName":          autorest.Encode("path", resourceGroupName),
340		"subscriptionId":             autorest.Encode("path", client.SubscriptionID),
341		"virtualmachineIndex":        autorest.Encode("path", virtualmachineIndex),
342		"virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName),
343	}
344
345	const APIVersion = "2018-10-01"
346	queryParameters := map[string]interface{}{
347		"api-version": APIVersion,
348	}
349	if len(expand) > 0 {
350		queryParameters["$expand"] = autorest.Encode("query", expand)
351	}
352
353	preparer := autorest.CreatePreparer(
354		autorest.AsGet(),
355		autorest.WithBaseURL(client.BaseURI),
356		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces/{networkInterfaceName}/ipconfigurations/{ipConfigurationName}/publicipaddresses/{publicIpAddressName}", pathParameters),
357		autorest.WithQueryParameters(queryParameters))
358	return preparer.Prepare((&http.Request{}).WithContext(ctx))
359}
360
361// GetVirtualMachineScaleSetPublicIPAddressSender sends the GetVirtualMachineScaleSetPublicIPAddress request. The method will close the
362// http.Response Body if it receives an error.
363func (client PublicIPAddressesClient) GetVirtualMachineScaleSetPublicIPAddressSender(req *http.Request) (*http.Response, error) {
364	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
365}
366
367// GetVirtualMachineScaleSetPublicIPAddressResponder handles the response to the GetVirtualMachineScaleSetPublicIPAddress request. The method always
368// closes the http.Response Body.
369func (client PublicIPAddressesClient) GetVirtualMachineScaleSetPublicIPAddressResponder(resp *http.Response) (result PublicIPAddress, err error) {
370	err = autorest.Respond(
371		resp,
372		client.ByInspecting(),
373		azure.WithErrorUnlessStatusCode(http.StatusOK),
374		autorest.ByUnmarshallingJSON(&result),
375		autorest.ByClosing())
376	result.Response = autorest.Response{Response: resp}
377	return
378}
379
380// List gets all public IP addresses in a resource group.
381// Parameters:
382// resourceGroupName - the name of the resource group.
383func (client PublicIPAddressesClient) List(ctx context.Context, resourceGroupName string) (result PublicIPAddressListResultPage, err error) {
384	if tracing.IsEnabled() {
385		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.List")
386		defer func() {
387			sc := -1
388			if result.pialr.Response.Response != nil {
389				sc = result.pialr.Response.Response.StatusCode
390			}
391			tracing.EndSpan(ctx, sc, err)
392		}()
393	}
394	result.fn = client.listNextResults
395	req, err := client.ListPreparer(ctx, resourceGroupName)
396	if err != nil {
397		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", nil, "Failure preparing request")
398		return
399	}
400
401	resp, err := client.ListSender(req)
402	if err != nil {
403		result.pialr.Response = autorest.Response{Response: resp}
404		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", resp, "Failure sending request")
405		return
406	}
407
408	result.pialr, err = client.ListResponder(resp)
409	if err != nil {
410		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", resp, "Failure responding to request")
411	}
412
413	return
414}
415
416// ListPreparer prepares the List request.
417func (client PublicIPAddressesClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
418	pathParameters := map[string]interface{}{
419		"resourceGroupName": autorest.Encode("path", resourceGroupName),
420		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
421	}
422
423	const APIVersion = "2019-11-01"
424	queryParameters := map[string]interface{}{
425		"api-version": APIVersion,
426	}
427
428	preparer := autorest.CreatePreparer(
429		autorest.AsGet(),
430		autorest.WithBaseURL(client.BaseURI),
431		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses", pathParameters),
432		autorest.WithQueryParameters(queryParameters))
433	return preparer.Prepare((&http.Request{}).WithContext(ctx))
434}
435
436// ListSender sends the List request. The method will close the
437// http.Response Body if it receives an error.
438func (client PublicIPAddressesClient) ListSender(req *http.Request) (*http.Response, error) {
439	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
440}
441
442// ListResponder handles the response to the List request. The method always
443// closes the http.Response Body.
444func (client PublicIPAddressesClient) ListResponder(resp *http.Response) (result PublicIPAddressListResult, err error) {
445	err = autorest.Respond(
446		resp,
447		client.ByInspecting(),
448		azure.WithErrorUnlessStatusCode(http.StatusOK),
449		autorest.ByUnmarshallingJSON(&result),
450		autorest.ByClosing())
451	result.Response = autorest.Response{Response: resp}
452	return
453}
454
455// listNextResults retrieves the next set of results, if any.
456func (client PublicIPAddressesClient) listNextResults(ctx context.Context, lastResults PublicIPAddressListResult) (result PublicIPAddressListResult, err error) {
457	req, err := lastResults.publicIPAddressListResultPreparer(ctx)
458	if err != nil {
459		return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listNextResults", nil, "Failure preparing next results request")
460	}
461	if req == nil {
462		return
463	}
464	resp, err := client.ListSender(req)
465	if err != nil {
466		result.Response = autorest.Response{Response: resp}
467		return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listNextResults", resp, "Failure sending next results request")
468	}
469	result, err = client.ListResponder(resp)
470	if err != nil {
471		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listNextResults", resp, "Failure responding to next results request")
472	}
473	return
474}
475
476// ListComplete enumerates all values, automatically crossing page boundaries as required.
477func (client PublicIPAddressesClient) ListComplete(ctx context.Context, resourceGroupName string) (result PublicIPAddressListResultIterator, err error) {
478	if tracing.IsEnabled() {
479		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.List")
480		defer func() {
481			sc := -1
482			if result.Response().Response.Response != nil {
483				sc = result.page.Response().Response.Response.StatusCode
484			}
485			tracing.EndSpan(ctx, sc, err)
486		}()
487	}
488	result.page, err = client.List(ctx, resourceGroupName)
489	return
490}
491
492// ListAll gets all the public IP addresses in a subscription.
493func (client PublicIPAddressesClient) ListAll(ctx context.Context) (result PublicIPAddressListResultPage, err error) {
494	if tracing.IsEnabled() {
495		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.ListAll")
496		defer func() {
497			sc := -1
498			if result.pialr.Response.Response != nil {
499				sc = result.pialr.Response.Response.StatusCode
500			}
501			tracing.EndSpan(ctx, sc, err)
502		}()
503	}
504	result.fn = client.listAllNextResults
505	req, err := client.ListAllPreparer(ctx)
506	if err != nil {
507		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", nil, "Failure preparing request")
508		return
509	}
510
511	resp, err := client.ListAllSender(req)
512	if err != nil {
513		result.pialr.Response = autorest.Response{Response: resp}
514		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", resp, "Failure sending request")
515		return
516	}
517
518	result.pialr, err = client.ListAllResponder(resp)
519	if err != nil {
520		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", resp, "Failure responding to request")
521	}
522
523	return
524}
525
526// ListAllPreparer prepares the ListAll request.
527func (client PublicIPAddressesClient) ListAllPreparer(ctx context.Context) (*http.Request, error) {
528	pathParameters := map[string]interface{}{
529		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
530	}
531
532	const APIVersion = "2019-11-01"
533	queryParameters := map[string]interface{}{
534		"api-version": APIVersion,
535	}
536
537	preparer := autorest.CreatePreparer(
538		autorest.AsGet(),
539		autorest.WithBaseURL(client.BaseURI),
540		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/publicIPAddresses", pathParameters),
541		autorest.WithQueryParameters(queryParameters))
542	return preparer.Prepare((&http.Request{}).WithContext(ctx))
543}
544
545// ListAllSender sends the ListAll request. The method will close the
546// http.Response Body if it receives an error.
547func (client PublicIPAddressesClient) ListAllSender(req *http.Request) (*http.Response, error) {
548	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
549}
550
551// ListAllResponder handles the response to the ListAll request. The method always
552// closes the http.Response Body.
553func (client PublicIPAddressesClient) ListAllResponder(resp *http.Response) (result PublicIPAddressListResult, err error) {
554	err = autorest.Respond(
555		resp,
556		client.ByInspecting(),
557		azure.WithErrorUnlessStatusCode(http.StatusOK),
558		autorest.ByUnmarshallingJSON(&result),
559		autorest.ByClosing())
560	result.Response = autorest.Response{Response: resp}
561	return
562}
563
564// listAllNextResults retrieves the next set of results, if any.
565func (client PublicIPAddressesClient) listAllNextResults(ctx context.Context, lastResults PublicIPAddressListResult) (result PublicIPAddressListResult, err error) {
566	req, err := lastResults.publicIPAddressListResultPreparer(ctx)
567	if err != nil {
568		return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listAllNextResults", nil, "Failure preparing next results request")
569	}
570	if req == nil {
571		return
572	}
573	resp, err := client.ListAllSender(req)
574	if err != nil {
575		result.Response = autorest.Response{Response: resp}
576		return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listAllNextResults", resp, "Failure sending next results request")
577	}
578	result, err = client.ListAllResponder(resp)
579	if err != nil {
580		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listAllNextResults", resp, "Failure responding to next results request")
581	}
582	return
583}
584
585// ListAllComplete enumerates all values, automatically crossing page boundaries as required.
586func (client PublicIPAddressesClient) ListAllComplete(ctx context.Context) (result PublicIPAddressListResultIterator, err error) {
587	if tracing.IsEnabled() {
588		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.ListAll")
589		defer func() {
590			sc := -1
591			if result.Response().Response.Response != nil {
592				sc = result.page.Response().Response.Response.StatusCode
593			}
594			tracing.EndSpan(ctx, sc, err)
595		}()
596	}
597	result.page, err = client.ListAll(ctx)
598	return
599}
600
601// ListVirtualMachineScaleSetPublicIPAddresses gets information about all public IP addresses on a virtual machine
602// scale set level.
603// Parameters:
604// resourceGroupName - the name of the resource group.
605// virtualMachineScaleSetName - the name of the virtual machine scale set.
606func (client PublicIPAddressesClient) ListVirtualMachineScaleSetPublicIPAddresses(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string) (result PublicIPAddressListResultPage, err error) {
607	if tracing.IsEnabled() {
608		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.ListVirtualMachineScaleSetPublicIPAddresses")
609		defer func() {
610			sc := -1
611			if result.pialr.Response.Response != nil {
612				sc = result.pialr.Response.Response.StatusCode
613			}
614			tracing.EndSpan(ctx, sc, err)
615		}()
616	}
617	result.fn = client.listVirtualMachineScaleSetPublicIPAddressesNextResults
618	req, err := client.ListVirtualMachineScaleSetPublicIPAddressesPreparer(ctx, resourceGroupName, virtualMachineScaleSetName)
619	if err != nil {
620		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListVirtualMachineScaleSetPublicIPAddresses", nil, "Failure preparing request")
621		return
622	}
623
624	resp, err := client.ListVirtualMachineScaleSetPublicIPAddressesSender(req)
625	if err != nil {
626		result.pialr.Response = autorest.Response{Response: resp}
627		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListVirtualMachineScaleSetPublicIPAddresses", resp, "Failure sending request")
628		return
629	}
630
631	result.pialr, err = client.ListVirtualMachineScaleSetPublicIPAddressesResponder(resp)
632	if err != nil {
633		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListVirtualMachineScaleSetPublicIPAddresses", resp, "Failure responding to request")
634	}
635
636	return
637}
638
639// ListVirtualMachineScaleSetPublicIPAddressesPreparer prepares the ListVirtualMachineScaleSetPublicIPAddresses request.
640func (client PublicIPAddressesClient) ListVirtualMachineScaleSetPublicIPAddressesPreparer(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string) (*http.Request, error) {
641	pathParameters := map[string]interface{}{
642		"resourceGroupName":          autorest.Encode("path", resourceGroupName),
643		"subscriptionId":             autorest.Encode("path", client.SubscriptionID),
644		"virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName),
645	}
646
647	const APIVersion = "2018-10-01"
648	queryParameters := map[string]interface{}{
649		"api-version": APIVersion,
650	}
651
652	preparer := autorest.CreatePreparer(
653		autorest.AsGet(),
654		autorest.WithBaseURL(client.BaseURI),
655		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/publicipaddresses", pathParameters),
656		autorest.WithQueryParameters(queryParameters))
657	return preparer.Prepare((&http.Request{}).WithContext(ctx))
658}
659
660// ListVirtualMachineScaleSetPublicIPAddressesSender sends the ListVirtualMachineScaleSetPublicIPAddresses request. The method will close the
661// http.Response Body if it receives an error.
662func (client PublicIPAddressesClient) ListVirtualMachineScaleSetPublicIPAddressesSender(req *http.Request) (*http.Response, error) {
663	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
664}
665
666// ListVirtualMachineScaleSetPublicIPAddressesResponder handles the response to the ListVirtualMachineScaleSetPublicIPAddresses request. The method always
667// closes the http.Response Body.
668func (client PublicIPAddressesClient) ListVirtualMachineScaleSetPublicIPAddressesResponder(resp *http.Response) (result PublicIPAddressListResult, err error) {
669	err = autorest.Respond(
670		resp,
671		client.ByInspecting(),
672		azure.WithErrorUnlessStatusCode(http.StatusOK),
673		autorest.ByUnmarshallingJSON(&result),
674		autorest.ByClosing())
675	result.Response = autorest.Response{Response: resp}
676	return
677}
678
679// listVirtualMachineScaleSetPublicIPAddressesNextResults retrieves the next set of results, if any.
680func (client PublicIPAddressesClient) listVirtualMachineScaleSetPublicIPAddressesNextResults(ctx context.Context, lastResults PublicIPAddressListResult) (result PublicIPAddressListResult, err error) {
681	req, err := lastResults.publicIPAddressListResultPreparer(ctx)
682	if err != nil {
683		return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listVirtualMachineScaleSetPublicIPAddressesNextResults", nil, "Failure preparing next results request")
684	}
685	if req == nil {
686		return
687	}
688	resp, err := client.ListVirtualMachineScaleSetPublicIPAddressesSender(req)
689	if err != nil {
690		result.Response = autorest.Response{Response: resp}
691		return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listVirtualMachineScaleSetPublicIPAddressesNextResults", resp, "Failure sending next results request")
692	}
693	result, err = client.ListVirtualMachineScaleSetPublicIPAddressesResponder(resp)
694	if err != nil {
695		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listVirtualMachineScaleSetPublicIPAddressesNextResults", resp, "Failure responding to next results request")
696	}
697	return
698}
699
700// ListVirtualMachineScaleSetPublicIPAddressesComplete enumerates all values, automatically crossing page boundaries as required.
701func (client PublicIPAddressesClient) ListVirtualMachineScaleSetPublicIPAddressesComplete(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string) (result PublicIPAddressListResultIterator, err error) {
702	if tracing.IsEnabled() {
703		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.ListVirtualMachineScaleSetPublicIPAddresses")
704		defer func() {
705			sc := -1
706			if result.Response().Response.Response != nil {
707				sc = result.page.Response().Response.Response.StatusCode
708			}
709			tracing.EndSpan(ctx, sc, err)
710		}()
711	}
712	result.page, err = client.ListVirtualMachineScaleSetPublicIPAddresses(ctx, resourceGroupName, virtualMachineScaleSetName)
713	return
714}
715
716// ListVirtualMachineScaleSetVMPublicIPAddresses gets information about all public IP addresses in a virtual machine IP
717// configuration in a virtual machine scale set.
718// Parameters:
719// resourceGroupName - the name of the resource group.
720// virtualMachineScaleSetName - the name of the virtual machine scale set.
721// virtualmachineIndex - the virtual machine index.
722// networkInterfaceName - the network interface name.
723// IPConfigurationName - the IP configuration name.
724func (client PublicIPAddressesClient) ListVirtualMachineScaleSetVMPublicIPAddresses(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string) (result PublicIPAddressListResultPage, err error) {
725	if tracing.IsEnabled() {
726		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.ListVirtualMachineScaleSetVMPublicIPAddresses")
727		defer func() {
728			sc := -1
729			if result.pialr.Response.Response != nil {
730				sc = result.pialr.Response.Response.StatusCode
731			}
732			tracing.EndSpan(ctx, sc, err)
733		}()
734	}
735	result.fn = client.listVirtualMachineScaleSetVMPublicIPAddressesNextResults
736	req, err := client.ListVirtualMachineScaleSetVMPublicIPAddressesPreparer(ctx, resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, IPConfigurationName)
737	if err != nil {
738		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListVirtualMachineScaleSetVMPublicIPAddresses", nil, "Failure preparing request")
739		return
740	}
741
742	resp, err := client.ListVirtualMachineScaleSetVMPublicIPAddressesSender(req)
743	if err != nil {
744		result.pialr.Response = autorest.Response{Response: resp}
745		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListVirtualMachineScaleSetVMPublicIPAddresses", resp, "Failure sending request")
746		return
747	}
748
749	result.pialr, err = client.ListVirtualMachineScaleSetVMPublicIPAddressesResponder(resp)
750	if err != nil {
751		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListVirtualMachineScaleSetVMPublicIPAddresses", resp, "Failure responding to request")
752	}
753
754	return
755}
756
757// ListVirtualMachineScaleSetVMPublicIPAddressesPreparer prepares the ListVirtualMachineScaleSetVMPublicIPAddresses request.
758func (client PublicIPAddressesClient) ListVirtualMachineScaleSetVMPublicIPAddressesPreparer(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string) (*http.Request, error) {
759	pathParameters := map[string]interface{}{
760		"ipConfigurationName":        autorest.Encode("path", IPConfigurationName),
761		"networkInterfaceName":       autorest.Encode("path", networkInterfaceName),
762		"resourceGroupName":          autorest.Encode("path", resourceGroupName),
763		"subscriptionId":             autorest.Encode("path", client.SubscriptionID),
764		"virtualmachineIndex":        autorest.Encode("path", virtualmachineIndex),
765		"virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName),
766	}
767
768	const APIVersion = "2018-10-01"
769	queryParameters := map[string]interface{}{
770		"api-version": APIVersion,
771	}
772
773	preparer := autorest.CreatePreparer(
774		autorest.AsGet(),
775		autorest.WithBaseURL(client.BaseURI),
776		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces/{networkInterfaceName}/ipconfigurations/{ipConfigurationName}/publicipaddresses", pathParameters),
777		autorest.WithQueryParameters(queryParameters))
778	return preparer.Prepare((&http.Request{}).WithContext(ctx))
779}
780
781// ListVirtualMachineScaleSetVMPublicIPAddressesSender sends the ListVirtualMachineScaleSetVMPublicIPAddresses request. The method will close the
782// http.Response Body if it receives an error.
783func (client PublicIPAddressesClient) ListVirtualMachineScaleSetVMPublicIPAddressesSender(req *http.Request) (*http.Response, error) {
784	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
785}
786
787// ListVirtualMachineScaleSetVMPublicIPAddressesResponder handles the response to the ListVirtualMachineScaleSetVMPublicIPAddresses request. The method always
788// closes the http.Response Body.
789func (client PublicIPAddressesClient) ListVirtualMachineScaleSetVMPublicIPAddressesResponder(resp *http.Response) (result PublicIPAddressListResult, err error) {
790	err = autorest.Respond(
791		resp,
792		client.ByInspecting(),
793		azure.WithErrorUnlessStatusCode(http.StatusOK),
794		autorest.ByUnmarshallingJSON(&result),
795		autorest.ByClosing())
796	result.Response = autorest.Response{Response: resp}
797	return
798}
799
800// listVirtualMachineScaleSetVMPublicIPAddressesNextResults retrieves the next set of results, if any.
801func (client PublicIPAddressesClient) listVirtualMachineScaleSetVMPublicIPAddressesNextResults(ctx context.Context, lastResults PublicIPAddressListResult) (result PublicIPAddressListResult, err error) {
802	req, err := lastResults.publicIPAddressListResultPreparer(ctx)
803	if err != nil {
804		return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listVirtualMachineScaleSetVMPublicIPAddressesNextResults", nil, "Failure preparing next results request")
805	}
806	if req == nil {
807		return
808	}
809	resp, err := client.ListVirtualMachineScaleSetVMPublicIPAddressesSender(req)
810	if err != nil {
811		result.Response = autorest.Response{Response: resp}
812		return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listVirtualMachineScaleSetVMPublicIPAddressesNextResults", resp, "Failure sending next results request")
813	}
814	result, err = client.ListVirtualMachineScaleSetVMPublicIPAddressesResponder(resp)
815	if err != nil {
816		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "listVirtualMachineScaleSetVMPublicIPAddressesNextResults", resp, "Failure responding to next results request")
817	}
818	return
819}
820
821// ListVirtualMachineScaleSetVMPublicIPAddressesComplete enumerates all values, automatically crossing page boundaries as required.
822func (client PublicIPAddressesClient) ListVirtualMachineScaleSetVMPublicIPAddressesComplete(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string) (result PublicIPAddressListResultIterator, err error) {
823	if tracing.IsEnabled() {
824		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.ListVirtualMachineScaleSetVMPublicIPAddresses")
825		defer func() {
826			sc := -1
827			if result.Response().Response.Response != nil {
828				sc = result.page.Response().Response.Response.StatusCode
829			}
830			tracing.EndSpan(ctx, sc, err)
831		}()
832	}
833	result.page, err = client.ListVirtualMachineScaleSetVMPublicIPAddresses(ctx, resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, IPConfigurationName)
834	return
835}
836
837// UpdateTags updates public IP address tags.
838// Parameters:
839// resourceGroupName - the name of the resource group.
840// publicIPAddressName - the name of the public IP address.
841// parameters - parameters supplied to update public IP address tags.
842func (client PublicIPAddressesClient) UpdateTags(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters TagsObject) (result PublicIPAddress, err error) {
843	if tracing.IsEnabled() {
844		ctx = tracing.StartSpan(ctx, fqdn+"/PublicIPAddressesClient.UpdateTags")
845		defer func() {
846			sc := -1
847			if result.Response.Response != nil {
848				sc = result.Response.Response.StatusCode
849			}
850			tracing.EndSpan(ctx, sc, err)
851		}()
852	}
853	req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, publicIPAddressName, parameters)
854	if err != nil {
855		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "UpdateTags", nil, "Failure preparing request")
856		return
857	}
858
859	resp, err := client.UpdateTagsSender(req)
860	if err != nil {
861		result.Response = autorest.Response{Response: resp}
862		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "UpdateTags", resp, "Failure sending request")
863		return
864	}
865
866	result, err = client.UpdateTagsResponder(resp)
867	if err != nil {
868		err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "UpdateTags", resp, "Failure responding to request")
869	}
870
871	return
872}
873
874// UpdateTagsPreparer prepares the UpdateTags request.
875func (client PublicIPAddressesClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters TagsObject) (*http.Request, error) {
876	pathParameters := map[string]interface{}{
877		"publicIpAddressName": autorest.Encode("path", publicIPAddressName),
878		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
879		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
880	}
881
882	const APIVersion = "2019-11-01"
883	queryParameters := map[string]interface{}{
884		"api-version": APIVersion,
885	}
886
887	preparer := autorest.CreatePreparer(
888		autorest.AsContentType("application/json; charset=utf-8"),
889		autorest.AsPatch(),
890		autorest.WithBaseURL(client.BaseURI),
891		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}", pathParameters),
892		autorest.WithJSON(parameters),
893		autorest.WithQueryParameters(queryParameters))
894	return preparer.Prepare((&http.Request{}).WithContext(ctx))
895}
896
897// UpdateTagsSender sends the UpdateTags request. The method will close the
898// http.Response Body if it receives an error.
899func (client PublicIPAddressesClient) UpdateTagsSender(req *http.Request) (*http.Response, error) {
900	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
901}
902
903// UpdateTagsResponder handles the response to the UpdateTags request. The method always
904// closes the http.Response Body.
905func (client PublicIPAddressesClient) UpdateTagsResponder(resp *http.Response) (result PublicIPAddress, err error) {
906	err = autorest.Respond(
907		resp,
908		client.ByInspecting(),
909		azure.WithErrorUnlessStatusCode(http.StatusOK),
910		autorest.ByUnmarshallingJSON(&result),
911		autorest.ByClosing())
912	result.Response = autorest.Response{Response: resp}
913	return
914}
915