...

Source file src/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-05-01/network/publicipprefixes.go

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

View as plain text