...

Source file src/github.com/Azure/azure-sdk-for-go/services/hybriddatamanager/mgmt/2016-06-01/hybriddata/datamanagers.go

Documentation: github.com/Azure/azure-sdk-for-go/services/hybriddatamanager/mgmt/2016-06-01/hybriddata

     1  package hybriddata
     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  // DataManagersClient is the client for the DataManagers methods of the Hybriddata service.
    19  type DataManagersClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewDataManagersClient creates an instance of the DataManagersClient client.
    24  func NewDataManagersClient(subscriptionID string) DataManagersClient {
    25  	return NewDataManagersClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewDataManagersClientWithBaseURI creates an instance of the DataManagersClient client using a custom endpoint.  Use
    29  // this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewDataManagersClientWithBaseURI(baseURI string, subscriptionID string) DataManagersClient {
    31  	return DataManagersClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Create creates a new data manager resource with the specified parameters. Existing resources cannot be updated with
    35  // this API
    36  // and should instead be updated with the Update data manager resource API.
    37  // Parameters:
    38  // resourceGroupName - the Resource Group Name
    39  // dataManagerName - the name of the DataManager Resource within the specified resource group. DataManager
    40  // names must be between 3 and 24 characters in length and use any alphanumeric and underscore only
    41  // dataManager - data manager resource details from request body.
    42  func (client DataManagersClient) Create(ctx context.Context, resourceGroupName string, dataManagerName string, dataManager DataManager) (result DataManagersCreateFuture, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/DataManagersClient.Create")
    45  		defer func() {
    46  			sc := -1
    47  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    48  				sc = result.FutureAPI.Response().StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	if err := validation.Validate([]validation.Validation{
    54  		{TargetValue: dataManagerName,
    55  			Constraints: []validation.Constraint{{Target: "dataManagerName", Name: validation.MaxLength, Rule: 24, Chain: nil},
    56  				{Target: "dataManagerName", Name: validation.MinLength, Rule: 3, Chain: nil},
    57  				{Target: "dataManagerName", Name: validation.Pattern, Rule: `^[-\w\.]+$`, Chain: nil}}}}); err != nil {
    58  		return result, validation.NewError("hybriddata.DataManagersClient", "Create", err.Error())
    59  	}
    60  
    61  	req, err := client.CreatePreparer(ctx, resourceGroupName, dataManagerName, dataManager)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Create", nil, "Failure preparing request")
    64  		return
    65  	}
    66  
    67  	result, err = client.CreateSender(req)
    68  	if err != nil {
    69  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Create", result.Response(), "Failure sending request")
    70  		return
    71  	}
    72  
    73  	return
    74  }
    75  
    76  // CreatePreparer prepares the Create request.
    77  func (client DataManagersClient) CreatePreparer(ctx context.Context, resourceGroupName string, dataManagerName string, dataManager DataManager) (*http.Request, error) {
    78  	pathParameters := map[string]interface{}{
    79  		"dataManagerName":   autorest.Encode("path", dataManagerName),
    80  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    81  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    82  	}
    83  
    84  	const APIVersion = "2016-06-01"
    85  	queryParameters := map[string]interface{}{
    86  		"api-version": APIVersion,
    87  	}
    88  
    89  	preparer := autorest.CreatePreparer(
    90  		autorest.AsContentType("application/json; charset=utf-8"),
    91  		autorest.AsPut(),
    92  		autorest.WithBaseURL(client.BaseURI),
    93  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridData/dataManagers/{dataManagerName}", pathParameters),
    94  		autorest.WithJSON(dataManager),
    95  		autorest.WithQueryParameters(queryParameters))
    96  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    97  }
    98  
    99  // CreateSender sends the Create request. The method will close the
   100  // http.Response Body if it receives an error.
   101  func (client DataManagersClient) CreateSender(req *http.Request) (future DataManagersCreateFuture, err error) {
   102  	var resp *http.Response
   103  	future.FutureAPI = &azure.Future{}
   104  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   105  	if err != nil {
   106  		return
   107  	}
   108  	var azf azure.Future
   109  	azf, err = azure.NewFutureFromResponse(resp)
   110  	future.FutureAPI = &azf
   111  	future.Result = future.result
   112  	return
   113  }
   114  
   115  // CreateResponder handles the response to the Create request. The method always
   116  // closes the http.Response Body.
   117  func (client DataManagersClient) CreateResponder(resp *http.Response) (result DataManager, err error) {
   118  	err = autorest.Respond(
   119  		resp,
   120  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   121  		autorest.ByUnmarshallingJSON(&result),
   122  		autorest.ByClosing())
   123  	result.Response = autorest.Response{Response: resp}
   124  	return
   125  }
   126  
   127  // Delete deletes a data manager resource in Microsoft Azure.
   128  // Parameters:
   129  // resourceGroupName - the Resource Group Name
   130  // dataManagerName - the name of the DataManager Resource within the specified resource group. DataManager
   131  // names must be between 3 and 24 characters in length and use any alphanumeric and underscore only
   132  func (client DataManagersClient) Delete(ctx context.Context, resourceGroupName string, dataManagerName string) (result DataManagersDeleteFuture, err error) {
   133  	if tracing.IsEnabled() {
   134  		ctx = tracing.StartSpan(ctx, fqdn+"/DataManagersClient.Delete")
   135  		defer func() {
   136  			sc := -1
   137  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   138  				sc = result.FutureAPI.Response().StatusCode
   139  			}
   140  			tracing.EndSpan(ctx, sc, err)
   141  		}()
   142  	}
   143  	if err := validation.Validate([]validation.Validation{
   144  		{TargetValue: dataManagerName,
   145  			Constraints: []validation.Constraint{{Target: "dataManagerName", Name: validation.MaxLength, Rule: 24, Chain: nil},
   146  				{Target: "dataManagerName", Name: validation.MinLength, Rule: 3, Chain: nil},
   147  				{Target: "dataManagerName", Name: validation.Pattern, Rule: `^[-\w\.]+$`, Chain: nil}}}}); err != nil {
   148  		return result, validation.NewError("hybriddata.DataManagersClient", "Delete", err.Error())
   149  	}
   150  
   151  	req, err := client.DeletePreparer(ctx, resourceGroupName, dataManagerName)
   152  	if err != nil {
   153  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Delete", nil, "Failure preparing request")
   154  		return
   155  	}
   156  
   157  	result, err = client.DeleteSender(req)
   158  	if err != nil {
   159  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Delete", result.Response(), "Failure sending request")
   160  		return
   161  	}
   162  
   163  	return
   164  }
   165  
   166  // DeletePreparer prepares the Delete request.
   167  func (client DataManagersClient) DeletePreparer(ctx context.Context, resourceGroupName string, dataManagerName string) (*http.Request, error) {
   168  	pathParameters := map[string]interface{}{
   169  		"dataManagerName":   autorest.Encode("path", dataManagerName),
   170  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   171  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   172  	}
   173  
   174  	const APIVersion = "2016-06-01"
   175  	queryParameters := map[string]interface{}{
   176  		"api-version": APIVersion,
   177  	}
   178  
   179  	preparer := autorest.CreatePreparer(
   180  		autorest.AsDelete(),
   181  		autorest.WithBaseURL(client.BaseURI),
   182  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridData/dataManagers/{dataManagerName}", pathParameters),
   183  		autorest.WithQueryParameters(queryParameters))
   184  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   185  }
   186  
   187  // DeleteSender sends the Delete request. The method will close the
   188  // http.Response Body if it receives an error.
   189  func (client DataManagersClient) DeleteSender(req *http.Request) (future DataManagersDeleteFuture, err error) {
   190  	var resp *http.Response
   191  	future.FutureAPI = &azure.Future{}
   192  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   193  	if err != nil {
   194  		return
   195  	}
   196  	var azf azure.Future
   197  	azf, err = azure.NewFutureFromResponse(resp)
   198  	future.FutureAPI = &azf
   199  	future.Result = future.result
   200  	return
   201  }
   202  
   203  // DeleteResponder handles the response to the Delete request. The method always
   204  // closes the http.Response Body.
   205  func (client DataManagersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   206  	err = autorest.Respond(
   207  		resp,
   208  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   209  		autorest.ByClosing())
   210  	result.Response = resp
   211  	return
   212  }
   213  
   214  // Get gets information about the specified data manager resource.
   215  // Parameters:
   216  // resourceGroupName - the Resource Group Name
   217  // dataManagerName - the name of the DataManager Resource within the specified resource group. DataManager
   218  // names must be between 3 and 24 characters in length and use any alphanumeric and underscore only
   219  func (client DataManagersClient) Get(ctx context.Context, resourceGroupName string, dataManagerName string) (result DataManager, err error) {
   220  	if tracing.IsEnabled() {
   221  		ctx = tracing.StartSpan(ctx, fqdn+"/DataManagersClient.Get")
   222  		defer func() {
   223  			sc := -1
   224  			if result.Response.Response != nil {
   225  				sc = result.Response.Response.StatusCode
   226  			}
   227  			tracing.EndSpan(ctx, sc, err)
   228  		}()
   229  	}
   230  	if err := validation.Validate([]validation.Validation{
   231  		{TargetValue: dataManagerName,
   232  			Constraints: []validation.Constraint{{Target: "dataManagerName", Name: validation.MaxLength, Rule: 24, Chain: nil},
   233  				{Target: "dataManagerName", Name: validation.MinLength, Rule: 3, Chain: nil},
   234  				{Target: "dataManagerName", Name: validation.Pattern, Rule: `^[-\w\.]+$`, Chain: nil}}}}); err != nil {
   235  		return result, validation.NewError("hybriddata.DataManagersClient", "Get", err.Error())
   236  	}
   237  
   238  	req, err := client.GetPreparer(ctx, resourceGroupName, dataManagerName)
   239  	if err != nil {
   240  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Get", nil, "Failure preparing request")
   241  		return
   242  	}
   243  
   244  	resp, err := client.GetSender(req)
   245  	if err != nil {
   246  		result.Response = autorest.Response{Response: resp}
   247  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Get", resp, "Failure sending request")
   248  		return
   249  	}
   250  
   251  	result, err = client.GetResponder(resp)
   252  	if err != nil {
   253  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Get", resp, "Failure responding to request")
   254  		return
   255  	}
   256  
   257  	return
   258  }
   259  
   260  // GetPreparer prepares the Get request.
   261  func (client DataManagersClient) GetPreparer(ctx context.Context, resourceGroupName string, dataManagerName string) (*http.Request, error) {
   262  	pathParameters := map[string]interface{}{
   263  		"dataManagerName":   autorest.Encode("path", dataManagerName),
   264  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   265  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   266  	}
   267  
   268  	const APIVersion = "2016-06-01"
   269  	queryParameters := map[string]interface{}{
   270  		"api-version": APIVersion,
   271  	}
   272  
   273  	preparer := autorest.CreatePreparer(
   274  		autorest.AsGet(),
   275  		autorest.WithBaseURL(client.BaseURI),
   276  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridData/dataManagers/{dataManagerName}", pathParameters),
   277  		autorest.WithQueryParameters(queryParameters))
   278  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   279  }
   280  
   281  // GetSender sends the Get request. The method will close the
   282  // http.Response Body if it receives an error.
   283  func (client DataManagersClient) GetSender(req *http.Request) (*http.Response, error) {
   284  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   285  }
   286  
   287  // GetResponder handles the response to the Get request. The method always
   288  // closes the http.Response Body.
   289  func (client DataManagersClient) GetResponder(resp *http.Response) (result DataManager, err error) {
   290  	err = autorest.Respond(
   291  		resp,
   292  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   293  		autorest.ByUnmarshallingJSON(&result),
   294  		autorest.ByClosing())
   295  	result.Response = autorest.Response{Response: resp}
   296  	return
   297  }
   298  
   299  // List lists all the data manager resources available under the subscription.
   300  func (client DataManagersClient) List(ctx context.Context) (result DataManagerList, err error) {
   301  	if tracing.IsEnabled() {
   302  		ctx = tracing.StartSpan(ctx, fqdn+"/DataManagersClient.List")
   303  		defer func() {
   304  			sc := -1
   305  			if result.Response.Response != nil {
   306  				sc = result.Response.Response.StatusCode
   307  			}
   308  			tracing.EndSpan(ctx, sc, err)
   309  		}()
   310  	}
   311  	req, err := client.ListPreparer(ctx)
   312  	if err != nil {
   313  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "List", nil, "Failure preparing request")
   314  		return
   315  	}
   316  
   317  	resp, err := client.ListSender(req)
   318  	if err != nil {
   319  		result.Response = autorest.Response{Response: resp}
   320  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "List", resp, "Failure sending request")
   321  		return
   322  	}
   323  
   324  	result, err = client.ListResponder(resp)
   325  	if err != nil {
   326  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "List", resp, "Failure responding to request")
   327  		return
   328  	}
   329  
   330  	return
   331  }
   332  
   333  // ListPreparer prepares the List request.
   334  func (client DataManagersClient) ListPreparer(ctx context.Context) (*http.Request, error) {
   335  	pathParameters := map[string]interface{}{
   336  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   337  	}
   338  
   339  	const APIVersion = "2016-06-01"
   340  	queryParameters := map[string]interface{}{
   341  		"api-version": APIVersion,
   342  	}
   343  
   344  	preparer := autorest.CreatePreparer(
   345  		autorest.AsGet(),
   346  		autorest.WithBaseURL(client.BaseURI),
   347  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HybridData/dataManagers", pathParameters),
   348  		autorest.WithQueryParameters(queryParameters))
   349  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   350  }
   351  
   352  // ListSender sends the List request. The method will close the
   353  // http.Response Body if it receives an error.
   354  func (client DataManagersClient) ListSender(req *http.Request) (*http.Response, error) {
   355  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   356  }
   357  
   358  // ListResponder handles the response to the List request. The method always
   359  // closes the http.Response Body.
   360  func (client DataManagersClient) ListResponder(resp *http.Response) (result DataManagerList, err error) {
   361  	err = autorest.Respond(
   362  		resp,
   363  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   364  		autorest.ByUnmarshallingJSON(&result),
   365  		autorest.ByClosing())
   366  	result.Response = autorest.Response{Response: resp}
   367  	return
   368  }
   369  
   370  // ListByResourceGroup lists all the data manager resources available under the given resource group.
   371  // Parameters:
   372  // resourceGroupName - the Resource Group Name
   373  func (client DataManagersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DataManagerList, err error) {
   374  	if tracing.IsEnabled() {
   375  		ctx = tracing.StartSpan(ctx, fqdn+"/DataManagersClient.ListByResourceGroup")
   376  		defer func() {
   377  			sc := -1
   378  			if result.Response.Response != nil {
   379  				sc = result.Response.Response.StatusCode
   380  			}
   381  			tracing.EndSpan(ctx, sc, err)
   382  		}()
   383  	}
   384  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   385  	if err != nil {
   386  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "ListByResourceGroup", nil, "Failure preparing request")
   387  		return
   388  	}
   389  
   390  	resp, err := client.ListByResourceGroupSender(req)
   391  	if err != nil {
   392  		result.Response = autorest.Response{Response: resp}
   393  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "ListByResourceGroup", resp, "Failure sending request")
   394  		return
   395  	}
   396  
   397  	result, err = client.ListByResourceGroupResponder(resp)
   398  	if err != nil {
   399  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "ListByResourceGroup", resp, "Failure responding to request")
   400  		return
   401  	}
   402  
   403  	return
   404  }
   405  
   406  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   407  func (client DataManagersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   408  	pathParameters := map[string]interface{}{
   409  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   410  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   411  	}
   412  
   413  	const APIVersion = "2016-06-01"
   414  	queryParameters := map[string]interface{}{
   415  		"api-version": APIVersion,
   416  	}
   417  
   418  	preparer := autorest.CreatePreparer(
   419  		autorest.AsGet(),
   420  		autorest.WithBaseURL(client.BaseURI),
   421  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridData/dataManagers", pathParameters),
   422  		autorest.WithQueryParameters(queryParameters))
   423  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   424  }
   425  
   426  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   427  // http.Response Body if it receives an error.
   428  func (client DataManagersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   429  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   430  }
   431  
   432  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   433  // closes the http.Response Body.
   434  func (client DataManagersClient) ListByResourceGroupResponder(resp *http.Response) (result DataManagerList, err error) {
   435  	err = autorest.Respond(
   436  		resp,
   437  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   438  		autorest.ByUnmarshallingJSON(&result),
   439  		autorest.ByClosing())
   440  	result.Response = autorest.Response{Response: resp}
   441  	return
   442  }
   443  
   444  // Update updates the properties of an existing data manager resource.
   445  // Parameters:
   446  // resourceGroupName - the Resource Group Name
   447  // dataManagerName - the name of the DataManager Resource within the specified resource group. DataManager
   448  // names must be between 3 and 24 characters in length and use any alphanumeric and underscore only
   449  // dataManagerUpdateParameter - data manager resource details from request body.
   450  // ifMatch - defines the If-Match condition. The patch will be performed only if the ETag of the data manager
   451  // resource on the server matches this value.
   452  func (client DataManagersClient) Update(ctx context.Context, resourceGroupName string, dataManagerName string, dataManagerUpdateParameter DataManagerUpdateParameter, ifMatch string) (result DataManagersUpdateFuture, err error) {
   453  	if tracing.IsEnabled() {
   454  		ctx = tracing.StartSpan(ctx, fqdn+"/DataManagersClient.Update")
   455  		defer func() {
   456  			sc := -1
   457  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   458  				sc = result.FutureAPI.Response().StatusCode
   459  			}
   460  			tracing.EndSpan(ctx, sc, err)
   461  		}()
   462  	}
   463  	if err := validation.Validate([]validation.Validation{
   464  		{TargetValue: dataManagerName,
   465  			Constraints: []validation.Constraint{{Target: "dataManagerName", Name: validation.MaxLength, Rule: 24, Chain: nil},
   466  				{Target: "dataManagerName", Name: validation.MinLength, Rule: 3, Chain: nil},
   467  				{Target: "dataManagerName", Name: validation.Pattern, Rule: `^[-\w\.]+$`, Chain: nil}}}}); err != nil {
   468  		return result, validation.NewError("hybriddata.DataManagersClient", "Update", err.Error())
   469  	}
   470  
   471  	req, err := client.UpdatePreparer(ctx, resourceGroupName, dataManagerName, dataManagerUpdateParameter, ifMatch)
   472  	if err != nil {
   473  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Update", nil, "Failure preparing request")
   474  		return
   475  	}
   476  
   477  	result, err = client.UpdateSender(req)
   478  	if err != nil {
   479  		err = autorest.NewErrorWithError(err, "hybriddata.DataManagersClient", "Update", result.Response(), "Failure sending request")
   480  		return
   481  	}
   482  
   483  	return
   484  }
   485  
   486  // UpdatePreparer prepares the Update request.
   487  func (client DataManagersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, dataManagerName string, dataManagerUpdateParameter DataManagerUpdateParameter, ifMatch string) (*http.Request, error) {
   488  	pathParameters := map[string]interface{}{
   489  		"dataManagerName":   autorest.Encode("path", dataManagerName),
   490  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   491  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   492  	}
   493  
   494  	const APIVersion = "2016-06-01"
   495  	queryParameters := map[string]interface{}{
   496  		"api-version": APIVersion,
   497  	}
   498  
   499  	preparer := autorest.CreatePreparer(
   500  		autorest.AsContentType("application/json; charset=utf-8"),
   501  		autorest.AsPatch(),
   502  		autorest.WithBaseURL(client.BaseURI),
   503  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridData/dataManagers/{dataManagerName}", pathParameters),
   504  		autorest.WithJSON(dataManagerUpdateParameter),
   505  		autorest.WithQueryParameters(queryParameters))
   506  	if len(ifMatch) > 0 {
   507  		preparer = autorest.DecoratePreparer(preparer,
   508  			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
   509  	}
   510  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   511  }
   512  
   513  // UpdateSender sends the Update request. The method will close the
   514  // http.Response Body if it receives an error.
   515  func (client DataManagersClient) UpdateSender(req *http.Request) (future DataManagersUpdateFuture, err error) {
   516  	var resp *http.Response
   517  	future.FutureAPI = &azure.Future{}
   518  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   519  	if err != nil {
   520  		return
   521  	}
   522  	var azf azure.Future
   523  	azf, err = azure.NewFutureFromResponse(resp)
   524  	future.FutureAPI = &azf
   525  	future.Result = future.result
   526  	return
   527  }
   528  
   529  // UpdateResponder handles the response to the Update request. The method always
   530  // closes the http.Response Body.
   531  func (client DataManagersClient) UpdateResponder(resp *http.Response) (result DataManager, err error) {
   532  	err = autorest.Respond(
   533  		resp,
   534  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   535  		autorest.ByUnmarshallingJSON(&result),
   536  		autorest.ByClosing())
   537  	result.Response = autorest.Response{Response: resp}
   538  	return
   539  }
   540  

View as plain text