Skip to content

Commit

Permalink
[Storage] Add comments for recursive ACL parameters; Resolve review c…
Browse files Browse the repository at this point in the history
…omments
  • Loading branch information
XiaoningLiu committed Jul 2, 2020
1 parent 06e0450 commit ec68624
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 87 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Increased the maximum block size for file from 100MiB to 4000MiB(~4GB). And thereby supporting ~200TB maximum size for file.
- Added more mappings for Blob and DFS endpoints. [issue #8744](https://github.com/Azure/azure-sdk-for-js/issues/8744).
- Added convenience methods `createIfNotExists`, `deleteIfExists` to `DataLakeFileSystemClient`, `DataLakePathClient`, `DataLakeDirectoryClient`, and `DataLakeFileClient`.
- Supported set access control list recursively.
- Added support to set access control list recursively.

## 12.0.1 (2020.05)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface AccessControlChanges {
aggregateCounters: AccessControlChangeCounters;
batchCounters: AccessControlChangeCounters;
batchFailures: AccessControlChangeFailure[];
continuation?: string;
continuationToken?: string;
}

// @public (undocumented)
Expand Down Expand Up @@ -874,8 +874,10 @@ export interface PathAccessControl {
}

// @public (undocumented)
export interface PathAccessControlItem extends RemovePathAccessControlItem {
// (undocumented)
export interface PathAccessControlItem {
accessControlType: AccessControlType;
defaultScope: boolean;
entityId: string;
permissions: RolePermissions;
}

Expand All @@ -891,14 +893,14 @@ export interface PathAppendDataHeaders {
export interface PathChangeAccessControlRecursiveOptions extends CommonOptions {
abortSignal?: AbortSignalLike;
batchSize?: number;
continuation?: string;
continuationToken?: string;
maxBatches?: number;
onProgress?: (progress: AccessControlChanges) => void;
}

// @public
export interface PathChangeAccessControlRecursiveResponse {
continuation?: string;
continuationToken?: string;
counters: AccessControlChangeCounters;
}

Expand Down Expand Up @@ -1466,12 +1468,9 @@ export interface RawAccessPolicy {

// @public (undocumented)
export interface RemovePathAccessControlItem {
// (undocumented)
accessControlType: AccessControlType;
// (undocumented)
defaultScope: boolean;
// (undocumented)
entityId: string;
entityId?: string;
}

export { RequestPolicy }
Expand Down
15 changes: 8 additions & 7 deletions sdk/storage/storage-file-datalake/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
PathSetMetadataResponse,
PathSetPermissionsOptions,
PathSetPermissionsResponse,
RemovePathAccessControlItem,
} from "./models";
import { newPipeline, Pipeline, StoragePipelineOptions } from "./Pipeline";
import { StorageClient } from "./StorageClient";
Expand Down Expand Up @@ -148,26 +149,26 @@ export class DataLakePathClient extends StorageClient {
changedDirectoriesCount: 0,
changedFilesCount: 0
},
continuation: undefined
continuationToken: undefined
};

try {
let continuation = options.continuation;
let continuationToken = options.continuationToken;
let batchCounter = 0;
let reachMaxBatches = false;
do {
const response = await this.pathContext.setAccessControlRecursive(mode, {
...options,
acl: toAclString(acl as PathAccessControlItem[]),
maxRecords: options.batchSize,
continuation,
continuation: continuationToken,
spanOptions
});
batchCounter++;
continuation = response.continuation;
continuationToken = response.continuation;

// Update result
result.continuation = continuation;
result.continuationToken = continuationToken;
result.counters.failedChangesCount += response.failureCount || 0;
result.counters.changedDirectoriesCount += response.directoriesSuccessful || 0;
result.counters.changedFilesCount += response.filesSuccessful || 0;
Expand All @@ -182,14 +183,14 @@ export class DataLakePathClient extends StorageClient {
changedFilesCount: response.filesSuccessful || 0
},
aggregateCounters: result.counters,
continuation
continuationToken: continuationToken
};
options.onProgress(progress);
}

reachMaxBatches =
options.maxBatches === undefined ? false : batchCounter >= options.maxBatches;
} while (continuation && !reachMaxBatches);
} while (continuationToken && !reachMaxBatches);

return result;
} catch (e) {
Expand Down
57 changes: 51 additions & 6 deletions sdk/storage/storage-file-datalake/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { HttpResponse, TransferProgressEvent } from "@azure/core-http";
import { LeaseAccessConditions, ModifiedAccessConditions, UserDelegationKeyModel } from "@azure/storage-blob";

import {
FileSystemListPathsHeaders,
FileSystemListPathsHeaders,
PathCreateResponse,
PathDeleteResponse,
Expand Down Expand Up @@ -404,12 +403,58 @@ export interface PathPermissions {
export type AccessControlType = "user" | "group" | "mask" | "other";

export interface RemovePathAccessControlItem {
/**
* Indicates whether this is the default entry for the ACL.
*
* @type {boolean}
* @memberof RemovePathAccessControlItem
*/
defaultScope: boolean;
/**
* Specifies which role this entry targets.
*
* @type {AccessControlType}
* @memberof RemovePathAccessControlItem
*/
accessControlType: AccessControlType;
entityId: string;
/**
* Specifies the entity for which this entry applies.
* Must be omitted for types mask or other. It must also be omitted when the user or group is the owner.
*
* @type {string}
* @memberof RemovePathAccessControlItem
*/
entityId?: string;
}

export interface PathAccessControlItem extends RemovePathAccessControlItem {
export interface PathAccessControlItem {
/**
* Indicates whether this is the default entry for the ACL.
*
* @type {boolean}
* @memberof PathAccessControlItem
*/
defaultScope: boolean;
/**
* Specifies which role this entry targets.
*
* @type {AccessControlType}
* @memberof PathAccessControlItem
*/
accessControlType: AccessControlType;
/**
* Specifies the entity for which this entry applies.
*
* @type {string}
* @memberof PathAccessControlItem
*/
entityId: string;
/**
* Access control permissions.
*
* @type {RolePermissions}
* @memberof PathAccessControlItem
*/
permissions: RolePermissions;
}

Expand Down Expand Up @@ -519,7 +564,7 @@ export interface PathChangeAccessControlRecursiveOptions extends CommonOptions {
* @type {string}
* @memberof PathChangeAccessControlRecursiveOptions
*/
continuation?: string;
continuationToken?: string;
/**
* Callback where caller can track progress of the operation
* as well as collect paths that failed to change Access Control.
Expand Down Expand Up @@ -594,7 +639,7 @@ export interface AccessControlChanges {
* @type {string}
* @memberof AccessControlChanges
*/
continuation?: string;
continuationToken?: string;
}

/**
Expand Down Expand Up @@ -644,7 +689,7 @@ export interface PathChangeAccessControlRecursiveResponse {
* @type {string}
* @memberof PathChangeAccessControlRecursiveResponse
*/
continuation?: string;
continuationToken?: string;
}

export interface PathSetPermissionsOptions extends CommonOptions {
Expand Down
Loading

0 comments on commit ec68624

Please sign in to comment.