-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add EventHubs resources * rename * Add test cases
- Loading branch information
1 parent
d61f695
commit 4266e1f
Showing
12 changed files
with
324 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
sdk/provisioning/Azure.Provisioning/src/eventhubs/EventHub.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Azure.ResourceManager.EventHubs; | ||
using Azure.ResourceManager.EventHubs.Models; | ||
|
||
namespace Azure.Provisioning.EventHubs | ||
{ | ||
/// <summary> | ||
/// Represents an Event Hub. | ||
/// </summary> | ||
public class EventHub : Resource<EventHubData> | ||
{ | ||
private const string ResourceTypeName = "Microsoft.EventHub/namespaces/eventhubs"; | ||
private static readonly Func<string, EventHubData> Empty = (name) => ArmEventHubsModelFactory.EventHubData(); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EventHub"/>. | ||
/// </summary> | ||
/// <param name="scope">The scope.</param> | ||
/// <param name="parent">The parent.</param> | ||
/// <param name="name">The name.</param> | ||
/// <param name="version">The version.</param> | ||
/// <param name="location">The location.</param> | ||
public EventHub(IConstruct scope, EventHubsNamespace? parent = null, string name = "hub", string version = EventHubsNamespace.DefaultVersion, AzureLocation? location = default) | ||
: this(scope, parent, name, version, false, (name) => ArmEventHubsModelFactory.EventHubData( | ||
name: name, | ||
resourceType: ResourceTypeName, | ||
location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS)) | ||
{ | ||
} | ||
|
||
private EventHub(IConstruct scope, EventHubsNamespace? parent = null, string name = "hub", string version = EventHubsNamespace.DefaultVersion, bool isExisting = true, Func<string, EventHubData>? creator = null) | ||
: base(scope, parent, name, ResourceTypeName, EventHubsNamespace.DefaultVersion, creator ?? Empty, isExisting) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of the <see cref="EventHub"/> class referencing an existing instance. | ||
/// </summary> | ||
/// <param name="scope">The scope.</param> | ||
/// <param name="name">The resource name.</param> | ||
/// <param name="parent">The resource group.</param> | ||
/// <returns>The KeyVault instance.</returns> | ||
public static EventHub FromExisting(IConstruct scope, string name, EventHubsNamespace parent) | ||
=> new EventHub(scope, parent: parent, name: name, isExisting: true); | ||
|
||
/// <inheritdoc/> | ||
protected override Resource? FindParentInScope(IConstruct scope) | ||
{ | ||
return scope.GetSingleResource<EventHubsNamespace>() ?? new EventHubsNamespace(scope); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
sdk/provisioning/Azure.Provisioning/src/eventhubs/EventHubsConsumerGroup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Azure.ResourceManager.EventHubs; | ||
using Azure.ResourceManager.EventHubs.Models; | ||
|
||
namespace Azure.Provisioning.EventHubs | ||
{ | ||
/// <summary> | ||
/// Represents an Event Hub consumer group. | ||
/// </summary> | ||
public class EventHubsConsumerGroup : Resource<EventHubsConsumerGroupData> | ||
{ | ||
private const string ResourceTypeName = "Microsoft.EventHub/namespaces/eventhubs/consumergroups"; | ||
private static readonly Func<string, EventHubsConsumerGroupData> Empty = (name) => ArmEventHubsModelFactory.EventHubsConsumerGroupData(); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EventHub"/>. | ||
/// </summary> | ||
/// <param name="scope">The scope.</param> | ||
/// <param name="parent">The parent.</param> | ||
/// <param name="name">The name.</param> | ||
/// <param name="version">The version.</param> | ||
/// <param name="location">The location.</param> | ||
public EventHubsConsumerGroup(IConstruct scope, EventHub? parent = null, string name = "hub", string version = EventHubsNamespace.DefaultVersion, AzureLocation? location = default) | ||
: this(scope, parent, name, version, false, (name) => ArmEventHubsModelFactory.EventHubsConsumerGroupData( | ||
name: name, | ||
resourceType: ResourceTypeName, | ||
location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS)) | ||
{ | ||
} | ||
|
||
private EventHubsConsumerGroup(IConstruct scope, EventHub? parent = null, string name = "hub", string version = EventHubsNamespace.DefaultVersion, bool isExisting = true, Func<string, EventHubsConsumerGroupData>? creator = null) | ||
: base(scope, parent, name, ResourceTypeName, EventHubsNamespace.DefaultVersion, creator ?? Empty, isExisting) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of the <see cref="EventHub"/> class referencing an existing instance. | ||
/// </summary> | ||
/// <param name="scope">The scope.</param> | ||
/// <param name="name">The resource name.</param> | ||
/// <param name="parent">The resource group.</param> | ||
/// <returns>The KeyVault instance.</returns> | ||
public static EventHubsConsumerGroup FromExisting(IConstruct scope, string name, EventHub parent) | ||
=> new EventHubsConsumerGroup(scope, parent: parent, name: name, isExisting: true); | ||
|
||
/// <inheritdoc/> | ||
protected override Resource? FindParentInScope(IConstruct scope) | ||
{ | ||
return scope.GetSingleResource<EventHub>() ?? new EventHub(scope); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
sdk/provisioning/Azure.Provisioning/src/eventhubs/EventHubsNamespace.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Azure.Provisioning.ResourceManager; | ||
using Azure.ResourceManager.EventHubs; | ||
using Azure.ResourceManager.EventHubs.Models; | ||
|
||
namespace Azure.Provisioning.EventHubs | ||
{ | ||
/// <summary> | ||
/// Represents an EventHubsNamespace. | ||
/// </summary> | ||
public class EventHubsNamespace : Resource<EventHubsNamespaceData> | ||
{ | ||
private const string ResourceTypeName = "Microsoft.EventHub/namespaces"; | ||
private static readonly Func<string, EventHubsNamespaceData> Empty = (name) => ArmEventHubsModelFactory.EventHubsNamespaceData(); | ||
internal const string DefaultVersion = "2021-11-01"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EventHubsNamespace"/>. | ||
/// </summary> | ||
/// <param name="scope">The scope.</param> | ||
/// <param name="sku">The sku.</param> | ||
/// <param name="parent">The parent.</param> | ||
/// <param name="name">The name.</param> | ||
/// <param name="version">The version.</param> | ||
/// <param name="location">The location.</param> | ||
public EventHubsNamespace(IConstruct scope, EventHubsSku? sku = default, ResourceGroup? parent = null, string name = "eh", string version = DefaultVersion, AzureLocation? location = default) | ||
: this(scope, parent, name, version, false, (name) => ArmEventHubsModelFactory.EventHubsNamespaceData( | ||
name: name, | ||
resourceType: ResourceTypeName, | ||
location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, | ||
sku: sku ?? new EventHubsSku(EventHubsSkuName.Standard), | ||
minimumTlsVersion: EventHubsTlsVersion.Tls1_2)) | ||
{ | ||
AssignProperty(data => data.Name, GetAzureName(scope, name)); | ||
} | ||
|
||
private EventHubsNamespace(IConstruct scope, ResourceGroup? parent = null, string name = "eh", string version = DefaultVersion, bool isExisting = true, Func<string, EventHubsNamespaceData>? creator = null) | ||
: base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of the <see cref="EventHubsNamespace"/> class referencing an existing instance. | ||
/// </summary> | ||
/// <param name="scope">The scope.</param> | ||
/// <param name="name">The resource name.</param> | ||
/// <param name="parent">The resource group.</param> | ||
/// <returns>The KeyVault instance.</returns> | ||
public static EventHubsNamespace FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) | ||
=> new EventHubsNamespace(scope, parent: parent, name: name, isExisting: true); | ||
|
||
/// <inheritdoc/> | ||
protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName); | ||
} | ||
} |
Oops, something went wrong.