azure-data-tables
Loading...
Searching...
No Matches
tables_sas_builder.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include "azure/data/tables/account_sas_builder.hpp"
7#include "azure/data/tables/credentials/named_key_credential.hpp"
9
10#include <azure/core/datetime.hpp>
11#include <azure/core/nullable.hpp>
12
13#include <string>
14#include <type_traits>
15
16namespace Azure { namespace Data { namespace Tables { namespace Sas {
17
22 enum class TablesSasPermissions
23 {
27 Read = 1,
31 Add = 2,
35 Delete = 4,
39 Update = 8,
43 All = ~0
44 };
45
50 class TablesSasBuilder final {
51 public:
56 SasProtocol Protocol;
57
62 Azure::Nullable<Azure::DateTime> StartsOn;
63
69 Azure::DateTime ExpiresOn;
70
77 Azure::Nullable<std::string> IPRange;
78
83 std::string Identifier;
84
88 std::string TableName;
89
93 std::string PartitionKeyStart;
94
98 std::string PartitionKeyEnd;
99
103 std::string RowKeyStart;
104
108 std::string RowKeyEnd;
109
115 void SetPermissions(TablesSasPermissions permissions);
116
122 void SetPermissions(std::string rawPermissions) { Permissions = std::move(rawPermissions); }
123
131 std::string GenerateSasToken(
133
140 std::string GetCanonicalName(
142 {
143 return Azure::Core::_internal::StringExtensions::ToLower(
144 "/table/" + credential.AccountName + "/" + TableName);
145 }
146
147 private:
148 std::string Permissions;
149 };
150
151}}}} // namespace Azure::Data::Tables::Sas
A NamedKeyCredential is a credential backed by an account's name and one of its access keys.
Definition named_key_credential.hpp:26
const std::string AccountName
The name of the Account.
Definition named_key_credential.hpp:55
TableSasBuilder is used to generate a Shared Access Signature (SAS) for an Azure Storage Tables.
Definition tables_sas_builder.hpp:50
std::string PartitionKeyEnd
The optional end of the partition key values range being made available.
Definition tables_sas_builder.hpp:98
void SetPermissions(TablesSasPermissions permissions)
Sets the permissions for the table SAS.
Definition tables_sas_builder.cpp:17
std::string GenerateSasToken(const Azure::Data::Tables::Credentials::NamedKeyCredential &credential)
Uses the NamedKeyCredential to sign this shared access signature, to produce the proper SAS query par...
Definition tables_sas_builder.cpp:39
std::string GetCanonicalName(const Azure::Data::Tables::Credentials::NamedKeyCredential &credential) const
Gets the canonical path for the shared access signature.
Definition tables_sas_builder.hpp:140
void SetPermissions(std::string rawPermissions)
Sets the permissions for the SAS using a raw permissions string.
Definition tables_sas_builder.hpp:122
Azure::DateTime ExpiresOn
The time at which the shared access signature becomes invalid. This field must be omitted if it has b...
Definition tables_sas_builder.hpp:69
Azure::Nullable< Azure::DateTime > StartsOn
Optionally specify the time at which the shared access signature becomes valid. This timestamp will b...
Definition tables_sas_builder.hpp:62
std::string RowKeyStart
The optional start of the row key values range being made available.
Definition tables_sas_builder.hpp:103
std::string PartitionKeyStart
The optional start of the partition key values range being made available.
Definition tables_sas_builder.hpp:93
SasProtocol Protocol
The optional signed protocol field specifies the protocol permitted for a request made with the SAS.
Definition tables_sas_builder.hpp:56
std::string Identifier
An optional unique value up to 64 characters in length that correlates to an access policy specified ...
Definition tables_sas_builder.hpp:83
std::string TableName
The name of the table being made accessible.
Definition tables_sas_builder.hpp:88
std::string RowKeyEnd
The optional end of the partition key values range being made available.
Definition tables_sas_builder.hpp:108
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 tables_sas_builder.hpp:77
Defines bitwise operators for enums.