...

Source file src/github.com/Azure/azure-sdk-for-go/services/storage/datalake/2019-10-31/storagedatalake/filesystem.go

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

View as plain text