...

Source file src/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-01-01/network/managers.go

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

View as plain text