Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive acl #14669

Merged
merged 19 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/storage/azure-storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

## 12.3.0-beta.1 (Unreleased)
- Added support for the 2019-02-10 service version.
gapra-msft marked this conversation as resolved.
Show resolved Hide resolved
- Added support for setting, modifying, and removing ACLs recursively.
- Added support to schedule file expiration.
- Added support to specify Arrow Output Serialization when querying a file.
>>>>>>> upstream/feature/storage/stg74
gapra-msft marked this conversation as resolved.
Show resolved Hide resolved

## 12.2.0 (2020-08-13)
- Fixed bug where Query Input Stream would throw when a ByteBuffer of length 0 was encountered.
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@
import com.azure.storage.file.datalake.implementation.models.LeaseAccessConditions;
import com.azure.storage.file.datalake.implementation.models.ModifiedAccessConditions;
import com.azure.storage.file.datalake.implementation.models.PathRenameMode;
import com.azure.storage.file.datalake.implementation.models.PathSetAccessControlRecursiveMode;
import com.azure.storage.file.datalake.implementation.models.SourceModifiedAccessConditions;
import com.azure.storage.file.datalake.implementation.util.DataLakeImplUtils;
import com.azure.storage.file.datalake.models.AccessControlChangeResult;
import com.azure.storage.file.datalake.models.DataLakeRequestConditions;
import com.azure.storage.file.datalake.models.PathAccessControl;
import com.azure.storage.file.datalake.models.PathAccessControlEntry;
import com.azure.storage.file.datalake.models.PathHttpHeaders;
import com.azure.storage.file.datalake.models.PathInfo;
import com.azure.storage.file.datalake.models.PathPermissions;
import com.azure.storage.file.datalake.models.PathProperties;
import com.azure.storage.file.datalake.models.RemovePathAccessControlEntry;
import com.azure.storage.file.datalake.models.UserDelegationKey;
import com.azure.storage.file.datalake.options.DirectoryRemoveAccessControlRecursiveOptions;
import com.azure.storage.file.datalake.options.DirectorySetAccessControlRecursiveOptions;
import com.azure.storage.file.datalake.options.DirectoryUpdateAccessControlRecursiveOptions;
import com.azure.storage.file.datalake.sas.DataLakeServiceSasSignatureValues;
import reactor.core.publisher.Mono;

Expand All @@ -35,6 +41,8 @@
import java.util.List;
import java.util.Map;

import static com.azure.core.util.FluxUtil.withContext;

/**
* This class provides a client that contains all operations that apply to any path object.
*/
Expand Down Expand Up @@ -354,6 +362,140 @@ public Response<PathInfo> setPermissionsWithResponse(PathPermissions permissions
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
* Sets the access control on a path and subpaths.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathClient.setAccessControlRecursive#List}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">Azure Docs</a></p>
*
* @param accessControlList The POSIX access control list for the file or directory.
* @return The result of the operation.
*/
public AccessControlChangeResult setAccessControlRecursive(List<PathAccessControlEntry> accessControlList) {
return setAccessControlRecursiveWithResponse(new DirectorySetAccessControlRecursiveOptions(accessControlList), null,
Context.NONE).getValue();
}

/**
* Sets the access control on a path and subpaths.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathClient.setAccessControlRecursive#SetAccessControlRecursiveOptions-Duration-Context}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">Azure Docs</a></p>
*
* @param options {@link DirectorySetAccessControlRecursiveOptions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A response containing the result of the operation.
*/
public Response<AccessControlChangeResult> setAccessControlRecursiveWithResponse(
DirectorySetAccessControlRecursiveOptions options, Duration timeout, Context context) {
Mono<Response<AccessControlChangeResult>> response =
dataLakePathAsyncClient.setAccessControlRecursiveWithResponse(
PathAccessControlEntry.serializeList(options.getAccessControlList()), options.getProgressHandler(),
PathSetAccessControlRecursiveMode.SET, options.getBatchSize(), options.getMaxBatches(),
options.isContinuingOnFailure(), options.getContinuationToken(), context);

return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do the try catch error thing here so we can log it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea idk why we don't do it on all the datalake methods. I'll add it to all the other ones, too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Looks like we don't do that for any of the methods in BlobClientBase either, so I think it'd be better to do that as a separate PR

}

/**
* Updates the access control on a path and subpaths.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathClient.updateAccessControlRecursive#List}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">Azure Docs</a></p>
*
* @param accessControlList The POSIX access control list for the file or directory.
* @return The result of the operation.
*/
public AccessControlChangeResult updateAccessControlRecursive(List<PathAccessControlEntry> accessControlList) {
return updateAccessControlRecursiveWithResponse(new DirectoryUpdateAccessControlRecursiveOptions(accessControlList),
null, Context.NONE).getValue();
}

/**
* Updates the access control on a path and subpaths.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathClient.updateAccessControlRecursive#UpdateAccessControlRecursiveOptions-Duration-Context}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">Azure Docs</a></p>
*
* @param options {@link DirectoryUpdateAccessControlRecursiveOptions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A response containing the result of the operation.
*/
public Response<AccessControlChangeResult> updateAccessControlRecursiveWithResponse(
DirectoryUpdateAccessControlRecursiveOptions options, Duration timeout, Context context) {
Mono<Response<AccessControlChangeResult>> response =
dataLakePathAsyncClient.setAccessControlRecursiveWithResponse(
PathAccessControlEntry.serializeList(options.getAccessControlList()), options.getProgressHandler(),
PathSetAccessControlRecursiveMode.MODIFY, options.getBatchSize(), options.getMaxBatches(),
options.isContinuingOnFailure(), options.getContinuationToken(), context);

return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
* Removes the access control on a path and subpaths.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathClient.removeAccessControlRecursive#List}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">Azure Docs</a></p>
*
* @param accessControlList The POSIX access control list for the file or directory.
* @return The result of the operation.
*/
public AccessControlChangeResult removeAccessControlRecursive(
List<RemovePathAccessControlEntry> accessControlList) {
return removeAccessControlRecursiveWithResponse(new DirectoryRemoveAccessControlRecursiveOptions(accessControlList),
null, Context.NONE).getValue();
}

/**
* Remove the access control on a path and subpaths.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathAsyncClient.removeAccessControlRecursive#RemoveAccessControlRecursiveOptions-Duration-Context}
*
* <p>For more information, see the
* <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">Azure Docs</a></p>
*
* @param options {@link DirectoryRemoveAccessControlRecursiveOptions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A response containing the result of the operation.
*/
public Response<AccessControlChangeResult> removeAccessControlRecursiveWithResponse(
DirectoryRemoveAccessControlRecursiveOptions options, Duration timeout, Context context) {
Mono<Response<AccessControlChangeResult>> response =
dataLakePathAsyncClient.setAccessControlRecursiveWithResponse(
RemovePathAccessControlEntry.serializeList(options.getAccessControlList()), options.getProgressHandler(),
PathSetAccessControlRecursiveMode.REMOVE, options.getBatchSize(), options.getMaxBatches(),
options.isContinuingOnFailure(), options.getContinuationToken(), context);

return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}


/**
* Returns the access control for a resource.
*
Expand Down Expand Up @@ -456,7 +598,7 @@ public Boolean exists() {
* <p>Note that this method does not guarantee that the path type (file/directory) matches expectations.</p>
* <p>For example, a DataLakeFileClient representing a path to a datalake directory will return true, and vice
* versa.</p>
*
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathClient.existsWithResponse#Duration-Context}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private interface PathsService {
@Patch("{filesystem}/{path}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(DataLakeStorageException.class)
Mono<PathsSetAccessControlRecursiveResponse> setAccessControlRecursive(@HostParam("url") String url, @QueryParam("timeout") Integer timeout, @QueryParam("continuation") String continuation, @QueryParam("mode") PathSetAccessControlRecursiveMode mode, @QueryParam("forceFlag") Boolean forceFlag, @QueryParam("maxRecords") Integer maxRecords, @HeaderParam("x-ms-acl") String acl, @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-version") String version, @QueryParam("action") String action, Context context);
Mono<PathsSetAccessControlRecursiveResponse> setAccessControlRecursive(@PathParam("filesystem") String fileSystem, @PathParam("path") String path1, @HostParam("url") String url, @QueryParam("timeout") Integer timeout, @QueryParam("continuation") String continuation, @QueryParam("mode") PathSetAccessControlRecursiveMode mode, @QueryParam("forceFlag") Boolean forceFlag, @QueryParam("maxRecords") Integer maxRecords, @HeaderParam("x-ms-acl") String acl, @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-version") String version, @QueryParam("action") String action, Context context);

@Patch("{filesystem}/{path}")
@ExpectedResponses({200})
Expand Down Expand Up @@ -726,7 +726,7 @@ public Mono<PathsSetAccessControlRecursiveResponse> setAccessControlRecursiveWit
final String acl = null;
final String requestId = null;
final String action = "setAccessControlRecursive";
return service.setAccessControlRecursive(this.client.getUrl(), timeout, continuation, mode, forceFlag, maxRecords, acl, requestId, this.client.getVersion(), action, context);
return service.setAccessControlRecursive(this.client.getFileSystem(), this.client.getPath1(), this.client.getUrl(), timeout, continuation, mode, forceFlag, maxRecords, acl, requestId, this.client.getVersion(), action, context);
}

/**
Expand All @@ -746,7 +746,7 @@ public Mono<PathsSetAccessControlRecursiveResponse> setAccessControlRecursiveWit
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PathsSetAccessControlRecursiveResponse> setAccessControlRecursiveWithRestResponseAsync(PathSetAccessControlRecursiveMode mode, Integer timeout, String continuation, Boolean forceFlag, Integer maxRecords, String acl, String requestId, Context context) {
final String action = "setAccessControlRecursive";
return service.setAccessControlRecursive(this.client.getUrl(), timeout, continuation, mode, forceFlag, maxRecords, acl, requestId, this.client.getVersion(), action, context);
return service.setAccessControlRecursive(this.client.getFileSystem(), this.client.getPath1(), this.client.getUrl(), timeout, continuation, mode, forceFlag, maxRecords, acl, requestId, this.client.getVersion(), action, context);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.storage.file.datalake.implementation.models;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
* Defines values for AppendMode.
*/
public enum AppendMode {
/**
* Enum value autoCreate.
*/
AUTO_CREATE("autoCreate");

/**
* The actual serialized value for a AppendMode instance.
*/
private final String value;

AppendMode(String value) {
this.value = value;
}

/**
* Parses a serialized value to a AppendMode instance.
*
* @param value the serialized value to parse.
* @return the parsed AppendMode object, or null if unable to parse.
*/
@JsonCreator
public static AppendMode fromString(String value) {
AppendMode[] items = AppendMode.values();
for (AppendMode item : items) {
if (item.toString().equalsIgnoreCase(value)) {
return item;
}
}
return null;
}

@JsonValue
@Override
public String toString() {
return this.value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.storage.file.datalake.implementation.models;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
* Defines values for BlobType.
*/
public enum BlobType {
/**
* Enum value appendblob.
*/
APPENDBLOB("appendblob");

/**
* The actual serialized value for a BlobType instance.
*/
private final String value;

BlobType(String value) {
this.value = value;
}

/**
* Parses a serialized value to a BlobType instance.
*
* @param value the serialized value to parse.
* @return the parsed BlobType object, or null if unable to parse.
*/
@JsonCreator
public static BlobType fromString(String value) {
BlobType[] items = BlobType.values();
for (BlobType item : items) {
if (item.toString().equalsIgnoreCase(value)) {
return item;
}
}
return null;
}

@JsonValue
@Override
public String toString() {
return this.value;
}
}
Loading