...

Source file src/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-03-01/network/interfaceipconfigurations.go

Documentation: github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-03-01/network

     1  package 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  
     9  import (
    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  // InterfaceIPConfigurationsClient is the network Client
    18  type InterfaceIPConfigurationsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewInterfaceIPConfigurationsClient creates an instance of the InterfaceIPConfigurationsClient client.
    23  func NewInterfaceIPConfigurationsClient(subscriptionID string) InterfaceIPConfigurationsClient {
    24  	return NewInterfaceIPConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewInterfaceIPConfigurationsClientWithBaseURI creates an instance of the InterfaceIPConfigurationsClient client
    28  // using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign
    29  // clouds, Azure stack).
    30  func NewInterfaceIPConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) InterfaceIPConfigurationsClient {
    31  	return InterfaceIPConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Get gets the specified network interface ip configuration.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group.
    37  // networkInterfaceName - the name of the network interface.
    38  // IPConfigurationName - the name of the ip configuration name.
    39  func (client InterfaceIPConfigurationsClient) Get(ctx context.Context, resourceGroupName string, networkInterfaceName string, IPConfigurationName string) (result InterfaceIPConfiguration, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/InterfaceIPConfigurationsClient.Get")
    42  		defer func() {
    43  			sc := -1
    44  			if result.Response.Response != nil {
    45  				sc = result.Response.Response.StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	req, err := client.GetPreparer(ctx, resourceGroupName, networkInterfaceName, IPConfigurationName)
    51  	if err != nil {
    52  		err = autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "Get", nil, "Failure preparing request")
    53  		return
    54  	}
    55  
    56  	resp, err := client.GetSender(req)
    57  	if err != nil {
    58  		result.Response = autorest.Response{Response: resp}
    59  		err = autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "Get", resp, "Failure sending request")
    60  		return
    61  	}
    62  
    63  	result, err = client.GetResponder(resp)
    64  	if err != nil {
    65  		err = autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "Get", resp, "Failure responding to request")
    66  		return
    67  	}
    68  
    69  	return
    70  }
    71  
    72  // GetPreparer prepares the Get request.
    73  func (client InterfaceIPConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, networkInterfaceName string, IPConfigurationName string) (*http.Request, error) {
    74  	pathParameters := map[string]interface{}{
    75  		"ipConfigurationName":  autorest.Encode("path", IPConfigurationName),
    76  		"networkInterfaceName": autorest.Encode("path", networkInterfaceName),
    77  		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
    78  		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
    79  	}
    80  
    81  	const APIVersion = "2020-03-01"
    82  	queryParameters := map[string]interface{}{
    83  		"api-version": APIVersion,
    84  	}
    85  
    86  	preparer := autorest.CreatePreparer(
    87  		autorest.AsGet(),
    88  		autorest.WithBaseURL(client.BaseURI),
    89  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}/ipConfigurations/{ipConfigurationName}", pathParameters),
    90  		autorest.WithQueryParameters(queryParameters))
    91  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    92  }
    93  
    94  // GetSender sends the Get request. The method will close the
    95  // http.Response Body if it receives an error.
    96  func (client InterfaceIPConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) {
    97  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    98  }
    99  
   100  // GetResponder handles the response to the Get request. The method always
   101  // closes the http.Response Body.
   102  func (client InterfaceIPConfigurationsClient) GetResponder(resp *http.Response) (result InterfaceIPConfiguration, err error) {
   103  	err = autorest.Respond(
   104  		resp,
   105  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   106  		autorest.ByUnmarshallingJSON(&result),
   107  		autorest.ByClosing())
   108  	result.Response = autorest.Response{Response: resp}
   109  	return
   110  }
   111  
   112  // List get all ip configurations in a network interface.
   113  // Parameters:
   114  // resourceGroupName - the name of the resource group.
   115  // networkInterfaceName - the name of the network interface.
   116  func (client InterfaceIPConfigurationsClient) List(ctx context.Context, resourceGroupName string, networkInterfaceName string) (result InterfaceIPConfigurationListResultPage, err error) {
   117  	if tracing.IsEnabled() {
   118  		ctx = tracing.StartSpan(ctx, fqdn+"/InterfaceIPConfigurationsClient.List")
   119  		defer func() {
   120  			sc := -1
   121  			if result.iiclr.Response.Response != nil {
   122  				sc = result.iiclr.Response.Response.StatusCode
   123  			}
   124  			tracing.EndSpan(ctx, sc, err)
   125  		}()
   126  	}
   127  	result.fn = client.listNextResults
   128  	req, err := client.ListPreparer(ctx, resourceGroupName, networkInterfaceName)
   129  	if err != nil {
   130  		err = autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "List", nil, "Failure preparing request")
   131  		return
   132  	}
   133  
   134  	resp, err := client.ListSender(req)
   135  	if err != nil {
   136  		result.iiclr.Response = autorest.Response{Response: resp}
   137  		err = autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "List", resp, "Failure sending request")
   138  		return
   139  	}
   140  
   141  	result.iiclr, err = client.ListResponder(resp)
   142  	if err != nil {
   143  		err = autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "List", resp, "Failure responding to request")
   144  		return
   145  	}
   146  	if result.iiclr.hasNextLink() && result.iiclr.IsEmpty() {
   147  		err = result.NextWithContext(ctx)
   148  		return
   149  	}
   150  
   151  	return
   152  }
   153  
   154  // ListPreparer prepares the List request.
   155  func (client InterfaceIPConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, networkInterfaceName string) (*http.Request, error) {
   156  	pathParameters := map[string]interface{}{
   157  		"networkInterfaceName": autorest.Encode("path", networkInterfaceName),
   158  		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
   159  		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
   160  	}
   161  
   162  	const APIVersion = "2020-03-01"
   163  	queryParameters := map[string]interface{}{
   164  		"api-version": APIVersion,
   165  	}
   166  
   167  	preparer := autorest.CreatePreparer(
   168  		autorest.AsGet(),
   169  		autorest.WithBaseURL(client.BaseURI),
   170  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}/ipConfigurations", pathParameters),
   171  		autorest.WithQueryParameters(queryParameters))
   172  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   173  }
   174  
   175  // ListSender sends the List request. The method will close the
   176  // http.Response Body if it receives an error.
   177  func (client InterfaceIPConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) {
   178  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   179  }
   180  
   181  // ListResponder handles the response to the List request. The method always
   182  // closes the http.Response Body.
   183  func (client InterfaceIPConfigurationsClient) ListResponder(resp *http.Response) (result InterfaceIPConfigurationListResult, err error) {
   184  	err = autorest.Respond(
   185  		resp,
   186  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   187  		autorest.ByUnmarshallingJSON(&result),
   188  		autorest.ByClosing())
   189  	result.Response = autorest.Response{Response: resp}
   190  	return
   191  }
   192  
   193  // listNextResults retrieves the next set of results, if any.
   194  func (client InterfaceIPConfigurationsClient) listNextResults(ctx context.Context, lastResults InterfaceIPConfigurationListResult) (result InterfaceIPConfigurationListResult, err error) {
   195  	req, err := lastResults.interfaceIPConfigurationListResultPreparer(ctx)
   196  	if err != nil {
   197  		return result, autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "listNextResults", nil, "Failure preparing next results request")
   198  	}
   199  	if req == nil {
   200  		return
   201  	}
   202  	resp, err := client.ListSender(req)
   203  	if err != nil {
   204  		result.Response = autorest.Response{Response: resp}
   205  		return result, autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "listNextResults", resp, "Failure sending next results request")
   206  	}
   207  	result, err = client.ListResponder(resp)
   208  	if err != nil {
   209  		err = autorest.NewErrorWithError(err, "network.InterfaceIPConfigurationsClient", "listNextResults", resp, "Failure responding to next results request")
   210  	}
   211  	return
   212  }
   213  
   214  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   215  func (client InterfaceIPConfigurationsClient) ListComplete(ctx context.Context, resourceGroupName string, networkInterfaceName string) (result InterfaceIPConfigurationListResultIterator, err error) {
   216  	if tracing.IsEnabled() {
   217  		ctx = tracing.StartSpan(ctx, fqdn+"/InterfaceIPConfigurationsClient.List")
   218  		defer func() {
   219  			sc := -1
   220  			if result.Response().Response.Response != nil {
   221  				sc = result.page.Response().Response.Response.StatusCode
   222  			}
   223  			tracing.EndSpan(ctx, sc, err)
   224  		}()
   225  	}
   226  	result.page, err = client.List(ctx, resourceGroupName, networkInterfaceName)
   227  	return
   228  }
   229  

View as plain text