...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/azuredata/mgmt/2017-03-01-preview/azuredata/sqlserverregistrations.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/azuredata/mgmt/2017-03-01-preview/azuredata

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

View as plain text