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