...

Source file src/github.com/Azure/azure-sdk-for-go/services/datalake/store/mgmt/2016-11-01/account/accounts.go

Documentation: github.com/Azure/azure-sdk-for-go/services/datalake/store/mgmt/2016-11-01/account

     1  package account
     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  // AccountsClient is the creates an Azure Data Lake Store account management client.
    19  type AccountsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewAccountsClient creates an instance of the AccountsClient client.
    24  func NewAccountsClient(subscriptionID string) AccountsClient {
    25  	return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewAccountsClientWithBaseURI creates an instance of the AccountsClient 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 NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient {
    31  	return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CheckNameAvailability checks whether the specified account name is available or taken.
    35  // Parameters:
    36  // location - the resource location without whitespace.
    37  // parameters - parameters supplied to check the Data Lake Store account name availability.
    38  func (client AccountsClient) CheckNameAvailability(ctx context.Context, location string, parameters CheckNameAvailabilityParameters) (result NameAvailabilityInformation, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CheckNameAvailability")
    41  		defer func() {
    42  			sc := -1
    43  			if result.Response.Response != nil {
    44  				sc = result.Response.Response.StatusCode
    45  			}
    46  			tracing.EndSpan(ctx, sc, err)
    47  		}()
    48  	}
    49  	if err := validation.Validate([]validation.Validation{
    50  		{TargetValue: parameters,
    51  			Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil},
    52  				{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
    53  		return result, validation.NewError("account.AccountsClient", "CheckNameAvailability", err.Error())
    54  	}
    55  
    56  	req, err := client.CheckNameAvailabilityPreparer(ctx, location, parameters)
    57  	if err != nil {
    58  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request")
    59  		return
    60  	}
    61  
    62  	resp, err := client.CheckNameAvailabilitySender(req)
    63  	if err != nil {
    64  		result.Response = autorest.Response{Response: resp}
    65  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "CheckNameAvailability", resp, "Failure sending request")
    66  		return
    67  	}
    68  
    69  	result, err = client.CheckNameAvailabilityResponder(resp)
    70  	if err != nil {
    71  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "CheckNameAvailability", resp, "Failure responding to request")
    72  		return
    73  	}
    74  
    75  	return
    76  }
    77  
    78  // CheckNameAvailabilityPreparer prepares the CheckNameAvailability request.
    79  func (client AccountsClient) CheckNameAvailabilityPreparer(ctx context.Context, location string, parameters CheckNameAvailabilityParameters) (*http.Request, error) {
    80  	pathParameters := map[string]interface{}{
    81  		"location":       autorest.Encode("path", location),
    82  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
    83  	}
    84  
    85  	const APIVersion = "2016-11-01"
    86  	queryParameters := map[string]interface{}{
    87  		"api-version": APIVersion,
    88  	}
    89  
    90  	preparer := autorest.CreatePreparer(
    91  		autorest.AsContentType("application/json; charset=utf-8"),
    92  		autorest.AsPost(),
    93  		autorest.WithBaseURL(client.BaseURI),
    94  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DataLakeStore/locations/{location}/checkNameAvailability", pathParameters),
    95  		autorest.WithJSON(parameters),
    96  		autorest.WithQueryParameters(queryParameters))
    97  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    98  }
    99  
   100  // CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the
   101  // http.Response Body if it receives an error.
   102  func (client AccountsClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) {
   103  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   104  }
   105  
   106  // CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always
   107  // closes the http.Response Body.
   108  func (client AccountsClient) CheckNameAvailabilityResponder(resp *http.Response) (result NameAvailabilityInformation, err error) {
   109  	err = autorest.Respond(
   110  		resp,
   111  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   112  		autorest.ByUnmarshallingJSON(&result),
   113  		autorest.ByClosing())
   114  	result.Response = autorest.Response{Response: resp}
   115  	return
   116  }
   117  
   118  // Create creates the specified Data Lake Store account.
   119  // Parameters:
   120  // resourceGroupName - the name of the Azure resource group.
   121  // accountName - the name of the Data Lake Store account.
   122  // parameters - parameters supplied to create the Data Lake Store account.
   123  func (client AccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, parameters CreateDataLakeStoreAccountParameters) (result AccountsCreateFutureType, err error) {
   124  	if tracing.IsEnabled() {
   125  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Create")
   126  		defer func() {
   127  			sc := -1
   128  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   129  				sc = result.FutureAPI.Response().StatusCode
   130  			}
   131  			tracing.EndSpan(ctx, sc, err)
   132  		}()
   133  	}
   134  	if err := validation.Validate([]validation.Validation{
   135  		{TargetValue: parameters,
   136  			Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
   137  				{Target: "parameters.Identity", Name: validation.Null, Rule: false,
   138  					Chain: []validation.Constraint{{Target: "parameters.Identity.Type", Name: validation.Null, Rule: true, Chain: nil}}},
   139  				{Target: "parameters.CreateDataLakeStoreAccountProperties", Name: validation.Null, Rule: false,
   140  					Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeStoreAccountProperties.EncryptionConfig", Name: validation.Null, Rule: false,
   141  						Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeStoreAccountProperties.EncryptionConfig.KeyVaultMetaInfo", Name: validation.Null, Rule: false,
   142  							Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeStoreAccountProperties.EncryptionConfig.KeyVaultMetaInfo.KeyVaultResourceID", Name: validation.Null, Rule: true, Chain: nil},
   143  								{Target: "parameters.CreateDataLakeStoreAccountProperties.EncryptionConfig.KeyVaultMetaInfo.EncryptionKeyName", Name: validation.Null, Rule: true, Chain: nil},
   144  								{Target: "parameters.CreateDataLakeStoreAccountProperties.EncryptionConfig.KeyVaultMetaInfo.EncryptionKeyVersion", Name: validation.Null, Rule: true, Chain: nil},
   145  							}},
   146  						}},
   147  					}}}}}); err != nil {
   148  		return result, validation.NewError("account.AccountsClient", "Create", err.Error())
   149  	}
   150  
   151  	req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, parameters)
   152  	if err != nil {
   153  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Create", nil, "Failure preparing request")
   154  		return
   155  	}
   156  
   157  	result, err = client.CreateSender(req)
   158  	if err != nil {
   159  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Create", result.Response(), "Failure sending request")
   160  		return
   161  	}
   162  
   163  	return
   164  }
   165  
   166  // CreatePreparer prepares the Create request.
   167  func (client AccountsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters CreateDataLakeStoreAccountParameters) (*http.Request, error) {
   168  	pathParameters := map[string]interface{}{
   169  		"accountName":       autorest.Encode("path", accountName),
   170  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   171  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   172  	}
   173  
   174  	const APIVersion = "2016-11-01"
   175  	queryParameters := map[string]interface{}{
   176  		"api-version": APIVersion,
   177  	}
   178  
   179  	preparer := autorest.CreatePreparer(
   180  		autorest.AsContentType("application/json; charset=utf-8"),
   181  		autorest.AsPut(),
   182  		autorest.WithBaseURL(client.BaseURI),
   183  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeStore/accounts/{accountName}", pathParameters),
   184  		autorest.WithJSON(parameters),
   185  		autorest.WithQueryParameters(queryParameters))
   186  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   187  }
   188  
   189  // CreateSender sends the Create request. The method will close the
   190  // http.Response Body if it receives an error.
   191  func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCreateFutureType, err error) {
   192  	var resp *http.Response
   193  	future.FutureAPI = &azure.Future{}
   194  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   195  	if err != nil {
   196  		return
   197  	}
   198  	var azf azure.Future
   199  	azf, err = azure.NewFutureFromResponse(resp)
   200  	future.FutureAPI = &azf
   201  	future.Result = future.result
   202  	return
   203  }
   204  
   205  // CreateResponder handles the response to the Create request. The method always
   206  // closes the http.Response Body.
   207  func (client AccountsClient) CreateResponder(resp *http.Response) (result DataLakeStoreAccount, err error) {
   208  	err = autorest.Respond(
   209  		resp,
   210  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   211  		autorest.ByUnmarshallingJSON(&result),
   212  		autorest.ByClosing())
   213  	result.Response = autorest.Response{Response: resp}
   214  	return
   215  }
   216  
   217  // Delete deletes the specified Data Lake Store account.
   218  // Parameters:
   219  // resourceGroupName - the name of the Azure resource group.
   220  // accountName - the name of the Data Lake Store account.
   221  func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result AccountsDeleteFutureType, err error) {
   222  	if tracing.IsEnabled() {
   223  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete")
   224  		defer func() {
   225  			sc := -1
   226  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   227  				sc = result.FutureAPI.Response().StatusCode
   228  			}
   229  			tracing.EndSpan(ctx, sc, err)
   230  		}()
   231  	}
   232  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName)
   233  	if err != nil {
   234  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Delete", nil, "Failure preparing request")
   235  		return
   236  	}
   237  
   238  	result, err = client.DeleteSender(req)
   239  	if err != nil {
   240  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Delete", result.Response(), "Failure sending request")
   241  		return
   242  	}
   243  
   244  	return
   245  }
   246  
   247  // DeletePreparer prepares the Delete request.
   248  func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   249  	pathParameters := map[string]interface{}{
   250  		"accountName":       autorest.Encode("path", accountName),
   251  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   252  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   253  	}
   254  
   255  	const APIVersion = "2016-11-01"
   256  	queryParameters := map[string]interface{}{
   257  		"api-version": APIVersion,
   258  	}
   259  
   260  	preparer := autorest.CreatePreparer(
   261  		autorest.AsDelete(),
   262  		autorest.WithBaseURL(client.BaseURI),
   263  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeStore/accounts/{accountName}", pathParameters),
   264  		autorest.WithQueryParameters(queryParameters))
   265  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   266  }
   267  
   268  // DeleteSender sends the Delete request. The method will close the
   269  // http.Response Body if it receives an error.
   270  func (client AccountsClient) DeleteSender(req *http.Request) (future AccountsDeleteFutureType, err error) {
   271  	var resp *http.Response
   272  	future.FutureAPI = &azure.Future{}
   273  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   274  	if err != nil {
   275  		return
   276  	}
   277  	var azf azure.Future
   278  	azf, err = azure.NewFutureFromResponse(resp)
   279  	future.FutureAPI = &azf
   280  	future.Result = future.result
   281  	return
   282  }
   283  
   284  // DeleteResponder handles the response to the Delete request. The method always
   285  // closes the http.Response Body.
   286  func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   287  	err = autorest.Respond(
   288  		resp,
   289  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   290  		autorest.ByClosing())
   291  	result.Response = resp
   292  	return
   293  }
   294  
   295  // EnableKeyVault attempts to enable a user managed Key Vault for encryption of the specified Data Lake Store account.
   296  // Parameters:
   297  // resourceGroupName - the name of the Azure resource group.
   298  // accountName - the name of the Data Lake Store account.
   299  func (client AccountsClient) EnableKeyVault(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) {
   300  	if tracing.IsEnabled() {
   301  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.EnableKeyVault")
   302  		defer func() {
   303  			sc := -1
   304  			if result.Response != nil {
   305  				sc = result.Response.StatusCode
   306  			}
   307  			tracing.EndSpan(ctx, sc, err)
   308  		}()
   309  	}
   310  	req, err := client.EnableKeyVaultPreparer(ctx, resourceGroupName, accountName)
   311  	if err != nil {
   312  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "EnableKeyVault", nil, "Failure preparing request")
   313  		return
   314  	}
   315  
   316  	resp, err := client.EnableKeyVaultSender(req)
   317  	if err != nil {
   318  		result.Response = resp
   319  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "EnableKeyVault", resp, "Failure sending request")
   320  		return
   321  	}
   322  
   323  	result, err = client.EnableKeyVaultResponder(resp)
   324  	if err != nil {
   325  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "EnableKeyVault", resp, "Failure responding to request")
   326  		return
   327  	}
   328  
   329  	return
   330  }
   331  
   332  // EnableKeyVaultPreparer prepares the EnableKeyVault request.
   333  func (client AccountsClient) EnableKeyVaultPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   334  	pathParameters := map[string]interface{}{
   335  		"accountName":       autorest.Encode("path", accountName),
   336  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   337  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   338  	}
   339  
   340  	const APIVersion = "2016-11-01"
   341  	queryParameters := map[string]interface{}{
   342  		"api-version": APIVersion,
   343  	}
   344  
   345  	preparer := autorest.CreatePreparer(
   346  		autorest.AsPost(),
   347  		autorest.WithBaseURL(client.BaseURI),
   348  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeStore/accounts/{accountName}/enableKeyVault", pathParameters),
   349  		autorest.WithQueryParameters(queryParameters))
   350  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   351  }
   352  
   353  // EnableKeyVaultSender sends the EnableKeyVault request. The method will close the
   354  // http.Response Body if it receives an error.
   355  func (client AccountsClient) EnableKeyVaultSender(req *http.Request) (*http.Response, error) {
   356  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   357  }
   358  
   359  // EnableKeyVaultResponder handles the response to the EnableKeyVault request. The method always
   360  // closes the http.Response Body.
   361  func (client AccountsClient) EnableKeyVaultResponder(resp *http.Response) (result autorest.Response, err error) {
   362  	err = autorest.Respond(
   363  		resp,
   364  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   365  		autorest.ByClosing())
   366  	result.Response = resp
   367  	return
   368  }
   369  
   370  // Get gets the specified Data Lake Store account.
   371  // Parameters:
   372  // resourceGroupName - the name of the Azure resource group.
   373  // accountName - the name of the Data Lake Store account.
   374  func (client AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result DataLakeStoreAccount, err error) {
   375  	if tracing.IsEnabled() {
   376  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Get")
   377  		defer func() {
   378  			sc := -1
   379  			if result.Response.Response != nil {
   380  				sc = result.Response.Response.StatusCode
   381  			}
   382  			tracing.EndSpan(ctx, sc, err)
   383  		}()
   384  	}
   385  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName)
   386  	if err != nil {
   387  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Get", nil, "Failure preparing request")
   388  		return
   389  	}
   390  
   391  	resp, err := client.GetSender(req)
   392  	if err != nil {
   393  		result.Response = autorest.Response{Response: resp}
   394  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Get", resp, "Failure sending request")
   395  		return
   396  	}
   397  
   398  	result, err = client.GetResponder(resp)
   399  	if err != nil {
   400  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Get", resp, "Failure responding to request")
   401  		return
   402  	}
   403  
   404  	return
   405  }
   406  
   407  // GetPreparer prepares the Get request.
   408  func (client AccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   409  	pathParameters := map[string]interface{}{
   410  		"accountName":       autorest.Encode("path", accountName),
   411  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   412  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   413  	}
   414  
   415  	const APIVersion = "2016-11-01"
   416  	queryParameters := map[string]interface{}{
   417  		"api-version": APIVersion,
   418  	}
   419  
   420  	preparer := autorest.CreatePreparer(
   421  		autorest.AsGet(),
   422  		autorest.WithBaseURL(client.BaseURI),
   423  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeStore/accounts/{accountName}", pathParameters),
   424  		autorest.WithQueryParameters(queryParameters))
   425  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   426  }
   427  
   428  // GetSender sends the Get request. The method will close the
   429  // http.Response Body if it receives an error.
   430  func (client AccountsClient) GetSender(req *http.Request) (*http.Response, error) {
   431  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   432  }
   433  
   434  // GetResponder handles the response to the Get request. The method always
   435  // closes the http.Response Body.
   436  func (client AccountsClient) GetResponder(resp *http.Response) (result DataLakeStoreAccount, err error) {
   437  	err = autorest.Respond(
   438  		resp,
   439  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   440  		autorest.ByUnmarshallingJSON(&result),
   441  		autorest.ByClosing())
   442  	result.Response = autorest.Response{Response: resp}
   443  	return
   444  }
   445  
   446  // List lists the Data Lake Store accounts within the subscription. The response includes a link to the next page of
   447  // results, if any.
   448  // Parameters:
   449  // filter - oData filter. Optional.
   450  // top - the number of items to return. Optional.
   451  // skip - the number of items to skip over before returning elements. Optional.
   452  // selectParameter - oData Select statement. Limits the properties on each entry to just those requested, e.g.
   453  // Categories?$select=CategoryName,Description. Optional.
   454  // orderby - orderBy clause. One or more comma-separated expressions with an optional "asc" (the default) or
   455  // "desc" depending on the order you'd like the values sorted, e.g. Categories?$orderby=CategoryName desc.
   456  // Optional.
   457  // count - the Boolean value of true or false to request a count of the matching resources included with the
   458  // resources in the response, e.g. Categories?$count=true. Optional.
   459  func (client AccountsClient) List(ctx context.Context, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeStoreAccountListResultPage, err error) {
   460  	if tracing.IsEnabled() {
   461  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List")
   462  		defer func() {
   463  			sc := -1
   464  			if result.dlsalr.Response.Response != nil {
   465  				sc = result.dlsalr.Response.Response.StatusCode
   466  			}
   467  			tracing.EndSpan(ctx, sc, err)
   468  		}()
   469  	}
   470  	if err := validation.Validate([]validation.Validation{
   471  		{TargetValue: top,
   472  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   473  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
   474  		{TargetValue: skip,
   475  			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
   476  				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
   477  		return result, validation.NewError("account.AccountsClient", "List", err.Error())
   478  	}
   479  
   480  	result.fn = client.listNextResults
   481  	req, err := client.ListPreparer(ctx, filter, top, skip, selectParameter, orderby, count)
   482  	if err != nil {
   483  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "List", nil, "Failure preparing request")
   484  		return
   485  	}
   486  
   487  	resp, err := client.ListSender(req)
   488  	if err != nil {
   489  		result.dlsalr.Response = autorest.Response{Response: resp}
   490  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "List", resp, "Failure sending request")
   491  		return
   492  	}
   493  
   494  	result.dlsalr, err = client.ListResponder(resp)
   495  	if err != nil {
   496  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "List", resp, "Failure responding to request")
   497  		return
   498  	}
   499  	if result.dlsalr.hasNextLink() && result.dlsalr.IsEmpty() {
   500  		err = result.NextWithContext(ctx)
   501  		return
   502  	}
   503  
   504  	return
   505  }
   506  
   507  // ListPreparer prepares the List request.
   508  func (client AccountsClient) ListPreparer(ctx context.Context, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (*http.Request, error) {
   509  	pathParameters := map[string]interface{}{
   510  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   511  	}
   512  
   513  	const APIVersion = "2016-11-01"
   514  	queryParameters := map[string]interface{}{
   515  		"api-version": APIVersion,
   516  	}
   517  	if len(filter) > 0 {
   518  		queryParameters["$filter"] = autorest.Encode("query", filter)
   519  	}
   520  	if top != nil {
   521  		queryParameters["$top"] = autorest.Encode("query", *top)
   522  	}
   523  	if skip != nil {
   524  		queryParameters["$skip"] = autorest.Encode("query", *skip)
   525  	}
   526  	if len(selectParameter) > 0 {
   527  		queryParameters["$select"] = autorest.Encode("query", selectParameter)
   528  	}
   529  	if len(orderby) > 0 {
   530  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   531  	}
   532  	if count != nil {
   533  		queryParameters["$count"] = autorest.Encode("query", *count)
   534  	}
   535  
   536  	preparer := autorest.CreatePreparer(
   537  		autorest.AsGet(),
   538  		autorest.WithBaseURL(client.BaseURI),
   539  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DataLakeStore/accounts", pathParameters),
   540  		autorest.WithQueryParameters(queryParameters))
   541  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   542  }
   543  
   544  // ListSender sends the List request. The method will close the
   545  // http.Response Body if it receives an error.
   546  func (client AccountsClient) ListSender(req *http.Request) (*http.Response, error) {
   547  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   548  }
   549  
   550  // ListResponder handles the response to the List request. The method always
   551  // closes the http.Response Body.
   552  func (client AccountsClient) ListResponder(resp *http.Response) (result DataLakeStoreAccountListResult, err error) {
   553  	err = autorest.Respond(
   554  		resp,
   555  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   556  		autorest.ByUnmarshallingJSON(&result),
   557  		autorest.ByClosing())
   558  	result.Response = autorest.Response{Response: resp}
   559  	return
   560  }
   561  
   562  // listNextResults retrieves the next set of results, if any.
   563  func (client AccountsClient) listNextResults(ctx context.Context, lastResults DataLakeStoreAccountListResult) (result DataLakeStoreAccountListResult, err error) {
   564  	req, err := lastResults.dataLakeStoreAccountListResultPreparer(ctx)
   565  	if err != nil {
   566  		return result, autorest.NewErrorWithError(err, "account.AccountsClient", "listNextResults", nil, "Failure preparing next results request")
   567  	}
   568  	if req == nil {
   569  		return
   570  	}
   571  	resp, err := client.ListSender(req)
   572  	if err != nil {
   573  		result.Response = autorest.Response{Response: resp}
   574  		return result, autorest.NewErrorWithError(err, "account.AccountsClient", "listNextResults", resp, "Failure sending next results request")
   575  	}
   576  	result, err = client.ListResponder(resp)
   577  	if err != nil {
   578  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "listNextResults", resp, "Failure responding to next results request")
   579  	}
   580  	return
   581  }
   582  
   583  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   584  func (client AccountsClient) ListComplete(ctx context.Context, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeStoreAccountListResultIterator, err error) {
   585  	if tracing.IsEnabled() {
   586  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List")
   587  		defer func() {
   588  			sc := -1
   589  			if result.Response().Response.Response != nil {
   590  				sc = result.page.Response().Response.Response.StatusCode
   591  			}
   592  			tracing.EndSpan(ctx, sc, err)
   593  		}()
   594  	}
   595  	result.page, err = client.List(ctx, filter, top, skip, selectParameter, orderby, count)
   596  	return
   597  }
   598  
   599  // ListByResourceGroup lists the Data Lake Store accounts within a specific resource group. The response includes a
   600  // link to the next page of results, if any.
   601  // Parameters:
   602  // resourceGroupName - the name of the Azure resource group.
   603  // filter - oData filter. Optional.
   604  // top - the number of items to return. Optional.
   605  // skip - the number of items to skip over before returning elements. Optional.
   606  // selectParameter - oData Select statement. Limits the properties on each entry to just those requested, e.g.
   607  // Categories?$select=CategoryName,Description. Optional.
   608  // orderby - orderBy clause. One or more comma-separated expressions with an optional "asc" (the default) or
   609  // "desc" depending on the order you'd like the values sorted, e.g. Categories?$orderby=CategoryName desc.
   610  // Optional.
   611  // count - a Boolean value of true or false to request a count of the matching resources included with the
   612  // resources in the response, e.g. Categories?$count=true. Optional.
   613  func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeStoreAccountListResultPage, err error) {
   614  	if tracing.IsEnabled() {
   615  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup")
   616  		defer func() {
   617  			sc := -1
   618  			if result.dlsalr.Response.Response != nil {
   619  				sc = result.dlsalr.Response.Response.StatusCode
   620  			}
   621  			tracing.EndSpan(ctx, sc, err)
   622  		}()
   623  	}
   624  	if err := validation.Validate([]validation.Validation{
   625  		{TargetValue: top,
   626  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   627  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
   628  		{TargetValue: skip,
   629  			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
   630  				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
   631  		return result, validation.NewError("account.AccountsClient", "ListByResourceGroup", err.Error())
   632  	}
   633  
   634  	result.fn = client.listByResourceGroupNextResults
   635  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, top, skip, selectParameter, orderby, count)
   636  	if err != nil {
   637  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request")
   638  		return
   639  	}
   640  
   641  	resp, err := client.ListByResourceGroupSender(req)
   642  	if err != nil {
   643  		result.dlsalr.Response = autorest.Response{Response: resp}
   644  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "ListByResourceGroup", resp, "Failure sending request")
   645  		return
   646  	}
   647  
   648  	result.dlsalr, err = client.ListByResourceGroupResponder(resp)
   649  	if err != nil {
   650  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request")
   651  		return
   652  	}
   653  	if result.dlsalr.hasNextLink() && result.dlsalr.IsEmpty() {
   654  		err = result.NextWithContext(ctx)
   655  		return
   656  	}
   657  
   658  	return
   659  }
   660  
   661  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   662  func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (*http.Request, error) {
   663  	pathParameters := map[string]interface{}{
   664  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   665  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   666  	}
   667  
   668  	const APIVersion = "2016-11-01"
   669  	queryParameters := map[string]interface{}{
   670  		"api-version": APIVersion,
   671  	}
   672  	if len(filter) > 0 {
   673  		queryParameters["$filter"] = autorest.Encode("query", filter)
   674  	}
   675  	if top != nil {
   676  		queryParameters["$top"] = autorest.Encode("query", *top)
   677  	}
   678  	if skip != nil {
   679  		queryParameters["$skip"] = autorest.Encode("query", *skip)
   680  	}
   681  	if len(selectParameter) > 0 {
   682  		queryParameters["$select"] = autorest.Encode("query", selectParameter)
   683  	}
   684  	if len(orderby) > 0 {
   685  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   686  	}
   687  	if count != nil {
   688  		queryParameters["$count"] = autorest.Encode("query", *count)
   689  	}
   690  
   691  	preparer := autorest.CreatePreparer(
   692  		autorest.AsGet(),
   693  		autorest.WithBaseURL(client.BaseURI),
   694  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeStore/accounts", pathParameters),
   695  		autorest.WithQueryParameters(queryParameters))
   696  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   697  }
   698  
   699  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   700  // http.Response Body if it receives an error.
   701  func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   702  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   703  }
   704  
   705  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   706  // closes the http.Response Body.
   707  func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result DataLakeStoreAccountListResult, err error) {
   708  	err = autorest.Respond(
   709  		resp,
   710  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   711  		autorest.ByUnmarshallingJSON(&result),
   712  		autorest.ByClosing())
   713  	result.Response = autorest.Response{Response: resp}
   714  	return
   715  }
   716  
   717  // listByResourceGroupNextResults retrieves the next set of results, if any.
   718  func (client AccountsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DataLakeStoreAccountListResult) (result DataLakeStoreAccountListResult, err error) {
   719  	req, err := lastResults.dataLakeStoreAccountListResultPreparer(ctx)
   720  	if err != nil {
   721  		return result, autorest.NewErrorWithError(err, "account.AccountsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   722  	}
   723  	if req == nil {
   724  		return
   725  	}
   726  	resp, err := client.ListByResourceGroupSender(req)
   727  	if err != nil {
   728  		result.Response = autorest.Response{Response: resp}
   729  		return result, autorest.NewErrorWithError(err, "account.AccountsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   730  	}
   731  	result, err = client.ListByResourceGroupResponder(resp)
   732  	if err != nil {
   733  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   734  	}
   735  	return
   736  }
   737  
   738  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   739  func (client AccountsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeStoreAccountListResultIterator, err error) {
   740  	if tracing.IsEnabled() {
   741  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup")
   742  		defer func() {
   743  			sc := -1
   744  			if result.Response().Response.Response != nil {
   745  				sc = result.page.Response().Response.Response.StatusCode
   746  			}
   747  			tracing.EndSpan(ctx, sc, err)
   748  		}()
   749  	}
   750  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, top, skip, selectParameter, orderby, count)
   751  	return
   752  }
   753  
   754  // Update updates the specified Data Lake Store account information.
   755  // Parameters:
   756  // resourceGroupName - the name of the Azure resource group.
   757  // accountName - the name of the Data Lake Store account.
   758  // parameters - parameters supplied to update the Data Lake Store account.
   759  func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters UpdateDataLakeStoreAccountParameters) (result AccountsUpdateFutureType, err error) {
   760  	if tracing.IsEnabled() {
   761  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update")
   762  		defer func() {
   763  			sc := -1
   764  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   765  				sc = result.FutureAPI.Response().StatusCode
   766  			}
   767  			tracing.EndSpan(ctx, sc, err)
   768  		}()
   769  	}
   770  	req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, parameters)
   771  	if err != nil {
   772  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Update", nil, "Failure preparing request")
   773  		return
   774  	}
   775  
   776  	result, err = client.UpdateSender(req)
   777  	if err != nil {
   778  		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Update", result.Response(), "Failure sending request")
   779  		return
   780  	}
   781  
   782  	return
   783  }
   784  
   785  // UpdatePreparer prepares the Update request.
   786  func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters UpdateDataLakeStoreAccountParameters) (*http.Request, error) {
   787  	pathParameters := map[string]interface{}{
   788  		"accountName":       autorest.Encode("path", accountName),
   789  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   790  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   791  	}
   792  
   793  	const APIVersion = "2016-11-01"
   794  	queryParameters := map[string]interface{}{
   795  		"api-version": APIVersion,
   796  	}
   797  
   798  	preparer := autorest.CreatePreparer(
   799  		autorest.AsContentType("application/json; charset=utf-8"),
   800  		autorest.AsPatch(),
   801  		autorest.WithBaseURL(client.BaseURI),
   802  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeStore/accounts/{accountName}", pathParameters),
   803  		autorest.WithJSON(parameters),
   804  		autorest.WithQueryParameters(queryParameters))
   805  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   806  }
   807  
   808  // UpdateSender sends the Update request. The method will close the
   809  // http.Response Body if it receives an error.
   810  func (client AccountsClient) UpdateSender(req *http.Request) (future AccountsUpdateFutureType, err error) {
   811  	var resp *http.Response
   812  	future.FutureAPI = &azure.Future{}
   813  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   814  	if err != nil {
   815  		return
   816  	}
   817  	var azf azure.Future
   818  	azf, err = azure.NewFutureFromResponse(resp)
   819  	future.FutureAPI = &azf
   820  	future.Result = future.result
   821  	return
   822  }
   823  
   824  // UpdateResponder handles the response to the Update request. The method always
   825  // closes the http.Response Body.
   826  func (client AccountsClient) UpdateResponder(resp *http.Response) (result DataLakeStoreAccount, err error) {
   827  	err = autorest.Respond(
   828  		resp,
   829  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
   830  		autorest.ByUnmarshallingJSON(&result),
   831  		autorest.ByClosing())
   832  	result.Response = autorest.Response{Response: resp}
   833  	return
   834  }
   835  

View as plain text