...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/storage/datalake/2018-06-17/storagedatalake/filesystem.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/storage/datalake/2018-06-17/storagedatalake

     1  package storagedatalake
     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  // FilesystemClient is the azure Data Lake Storage provides storage for Hadoop and other big data workloads.
    19  type FilesystemClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewFilesystemClient creates an instance of the FilesystemClient client.
    24  func NewFilesystemClient(xMsVersion string, accountName string) FilesystemClient {
    25  	return FilesystemClient{New(xMsVersion, accountName)}
    26  }
    27  
    28  // Create create a filesystem rooted at the specified location. If the filesystem already exists, the operation fails.
    29  // This operation does not support conditional HTTP requests.
    30  // Parameters:
    31  // filesystem - the filesystem identifier.  The value must start and end with a letter or number and must
    32  // contain only letters, numbers, and the dash (-) character.  Consecutive dashes are not permitted.  All
    33  // letters must be lowercase.  The value must have between 3 and 63 characters.
    34  // xMsProperties - user-defined properties to be stored with the filesystem, in the format of a comma-separated
    35  // list of name and value pairs "n1=v1, n2=v2, ...", where each value is base64 encoded.
    36  // xMsClientRequestID - a UUID recorded in the analytics logs for troubleshooting and correlation.
    37  // timeout - an optional operation timeout value in seconds. The period begins when the request is received by
    38  // the service. If the timeout value elapses before the operation completes, the operation fails.
    39  // xMsDate - specifies the Coordinated Universal Time (UTC) for the request.  This is required when using
    40  // shared key authorization.
    41  func (client FilesystemClient) Create(ctx context.Context, filesystem string, xMsProperties string, xMsClientRequestID string, timeout *int32, xMsDate string) (result autorest.Response, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/FilesystemClient.Create")
    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  	if err := validation.Validate([]validation.Validation{
    53  		{TargetValue: xMsClientRequestID,
    54  			Constraints: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Empty, Rule: false,
    55  				Chain: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Pattern, Rule: `^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$`, Chain: nil}}}}},
    56  		{TargetValue: timeout,
    57  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
    58  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
    59  		return result, validation.NewError("storagedatalake.FilesystemClient", "Create", err.Error())
    60  	}
    61  
    62  	req, err := client.CreatePreparer(ctx, filesystem, xMsProperties, xMsClientRequestID, timeout, xMsDate)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "Create", nil, "Failure preparing request")
    65  		return
    66  	}
    67  
    68  	resp, err := client.CreateSender(req)
    69  	if err != nil {
    70  		result.Response = resp
    71  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "Create", resp, "Failure sending request")
    72  		return
    73  	}
    74  
    75  	result, err = client.CreateResponder(resp)
    76  	if err != nil {
    77  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "Create", resp, "Failure responding to request")
    78  		return
    79  	}
    80  
    81  	return
    82  }
    83  
    84  // CreatePreparer prepares the Create request.
    85  func (client FilesystemClient) CreatePreparer(ctx context.Context, filesystem string, xMsProperties string, xMsClientRequestID string, timeout *int32, xMsDate string) (*http.Request, error) {
    86  	urlParameters := map[string]interface{}{
    87  		"accountName": client.AccountName,
    88  		"dnsSuffix":   client.DNSSuffix,
    89  	}
    90  
    91  	pathParameters := map[string]interface{}{
    92  		"filesystem": autorest.Encode("path", filesystem),
    93  	}
    94  
    95  	queryParameters := map[string]interface{}{
    96  		"resource": autorest.Encode("query", "filesystem"),
    97  	}
    98  	if timeout != nil {
    99  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   100  	}
   101  
   102  	preparer := autorest.CreatePreparer(
   103  		autorest.AsPut(),
   104  		autorest.WithCustomBaseURL("https://{accountName}.{dnsSuffix}", urlParameters),
   105  		autorest.WithPathParameters("/{filesystem}", pathParameters),
   106  		autorest.WithQueryParameters(queryParameters))
   107  	if len(xMsProperties) > 0 {
   108  		preparer = autorest.DecoratePreparer(preparer,
   109  			autorest.WithHeader("x-ms-properties", autorest.String(xMsProperties)))
   110  	}
   111  	if len(xMsClientRequestID) > 0 {
   112  		preparer = autorest.DecoratePreparer(preparer,
   113  			autorest.WithHeader("x-ms-client-request-id", autorest.String(xMsClientRequestID)))
   114  	}
   115  	if len(xMsDate) > 0 {
   116  		preparer = autorest.DecoratePreparer(preparer,
   117  			autorest.WithHeader("x-ms-date", autorest.String(xMsDate)))
   118  	}
   119  	if len(client.XMsVersion) > 0 {
   120  		preparer = autorest.DecoratePreparer(preparer,
   121  			autorest.WithHeader("x-ms-version", autorest.String(client.XMsVersion)))
   122  	}
   123  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   124  }
   125  
   126  // CreateSender sends the Create request. The method will close the
   127  // http.Response Body if it receives an error.
   128  func (client FilesystemClient) CreateSender(req *http.Request) (*http.Response, error) {
   129  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   130  }
   131  
   132  // CreateResponder handles the response to the Create request. The method always
   133  // closes the http.Response Body.
   134  func (client FilesystemClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) {
   135  	err = autorest.Respond(
   136  		resp,
   137  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   138  		autorest.ByClosing())
   139  	result.Response = resp
   140  	return
   141  }
   142  
   143  // Delete marks the filesystem for deletion.  When a filesystem is deleted, a filesystem with the same identifier
   144  // cannot be created for at least 30 seconds. While the filesystem is being deleted, attempts to create a filesystem
   145  // with the same identifier will fail with status code 409 (Conflict), with the service returning additional error
   146  // information indicating that the filesystem is being deleted. All other operations, including operations on any files
   147  // or directories within the filesystem, will fail with status code 404 (Not Found) while the filesystem is being
   148  // deleted. This operation supports conditional HTTP requests.  For more information, see [Specifying Conditional
   149  // Headers for Blob Service
   150  // Operations](https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations).
   151  // Parameters:
   152  // filesystem - the filesystem identifier.  The value must start and end with a letter or number and must
   153  // contain only letters, numbers, and the dash (-) character.  Consecutive dashes are not permitted.  All
   154  // letters must be lowercase.  The value must have between 3 and 63 characters.
   155  // ifModifiedSince - optional. A date and time value. Specify this header to perform the operation only if the
   156  // resource has been modified since the specified date and time.
   157  // ifUnmodifiedSince - optional. A date and time value. Specify this header to perform the operation only if
   158  // the resource has not been modified since the specified date and time.
   159  // xMsClientRequestID - a UUID recorded in the analytics logs for troubleshooting and correlation.
   160  // timeout - an optional operation timeout value in seconds. The period begins when the request is received by
   161  // the service. If the timeout value elapses before the operation completes, the operation fails.
   162  // xMsDate - specifies the Coordinated Universal Time (UTC) for the request.  This is required when using
   163  // shared key authorization.
   164  func (client FilesystemClient) Delete(ctx context.Context, filesystem string, ifModifiedSince string, ifUnmodifiedSince string, xMsClientRequestID string, timeout *int32, xMsDate string) (result autorest.Response, err error) {
   165  	if tracing.IsEnabled() {
   166  		ctx = tracing.StartSpan(ctx, fqdn+"/FilesystemClient.Delete")
   167  		defer func() {
   168  			sc := -1
   169  			if result.Response != nil {
   170  				sc = result.Response.StatusCode
   171  			}
   172  			tracing.EndSpan(ctx, sc, err)
   173  		}()
   174  	}
   175  	if err := validation.Validate([]validation.Validation{
   176  		{TargetValue: xMsClientRequestID,
   177  			Constraints: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Empty, Rule: false,
   178  				Chain: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Pattern, Rule: `^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$`, Chain: nil}}}}},
   179  		{TargetValue: timeout,
   180  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   181  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
   182  		return result, validation.NewError("storagedatalake.FilesystemClient", "Delete", err.Error())
   183  	}
   184  
   185  	req, err := client.DeletePreparer(ctx, filesystem, ifModifiedSince, ifUnmodifiedSince, xMsClientRequestID, timeout, xMsDate)
   186  	if err != nil {
   187  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "Delete", nil, "Failure preparing request")
   188  		return
   189  	}
   190  
   191  	resp, err := client.DeleteSender(req)
   192  	if err != nil {
   193  		result.Response = resp
   194  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "Delete", resp, "Failure sending request")
   195  		return
   196  	}
   197  
   198  	result, err = client.DeleteResponder(resp)
   199  	if err != nil {
   200  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "Delete", resp, "Failure responding to request")
   201  		return
   202  	}
   203  
   204  	return
   205  }
   206  
   207  // DeletePreparer prepares the Delete request.
   208  func (client FilesystemClient) DeletePreparer(ctx context.Context, filesystem string, ifModifiedSince string, ifUnmodifiedSince string, xMsClientRequestID string, timeout *int32, xMsDate string) (*http.Request, error) {
   209  	urlParameters := map[string]interface{}{
   210  		"accountName": client.AccountName,
   211  		"dnsSuffix":   client.DNSSuffix,
   212  	}
   213  
   214  	pathParameters := map[string]interface{}{
   215  		"filesystem": autorest.Encode("path", filesystem),
   216  	}
   217  
   218  	queryParameters := map[string]interface{}{
   219  		"resource": autorest.Encode("query", "filesystem"),
   220  	}
   221  	if timeout != nil {
   222  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   223  	}
   224  
   225  	preparer := autorest.CreatePreparer(
   226  		autorest.AsDelete(),
   227  		autorest.WithCustomBaseURL("https://{accountName}.{dnsSuffix}", urlParameters),
   228  		autorest.WithPathParameters("/{filesystem}", pathParameters),
   229  		autorest.WithQueryParameters(queryParameters))
   230  	if len(ifModifiedSince) > 0 {
   231  		preparer = autorest.DecoratePreparer(preparer,
   232  			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
   233  	}
   234  	if len(ifUnmodifiedSince) > 0 {
   235  		preparer = autorest.DecoratePreparer(preparer,
   236  			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
   237  	}
   238  	if len(xMsClientRequestID) > 0 {
   239  		preparer = autorest.DecoratePreparer(preparer,
   240  			autorest.WithHeader("x-ms-client-request-id", autorest.String(xMsClientRequestID)))
   241  	}
   242  	if len(xMsDate) > 0 {
   243  		preparer = autorest.DecoratePreparer(preparer,
   244  			autorest.WithHeader("x-ms-date", autorest.String(xMsDate)))
   245  	}
   246  	if len(client.XMsVersion) > 0 {
   247  		preparer = autorest.DecoratePreparer(preparer,
   248  			autorest.WithHeader("x-ms-version", autorest.String(client.XMsVersion)))
   249  	}
   250  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   251  }
   252  
   253  // DeleteSender sends the Delete request. The method will close the
   254  // http.Response Body if it receives an error.
   255  func (client FilesystemClient) DeleteSender(req *http.Request) (*http.Response, error) {
   256  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   257  }
   258  
   259  // DeleteResponder handles the response to the Delete request. The method always
   260  // closes the http.Response Body.
   261  func (client FilesystemClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   262  	err = autorest.Respond(
   263  		resp,
   264  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   265  		autorest.ByClosing())
   266  	result.Response = resp
   267  	return
   268  }
   269  
   270  // GetProperties all system and user-defined filesystem properties are specified in the response headers.
   271  // Parameters:
   272  // filesystem - the filesystem identifier.  The value must start and end with a letter or number and must
   273  // contain only letters, numbers, and the dash (-) character.  Consecutive dashes are not permitted.  All
   274  // letters must be lowercase.  The value must have between 3 and 63 characters.
   275  // xMsClientRequestID - a UUID recorded in the analytics logs for troubleshooting and correlation.
   276  // timeout - an optional operation timeout value in seconds. The period begins when the request is received by
   277  // the service. If the timeout value elapses before the operation completes, the operation fails.
   278  // xMsDate - specifies the Coordinated Universal Time (UTC) for the request.  This is required when using
   279  // shared key authorization.
   280  func (client FilesystemClient) GetProperties(ctx context.Context, filesystem string, xMsClientRequestID string, timeout *int32, xMsDate string) (result autorest.Response, err error) {
   281  	if tracing.IsEnabled() {
   282  		ctx = tracing.StartSpan(ctx, fqdn+"/FilesystemClient.GetProperties")
   283  		defer func() {
   284  			sc := -1
   285  			if result.Response != nil {
   286  				sc = result.Response.StatusCode
   287  			}
   288  			tracing.EndSpan(ctx, sc, err)
   289  		}()
   290  	}
   291  	if err := validation.Validate([]validation.Validation{
   292  		{TargetValue: xMsClientRequestID,
   293  			Constraints: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Empty, Rule: false,
   294  				Chain: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Pattern, Rule: `^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$`, Chain: nil}}}}},
   295  		{TargetValue: timeout,
   296  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   297  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
   298  		return result, validation.NewError("storagedatalake.FilesystemClient", "GetProperties", err.Error())
   299  	}
   300  
   301  	req, err := client.GetPropertiesPreparer(ctx, filesystem, xMsClientRequestID, timeout, xMsDate)
   302  	if err != nil {
   303  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "GetProperties", nil, "Failure preparing request")
   304  		return
   305  	}
   306  
   307  	resp, err := client.GetPropertiesSender(req)
   308  	if err != nil {
   309  		result.Response = resp
   310  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "GetProperties", resp, "Failure sending request")
   311  		return
   312  	}
   313  
   314  	result, err = client.GetPropertiesResponder(resp)
   315  	if err != nil {
   316  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "GetProperties", resp, "Failure responding to request")
   317  		return
   318  	}
   319  
   320  	return
   321  }
   322  
   323  // GetPropertiesPreparer prepares the GetProperties request.
   324  func (client FilesystemClient) GetPropertiesPreparer(ctx context.Context, filesystem string, xMsClientRequestID string, timeout *int32, xMsDate string) (*http.Request, error) {
   325  	urlParameters := map[string]interface{}{
   326  		"accountName": client.AccountName,
   327  		"dnsSuffix":   client.DNSSuffix,
   328  	}
   329  
   330  	pathParameters := map[string]interface{}{
   331  		"filesystem": autorest.Encode("path", filesystem),
   332  	}
   333  
   334  	queryParameters := map[string]interface{}{
   335  		"resource": autorest.Encode("query", "filesystem"),
   336  	}
   337  	if timeout != nil {
   338  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   339  	}
   340  
   341  	preparer := autorest.CreatePreparer(
   342  		autorest.AsHead(),
   343  		autorest.WithCustomBaseURL("https://{accountName}.{dnsSuffix}", urlParameters),
   344  		autorest.WithPathParameters("/{filesystem}", pathParameters),
   345  		autorest.WithQueryParameters(queryParameters))
   346  	if len(xMsClientRequestID) > 0 {
   347  		preparer = autorest.DecoratePreparer(preparer,
   348  			autorest.WithHeader("x-ms-client-request-id", autorest.String(xMsClientRequestID)))
   349  	}
   350  	if len(xMsDate) > 0 {
   351  		preparer = autorest.DecoratePreparer(preparer,
   352  			autorest.WithHeader("x-ms-date", autorest.String(xMsDate)))
   353  	}
   354  	if len(client.XMsVersion) > 0 {
   355  		preparer = autorest.DecoratePreparer(preparer,
   356  			autorest.WithHeader("x-ms-version", autorest.String(client.XMsVersion)))
   357  	}
   358  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   359  }
   360  
   361  // GetPropertiesSender sends the GetProperties request. The method will close the
   362  // http.Response Body if it receives an error.
   363  func (client FilesystemClient) GetPropertiesSender(req *http.Request) (*http.Response, error) {
   364  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   365  }
   366  
   367  // GetPropertiesResponder handles the response to the GetProperties request. The method always
   368  // closes the http.Response Body.
   369  func (client FilesystemClient) GetPropertiesResponder(resp *http.Response) (result autorest.Response, err error) {
   370  	err = autorest.Respond(
   371  		resp,
   372  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   373  		autorest.ByClosing())
   374  	result.Response = resp
   375  	return
   376  }
   377  
   378  // List list filesystems and their properties in given account.
   379  // Parameters:
   380  // prefix - filters results to filesystems within the specified prefix.
   381  // continuation - the number of filesystems returned with each invocation is limited. If the number of
   382  // filesystems to be returned exceeds this limit, a continuation token is returned in the response header
   383  // x-ms-continuation. When a continuation token is  returned in the response, it must be specified in a
   384  // subsequent invocation of the list operation to continue listing the filesystems.
   385  // maxResults - an optional value that specifies the maximum number of items to return. If omitted or greater
   386  // than 5,000, the response will include up to 5,000 items.
   387  // xMsClientRequestID - a UUID recorded in the analytics logs for troubleshooting and correlation.
   388  // timeout - an optional operation timeout value in seconds. The period begins when the request is received by
   389  // the service. If the timeout value elapses before the operation completes, the operation fails.
   390  // xMsDate - specifies the Coordinated Universal Time (UTC) for the request.  This is required when using
   391  // shared key authorization.
   392  func (client FilesystemClient) List(ctx context.Context, prefix string, continuation string, maxResults *int32, xMsClientRequestID string, timeout *int32, xMsDate string) (result FilesystemList, err error) {
   393  	if tracing.IsEnabled() {
   394  		ctx = tracing.StartSpan(ctx, fqdn+"/FilesystemClient.List")
   395  		defer func() {
   396  			sc := -1
   397  			if result.Response.Response != nil {
   398  				sc = result.Response.Response.StatusCode
   399  			}
   400  			tracing.EndSpan(ctx, sc, err)
   401  		}()
   402  	}
   403  	if err := validation.Validate([]validation.Validation{
   404  		{TargetValue: maxResults,
   405  			Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
   406  				Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
   407  		{TargetValue: xMsClientRequestID,
   408  			Constraints: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Empty, Rule: false,
   409  				Chain: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Pattern, Rule: `^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$`, Chain: nil}}}}},
   410  		{TargetValue: timeout,
   411  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   412  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
   413  		return result, validation.NewError("storagedatalake.FilesystemClient", "List", err.Error())
   414  	}
   415  
   416  	req, err := client.ListPreparer(ctx, prefix, continuation, maxResults, xMsClientRequestID, timeout, xMsDate)
   417  	if err != nil {
   418  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "List", nil, "Failure preparing request")
   419  		return
   420  	}
   421  
   422  	resp, err := client.ListSender(req)
   423  	if err != nil {
   424  		result.Response = autorest.Response{Response: resp}
   425  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "List", resp, "Failure sending request")
   426  		return
   427  	}
   428  
   429  	result, err = client.ListResponder(resp)
   430  	if err != nil {
   431  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "List", resp, "Failure responding to request")
   432  		return
   433  	}
   434  
   435  	return
   436  }
   437  
   438  // ListPreparer prepares the List request.
   439  func (client FilesystemClient) ListPreparer(ctx context.Context, prefix string, continuation string, maxResults *int32, xMsClientRequestID string, timeout *int32, xMsDate string) (*http.Request, error) {
   440  	urlParameters := map[string]interface{}{
   441  		"accountName": client.AccountName,
   442  		"dnsSuffix":   client.DNSSuffix,
   443  	}
   444  
   445  	queryParameters := map[string]interface{}{
   446  		"resource": autorest.Encode("query", "account"),
   447  	}
   448  	if len(prefix) > 0 {
   449  		queryParameters["prefix"] = autorest.Encode("query", prefix)
   450  	}
   451  	if len(continuation) > 0 {
   452  		queryParameters["continuation"] = autorest.Encode("query", continuation)
   453  	}
   454  	if maxResults != nil {
   455  		queryParameters["maxResults"] = autorest.Encode("query", *maxResults)
   456  	}
   457  	if timeout != nil {
   458  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   459  	}
   460  
   461  	preparer := autorest.CreatePreparer(
   462  		autorest.AsGet(),
   463  		autorest.WithCustomBaseURL("https://{accountName}.{dnsSuffix}", urlParameters),
   464  		autorest.WithPath("/"),
   465  		autorest.WithQueryParameters(queryParameters))
   466  	if len(xMsClientRequestID) > 0 {
   467  		preparer = autorest.DecoratePreparer(preparer,
   468  			autorest.WithHeader("x-ms-client-request-id", autorest.String(xMsClientRequestID)))
   469  	}
   470  	if len(xMsDate) > 0 {
   471  		preparer = autorest.DecoratePreparer(preparer,
   472  			autorest.WithHeader("x-ms-date", autorest.String(xMsDate)))
   473  	}
   474  	if len(client.XMsVersion) > 0 {
   475  		preparer = autorest.DecoratePreparer(preparer,
   476  			autorest.WithHeader("x-ms-version", autorest.String(client.XMsVersion)))
   477  	}
   478  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   479  }
   480  
   481  // ListSender sends the List request. The method will close the
   482  // http.Response Body if it receives an error.
   483  func (client FilesystemClient) ListSender(req *http.Request) (*http.Response, error) {
   484  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   485  }
   486  
   487  // ListResponder handles the response to the List request. The method always
   488  // closes the http.Response Body.
   489  func (client FilesystemClient) ListResponder(resp *http.Response) (result FilesystemList, err error) {
   490  	err = autorest.Respond(
   491  		resp,
   492  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   493  		autorest.ByUnmarshallingJSON(&result),
   494  		autorest.ByClosing())
   495  	result.Response = autorest.Response{Response: resp}
   496  	return
   497  }
   498  
   499  // SetProperties set properties for the filesystem.  This operation supports conditional HTTP requests.  For more
   500  // information, see [Specifying Conditional Headers for Blob Service
   501  // Operations](https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations).
   502  // Parameters:
   503  // filesystem - the filesystem identifier.  The value must start and end with a letter or number and must
   504  // contain only letters, numbers, and the dash (-) character.  Consecutive dashes are not permitted.  All
   505  // letters must be lowercase.  The value must have between 3 and 63 characters.
   506  // xMsProperties - optional. User-defined properties to be stored with the filesystem, in the format of a
   507  // comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value is base64 encoded.  If
   508  // the filesystem exists, any properties not included in the list will be removed.  All properties are removed
   509  // if the header is omitted.  To merge new and existing properties, first get all existing properties and the
   510  // current E-Tag, then make a conditional request with the E-Tag and include values for all properties.
   511  // ifModifiedSince - optional. A date and time value. Specify this header to perform the operation only if the
   512  // resource has been modified since the specified date and time.
   513  // ifUnmodifiedSince - optional. A date and time value. Specify this header to perform the operation only if
   514  // the resource has not been modified since the specified date and time.
   515  // xMsClientRequestID - a UUID recorded in the analytics logs for troubleshooting and correlation.
   516  // timeout - an optional operation timeout value in seconds. The period begins when the request is received by
   517  // the service. If the timeout value elapses before the operation completes, the operation fails.
   518  // xMsDate - specifies the Coordinated Universal Time (UTC) for the request.  This is required when using
   519  // shared key authorization.
   520  func (client FilesystemClient) SetProperties(ctx context.Context, filesystem string, xMsProperties string, ifModifiedSince string, ifUnmodifiedSince string, xMsClientRequestID string, timeout *int32, xMsDate string) (result autorest.Response, err error) {
   521  	if tracing.IsEnabled() {
   522  		ctx = tracing.StartSpan(ctx, fqdn+"/FilesystemClient.SetProperties")
   523  		defer func() {
   524  			sc := -1
   525  			if result.Response != nil {
   526  				sc = result.Response.StatusCode
   527  			}
   528  			tracing.EndSpan(ctx, sc, err)
   529  		}()
   530  	}
   531  	if err := validation.Validate([]validation.Validation{
   532  		{TargetValue: xMsClientRequestID,
   533  			Constraints: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Empty, Rule: false,
   534  				Chain: []validation.Constraint{{Target: "xMsClientRequestID", Name: validation.Pattern, Rule: `^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$`, Chain: nil}}}}},
   535  		{TargetValue: timeout,
   536  			Constraints: []validation.Constraint{{Target: "timeout", Name: validation.Null, Rule: false,
   537  				Chain: []validation.Constraint{{Target: "timeout", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
   538  		return result, validation.NewError("storagedatalake.FilesystemClient", "SetProperties", err.Error())
   539  	}
   540  
   541  	req, err := client.SetPropertiesPreparer(ctx, filesystem, xMsProperties, ifModifiedSince, ifUnmodifiedSince, xMsClientRequestID, timeout, xMsDate)
   542  	if err != nil {
   543  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "SetProperties", nil, "Failure preparing request")
   544  		return
   545  	}
   546  
   547  	resp, err := client.SetPropertiesSender(req)
   548  	if err != nil {
   549  		result.Response = resp
   550  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "SetProperties", resp, "Failure sending request")
   551  		return
   552  	}
   553  
   554  	result, err = client.SetPropertiesResponder(resp)
   555  	if err != nil {
   556  		err = autorest.NewErrorWithError(err, "storagedatalake.FilesystemClient", "SetProperties", resp, "Failure responding to request")
   557  		return
   558  	}
   559  
   560  	return
   561  }
   562  
   563  // SetPropertiesPreparer prepares the SetProperties request.
   564  func (client FilesystemClient) SetPropertiesPreparer(ctx context.Context, filesystem string, xMsProperties string, ifModifiedSince string, ifUnmodifiedSince string, xMsClientRequestID string, timeout *int32, xMsDate string) (*http.Request, error) {
   565  	urlParameters := map[string]interface{}{
   566  		"accountName": client.AccountName,
   567  		"dnsSuffix":   client.DNSSuffix,
   568  	}
   569  
   570  	pathParameters := map[string]interface{}{
   571  		"filesystem": autorest.Encode("path", filesystem),
   572  	}
   573  
   574  	queryParameters := map[string]interface{}{
   575  		"resource": autorest.Encode("query", "filesystem"),
   576  	}
   577  	if timeout != nil {
   578  		queryParameters["timeout"] = autorest.Encode("query", *timeout)
   579  	}
   580  
   581  	preparer := autorest.CreatePreparer(
   582  		autorest.AsPatch(),
   583  		autorest.WithCustomBaseURL("https://{accountName}.{dnsSuffix}", urlParameters),
   584  		autorest.WithPathParameters("/{filesystem}", pathParameters),
   585  		autorest.WithQueryParameters(queryParameters))
   586  	if len(xMsProperties) > 0 {
   587  		preparer = autorest.DecoratePreparer(preparer,
   588  			autorest.WithHeader("x-ms-properties", autorest.String(xMsProperties)))
   589  	}
   590  	if len(ifModifiedSince) > 0 {
   591  		preparer = autorest.DecoratePreparer(preparer,
   592  			autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince)))
   593  	}
   594  	if len(ifUnmodifiedSince) > 0 {
   595  		preparer = autorest.DecoratePreparer(preparer,
   596  			autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince)))
   597  	}
   598  	if len(xMsClientRequestID) > 0 {
   599  		preparer = autorest.DecoratePreparer(preparer,
   600  			autorest.WithHeader("x-ms-client-request-id", autorest.String(xMsClientRequestID)))
   601  	}
   602  	if len(xMsDate) > 0 {
   603  		preparer = autorest.DecoratePreparer(preparer,
   604  			autorest.WithHeader("x-ms-date", autorest.String(xMsDate)))
   605  	}
   606  	if len(client.XMsVersion) > 0 {
   607  		preparer = autorest.DecoratePreparer(preparer,
   608  			autorest.WithHeader("x-ms-version", autorest.String(client.XMsVersion)))
   609  	}
   610  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   611  }
   612  
   613  // SetPropertiesSender sends the SetProperties request. The method will close the
   614  // http.Response Body if it receives an error.
   615  func (client FilesystemClient) SetPropertiesSender(req *http.Request) (*http.Response, error) {
   616  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   617  }
   618  
   619  // SetPropertiesResponder handles the response to the SetProperties request. The method always
   620  // closes the http.Response Body.
   621  func (client FilesystemClient) SetPropertiesResponder(resp *http.Response) (result autorest.Response, err error) {
   622  	err = autorest.Respond(
   623  		resp,
   624  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   625  		autorest.ByClosing())
   626  	result.Response = resp
   627  	return
   628  }
   629  

View as plain text