...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/datalake/analytics/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  // DataLakeStoreAccountsClient is the creates an Azure Data Lake Analytics account management client.
    19  type DataLakeStoreAccountsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewDataLakeStoreAccountsClient creates an instance of the DataLakeStoreAccountsClient client.
    24  func NewDataLakeStoreAccountsClient(subscriptionID string) DataLakeStoreAccountsClient {
    25  	return NewDataLakeStoreAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewDataLakeStoreAccountsClientWithBaseURI creates an instance of the DataLakeStoreAccountsClient 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 NewDataLakeStoreAccountsClientWithBaseURI(baseURI string, subscriptionID string) DataLakeStoreAccountsClient {
    32  	return DataLakeStoreAccountsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Add updates the specified Data Lake Analytics account to include the additional Data Lake Store account.
    36  // Parameters:
    37  // resourceGroupName - the name of the Azure resource group.
    38  // accountName - the name of the Data Lake Analytics account.
    39  // dataLakeStoreAccountName - the name of the Data Lake Store account to add.
    40  // parameters - the details of the Data Lake Store account.
    41  func (client DataLakeStoreAccountsClient) Add(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string, parameters *AddDataLakeStoreParameters) (result autorest.Response, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.Add")
    44  		defer func() {
    45  			sc := -1
    46  			if result.Response != nil {
    47  				sc = result.Response.StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	req, err := client.AddPreparer(ctx, resourceGroupName, accountName, dataLakeStoreAccountName, parameters)
    53  	if err != nil {
    54  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", nil, "Failure preparing request")
    55  		return
    56  	}
    57  
    58  	resp, err := client.AddSender(req)
    59  	if err != nil {
    60  		result.Response = resp
    61  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", resp, "Failure sending request")
    62  		return
    63  	}
    64  
    65  	result, err = client.AddResponder(resp)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", resp, "Failure responding to request")
    68  		return
    69  	}
    70  
    71  	return
    72  }
    73  
    74  // AddPreparer prepares the Add request.
    75  func (client DataLakeStoreAccountsClient) AddPreparer(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string, parameters *AddDataLakeStoreParameters) (*http.Request, error) {
    76  	pathParameters := map[string]interface{}{
    77  		"accountName":              autorest.Encode("path", accountName),
    78  		"dataLakeStoreAccountName": autorest.Encode("path", dataLakeStoreAccountName),
    79  		"resourceGroupName":        autorest.Encode("path", resourceGroupName),
    80  		"subscriptionId":           autorest.Encode("path", client.SubscriptionID),
    81  	}
    82  
    83  	const APIVersion = "2016-11-01"
    84  	queryParameters := map[string]interface{}{
    85  		"api-version": APIVersion,
    86  	}
    87  
    88  	preparer := autorest.CreatePreparer(
    89  		autorest.AsContentType("application/json; charset=utf-8"),
    90  		autorest.AsPut(),
    91  		autorest.WithBaseURL(client.BaseURI),
    92  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}/dataLakeStoreAccounts/{dataLakeStoreAccountName}", pathParameters),
    93  		autorest.WithQueryParameters(queryParameters))
    94  	if parameters != nil {
    95  		preparer = autorest.DecoratePreparer(preparer,
    96  			autorest.WithJSON(parameters))
    97  	}
    98  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    99  }
   100  
   101  // AddSender sends the Add request. The method will close the
   102  // http.Response Body if it receives an error.
   103  func (client DataLakeStoreAccountsClient) AddSender(req *http.Request) (*http.Response, error) {
   104  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   105  }
   106  
   107  // AddResponder handles the response to the Add request. The method always
   108  // closes the http.Response Body.
   109  func (client DataLakeStoreAccountsClient) AddResponder(resp *http.Response) (result autorest.Response, err error) {
   110  	err = autorest.Respond(
   111  		resp,
   112  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   113  		autorest.ByClosing())
   114  	result.Response = resp
   115  	return
   116  }
   117  
   118  // Delete updates the Data Lake Analytics account specified to remove 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 Analytics account.
   122  // dataLakeStoreAccountName - the name of the Data Lake Store account to remove
   123  func (client DataLakeStoreAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string) (result autorest.Response, err error) {
   124  	if tracing.IsEnabled() {
   125  		ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.Delete")
   126  		defer func() {
   127  			sc := -1
   128  			if result.Response != nil {
   129  				sc = result.Response.StatusCode
   130  			}
   131  			tracing.EndSpan(ctx, sc, err)
   132  		}()
   133  	}
   134  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, dataLakeStoreAccountName)
   135  	if err != nil {
   136  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", nil, "Failure preparing request")
   137  		return
   138  	}
   139  
   140  	resp, err := client.DeleteSender(req)
   141  	if err != nil {
   142  		result.Response = resp
   143  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", resp, "Failure sending request")
   144  		return
   145  	}
   146  
   147  	result, err = client.DeleteResponder(resp)
   148  	if err != nil {
   149  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", resp, "Failure responding to request")
   150  		return
   151  	}
   152  
   153  	return
   154  }
   155  
   156  // DeletePreparer prepares the Delete request.
   157  func (client DataLakeStoreAccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string) (*http.Request, error) {
   158  	pathParameters := map[string]interface{}{
   159  		"accountName":              autorest.Encode("path", accountName),
   160  		"dataLakeStoreAccountName": autorest.Encode("path", dataLakeStoreAccountName),
   161  		"resourceGroupName":        autorest.Encode("path", resourceGroupName),
   162  		"subscriptionId":           autorest.Encode("path", client.SubscriptionID),
   163  	}
   164  
   165  	const APIVersion = "2016-11-01"
   166  	queryParameters := map[string]interface{}{
   167  		"api-version": APIVersion,
   168  	}
   169  
   170  	preparer := autorest.CreatePreparer(
   171  		autorest.AsDelete(),
   172  		autorest.WithBaseURL(client.BaseURI),
   173  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}/dataLakeStoreAccounts/{dataLakeStoreAccountName}", pathParameters),
   174  		autorest.WithQueryParameters(queryParameters))
   175  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   176  }
   177  
   178  // DeleteSender sends the Delete request. The method will close the
   179  // http.Response Body if it receives an error.
   180  func (client DataLakeStoreAccountsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   181  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   182  }
   183  
   184  // DeleteResponder handles the response to the Delete request. The method always
   185  // closes the http.Response Body.
   186  func (client DataLakeStoreAccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   187  	err = autorest.Respond(
   188  		resp,
   189  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   190  		autorest.ByClosing())
   191  	result.Response = resp
   192  	return
   193  }
   194  
   195  // Get gets the specified Data Lake Store account details in the specified Data Lake Analytics account.
   196  // Parameters:
   197  // resourceGroupName - the name of the Azure resource group.
   198  // accountName - the name of the Data Lake Analytics account.
   199  // dataLakeStoreAccountName - the name of the Data Lake Store account to retrieve
   200  func (client DataLakeStoreAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string) (result DataLakeStoreAccountInformation, err error) {
   201  	if tracing.IsEnabled() {
   202  		ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.Get")
   203  		defer func() {
   204  			sc := -1
   205  			if result.Response.Response != nil {
   206  				sc = result.Response.Response.StatusCode
   207  			}
   208  			tracing.EndSpan(ctx, sc, err)
   209  		}()
   210  	}
   211  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, dataLakeStoreAccountName)
   212  	if err != nil {
   213  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", nil, "Failure preparing request")
   214  		return
   215  	}
   216  
   217  	resp, err := client.GetSender(req)
   218  	if err != nil {
   219  		result.Response = autorest.Response{Response: resp}
   220  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", resp, "Failure sending request")
   221  		return
   222  	}
   223  
   224  	result, err = client.GetResponder(resp)
   225  	if err != nil {
   226  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", resp, "Failure responding to request")
   227  		return
   228  	}
   229  
   230  	return
   231  }
   232  
   233  // GetPreparer prepares the Get request.
   234  func (client DataLakeStoreAccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string) (*http.Request, error) {
   235  	pathParameters := map[string]interface{}{
   236  		"accountName":              autorest.Encode("path", accountName),
   237  		"dataLakeStoreAccountName": autorest.Encode("path", dataLakeStoreAccountName),
   238  		"resourceGroupName":        autorest.Encode("path", resourceGroupName),
   239  		"subscriptionId":           autorest.Encode("path", client.SubscriptionID),
   240  	}
   241  
   242  	const APIVersion = "2016-11-01"
   243  	queryParameters := map[string]interface{}{
   244  		"api-version": APIVersion,
   245  	}
   246  
   247  	preparer := autorest.CreatePreparer(
   248  		autorest.AsGet(),
   249  		autorest.WithBaseURL(client.BaseURI),
   250  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}/dataLakeStoreAccounts/{dataLakeStoreAccountName}", pathParameters),
   251  		autorest.WithQueryParameters(queryParameters))
   252  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   253  }
   254  
   255  // GetSender sends the Get request. The method will close the
   256  // http.Response Body if it receives an error.
   257  func (client DataLakeStoreAccountsClient) GetSender(req *http.Request) (*http.Response, error) {
   258  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   259  }
   260  
   261  // GetResponder handles the response to the Get request. The method always
   262  // closes the http.Response Body.
   263  func (client DataLakeStoreAccountsClient) GetResponder(resp *http.Response) (result DataLakeStoreAccountInformation, err error) {
   264  	err = autorest.Respond(
   265  		resp,
   266  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   267  		autorest.ByUnmarshallingJSON(&result),
   268  		autorest.ByClosing())
   269  	result.Response = autorest.Response{Response: resp}
   270  	return
   271  }
   272  
   273  // ListByAccount gets the first page of Data Lake Store accounts linked to the specified Data Lake Analytics account.
   274  // The response includes a link to the next page, if any.
   275  // Parameters:
   276  // resourceGroupName - the name of the Azure resource group.
   277  // accountName - the name of the Data Lake Analytics account.
   278  // filter - oData filter. Optional.
   279  // top - the number of items to return. Optional.
   280  // skip - the number of items to skip over before returning elements. Optional.
   281  // selectParameter - oData Select statement. Limits the properties on each entry to just those requested, e.g.
   282  // Categories?$select=CategoryName,Description. Optional.
   283  // orderby - orderBy clause. One or more comma-separated expressions with an optional "asc" (the default) or
   284  // "desc" depending on the order you'd like the values sorted, e.g. Categories?$orderby=CategoryName desc.
   285  // Optional.
   286  // count - the Boolean value of true or false to request a count of the matching resources included with the
   287  // resources in the response, e.g. Categories?$count=true. Optional.
   288  func (client DataLakeStoreAccountsClient) ListByAccount(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeStoreAccountInformationListResultPage, err error) {
   289  	if tracing.IsEnabled() {
   290  		ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.ListByAccount")
   291  		defer func() {
   292  			sc := -1
   293  			if result.dlsailr.Response.Response != nil {
   294  				sc = result.dlsailr.Response.Response.StatusCode
   295  			}
   296  			tracing.EndSpan(ctx, sc, err)
   297  		}()
   298  	}
   299  	if err := validation.Validate([]validation.Validation{
   300  		{TargetValue: top,
   301  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   302  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
   303  		{TargetValue: skip,
   304  			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
   305  				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
   306  		return result, validation.NewError("account.DataLakeStoreAccountsClient", "ListByAccount", err.Error())
   307  	}
   308  
   309  	result.fn = client.listByAccountNextResults
   310  	req, err := client.ListByAccountPreparer(ctx, resourceGroupName, accountName, filter, top, skip, selectParameter, orderby, count)
   311  	if err != nil {
   312  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", nil, "Failure preparing request")
   313  		return
   314  	}
   315  
   316  	resp, err := client.ListByAccountSender(req)
   317  	if err != nil {
   318  		result.dlsailr.Response = autorest.Response{Response: resp}
   319  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", resp, "Failure sending request")
   320  		return
   321  	}
   322  
   323  	result.dlsailr, err = client.ListByAccountResponder(resp)
   324  	if err != nil {
   325  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", resp, "Failure responding to request")
   326  		return
   327  	}
   328  	if result.dlsailr.hasNextLink() && result.dlsailr.IsEmpty() {
   329  		err = result.NextWithContext(ctx)
   330  		return
   331  	}
   332  
   333  	return
   334  }
   335  
   336  // ListByAccountPreparer prepares the ListByAccount request.
   337  func (client DataLakeStoreAccountsClient) ListByAccountPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (*http.Request, error) {
   338  	pathParameters := map[string]interface{}{
   339  		"accountName":       autorest.Encode("path", accountName),
   340  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   341  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   342  	}
   343  
   344  	const APIVersion = "2016-11-01"
   345  	queryParameters := map[string]interface{}{
   346  		"api-version": APIVersion,
   347  	}
   348  	if len(filter) > 0 {
   349  		queryParameters["$filter"] = autorest.Encode("query", filter)
   350  	}
   351  	if top != nil {
   352  		queryParameters["$top"] = autorest.Encode("query", *top)
   353  	}
   354  	if skip != nil {
   355  		queryParameters["$skip"] = autorest.Encode("query", *skip)
   356  	}
   357  	if len(selectParameter) > 0 {
   358  		queryParameters["$select"] = autorest.Encode("query", selectParameter)
   359  	}
   360  	if len(orderby) > 0 {
   361  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   362  	}
   363  	if count != nil {
   364  		queryParameters["$count"] = autorest.Encode("query", *count)
   365  	}
   366  
   367  	preparer := autorest.CreatePreparer(
   368  		autorest.AsGet(),
   369  		autorest.WithBaseURL(client.BaseURI),
   370  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}/dataLakeStoreAccounts", pathParameters),
   371  		autorest.WithQueryParameters(queryParameters))
   372  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   373  }
   374  
   375  // ListByAccountSender sends the ListByAccount request. The method will close the
   376  // http.Response Body if it receives an error.
   377  func (client DataLakeStoreAccountsClient) ListByAccountSender(req *http.Request) (*http.Response, error) {
   378  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   379  }
   380  
   381  // ListByAccountResponder handles the response to the ListByAccount request. The method always
   382  // closes the http.Response Body.
   383  func (client DataLakeStoreAccountsClient) ListByAccountResponder(resp *http.Response) (result DataLakeStoreAccountInformationListResult, err error) {
   384  	err = autorest.Respond(
   385  		resp,
   386  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   387  		autorest.ByUnmarshallingJSON(&result),
   388  		autorest.ByClosing())
   389  	result.Response = autorest.Response{Response: resp}
   390  	return
   391  }
   392  
   393  // listByAccountNextResults retrieves the next set of results, if any.
   394  func (client DataLakeStoreAccountsClient) listByAccountNextResults(ctx context.Context, lastResults DataLakeStoreAccountInformationListResult) (result DataLakeStoreAccountInformationListResult, err error) {
   395  	req, err := lastResults.dataLakeStoreAccountInformationListResultPreparer(ctx)
   396  	if err != nil {
   397  		return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "listByAccountNextResults", nil, "Failure preparing next results request")
   398  	}
   399  	if req == nil {
   400  		return
   401  	}
   402  	resp, err := client.ListByAccountSender(req)
   403  	if err != nil {
   404  		result.Response = autorest.Response{Response: resp}
   405  		return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "listByAccountNextResults", resp, "Failure sending next results request")
   406  	}
   407  	result, err = client.ListByAccountResponder(resp)
   408  	if err != nil {
   409  		err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "listByAccountNextResults", resp, "Failure responding to next results request")
   410  	}
   411  	return
   412  }
   413  
   414  // ListByAccountComplete enumerates all values, automatically crossing page boundaries as required.
   415  func (client DataLakeStoreAccountsClient) ListByAccountComplete(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeStoreAccountInformationListResultIterator, err error) {
   416  	if tracing.IsEnabled() {
   417  		ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.ListByAccount")
   418  		defer func() {
   419  			sc := -1
   420  			if result.Response().Response.Response != nil {
   421  				sc = result.page.Response().Response.Response.StatusCode
   422  			}
   423  			tracing.EndSpan(ctx, sc, err)
   424  		}()
   425  	}
   426  	result.page, err = client.ListByAccount(ctx, resourceGroupName, accountName, filter, top, skip, selectParameter, orderby, count)
   427  	return
   428  }
   429  

View as plain text