Skip to content

Commit 1b351de

Browse files
authored
Added 2020-02-10 features. (#692)
* Added 2020-02-10 features. * Resolved comments.
1 parent 453545a commit 1b351de

File tree

16 files changed

+2547
-714
lines changed

16 files changed

+2547
-714
lines changed

sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,27 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
137137
bool Recursive,
138138
const DeleteDirectoryOptions& options = DeleteDirectoryOptions()) const;
139139

140+
/**
141+
* @brief Sets POSIX access control rights on files and directories under given directory
142+
* recursively.
143+
* @param mode Mode PathSetAccessControlRecursiveMode::Set sets POSIX access control rights on
144+
* files and directories, PathSetAccessControlRecursiveMode::Modify modifies one or more POSIX
145+
* access control rights that pre-exist on files and directories,
146+
* PathSetAccessControlRecursiveMode::Remove removes one or more POSIX access control rights
147+
* that were present earlier on files and directories
148+
* @param acls Sets POSIX access control rights on files and directories. Each access control
149+
* entry (ACE) consists of a scope, a type, a user or group identifier, and permissions.
150+
* @param options Optional parameters to set an access control recursively to the resource the
151+
* directory points to.
152+
* @return Azure::Core::Response<SetDirectoryAccessControlRecursiveResult>
153+
* @remark This request is sent to dfs endpoint.
154+
*/
155+
Azure::Core::Response<SetDirectoryAccessControlRecursiveResult> SetAccessControlRecursive(
156+
PathSetAccessControlRecursiveMode mode,
157+
std::vector<Acl> acls,
158+
const SetDirectoryAccessControlRecursiveOptions& options
159+
= SetDirectoryAccessControlRecursiveOptions()) const;
160+
140161
private:
141162
explicit DirectoryClient(
142163
Azure::Core::Http::Url dfsUri,

sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,43 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
647647
PathAccessConditions AccessConditions;
648648
};
649649

650+
/**
651+
* @brief Optional parameters for PathClient::SetAccessControlRecursive
652+
*/
653+
struct SetDirectoryAccessControlRecursiveOptions
654+
{
655+
/**
656+
* @brief Context for cancelling long running operations.
657+
*/
658+
Azure::Core::Context Context;
659+
660+
/**
661+
* @brief When performing setAccessControlRecursive on a directory, the number of paths that
662+
* are processed with each invocation is limited. If the number of paths to be processed
663+
* exceeds this limit, a continuation token is returned in this response header. When a
664+
* continuation token is returned in the response, it must be specified in a subsequent
665+
* invocation of the setAccessControlRecursive operation to continue the
666+
* setAccessControlRecursive operation on the directory.
667+
*/
668+
Azure::Core::Nullable<std::string> Continuation;
669+
670+
/**
671+
* @brief It specifies the maximum number of files or directories on which the acl change will
672+
* be applied. If omitted or greater than 2,000, the request will process up to 2,000
673+
* items.
674+
*/
675+
Azure::Core::Nullable<int32_t> MaxRecords;
676+
677+
/**
678+
* @brief Optional. Valid for "SetAccessControlRecursive" operation. If set to false, the
679+
* operation will terminate quickly on encountering user errors (4XX). If true, the operation
680+
* will ignore user errors and proceed with the operation on other sub-entities of the
681+
* directory. Continuation token will only be returned when forceFlag is true in case of user
682+
* errors. If not set the default value is false for this.
683+
*/
684+
Azure::Core::Nullable<bool> ForceFlag;
685+
};
686+
650687
using CreateFileOptions = CreatePathOptions;
651688
using CreateDirectoryOptions = CreatePathOptions;
652689

sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
183183
Azure::Core::Nullable<std::string> Continuation;
184184
};
185185

186-
using DirectorySetAccessControlRecursiveInfo = PathSetAccessControlRecursiveResult;
186+
using SetDirectoryAccessControlRecursiveResult = PathSetAccessControlRecursiveResult;
187187
using CreateDirectoryResult = CreatePathResult;
188188
using DeleteDirectoryResult = PathDeleteResult;
189189

sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/protocol/datalake_rest_client.hpp

Lines changed: 213 additions & 11 deletions
Large diffs are not rendered by default.

sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,21 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
196196
return DataLakeRestClient::Path::Delete(
197197
m_dfsUri, *m_pipeline, options.Context, protocolLayerOptions);
198198
}
199+
200+
Azure::Core::Response<SetDirectoryAccessControlRecursiveResult>
201+
DirectoryClient::SetAccessControlRecursive(
202+
PathSetAccessControlRecursiveMode mode,
203+
std::vector<Acl> acls,
204+
const SetDirectoryAccessControlRecursiveOptions& options) const
205+
{
206+
DataLakeRestClient::Path::SetAccessControlRecursiveOptions protocolLayerOptions;
207+
protocolLayerOptions.Mode = mode;
208+
protocolLayerOptions.Continuation = options.Continuation;
209+
protocolLayerOptions.MaxRecords = options.MaxRecords;
210+
protocolLayerOptions.ForceFlag = options.ForceFlag;
211+
protocolLayerOptions.Acl = Acl::SerializeAcls(acls);
212+
return DataLakeRestClient::Path::SetAccessControlRecursive(
213+
m_dfsUri, *m_pipeline, options.Context, protocolLayerOptions);
214+
}
215+
199216
}}}} // namespace Azure::Storage::Files::DataLake

sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
105105
{
106106
auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString);
107107
auto fileUri = std::move(parsedConnectionString.DataLakeServiceUri);
108-
fileUri.AppendPath(fileSystemName, true);
109-
fileUri.AppendPath(filePath, true);
108+
fileUri.AppendPath(fileSystemName);
109+
fileUri.AppendPath(filePath);
110110

111111
if (parsedConnectionString.KeyCredential)
112112
{

sdk/storage/azure-storage-files-datalake/test/datalake_directory_client_test.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,42 @@ namespace Azure { namespace Storage { namespace Test {
295295
}
296296
}
297297

298+
TEST_F(DataLakeDirectoryClientTest, DirectorySetAccessControlRecursive)
299+
{
300+
// Setup directories.
301+
auto rootDirectoryName = LowercaseRandomString();
302+
auto directoryName1 = LowercaseRandomString();
303+
auto directoryName2 = LowercaseRandomString();
304+
auto rootDirectoryClient = m_fileSystemClient->GetDirectoryClient(rootDirectoryName);
305+
rootDirectoryClient.Create();
306+
auto directoryClient1
307+
= m_fileSystemClient->GetDirectoryClient(rootDirectoryName + "/" + directoryName1);
308+
directoryClient1.Create();
309+
auto directoryClient2
310+
= m_fileSystemClient->GetDirectoryClient(rootDirectoryName + "/" + directoryName2);
311+
directoryClient2.Create();
312+
313+
{
314+
// Set/Get Acls recursive works.
315+
std::vector<Files::DataLake::Acl> acls = GetValidAcls();
316+
EXPECT_NO_THROW(directoryClient1.SetAccessControl(acls));
317+
EXPECT_NO_THROW(rootDirectoryClient.SetAccessControlRecursive(
318+
Files::DataLake::PathSetAccessControlRecursiveMode::Modify, acls));
319+
std::vector<Files::DataLake::Acl> resultAcls1;
320+
std::vector<Files::DataLake::Acl> resultAcls2;
321+
EXPECT_NO_THROW(resultAcls1 = directoryClient1.GetAccessControls()->Acls);
322+
EXPECT_NO_THROW(resultAcls2 = directoryClient2.GetAccessControls()->Acls);
323+
for (const auto& acl : resultAcls2)
324+
{
325+
auto iter = std::find_if(
326+
resultAcls1.begin(), resultAcls1.end(), [&acl](const Files::DataLake::Acl& targetAcl) {
327+
return (targetAcl.Type == acl.Type) && (targetAcl.Id == acl.Id)
328+
&& (targetAcl.Scope == acl.Scope);
329+
});
330+
EXPECT_TRUE(iter != resultAcls1.end());
331+
EXPECT_EQ(iter->Permissions, acl.Permissions);
332+
}
333+
}
334+
}
335+
298336
}}} // namespace Azure::Storage::Test

0 commit comments

Comments
 (0)