...

Source file src/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-08-01/network/virtualnetworktaps.go

Documentation: github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-08-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/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // VirtualNetworkTapsClient is the network Client
    19  type VirtualNetworkTapsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewVirtualNetworkTapsClient creates an instance of the VirtualNetworkTapsClient client.
    24  func NewVirtualNetworkTapsClient(subscriptionID string) VirtualNetworkTapsClient {
    25  	return NewVirtualNetworkTapsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewVirtualNetworkTapsClientWithBaseURI creates an instance of the VirtualNetworkTapsClient client using a custom
    29  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    30  // stack).
    31  func NewVirtualNetworkTapsClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkTapsClient {
    32  	return VirtualNetworkTapsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdate creates or updates a Virtual Network Tap.
    36  // Parameters:
    37  // resourceGroupName - the name of the resource group.
    38  // tapName - the name of the virtual network tap.
    39  // parameters - parameters supplied to the create or update virtual network tap operation.
    40  func (client VirtualNetworkTapsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, tapName string, parameters VirtualNetworkTap) (result VirtualNetworkTapsCreateOrUpdateFuture, err error) {
    41  	if tracing.IsEnabled() {
    42  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkTapsClient.CreateOrUpdate")
    43  		defer func() {
    44  			sc := -1
    45  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    46  				sc = result.FutureAPI.Response().StatusCode
    47  			}
    48  			tracing.EndSpan(ctx, sc, err)
    49  		}()
    50  	}
    51  	if err := validation.Validate([]validation.Validation{
    52  		{TargetValue: parameters,
    53  			Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat", Name: validation.Null, Rule: false,
    54  				Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationNetworkInterfaceIPConfiguration", Name: validation.Null, Rule: false,
    55  					Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationNetworkInterfaceIPConfiguration.InterfaceIPConfigurationPropertiesFormat", Name: validation.Null, Rule: false,
    56  						Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationNetworkInterfaceIPConfiguration.InterfaceIPConfigurationPropertiesFormat.PublicIPAddress", Name: validation.Null, Rule: false,
    57  							Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationNetworkInterfaceIPConfiguration.InterfaceIPConfigurationPropertiesFormat.PublicIPAddress.PublicIPAddressPropertiesFormat", Name: validation.Null, Rule: false,
    58  								Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationNetworkInterfaceIPConfiguration.InterfaceIPConfigurationPropertiesFormat.PublicIPAddress.PublicIPAddressPropertiesFormat.IPConfiguration", Name: validation.Null, Rule: false,
    59  									Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationNetworkInterfaceIPConfiguration.InterfaceIPConfigurationPropertiesFormat.PublicIPAddress.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat", Name: validation.Null, Rule: false,
    60  										Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationNetworkInterfaceIPConfiguration.InterfaceIPConfigurationPropertiesFormat.PublicIPAddress.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.PublicIPAddress", Name: validation.Null, Rule: false, Chain: nil}}},
    61  									}},
    62  								}},
    63  							}},
    64  						}},
    65  					}},
    66  					{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationLoadBalancerFrontEndIPConfiguration", Name: validation.Null, Rule: false,
    67  						Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationLoadBalancerFrontEndIPConfiguration.FrontendIPConfigurationPropertiesFormat", Name: validation.Null, Rule: false,
    68  							Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationLoadBalancerFrontEndIPConfiguration.FrontendIPConfigurationPropertiesFormat.PublicIPAddress", Name: validation.Null, Rule: false,
    69  								Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationLoadBalancerFrontEndIPConfiguration.FrontendIPConfigurationPropertiesFormat.PublicIPAddress.PublicIPAddressPropertiesFormat", Name: validation.Null, Rule: false,
    70  									Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationLoadBalancerFrontEndIPConfiguration.FrontendIPConfigurationPropertiesFormat.PublicIPAddress.PublicIPAddressPropertiesFormat.IPConfiguration", Name: validation.Null, Rule: false,
    71  										Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationLoadBalancerFrontEndIPConfiguration.FrontendIPConfigurationPropertiesFormat.PublicIPAddress.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat", Name: validation.Null, Rule: false,
    72  											Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkTapPropertiesFormat.DestinationLoadBalancerFrontEndIPConfiguration.FrontendIPConfigurationPropertiesFormat.PublicIPAddress.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.PublicIPAddress", Name: validation.Null, Rule: false, Chain: nil}}},
    73  										}},
    74  									}},
    75  								}},
    76  							}},
    77  						}},
    78  				}}}}}); err != nil {
    79  		return result, validation.NewError("network.VirtualNetworkTapsClient", "CreateOrUpdate", err.Error())
    80  	}
    81  
    82  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, tapName, parameters)
    83  	if err != nil {
    84  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "CreateOrUpdate", nil, "Failure preparing request")
    85  		return
    86  	}
    87  
    88  	result, err = client.CreateOrUpdateSender(req)
    89  	if err != nil {
    90  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    91  		return
    92  	}
    93  
    94  	return
    95  }
    96  
    97  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    98  func (client VirtualNetworkTapsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, tapName string, parameters VirtualNetworkTap) (*http.Request, error) {
    99  	pathParameters := map[string]interface{}{
   100  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   101  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   102  		"tapName":           autorest.Encode("path", tapName),
   103  	}
   104  
   105  	const APIVersion = "2018-08-01"
   106  	queryParameters := map[string]interface{}{
   107  		"api-version": APIVersion,
   108  	}
   109  
   110  	preparer := autorest.CreatePreparer(
   111  		autorest.AsContentType("application/json; charset=utf-8"),
   112  		autorest.AsPut(),
   113  		autorest.WithBaseURL(client.BaseURI),
   114  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps/{tapName}", pathParameters),
   115  		autorest.WithJSON(parameters),
   116  		autorest.WithQueryParameters(queryParameters))
   117  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   118  }
   119  
   120  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   121  // http.Response Body if it receives an error.
   122  func (client VirtualNetworkTapsClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkTapsCreateOrUpdateFuture, err error) {
   123  	var resp *http.Response
   124  	future.FutureAPI = &azure.Future{}
   125  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   126  	if err != nil {
   127  		return
   128  	}
   129  	var azf azure.Future
   130  	azf, err = azure.NewFutureFromResponse(resp)
   131  	future.FutureAPI = &azf
   132  	future.Result = future.result
   133  	return
   134  }
   135  
   136  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   137  // closes the http.Response Body.
   138  func (client VirtualNetworkTapsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkTap, err error) {
   139  	err = autorest.Respond(
   140  		resp,
   141  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   142  		autorest.ByUnmarshallingJSON(&result),
   143  		autorest.ByClosing())
   144  	result.Response = autorest.Response{Response: resp}
   145  	return
   146  }
   147  
   148  // Delete deletes the specified virtual network tap.
   149  // Parameters:
   150  // resourceGroupName - the name of the resource group.
   151  // tapName - the name of the virtual network tap.
   152  func (client VirtualNetworkTapsClient) Delete(ctx context.Context, resourceGroupName string, tapName string) (result VirtualNetworkTapsDeleteFuture, err error) {
   153  	if tracing.IsEnabled() {
   154  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkTapsClient.Delete")
   155  		defer func() {
   156  			sc := -1
   157  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   158  				sc = result.FutureAPI.Response().StatusCode
   159  			}
   160  			tracing.EndSpan(ctx, sc, err)
   161  		}()
   162  	}
   163  	req, err := client.DeletePreparer(ctx, resourceGroupName, tapName)
   164  	if err != nil {
   165  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "Delete", nil, "Failure preparing request")
   166  		return
   167  	}
   168  
   169  	result, err = client.DeleteSender(req)
   170  	if err != nil {
   171  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "Delete", result.Response(), "Failure sending request")
   172  		return
   173  	}
   174  
   175  	return
   176  }
   177  
   178  // DeletePreparer prepares the Delete request.
   179  func (client VirtualNetworkTapsClient) DeletePreparer(ctx context.Context, resourceGroupName string, tapName string) (*http.Request, error) {
   180  	pathParameters := map[string]interface{}{
   181  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   182  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   183  		"tapName":           autorest.Encode("path", tapName),
   184  	}
   185  
   186  	const APIVersion = "2018-08-01"
   187  	queryParameters := map[string]interface{}{
   188  		"api-version": APIVersion,
   189  	}
   190  
   191  	preparer := autorest.CreatePreparer(
   192  		autorest.AsDelete(),
   193  		autorest.WithBaseURL(client.BaseURI),
   194  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps/{tapName}", pathParameters),
   195  		autorest.WithQueryParameters(queryParameters))
   196  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   197  }
   198  
   199  // DeleteSender sends the Delete request. The method will close the
   200  // http.Response Body if it receives an error.
   201  func (client VirtualNetworkTapsClient) DeleteSender(req *http.Request) (future VirtualNetworkTapsDeleteFuture, err error) {
   202  	var resp *http.Response
   203  	future.FutureAPI = &azure.Future{}
   204  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   205  	if err != nil {
   206  		return
   207  	}
   208  	var azf azure.Future
   209  	azf, err = azure.NewFutureFromResponse(resp)
   210  	future.FutureAPI = &azf
   211  	future.Result = future.result
   212  	return
   213  }
   214  
   215  // DeleteResponder handles the response to the Delete request. The method always
   216  // closes the http.Response Body.
   217  func (client VirtualNetworkTapsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   218  	err = autorest.Respond(
   219  		resp,
   220  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   221  		autorest.ByClosing())
   222  	result.Response = resp
   223  	return
   224  }
   225  
   226  // Get gets information about the specified virtual network tap.
   227  // Parameters:
   228  // resourceGroupName - the name of the resource group.
   229  // tapName - the name of virtual network tap.
   230  func (client VirtualNetworkTapsClient) Get(ctx context.Context, resourceGroupName string, tapName string) (result VirtualNetworkTap, err error) {
   231  	if tracing.IsEnabled() {
   232  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkTapsClient.Get")
   233  		defer func() {
   234  			sc := -1
   235  			if result.Response.Response != nil {
   236  				sc = result.Response.Response.StatusCode
   237  			}
   238  			tracing.EndSpan(ctx, sc, err)
   239  		}()
   240  	}
   241  	req, err := client.GetPreparer(ctx, resourceGroupName, tapName)
   242  	if err != nil {
   243  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "Get", nil, "Failure preparing request")
   244  		return
   245  	}
   246  
   247  	resp, err := client.GetSender(req)
   248  	if err != nil {
   249  		result.Response = autorest.Response{Response: resp}
   250  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "Get", resp, "Failure sending request")
   251  		return
   252  	}
   253  
   254  	result, err = client.GetResponder(resp)
   255  	if err != nil {
   256  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "Get", resp, "Failure responding to request")
   257  		return
   258  	}
   259  
   260  	return
   261  }
   262  
   263  // GetPreparer prepares the Get request.
   264  func (client VirtualNetworkTapsClient) GetPreparer(ctx context.Context, resourceGroupName string, tapName string) (*http.Request, error) {
   265  	pathParameters := map[string]interface{}{
   266  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   267  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   268  		"tapName":           autorest.Encode("path", tapName),
   269  	}
   270  
   271  	const APIVersion = "2018-08-01"
   272  	queryParameters := map[string]interface{}{
   273  		"api-version": APIVersion,
   274  	}
   275  
   276  	preparer := autorest.CreatePreparer(
   277  		autorest.AsGet(),
   278  		autorest.WithBaseURL(client.BaseURI),
   279  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps/{tapName}", pathParameters),
   280  		autorest.WithQueryParameters(queryParameters))
   281  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   282  }
   283  
   284  // GetSender sends the Get request. The method will close the
   285  // http.Response Body if it receives an error.
   286  func (client VirtualNetworkTapsClient) GetSender(req *http.Request) (*http.Response, error) {
   287  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   288  }
   289  
   290  // GetResponder handles the response to the Get request. The method always
   291  // closes the http.Response Body.
   292  func (client VirtualNetworkTapsClient) GetResponder(resp *http.Response) (result VirtualNetworkTap, err error) {
   293  	err = autorest.Respond(
   294  		resp,
   295  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   296  		autorest.ByUnmarshallingJSON(&result),
   297  		autorest.ByClosing())
   298  	result.Response = autorest.Response{Response: resp}
   299  	return
   300  }
   301  
   302  // ListAll gets all the VirtualNetworkTaps in a subscription.
   303  func (client VirtualNetworkTapsClient) ListAll(ctx context.Context) (result VirtualNetworkTapListResultPage, err error) {
   304  	if tracing.IsEnabled() {
   305  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkTapsClient.ListAll")
   306  		defer func() {
   307  			sc := -1
   308  			if result.vntlr.Response.Response != nil {
   309  				sc = result.vntlr.Response.Response.StatusCode
   310  			}
   311  			tracing.EndSpan(ctx, sc, err)
   312  		}()
   313  	}
   314  	result.fn = client.listAllNextResults
   315  	req, err := client.ListAllPreparer(ctx)
   316  	if err != nil {
   317  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "ListAll", nil, "Failure preparing request")
   318  		return
   319  	}
   320  
   321  	resp, err := client.ListAllSender(req)
   322  	if err != nil {
   323  		result.vntlr.Response = autorest.Response{Response: resp}
   324  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "ListAll", resp, "Failure sending request")
   325  		return
   326  	}
   327  
   328  	result.vntlr, err = client.ListAllResponder(resp)
   329  	if err != nil {
   330  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "ListAll", resp, "Failure responding to request")
   331  		return
   332  	}
   333  	if result.vntlr.hasNextLink() && result.vntlr.IsEmpty() {
   334  		err = result.NextWithContext(ctx)
   335  		return
   336  	}
   337  
   338  	return
   339  }
   340  
   341  // ListAllPreparer prepares the ListAll request.
   342  func (client VirtualNetworkTapsClient) ListAllPreparer(ctx context.Context) (*http.Request, error) {
   343  	pathParameters := map[string]interface{}{
   344  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   345  	}
   346  
   347  	const APIVersion = "2018-08-01"
   348  	queryParameters := map[string]interface{}{
   349  		"api-version": APIVersion,
   350  	}
   351  
   352  	preparer := autorest.CreatePreparer(
   353  		autorest.AsGet(),
   354  		autorest.WithBaseURL(client.BaseURI),
   355  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualNetworkTaps", pathParameters),
   356  		autorest.WithQueryParameters(queryParameters))
   357  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   358  }
   359  
   360  // ListAllSender sends the ListAll request. The method will close the
   361  // http.Response Body if it receives an error.
   362  func (client VirtualNetworkTapsClient) ListAllSender(req *http.Request) (*http.Response, error) {
   363  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   364  }
   365  
   366  // ListAllResponder handles the response to the ListAll request. The method always
   367  // closes the http.Response Body.
   368  func (client VirtualNetworkTapsClient) ListAllResponder(resp *http.Response) (result VirtualNetworkTapListResult, err error) {
   369  	err = autorest.Respond(
   370  		resp,
   371  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   372  		autorest.ByUnmarshallingJSON(&result),
   373  		autorest.ByClosing())
   374  	result.Response = autorest.Response{Response: resp}
   375  	return
   376  }
   377  
   378  // listAllNextResults retrieves the next set of results, if any.
   379  func (client VirtualNetworkTapsClient) listAllNextResults(ctx context.Context, lastResults VirtualNetworkTapListResult) (result VirtualNetworkTapListResult, err error) {
   380  	req, err := lastResults.virtualNetworkTapListResultPreparer(ctx)
   381  	if err != nil {
   382  		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "listAllNextResults", nil, "Failure preparing next results request")
   383  	}
   384  	if req == nil {
   385  		return
   386  	}
   387  	resp, err := client.ListAllSender(req)
   388  	if err != nil {
   389  		result.Response = autorest.Response{Response: resp}
   390  		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "listAllNextResults", resp, "Failure sending next results request")
   391  	}
   392  	result, err = client.ListAllResponder(resp)
   393  	if err != nil {
   394  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "listAllNextResults", resp, "Failure responding to next results request")
   395  	}
   396  	return
   397  }
   398  
   399  // ListAllComplete enumerates all values, automatically crossing page boundaries as required.
   400  func (client VirtualNetworkTapsClient) ListAllComplete(ctx context.Context) (result VirtualNetworkTapListResultIterator, err error) {
   401  	if tracing.IsEnabled() {
   402  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkTapsClient.ListAll")
   403  		defer func() {
   404  			sc := -1
   405  			if result.Response().Response.Response != nil {
   406  				sc = result.page.Response().Response.Response.StatusCode
   407  			}
   408  			tracing.EndSpan(ctx, sc, err)
   409  		}()
   410  	}
   411  	result.page, err = client.ListAll(ctx)
   412  	return
   413  }
   414  
   415  // ListByResourceGroup gets all the VirtualNetworkTaps in a subscription.
   416  // Parameters:
   417  // resourceGroupName - the name of the resource group.
   418  func (client VirtualNetworkTapsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result VirtualNetworkTapListResultPage, err error) {
   419  	if tracing.IsEnabled() {
   420  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkTapsClient.ListByResourceGroup")
   421  		defer func() {
   422  			sc := -1
   423  			if result.vntlr.Response.Response != nil {
   424  				sc = result.vntlr.Response.Response.StatusCode
   425  			}
   426  			tracing.EndSpan(ctx, sc, err)
   427  		}()
   428  	}
   429  	result.fn = client.listByResourceGroupNextResults
   430  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   431  	if err != nil {
   432  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "ListByResourceGroup", nil, "Failure preparing request")
   433  		return
   434  	}
   435  
   436  	resp, err := client.ListByResourceGroupSender(req)
   437  	if err != nil {
   438  		result.vntlr.Response = autorest.Response{Response: resp}
   439  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "ListByResourceGroup", resp, "Failure sending request")
   440  		return
   441  	}
   442  
   443  	result.vntlr, err = client.ListByResourceGroupResponder(resp)
   444  	if err != nil {
   445  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "ListByResourceGroup", resp, "Failure responding to request")
   446  		return
   447  	}
   448  	if result.vntlr.hasNextLink() && result.vntlr.IsEmpty() {
   449  		err = result.NextWithContext(ctx)
   450  		return
   451  	}
   452  
   453  	return
   454  }
   455  
   456  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   457  func (client VirtualNetworkTapsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   458  	pathParameters := map[string]interface{}{
   459  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   460  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   461  	}
   462  
   463  	const APIVersion = "2018-08-01"
   464  	queryParameters := map[string]interface{}{
   465  		"api-version": APIVersion,
   466  	}
   467  
   468  	preparer := autorest.CreatePreparer(
   469  		autorest.AsGet(),
   470  		autorest.WithBaseURL(client.BaseURI),
   471  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps", pathParameters),
   472  		autorest.WithQueryParameters(queryParameters))
   473  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   474  }
   475  
   476  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   477  // http.Response Body if it receives an error.
   478  func (client VirtualNetworkTapsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   479  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   480  }
   481  
   482  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   483  // closes the http.Response Body.
   484  func (client VirtualNetworkTapsClient) ListByResourceGroupResponder(resp *http.Response) (result VirtualNetworkTapListResult, err error) {
   485  	err = autorest.Respond(
   486  		resp,
   487  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   488  		autorest.ByUnmarshallingJSON(&result),
   489  		autorest.ByClosing())
   490  	result.Response = autorest.Response{Response: resp}
   491  	return
   492  }
   493  
   494  // listByResourceGroupNextResults retrieves the next set of results, if any.
   495  func (client VirtualNetworkTapsClient) listByResourceGroupNextResults(ctx context.Context, lastResults VirtualNetworkTapListResult) (result VirtualNetworkTapListResult, err error) {
   496  	req, err := lastResults.virtualNetworkTapListResultPreparer(ctx)
   497  	if err != nil {
   498  		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   499  	}
   500  	if req == nil {
   501  		return
   502  	}
   503  	resp, err := client.ListByResourceGroupSender(req)
   504  	if err != nil {
   505  		result.Response = autorest.Response{Response: resp}
   506  		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   507  	}
   508  	result, err = client.ListByResourceGroupResponder(resp)
   509  	if err != nil {
   510  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   511  	}
   512  	return
   513  }
   514  
   515  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   516  func (client VirtualNetworkTapsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkTapListResultIterator, err error) {
   517  	if tracing.IsEnabled() {
   518  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkTapsClient.ListByResourceGroup")
   519  		defer func() {
   520  			sc := -1
   521  			if result.Response().Response.Response != nil {
   522  				sc = result.page.Response().Response.Response.StatusCode
   523  			}
   524  			tracing.EndSpan(ctx, sc, err)
   525  		}()
   526  	}
   527  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
   528  	return
   529  }
   530  
   531  // UpdateTags updates an VirtualNetworkTap tags.
   532  // Parameters:
   533  // resourceGroupName - the name of the resource group.
   534  // tapName - the name of the tap.
   535  // tapParameters - parameters supplied to update VirtualNetworkTap tags.
   536  func (client VirtualNetworkTapsClient) UpdateTags(ctx context.Context, resourceGroupName string, tapName string, tapParameters TagsObject) (result VirtualNetworkTapsUpdateTagsFuture, err error) {
   537  	if tracing.IsEnabled() {
   538  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkTapsClient.UpdateTags")
   539  		defer func() {
   540  			sc := -1
   541  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   542  				sc = result.FutureAPI.Response().StatusCode
   543  			}
   544  			tracing.EndSpan(ctx, sc, err)
   545  		}()
   546  	}
   547  	req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, tapName, tapParameters)
   548  	if err != nil {
   549  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "UpdateTags", nil, "Failure preparing request")
   550  		return
   551  	}
   552  
   553  	result, err = client.UpdateTagsSender(req)
   554  	if err != nil {
   555  		err = autorest.NewErrorWithError(err, "network.VirtualNetworkTapsClient", "UpdateTags", result.Response(), "Failure sending request")
   556  		return
   557  	}
   558  
   559  	return
   560  }
   561  
   562  // UpdateTagsPreparer prepares the UpdateTags request.
   563  func (client VirtualNetworkTapsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, tapName string, tapParameters TagsObject) (*http.Request, error) {
   564  	pathParameters := map[string]interface{}{
   565  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   566  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   567  		"tapName":           autorest.Encode("path", tapName),
   568  	}
   569  
   570  	const APIVersion = "2018-08-01"
   571  	queryParameters := map[string]interface{}{
   572  		"api-version": APIVersion,
   573  	}
   574  
   575  	preparer := autorest.CreatePreparer(
   576  		autorest.AsContentType("application/json; charset=utf-8"),
   577  		autorest.AsPatch(),
   578  		autorest.WithBaseURL(client.BaseURI),
   579  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps/{tapName}", pathParameters),
   580  		autorest.WithJSON(tapParameters),
   581  		autorest.WithQueryParameters(queryParameters))
   582  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   583  }
   584  
   585  // UpdateTagsSender sends the UpdateTags request. The method will close the
   586  // http.Response Body if it receives an error.
   587  func (client VirtualNetworkTapsClient) UpdateTagsSender(req *http.Request) (future VirtualNetworkTapsUpdateTagsFuture, err error) {
   588  	var resp *http.Response
   589  	future.FutureAPI = &azure.Future{}
   590  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   591  	if err != nil {
   592  		return
   593  	}
   594  	var azf azure.Future
   595  	azf, err = azure.NewFutureFromResponse(resp)
   596  	future.FutureAPI = &azf
   597  	future.Result = future.result
   598  	return
   599  }
   600  
   601  // UpdateTagsResponder handles the response to the UpdateTags request. The method always
   602  // closes the http.Response Body.
   603  func (client VirtualNetworkTapsClient) UpdateTagsResponder(resp *http.Response) (result VirtualNetworkTap, err error) {
   604  	err = autorest.Respond(
   605  		resp,
   606  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   607  		autorest.ByUnmarshallingJSON(&result),
   608  		autorest.ByClosing())
   609  	result.Response = autorest.Response{Response: resp}
   610  	return
   611  }
   612  

View as plain text