azure-storage-files-datalake
Loading...
Searching...
No Matches
datalake_sas_builder.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include "azure/storage/files/datalake/datalake_responses.hpp"
7
8#include <azure/core/nullable.hpp>
9#include <azure/storage/common/account_sas_builder.hpp>
10
11#include <cstdint>
12#include <string>
13#include <type_traits>
14
15namespace Azure { namespace Storage { namespace Sas {
16
20 enum class DataLakeSasResource
21 {
26 FileSystem,
27
31 File,
32
37 Directory,
38 };
39
43 enum class DataLakeFileSystemSasPermissions
44 {
48 Read = 1,
49
53 Write = 2,
54
58 Delete = 4,
59
63 List = 8,
64
68 Add = 16,
69
73 Create = 32,
74
78 All = ~0,
79 };
80
81 inline DataLakeFileSystemSasPermissions operator|(
82 DataLakeFileSystemSasPermissions lhs,
83 DataLakeFileSystemSasPermissions rhs)
84 {
85 using type = std::underlying_type_t<DataLakeFileSystemSasPermissions>;
86 return static_cast<DataLakeFileSystemSasPermissions>(
87 static_cast<type>(lhs) | static_cast<type>(rhs));
88 }
89
90 inline DataLakeFileSystemSasPermissions operator&(
91 DataLakeFileSystemSasPermissions lhs,
92 DataLakeFileSystemSasPermissions rhs)
93 {
94 using type = std::underlying_type_t<DataLakeFileSystemSasPermissions>;
95 return static_cast<DataLakeFileSystemSasPermissions>(
96 static_cast<type>(lhs) & static_cast<type>(rhs));
97 }
98
102 enum class DataLakeSasPermissions
103 {
107 Read = 1,
108
112 Write = 2,
113
118 Delete = 4,
119
123 Add = 8,
124
128 Create = 16,
129
133 List = 32,
134
138 Move = 64,
139
144 Execute = 128,
145
150 ManageOwnership = 256,
151
155 ManageAccessControl = 512,
156
160 All = ~0,
161 };
162
163 inline DataLakeSasPermissions operator|(DataLakeSasPermissions lhs, DataLakeSasPermissions rhs)
164 {
165 using type = std::underlying_type_t<DataLakeSasPermissions>;
166 return static_cast<DataLakeSasPermissions>(static_cast<type>(lhs) | static_cast<type>(rhs));
167 }
168
169 inline DataLakeSasPermissions operator&(DataLakeSasPermissions lhs, DataLakeSasPermissions rhs)
170 {
171 using type = std::underlying_type_t<DataLakeSasPermissions>;
172 return static_cast<DataLakeSasPermissions>(static_cast<type>(lhs) & static_cast<type>(rhs));
173 }
174
180 {
185 SasProtocol Protocol;
186
191 Azure::Nullable<Azure::DateTime> StartsOn;
192
198 Azure::DateTime ExpiresOn;
199
206 Azure::Nullable<std::string> IPRange;
207
212 std::string Identifier;
213
217 std::string FileSystemName;
218
222 std::string Path;
223
229 bool IsDirectory = false;
230
237 Azure::Nullable<int32_t> DirectoryDepth;
238
242 DataLakeSasResource Resource;
243
247 std::string CacheControl;
248
253
257 std::string ContentEncoding;
258
262 std::string ContentLanguage;
263
267 std::string ContentType;
268
278
287 std::string AgentObjectId;
288
294 std::string CorrelationId;
295
299 std::string EncryptionScope;
300
306 void SetPermissions(DataLakeFileSystemSasPermissions permissions);
307
313 void SetPermissions(DataLakeSasPermissions permissions);
314
322 std::string GenerateSasToken(const StorageSharedKeyCredential& credential);
323
329 void SetPermissions(std::string rawPermissions) { Permissions = std::move(rawPermissions); }
330
340 std::string GenerateSasToken(
341 const Files::DataLake::Models::UserDelegationKey& userDelegationKey,
342 const std::string& accountName);
343
352 std::string GenerateSasStringToSign(const StorageSharedKeyCredential& credential);
353
364 const Blobs::Models::UserDelegationKey& userDelegationKey,
365 const std::string& accountName);
366
367 private:
368 std::string Permissions;
369 };
370
371}}} // namespace Azure::Storage::Sas
DataLakeSasBuilder is used to generate a Shared Access Signature (SAS) for an Azure Storage DataLake ...
Definition datalake_sas_builder.hpp:180
std::string ContentLanguage
Override the value returned for Content-Language response header.
Definition datalake_sas_builder.hpp:262
std::string PreauthorizedAgentObjectId
This value will be used for the AAD Object ID of a user authorized by the owner of the User Delegatio...
Definition datalake_sas_builder.hpp:277
std::string FileSystemName
The name of the filesystem being made accessible.
Definition datalake_sas_builder.hpp:217
std::string EncryptionScope
Optional encryption scope to use when sending requests authorized with this SAS url.
Definition datalake_sas_builder.hpp:299
std::string AgentObjectId
This value will be used for the AAD Object ID of a user authorized by the owner of the User Delegatio...
Definition datalake_sas_builder.hpp:287
DataLakeSasResource Resource
Specifies which resources are accessible via the shared access signature.
Definition datalake_sas_builder.hpp:242
void SetPermissions(DataLakeSasPermissions permissions)
Sets the permissions for the file SAS or directory SAS.
Azure::Nullable< std::string > IPRange
Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address f...
Definition datalake_sas_builder.hpp:206
std::string GenerateSasStringToSign(const Blobs::Models::UserDelegationKey &userDelegationKey, const std::string &accountName)
For debugging purposes only.
std::string ContentType
Override the value returned for Content-Type response header.
Definition datalake_sas_builder.hpp:267
Azure::DateTime ExpiresOn
The time at which the shared access signature becomes invalid. This field must be omitted if it has b...
Definition datalake_sas_builder.hpp:198
std::string Path
The name of the path being made accessible, or empty for a filesystem SAS.
Definition datalake_sas_builder.hpp:222
void SetPermissions(DataLakeFileSystemSasPermissions permissions)
Sets the permissions for the filesystem SAS.
void SetPermissions(std::string rawPermissions)
Sets the permissions for the SAS using a raw permissions string.
Definition datalake_sas_builder.hpp:329
std::string ContentEncoding
Override the value returned for Content-Encoding response header.
Definition datalake_sas_builder.hpp:257
std::string GenerateSasToken(const Files::DataLake::Models::UserDelegationKey &userDelegationKey, const std::string &accountName)
Uses an account's user delegation key to sign this shared access signature, to produce the proper SAS...
bool IsDirectory
Defines whether or not the Path is a directory. If this value is set to true, the Path is a directory...
Definition datalake_sas_builder.hpp:229
std::string CacheControl
Override the value returned for Cache-Control response header.
Definition datalake_sas_builder.hpp:247
Azure::Nullable< Azure::DateTime > StartsOn
Optionally specify the time at which the shared access signature becomes valid. This timestamp will b...
Definition datalake_sas_builder.hpp:191
std::string GenerateSasToken(const StorageSharedKeyCredential &credential)
Uses the StorageSharedKeyCredential to sign this shared access signature, to produce the proper SAS q...
std::string GenerateSasStringToSign(const StorageSharedKeyCredential &credential)
For debugging purposes only.
SasProtocol Protocol
The optional signed protocol field specifies the protocol permitted for a request made with the SAS.
Definition datalake_sas_builder.hpp:185
std::string Identifier
An optional unique value up to 64 characters in length that correlates to an access policy specified ...
Definition datalake_sas_builder.hpp:212
std::string CorrelationId
This value will be used for correlating the storage audit logs with the audit logs used by the princi...
Definition datalake_sas_builder.hpp:294
Azure::Nullable< int32_t > DirectoryDepth
Required when Resource is set to Directory to indicate the depth of the directory specified in the ca...
Definition datalake_sas_builder.hpp:237
std::string ContentDisposition
Override the value returned for Content-Disposition response header.
Definition datalake_sas_builder.hpp:252