forked from Azure/azure-sdk-for-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventhubs_admin_client.hpp
More file actions
272 lines (242 loc) · 9.03 KB
/
eventhubs_admin_client.hpp
File metadata and controls
272 lines (242 loc) · 9.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <azure/core/context.hpp>
#include <azure/core/internal/http/pipeline.hpp>
#include <azure/core/internal/json/json.hpp>
#include <azure/core/operation.hpp>
#include <azure/core/test/test_base.hpp>
#include <string>
#include <vector>
namespace Azure { namespace Messaging { namespace EventHubs { namespace Test {
// Derived from Azure::Core::Test::TestBase to get access to GetTestCredential, which has logic to
// add the pipeline credential when run in CI.
class EventHubsManagement : Azure::Core::Test::TestBase {
public:
enum class EventHubsPricingTier
{
Premium,
Standard,
Basic
};
EventHubsManagement();
~EventHubsManagement() = default;
struct NamespaceIdentity
{
};
enum class SystemDataByType
{
User,
Application,
ManagedIdentity,
Key,
};
struct NamespaceSystemData
{
std::string CreatedBy;
SystemDataByType CreatedByType;
std::string CreatedAt;
std::string LastModifiedBy;
SystemDataByType LastModifiedByType;
std::string LastModifiedAt;
static NamespaceSystemData Deserialize(Azure::Core::Json::_internal::json const& json);
};
struct NamespaceProperties
{
std::string MinimumTlsVersion;
std::string ProvisioningState;
std::string Status;
std::string CreatedAt;
std::string UpdatedAt;
std::string ServiceBusEndpoint;
std::string ClusterArmId;
std::string MetricId;
bool IsAutoInflateEnabled;
std::string PublicNetworkAccess;
std::int32_t MaximumThroughputUnits;
bool KafkaEnabled;
bool ZoneRedundant;
// NamespaceEncryption Encryption; - SKIPPED.
// PrivateEndpointConnections - SKIPPED.
bool DisableLocalAuth;
std::string AlternateName;
static NamespaceProperties Deserialize(Azure::Core::Json::_internal::json const& json);
};
struct NamespaceSku
{
std::string PricingTier;
std::string Name;
std::int32_t Capacity;
static NamespaceSku Deserialize(Azure::Core::Json::_internal::json const& json);
};
struct EventHubsNamespace
{
NamespaceSku Sku;
NamespaceIdentity Identity;
NamespaceSystemData SystemData;
NamespaceProperties Properties;
std::int32_t Capacity;
std::string Name;
std::string Location;
std::map<std::string, std::string> Tags;
std::string Id;
std::string Type;
static EventHubsNamespace Deserialize(Azure::Core::Json::_internal::json const& json);
};
class EventHubsCreateOrUpdateOperation : public Azure::Core::Operation<EventHubsNamespace> {
public:
EventHubsCreateOrUpdateOperation(
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> pipeline,
Azure::Core::Json::_internal::json const& jsonCreateResult);
private:
void UpdateStatus();
// Inherited via Operation
std::unique_ptr<Azure::Core::Http::RawResponse> PollInternal(
Azure::Core::Context const& context) override;
Response<EventHubsNamespace> PollUntilDoneInternal(
std::chrono::milliseconds period,
Azure::Core::Context& context) override;
EventHubsNamespace Value() const override;
std::string GetResumeToken() const override;
EventHubsNamespace m_namespaceInfo;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
};
class EventHubsDeleteOperation : public Azure::Core::Operation<bool> {
public:
EventHubsDeleteOperation(
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> pipeline,
std::string const& pollingLocation);
private:
// Inherited via Operation
std::unique_ptr<Azure::Core::Http::RawResponse> PollInternal(
Azure::Core::Context const& context) override;
Response<bool> PollUntilDoneInternal(
std::chrono::milliseconds period,
Azure::Core::Context& context) override;
bool Value() const override;
std::string GetResumeToken() const override;
std::string m_pollingUrl;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
};
class Namespace;
struct EventHubCreationOptions
{
std::string Namespace;
std::string Name;
std::string ResourceGroup;
std::string SubscriptionId;
};
class EventHub {
EventHub(
EventHubCreationOptions const& options,
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> pipeline)
: m_namespace{options.Namespace}, m_name(options.Name),
m_resourceGroup(options.ResourceGroup), m_subscriptionId{options.SubscriptionId},
m_pipeline{pipeline}
{
}
public:
std::string const& Name() const { return m_name; }
std::string const& ResourceGroup() const { return m_resourceGroup; }
bool CreateConsumerGroup(
std::string const& consumerGroupName,
Azure::Core::Context const& context = {});
bool DeleteConsumerGroup(
std::string const& consumerGroupName,
Azure::Core::Context const& context = {});
bool DoesConsumerGroupExist(
std::string const& consumerGroupName,
Azure::Core::Context const& context = {});
private:
std::string m_namespace;
std::string m_name;
std::string m_resourceGroup;
std::string m_subscriptionId;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
friend class EventHubsManagement;
friend class EventHubsManagement::Namespace;
};
struct CreateEventHubOptions
{
/// <summary>
/// Blob naming convention for archive, e.g.
/// {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here
/// all the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order.
/// </summary>
std::string ArchiveNameFormat;
std::string BlobContainerName;
std::chrono::seconds CaptureInterval;
std::uint32_t CaptureSizeLimit;
std::string DestinationName; // Should be EventHubArchive.AzureBlockBlob.
bool EnableCapture;
bool EnableSystemAssignedIdentity;
std::vector<std::string> UserAssignedIdentityIds;
std::int8_t PartitionCount;
std::int32_t RetentionPeriodInHours;
bool SkipEmptyArchives;
std::string Status; // One of Active, Disabled, SendDisabled.
std::string StorageAccount;
std::int32_t TombstoneRetentionTimeInHours;
};
struct ConsumerGroup
{
Azure::DateTime CreatedAt;
Azure::DateTime UpdatedAt;
std::string UserMetadata;
};
class Namespace {
Namespace(
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> pipeline,
std::string const& name,
std::string const& resourceGroup,
std::string const& subscriptionId,
Azure::Core::Context const& context);
public:
std::string const& Name() const { return m_name; }
std::string const& ResourceGroup() const { return m_resourceGroup; }
std::vector<std::string> ListEventHubs(Azure::Core::Context const& context = {});
EventHub CreateEventHub(
std::string const& eventHubName,
CreateEventHubOptions const& options = {},
Azure::Core::Context const& context = {});
bool DeleteEventHub(
std::string const& eventHubName,
Azure::Core::Context const& context = {});
bool DoesEventHubExist(
std::string const& eventHubName,
Azure::Core::Context const& context = {});
ConsumerGroup CreateConsumerGroup(
std::string const& eventHubName,
std::string const& consumerGroupName,
Azure::Core::Context const& context = {});
private:
std::string m_name;
std::string m_resourceGroup;
std::string m_subscriptionId;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
friend class EventHubsManagement;
};
EventHubsCreateOrUpdateOperation CreateNamespace(
std::string const& namespaceName,
EventHubsPricingTier pricingTier = EventHubsPricingTier::Standard,
Azure::Core::Context const& context = {});
EventHubsDeleteOperation DeleteNamespace(
std::string const& namespaceName,
bool force = false,
Azure::Core::Context const& context = {});
Namespace GetNamespace(
std::string const& namespaceName,
Azure::Core::Context const& context = {});
std::vector<std::string> ListNamespaces(Azure::Core::Context const& context = {});
bool DoesNamespaceExist(
std::string const& namespaceName,
Azure::Core::Context const& context = {});
private:
// Dummy test body to satisfy Azure::Core::Test::TestBase.
void TestBody() {}
std::string m_resourceGroup;
std::string m_location;
std::string m_subscriptionId;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
};
}}}} // namespace Azure::Messaging::EventHubs::Test