Skip to content

Commit

Permalink
Remove Create/Get SymbolicLink API
Browse files Browse the repository at this point in the history
  • Loading branch information
microzchang committed Dec 13, 2024
1 parent 5f41928 commit e3f04c9
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,30 +379,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const UploadFileRangeFromUriOptions& options = UploadFileRangeFromUriOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

/**
* @brief NFS only. Creates a symbolic link to the file specified by path.
* @param linkText The absolution or relative path to the file to be linked to.
* @param options Optional parameters to create this file's symbolic link.
* @param context Context for cancelling long running operations.
* @return Azure::Response<Models::CreateFileSymbolicLinkResult> containing the returned
* information.
*/
Azure::Response<Models::CreateFileSymbolicLinkResult> CreateSymbolicLink(
const std::string& linkText,
const CreateSymbolicLinkOptions& options = CreateSymbolicLinkOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

/**
* @brief NFS only. Reads the value of the symbolic link.
* @param options Optional parameters to get this file's symbolic link.
* @param context Context for cancelling long running operations.
* @return Azure::Response<Models::GetFileSymbolicLinkResult> containing the returned
* information.
*/
Azure::Response<Models::GetFileSymbolicLinkResult> GetSymbolicLink(
const GetSymbolicLinkOptions& options = GetSymbolicLinkOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

/**
* @brief NFS only. Creates a hard link to the file specified by path.
* @param targetFile Path of the file to create the hard link to, not including the share.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1387,53 +1387,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
};

/**
* @brief Optional parameters for
* #Azure::Storage::Files::Shares::ShareFileClient::CreateSymbolicLink.
*/
struct CreateSymbolicLinkOptions final
{
/**
* A name-value pair to associate with a file storage object.
*/
Storage::Metadata Metadata;

/**
* Creation time for the file or directory.
*/
Nullable<DateTime> CreatedOn;

/**
* Last write time for the file or directory.
*/
Nullable<DateTime> LastWrittenOn;

/**
* Specify the access condition for the path.
*/
LeaseAccessConditions AccessConditions;

/**
* NFS only. The owner user identifier (UID) to be set on the symbolic link. The default value
* is 0 (root).
*/
Nullable<std::string> Owner;

/**
* NFS only. The owner group identifier (GID) to be set on the symbolic link. The default value
* is 0 (root group).
*/
Nullable<std::string> Group;
};

/**
* @brief Optional parameters for
* #Azure::Storage::Files::Shares::ShareFileClient::GetSymbolicLink.
*/
struct GetSymbolicLinkOptions final
{
};

/**
* @brief Optional parameters for
* #Azure::Storage::Files::Shares::ShareFileClient::CreateHardLink.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,55 +591,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
FilePosixProperties NfsProperties;
};

/**
* @brief Response type for #Azure::Storage::Files::Shares::ShareFileClient::CreateSymbolicLink.
*/
struct CreateFileSymbolicLinkResult final
{
/**
* The ETag contains a value which represents the version of the file, in quotes.
*/
Azure::ETag ETag;

/**
* Returns the date and time the share was last modified. Any operation that modifies the
* directory or its properties updates the last modified time. Operations on files do not
* affect the last modified time of the directory.
*/
DateTime LastModified;

/**
* The SMB related properties for the file.
*/
FileSmbProperties SmbProperties;

/**
* The NFS related properties for the file.
*/
FilePosixProperties NfsProperties;
};
/**
* @brief Response type for #Azure::Storage::Files::Shares::ShareFileClient::GetSymbolicLink.
*/
struct GetFileSymbolicLinkResult final
{
/**
* The ETag contains a value which represents the version of the file, in quotes.
*/
Azure::ETag ETag;
/**
* Returns the date and time the share was last modified. Any operation that modifies the
* directory or its properties updates the last modified time. Operations on files do not
* affect the last modified time of the directory.
*/
DateTime LastModified;
/**
* The path to the original file, the symbolic link is pointing to. The path is of type
* string which is not resolved and is stored as is. The path can be absolute path or the
* relative path depending on the content stored in the symbolic link file.
*/
std::string LinkText;
};
/**
* @brief Response type for #Azure::Storage::Files::Shares::ShareFileClient::CreateHardLink.
*/
Expand Down
59 changes: 0 additions & 59 deletions sdk/storage/azure-storage-files-shares/src/share_file_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,65 +1434,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);
}

Azure::Response<Models::CreateFileSymbolicLinkResult> ShareFileClient::CreateSymbolicLink(
const std::string& linkText,
const CreateSymbolicLinkOptions& options,
const Azure::Core::Context& context) const
{
_detail::FileClient::CreateFileSymbolicLinkOptions protocolLayerOptions;
protocolLayerOptions.LinkText = linkText;
if (options.CreatedOn.HasValue())
{
protocolLayerOptions.FileCreationTime = options.CreatedOn.Value().ToString(
Azure::DateTime::DateFormat::Rfc3339, DateTime::TimeFractionFormat::AllDigits);
}

if (options.LastWrittenOn.HasValue())
{
protocolLayerOptions.FileLastWriteTime = options.LastWrittenOn.Value().ToString(
Azure::DateTime::DateFormat::Rfc3339, DateTime::TimeFractionFormat::AllDigits);
}

protocolLayerOptions.FileRequestIntent = m_shareTokenIntent;
protocolLayerOptions.Owner = options.Owner;
protocolLayerOptions.Group = options.Group;
protocolLayerOptions.Metadata
= std::map<std::string, std::string>(options.Metadata.begin(), options.Metadata.end());
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;

auto response = _detail::FileClient::CreateSymbolicLink(
*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);

Models::CreateFileSymbolicLinkResult ret;
ret.ETag = std::move(response.Value.ETag);
ret.SmbProperties = std::move(response.Value.SmbProperties);
ret.LastModified = std::move(response.Value.LastModified);
ret.NfsProperties.FileMode = Models::NfsFileMode::ParseOctalFileMode(response.Value.FileMode);
ret.NfsProperties.Owner = std::move(response.Value.Owner);
ret.NfsProperties.Group = std::move(response.Value.Group);
ret.NfsProperties.NfsFileType = std::move(response.Value.NfsFileType);
return Azure::Response<Models::CreateFileSymbolicLinkResult>(
std::move(ret), std::move(response.RawResponse));
}

Azure::Response<Models::GetFileSymbolicLinkResult> ShareFileClient::GetSymbolicLink(
const GetSymbolicLinkOptions& options,
const Azure::Core::Context& context) const
{
(void)options;
_detail::FileClient::GetFileSymbolicLinkOptions protocolLayerOptions;
protocolLayerOptions.FileRequestIntent = m_shareTokenIntent;
auto response = _detail::FileClient::GetSymbolicLink(
*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);

Models::GetFileSymbolicLinkResult ret;
ret.ETag = std::move(response.Value.ETag);
ret.LastModified = std::move(response.Value.LastModified);
ret.LinkText = std::move(response.Value.LinkText);
return Azure::Response<Models::GetFileSymbolicLinkResult>(
std::move(ret), std::move(response.RawResponse));
}

Azure::Response<Models::CreateFileHardLinkResult> ShareFileClient::CreateHardLink(
const std::string& targetFile,
const CreateHardLinkOptions& options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2328,55 +2328,6 @@ namespace Azure { namespace Storage { namespace Test {
setOptions.NfsProperties.Owner.Value());
EXPECT_TRUE(downloadToResult.Details.NfsProperties.LinkCount.HasValue());

// Create SymbolicLink
std::string sourceUrl = fileClient.GetUrl();
auto symbolicLinkClient
= shareClient.GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
Files::Shares::CreateSymbolicLinkOptions createSymbolicLinkOptions;
createSymbolicLinkOptions.CreatedOn = otherProperties.SmbProperties.CreatedOn;
createSymbolicLinkOptions.LastWrittenOn = otherProperties.SmbProperties.LastWrittenOn;

createSymbolicLinkOptions.Metadata = RandomMetadata();
createSymbolicLinkOptions.Group = "123";
createSymbolicLinkOptions.Owner = "456";
Files::Shares::Models::CreateFileSymbolicLinkResult createSymbolicLinkResult;
EXPECT_NO_THROW(
createSymbolicLinkResult
= symbolicLinkClient.CreateSymbolicLink(sourceUrl, createSymbolicLinkOptions).Value);
EXPECT_TRUE(createSymbolicLinkResult.NfsProperties.FileMode.HasValue());
EXPECT_EQ(createSymbolicLinkResult.NfsProperties.FileMode.Value().ToOctalFileMode(), octalMode);
EXPECT_TRUE(createSymbolicLinkResult.NfsProperties.Group.HasValue());
EXPECT_EQ(
createSymbolicLinkResult.NfsProperties.Group.Value(),
createSymbolicLinkOptions.Group.Value());
EXPECT_TRUE(createSymbolicLinkResult.NfsProperties.FileMode.HasValue());
EXPECT_EQ(
createSymbolicLinkResult.NfsProperties.Owner.Value(),
createSymbolicLinkOptions.Owner.Value());
EXPECT_TRUE(createSymbolicLinkResult.NfsProperties.NfsFileType.HasValue());
EXPECT_EQ(
createSymbolicLinkResult.NfsProperties.NfsFileType.Value(),
Files::Shares::Models::NfsFileType::SymLink);
EXPECT_EQ(
createSymbolicLinkResult.SmbProperties.CreatedOn.Value(),
createSymbolicLinkOptions.CreatedOn.Value());
EXPECT_EQ(
createSymbolicLinkResult.SmbProperties.LastWrittenOn.Value(),
createSymbolicLinkOptions.LastWrittenOn.Value());
EXPECT_TRUE(createSymbolicLinkResult.SmbProperties.ChangedOn.HasValue());
EXPECT_TRUE(!createSymbolicLinkResult.SmbProperties.FileId.empty());
EXPECT_TRUE(!createSymbolicLinkResult.SmbProperties.ParentFileId.empty());
EXPECT_TRUE(createSymbolicLinkResult.ETag.HasValue());

// Get SymbolicLink
Files::Shares::Models::GetFileSymbolicLinkResult getSymbolicLinkResult;
EXPECT_NO_THROW(getSymbolicLinkResult = symbolicLinkClient.GetSymbolicLink().Value);
EXPECT_TRUE(getSymbolicLinkResult.ETag.HasValue());
if (!m_testContext.IsPlaybackMode())
{
EXPECT_EQ(getSymbolicLinkResult.LinkText, sourceUrl);
}

// Create HardLink
auto hardLinkClient
= shareClient.GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
Expand All @@ -2401,10 +2352,10 @@ namespace Azure { namespace Storage { namespace Test {
Files::Shares::Models::NfsFileType::Regular);
EXPECT_TRUE(createFileHardLinkResult.SmbProperties.CreatedOn.HasValue());
EXPECT_TRUE(createFileHardLinkResult.SmbProperties.LastWrittenOn.HasValue());
EXPECT_TRUE(createSymbolicLinkResult.SmbProperties.ChangedOn.HasValue());
EXPECT_TRUE(!createSymbolicLinkResult.SmbProperties.FileId.empty());
EXPECT_TRUE(!createSymbolicLinkResult.SmbProperties.ParentFileId.empty());
EXPECT_TRUE(createSymbolicLinkResult.ETag.HasValue());
EXPECT_TRUE(createFileHardLinkResult.SmbProperties.ChangedOn.HasValue());
EXPECT_TRUE(!createFileHardLinkResult.SmbProperties.FileId.empty());
EXPECT_TRUE(!createFileHardLinkResult.SmbProperties.ParentFileId.empty());
EXPECT_TRUE(createFileHardLinkResult.ETag.HasValue());

// Delete
Files::Shares::Models::DeleteFileResult deleteResult;
Expand Down

0 comments on commit e3f04c9

Please sign in to comment.