-
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 ServiceBus resources * api * fix * cspell
- Loading branch information
1 parent
3321d49
commit dd8060e
Showing
13 changed files
with
365 additions
and
2 deletions.
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
60 changes: 60 additions & 0 deletions
60
sdk/provisioning/Azure.Provisioning/src/servicebus/ServiceBusNamespace.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,60 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Azure.Provisioning.ResourceManager; | ||
using Azure.Provisioning.Storage; | ||
using Azure.ResourceManager.ServiceBus; | ||
using Azure.ResourceManager.ServiceBus.Models; | ||
|
||
namespace Azure.Provisioning.ServiceBus | ||
{ | ||
/// <summary> | ||
/// Represents a Service Bus namespace. | ||
/// </summary> | ||
public class ServiceBusNamespace : Resource<ServiceBusNamespaceData> | ||
{ | ||
private const string ResourceTypeName = "Microsoft.ServiceBus/namespaces"; | ||
private static readonly Func<string, ServiceBusNamespaceData> Empty = (name) => ArmServiceBusModelFactory.ServiceBusNamespaceData(); | ||
internal const string DefaultVersion = "2021-11-01"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ServiceBusNamespace"/>. | ||
/// </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 ServiceBusNamespace(IConstruct scope, ServiceBusSku? sku = default, ResourceGroup? parent = null, string name = "sb", string version = DefaultVersion, AzureLocation? location = default) | ||
: this(scope, parent, name, version, false, (name) => ArmServiceBusModelFactory.ServiceBusNamespaceData( | ||
name: name, | ||
resourceType: ResourceTypeName, | ||
location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, | ||
sku: sku ?? new ServiceBusSku(ServiceBusSkuName.Standard), | ||
minimumTlsVersion: ServiceBusMinimumTlsVersion.Tls1_2)) | ||
{ | ||
AssignProperty(data => data.Name, GetAzureName(scope, name)); | ||
} | ||
|
||
private ServiceBusNamespace(IConstruct scope, ResourceGroup? parent = null, string name = "sb", string version = DefaultVersion, bool isExisting = true, Func<string, ServiceBusNamespaceData>? creator = null) | ||
: base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of the <see cref="ServiceBusNamespace"/> 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 ServiceBusNamespace FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) | ||
=> new ServiceBusNamespace(scope, parent: parent, name: name, isExisting: true); | ||
|
||
/// <inheritdoc/> | ||
protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
sdk/provisioning/Azure.Provisioning/src/servicebus/ServiceBusQueue.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,60 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Azure.Provisioning.ResourceManager; | ||
using Azure.Provisioning.Storage; | ||
using Azure.ResourceManager.ServiceBus; | ||
using Azure.ResourceManager.ServiceBus.Models; | ||
|
||
namespace Azure.Provisioning.ServiceBus | ||
{ | ||
/// <summary> | ||
/// Represents a Service Bus queue. | ||
/// </summary> | ||
public class ServiceBusQueue : Resource<ServiceBusQueueData> | ||
{ | ||
private const string ResourceTypeName = "Microsoft.ServiceBus/namespaces/queues"; | ||
private static readonly Func<string, ServiceBusQueueData> Empty = (name) => ArmServiceBusModelFactory.ServiceBusQueueData(); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ServiceBusQueue"/>. | ||
/// </summary> | ||
/// <param name="scope">The scope.</param> | ||
/// <param name="requiresSession">Whether to use sessions.</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 ServiceBusQueue(IConstruct scope, bool? requiresSession = default, ServiceBusNamespace? parent = null, string name = "queue", string version = ServiceBusNamespace.DefaultVersion, AzureLocation? location = default) | ||
: this(scope, parent, name, version, false, (name) => ArmServiceBusModelFactory.ServiceBusQueueData( | ||
name: name, | ||
requiresSession: requiresSession, | ||
resourceType: ResourceTypeName, | ||
location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS)) | ||
{ | ||
} | ||
|
||
private ServiceBusQueue(IConstruct scope, ServiceBusNamespace? parent = null, string name = "queue", string version = ServiceBusNamespace.DefaultVersion, bool isExisting = true, Func<string, ServiceBusQueueData>? creator = null) | ||
: base(scope, parent, name, ResourceTypeName, ServiceBusNamespace.DefaultVersion, creator ?? Empty, isExisting) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of the <see cref="ServiceBusQueue"/> 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 ServiceBusQueue FromExisting(IConstruct scope, string name, ServiceBusNamespace parent) | ||
=> new ServiceBusQueue(scope, parent: parent, name: name, isExisting: true); | ||
|
||
/// <inheritdoc/> | ||
protected override Resource? FindParentInScope(IConstruct scope) | ||
{ | ||
return scope.GetSingleResource<ServiceBusNamespace>() ?? new ServiceBusNamespace(scope); | ||
} | ||
} | ||
} |
Oops, something went wrong.