...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-04-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  // VirtualHubRouteTableV2sClient is the network Client
    18  type VirtualHubRouteTableV2sClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewVirtualHubRouteTableV2sClient creates an instance of the VirtualHubRouteTableV2sClient client.
    23  func NewVirtualHubRouteTableV2sClient(subscriptionID string) VirtualHubRouteTableV2sClient {
    24  	return NewVirtualHubRouteTableV2sClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewVirtualHubRouteTableV2sClientWithBaseURI creates an instance of the VirtualHubRouteTableV2sClient client using a
    28  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    29  // Azure stack).
    30  func NewVirtualHubRouteTableV2sClientWithBaseURI(baseURI string, subscriptionID string) VirtualHubRouteTableV2sClient {
    31  	return VirtualHubRouteTableV2sClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CreateOrUpdate creates a VirtualHubRouteTableV2 resource if it doesn't exist else updates the existing
    35  // VirtualHubRouteTableV2.
    36  // Parameters:
    37  // resourceGroupName - the resource group name of the VirtualHub.
    38  // virtualHubName - the name of the VirtualHub.
    39  // routeTableName - the name of the VirtualHubRouteTableV2.
    40  // virtualHubRouteTableV2Parameters - parameters supplied to create or update VirtualHubRouteTableV2.
    41  func (client VirtualHubRouteTableV2sClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualHubName string, routeTableName string, virtualHubRouteTableV2Parameters VirtualHubRouteTableV2) (result VirtualHubRouteTableV2sCreateOrUpdateFuture, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualHubRouteTableV2sClient.CreateOrUpdate")
    44  		defer func() {
    45  			sc := -1
    46  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    47  				sc = result.FutureAPI.Response().StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, virtualHubName, routeTableName, virtualHubRouteTableV2Parameters)
    53  	if err != nil {
    54  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "CreateOrUpdate", nil, "Failure preparing request")
    55  		return
    56  	}
    57  
    58  	result, err = client.CreateOrUpdateSender(req)
    59  	if err != nil {
    60  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    61  		return
    62  	}
    63  
    64  	return
    65  }
    66  
    67  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    68  func (client VirtualHubRouteTableV2sClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, virtualHubName string, routeTableName string, virtualHubRouteTableV2Parameters VirtualHubRouteTableV2) (*http.Request, error) {
    69  	pathParameters := map[string]interface{}{
    70  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    71  		"routeTableName":    autorest.Encode("path", routeTableName),
    72  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    73  		"virtualHubName":    autorest.Encode("path", virtualHubName),
    74  	}
    75  
    76  	const APIVersion = "2020-04-01"
    77  	queryParameters := map[string]interface{}{
    78  		"api-version": APIVersion,
    79  	}
    80  
    81  	virtualHubRouteTableV2Parameters.Etag = nil
    82  	preparer := autorest.CreatePreparer(
    83  		autorest.AsContentType("application/json; charset=utf-8"),
    84  		autorest.AsPut(),
    85  		autorest.WithBaseURL(client.BaseURI),
    86  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/routeTables/{routeTableName}", pathParameters),
    87  		autorest.WithJSON(virtualHubRouteTableV2Parameters),
    88  		autorest.WithQueryParameters(queryParameters))
    89  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    90  }
    91  
    92  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
    93  // http.Response Body if it receives an error.
    94  func (client VirtualHubRouteTableV2sClient) CreateOrUpdateSender(req *http.Request) (future VirtualHubRouteTableV2sCreateOrUpdateFuture, err error) {
    95  	var resp *http.Response
    96  	future.FutureAPI = &azure.Future{}
    97  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    98  	if err != nil {
    99  		return
   100  	}
   101  	var azf azure.Future
   102  	azf, err = azure.NewFutureFromResponse(resp)
   103  	future.FutureAPI = &azf
   104  	future.Result = future.result
   105  	return
   106  }
   107  
   108  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   109  // closes the http.Response Body.
   110  func (client VirtualHubRouteTableV2sClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualHubRouteTableV2, err error) {
   111  	err = autorest.Respond(
   112  		resp,
   113  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   114  		autorest.ByUnmarshallingJSON(&result),
   115  		autorest.ByClosing())
   116  	result.Response = autorest.Response{Response: resp}
   117  	return
   118  }
   119  
   120  // Delete deletes a VirtualHubRouteTableV2.
   121  // Parameters:
   122  // resourceGroupName - the resource group name of the VirtualHubRouteTableV2.
   123  // virtualHubName - the name of the VirtualHub.
   124  // routeTableName - the name of the VirtualHubRouteTableV2.
   125  func (client VirtualHubRouteTableV2sClient) Delete(ctx context.Context, resourceGroupName string, virtualHubName string, routeTableName string) (result VirtualHubRouteTableV2sDeleteFuture, err error) {
   126  	if tracing.IsEnabled() {
   127  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualHubRouteTableV2sClient.Delete")
   128  		defer func() {
   129  			sc := -1
   130  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   131  				sc = result.FutureAPI.Response().StatusCode
   132  			}
   133  			tracing.EndSpan(ctx, sc, err)
   134  		}()
   135  	}
   136  	req, err := client.DeletePreparer(ctx, resourceGroupName, virtualHubName, routeTableName)
   137  	if err != nil {
   138  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "Delete", nil, "Failure preparing request")
   139  		return
   140  	}
   141  
   142  	result, err = client.DeleteSender(req)
   143  	if err != nil {
   144  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "Delete", result.Response(), "Failure sending request")
   145  		return
   146  	}
   147  
   148  	return
   149  }
   150  
   151  // DeletePreparer prepares the Delete request.
   152  func (client VirtualHubRouteTableV2sClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualHubName string, routeTableName string) (*http.Request, error) {
   153  	pathParameters := map[string]interface{}{
   154  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   155  		"routeTableName":    autorest.Encode("path", routeTableName),
   156  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   157  		"virtualHubName":    autorest.Encode("path", virtualHubName),
   158  	}
   159  
   160  	const APIVersion = "2020-04-01"
   161  	queryParameters := map[string]interface{}{
   162  		"api-version": APIVersion,
   163  	}
   164  
   165  	preparer := autorest.CreatePreparer(
   166  		autorest.AsDelete(),
   167  		autorest.WithBaseURL(client.BaseURI),
   168  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/routeTables/{routeTableName}", pathParameters),
   169  		autorest.WithQueryParameters(queryParameters))
   170  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   171  }
   172  
   173  // DeleteSender sends the Delete request. The method will close the
   174  // http.Response Body if it receives an error.
   175  func (client VirtualHubRouteTableV2sClient) DeleteSender(req *http.Request) (future VirtualHubRouteTableV2sDeleteFuture, err error) {
   176  	var resp *http.Response
   177  	future.FutureAPI = &azure.Future{}
   178  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   179  	if err != nil {
   180  		return
   181  	}
   182  	var azf azure.Future
   183  	azf, err = azure.NewFutureFromResponse(resp)
   184  	future.FutureAPI = &azf
   185  	future.Result = future.result
   186  	return
   187  }
   188  
   189  // DeleteResponder handles the response to the Delete request. The method always
   190  // closes the http.Response Body.
   191  func (client VirtualHubRouteTableV2sClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   192  	err = autorest.Respond(
   193  		resp,
   194  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   195  		autorest.ByClosing())
   196  	result.Response = resp
   197  	return
   198  }
   199  
   200  // Get retrieves the details of a VirtualHubRouteTableV2.
   201  // Parameters:
   202  // resourceGroupName - the resource group name of the VirtualHubRouteTableV2.
   203  // virtualHubName - the name of the VirtualHub.
   204  // routeTableName - the name of the VirtualHubRouteTableV2.
   205  func (client VirtualHubRouteTableV2sClient) Get(ctx context.Context, resourceGroupName string, virtualHubName string, routeTableName string) (result VirtualHubRouteTableV2, err error) {
   206  	if tracing.IsEnabled() {
   207  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualHubRouteTableV2sClient.Get")
   208  		defer func() {
   209  			sc := -1
   210  			if result.Response.Response != nil {
   211  				sc = result.Response.Response.StatusCode
   212  			}
   213  			tracing.EndSpan(ctx, sc, err)
   214  		}()
   215  	}
   216  	req, err := client.GetPreparer(ctx, resourceGroupName, virtualHubName, routeTableName)
   217  	if err != nil {
   218  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "Get", nil, "Failure preparing request")
   219  		return
   220  	}
   221  
   222  	resp, err := client.GetSender(req)
   223  	if err != nil {
   224  		result.Response = autorest.Response{Response: resp}
   225  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "Get", resp, "Failure sending request")
   226  		return
   227  	}
   228  
   229  	result, err = client.GetResponder(resp)
   230  	if err != nil {
   231  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "Get", resp, "Failure responding to request")
   232  		return
   233  	}
   234  
   235  	return
   236  }
   237  
   238  // GetPreparer prepares the Get request.
   239  func (client VirtualHubRouteTableV2sClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualHubName string, routeTableName string) (*http.Request, error) {
   240  	pathParameters := map[string]interface{}{
   241  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   242  		"routeTableName":    autorest.Encode("path", routeTableName),
   243  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   244  		"virtualHubName":    autorest.Encode("path", virtualHubName),
   245  	}
   246  
   247  	const APIVersion = "2020-04-01"
   248  	queryParameters := map[string]interface{}{
   249  		"api-version": APIVersion,
   250  	}
   251  
   252  	preparer := autorest.CreatePreparer(
   253  		autorest.AsGet(),
   254  		autorest.WithBaseURL(client.BaseURI),
   255  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/routeTables/{routeTableName}", pathParameters),
   256  		autorest.WithQueryParameters(queryParameters))
   257  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   258  }
   259  
   260  // GetSender sends the Get request. The method will close the
   261  // http.Response Body if it receives an error.
   262  func (client VirtualHubRouteTableV2sClient) GetSender(req *http.Request) (*http.Response, error) {
   263  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   264  }
   265  
   266  // GetResponder handles the response to the Get request. The method always
   267  // closes the http.Response Body.
   268  func (client VirtualHubRouteTableV2sClient) GetResponder(resp *http.Response) (result VirtualHubRouteTableV2, err error) {
   269  	err = autorest.Respond(
   270  		resp,
   271  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   272  		autorest.ByUnmarshallingJSON(&result),
   273  		autorest.ByClosing())
   274  	result.Response = autorest.Response{Response: resp}
   275  	return
   276  }
   277  
   278  // List retrieves the details of all VirtualHubRouteTableV2s.
   279  // Parameters:
   280  // resourceGroupName - the resource group name of the VirtualHub.
   281  // virtualHubName - the name of the VirtualHub.
   282  func (client VirtualHubRouteTableV2sClient) List(ctx context.Context, resourceGroupName string, virtualHubName string) (result ListVirtualHubRouteTableV2sResultPage, err error) {
   283  	if tracing.IsEnabled() {
   284  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualHubRouteTableV2sClient.List")
   285  		defer func() {
   286  			sc := -1
   287  			if result.lvhrtvr.Response.Response != nil {
   288  				sc = result.lvhrtvr.Response.Response.StatusCode
   289  			}
   290  			tracing.EndSpan(ctx, sc, err)
   291  		}()
   292  	}
   293  	result.fn = client.listNextResults
   294  	req, err := client.ListPreparer(ctx, resourceGroupName, virtualHubName)
   295  	if err != nil {
   296  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "List", nil, "Failure preparing request")
   297  		return
   298  	}
   299  
   300  	resp, err := client.ListSender(req)
   301  	if err != nil {
   302  		result.lvhrtvr.Response = autorest.Response{Response: resp}
   303  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "List", resp, "Failure sending request")
   304  		return
   305  	}
   306  
   307  	result.lvhrtvr, err = client.ListResponder(resp)
   308  	if err != nil {
   309  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "List", resp, "Failure responding to request")
   310  		return
   311  	}
   312  	if result.lvhrtvr.hasNextLink() && result.lvhrtvr.IsEmpty() {
   313  		err = result.NextWithContext(ctx)
   314  		return
   315  	}
   316  
   317  	return
   318  }
   319  
   320  // ListPreparer prepares the List request.
   321  func (client VirtualHubRouteTableV2sClient) ListPreparer(ctx context.Context, resourceGroupName string, virtualHubName string) (*http.Request, error) {
   322  	pathParameters := map[string]interface{}{
   323  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   324  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   325  		"virtualHubName":    autorest.Encode("path", virtualHubName),
   326  	}
   327  
   328  	const APIVersion = "2020-04-01"
   329  	queryParameters := map[string]interface{}{
   330  		"api-version": APIVersion,
   331  	}
   332  
   333  	preparer := autorest.CreatePreparer(
   334  		autorest.AsGet(),
   335  		autorest.WithBaseURL(client.BaseURI),
   336  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/routeTables", pathParameters),
   337  		autorest.WithQueryParameters(queryParameters))
   338  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   339  }
   340  
   341  // ListSender sends the List request. The method will close the
   342  // http.Response Body if it receives an error.
   343  func (client VirtualHubRouteTableV2sClient) ListSender(req *http.Request) (*http.Response, error) {
   344  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   345  }
   346  
   347  // ListResponder handles the response to the List request. The method always
   348  // closes the http.Response Body.
   349  func (client VirtualHubRouteTableV2sClient) ListResponder(resp *http.Response) (result ListVirtualHubRouteTableV2sResult, err error) {
   350  	err = autorest.Respond(
   351  		resp,
   352  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   353  		autorest.ByUnmarshallingJSON(&result),
   354  		autorest.ByClosing())
   355  	result.Response = autorest.Response{Response: resp}
   356  	return
   357  }
   358  
   359  // listNextResults retrieves the next set of results, if any.
   360  func (client VirtualHubRouteTableV2sClient) listNextResults(ctx context.Context, lastResults ListVirtualHubRouteTableV2sResult) (result ListVirtualHubRouteTableV2sResult, err error) {
   361  	req, err := lastResults.listVirtualHubRouteTableV2sResultPreparer(ctx)
   362  	if err != nil {
   363  		return result, autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "listNextResults", nil, "Failure preparing next results request")
   364  	}
   365  	if req == nil {
   366  		return
   367  	}
   368  	resp, err := client.ListSender(req)
   369  	if err != nil {
   370  		result.Response = autorest.Response{Response: resp}
   371  		return result, autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "listNextResults", resp, "Failure sending next results request")
   372  	}
   373  	result, err = client.ListResponder(resp)
   374  	if err != nil {
   375  		err = autorest.NewErrorWithError(err, "network.VirtualHubRouteTableV2sClient", "listNextResults", resp, "Failure responding to next results request")
   376  	}
   377  	return
   378  }
   379  
   380  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   381  func (client VirtualHubRouteTableV2sClient) ListComplete(ctx context.Context, resourceGroupName string, virtualHubName string) (result ListVirtualHubRouteTableV2sResultIterator, err error) {
   382  	if tracing.IsEnabled() {
   383  		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualHubRouteTableV2sClient.List")
   384  		defer func() {
   385  			sc := -1
   386  			if result.Response().Response.Response != nil {
   387  				sc = result.page.Response().Response.Response.StatusCode
   388  			}
   389  			tracing.EndSpan(ctx, sc, err)
   390  		}()
   391  	}
   392  	result.page, err = client.List(ctx, resourceGroupName, virtualHubName)
   393  	return
   394  }
   395  

View as plain text