Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Servicebus] az servicebus namespace replica: New command group to manage servicebus namespace replicas #29987

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interactions:
User-Agent:
- AZURECLI/2.64.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0)
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2022-10-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2023-01-01-preview
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006","name":"cli-test-resource-000006","type":"Microsoft.ServiceBus/Namespaces","location":"eastus","tags":{},"properties":{"premiumMessagingPartitions":1,"minimumTlsVersion":"1.2","publicNetworkAccess":"Enabled","disableLocalAuth":false,"zoneRedundant":false,"metricId":"0b1f6471-1bf0-4dda-aec3-cb9272f09590:cli-test-resource-000006","serviceBusEndpoint":"https://cli-test-resource-000006.servicebus.windows.net:443/","provisioningState":"Creating","status":"Creating","createdAt":"2024-09-14T13:15:26.0157336Z","updatedAt":"2024-09-14T13:15:26.0157336Z"},"sku":{"name":"Premium","tier":"Premium","capacity":1}}'
Expand Down Expand Up @@ -72,7 +72,7 @@ interactions:
User-Agent:
- AZURECLI/2.64.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2022-10-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2023-01-01-preview
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006","name":"cli-test-resource-000006","type":"Microsoft.ServiceBus/Namespaces","location":"eastus","tags":{},"properties":{"premiumMessagingPartitions":1,"minimumTlsVersion":"1.2","publicNetworkAccess":"Enabled","disableLocalAuth":false,"zoneRedundant":false,"metricId":"0b1f6471-1bf0-4dda-aec3-cb9272f09590:cli-test-resource-000006","serviceBusEndpoint":"https://cli-test-resource-000006.servicebus.windows.net:443/","provisioningState":"Creating","status":"Creating","createdAt":"2024-09-14T13:15:26.0157336Z","updatedAt":"2024-09-14T13:15:26.0157336Z"},"sku":{"name":"Premium","tier":"Premium","capacity":1}}'
Expand Down Expand Up @@ -122,7 +122,7 @@ interactions:
User-Agent:
- AZURECLI/2.64.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2022-10-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2023-01-01-preview
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006","name":"cli-test-resource-000006","type":"Microsoft.ServiceBus/Namespaces","location":"eastus","tags":{},"properties":{"premiumMessagingPartitions":1,"minimumTlsVersion":"1.2","publicNetworkAccess":"Enabled","disableLocalAuth":false,"zoneRedundant":false,"metricId":"0b1f6471-1bf0-4dda-aec3-cb9272f09590:cli-test-resource-000006","serviceBusEndpoint":"https://cli-test-resource-000006.servicebus.windows.net:443/","provisioningState":"Creating","status":"Creating","createdAt":"2024-09-14T13:15:26.0157336Z","updatedAt":"2024-09-14T13:15:26.0157336Z"},"sku":{"name":"Premium","tier":"Premium","capacity":1}}'
Expand Down Expand Up @@ -172,7 +172,7 @@ interactions:
User-Agent:
- AZURECLI/2.64.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2022-10-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2023-01-01-preview
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006","name":"cli-test-resource-000006","type":"Microsoft.ServiceBus/Namespaces","location":"eastus","tags":{},"properties":{"premiumMessagingPartitions":1,"minimumTlsVersion":"1.2","publicNetworkAccess":"Enabled","disableLocalAuth":false,"zoneRedundant":false,"metricId":"0b1f6471-1bf0-4dda-aec3-cb9272f09590:cli-test-resource-000006","serviceBusEndpoint":"https://cli-test-resource-000006.servicebus.windows.net:443/","provisioningState":"Succeeded","status":"Active","createdAt":"2024-09-14T13:15:26.0157336Z","updatedAt":"2024-09-14T13:16:09.2210478Z"},"sku":{"name":"Premium","tier":"Premium","capacity":1}}'
Expand Down Expand Up @@ -222,7 +222,7 @@ interactions:
User-Agent:
- AZURECLI/2.64.0 azsdk-python-core/1.28.0 Python/3.12.6 (Windows-11-10.0.22631-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2022-10-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006?api-version=2023-01-01-preview
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_private_endpoint_connection_service_bus000001/providers/Microsoft.ServiceBus/namespaces/cli-test-resource-000006","name":"cli-test-resource-000006","type":"Microsoft.ServiceBus/Namespaces","location":"eastus","tags":{},"properties":{"premiumMessagingPartitions":1,"minimumTlsVersion":"1.2","publicNetworkAccess":"Enabled","disableLocalAuth":false,"zoneRedundant":false,"metricId":"0b1f6471-1bf0-4dda-aec3-cb9272f09590:cli-test-resource-000006","serviceBusEndpoint":"https://cli-test-resource-000006.servicebus.windows.net:443/","provisioningState":"Succeeded","status":"Active","createdAt":"2024-09-14T13:15:26.0157336Z","updatedAt":"2024-09-14T13:16:09.2210478Z"},"sku":{"name":"Premium","tier":"Premium","capacity":1}}'
Expand Down Expand Up @@ -1278,4 +1278,4 @@ interactions:
status:
code: 202
message: Accepted
version: 1
version: 1
23 changes: 23 additions & 0 deletions src/azure-cli/azure/cli/command_modules/servicebus/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,29 @@
crafted: true
"""

helps['servicebus namespace replica'] = """
type: group
short-summary: Manage servicebus namespace replicas.
"""

helps['servicebus namespace replica add'] = """
type: command
short-summary: Add one or more Replica properties to a namespace.
examples:
- name: Add one or more Replica properties to a namespace.
text: |
az servicebus namespace replica add --namespace-name mynamespace -g MyResourceGroup --geo-data-replication-config role-type=Secondary location-name=mylocation
"""

helps['servicebus namespace replica remove'] = """
type: command
short-summary: Remove one or more Replica properties to a namespace.
examples:
- name: Remove one or more Replica properties to a namespace.
text: |
az servicebus namespace replica remove --namespace-name mynamespace -g MyResourceGroup --geo-data-replication-config role-type=Secondary location-name=mylocation
"""

helps['servicebus queue'] = """
type: group
short-summary: Manage Azure Service Bus Queue and Authorization Rule
Expand Down
14 changes: 14 additions & 0 deletions src/azure-cli/azure/cli/command_modules/servicebus/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def load_arguments_sb(self, _):
_validate_duplicate_detection_history_time_window, \
_validate_default_message_time_to_live, \
_validate_lock_duration, validate_partner_namespace, validate_premiumsku_capacity
from azure.cli.command_modules.servicebus.action import AlertAddlocation

(SkuName, FilterType, TlsVersion) = self.get_models('SkuName', 'FilterType', 'TlsVersion', resource_type=ResourceType.MGMT_SERVICEBUS)

Expand Down Expand Up @@ -48,6 +49,10 @@ def load_arguments_sb(self, _):
help='This determines if traffic is allowed over public network. By default it is enabled. If value is SecuredByPerimeter then Inbound and Outbound communication is controlled by the network security perimeter and profile\' access rules.')
c.argument('premium_messaging_partitions', options_list=['--premium-messaging-partitions', '--premium-partitions'], is_preview=True, type=int, help='The number of partitions of a Service Bus namespace. This property is only applicable to Premium SKU namespaces. The default value is 1 and possible values are 1, 2 and 4')
c.argument('alternate_name', help='Alternate name specified when alias and namespace names are same.')
c.argument('geo_data_replication_config', action=AlertAddlocation, nargs='+', options_list=['--geo-data-replication-config', '--replica-config'],
help='A list of regions where replicas of the namespace are maintained Object')
c.argument('max_replication_lag_duration_in_seconds', type=int, options_list=['--max-replication-lag-duration-in-seconds', '--max-lag'],
help='The maximum acceptable lag for data replication operations from the primary replica to a quorum of secondary replicas')

with self.argument_context('servicebus namespace create') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
Expand Down Expand Up @@ -151,3 +156,12 @@ def load_arguments_sb(self, _):
c.argument('require_infrastructure_encryption', options_list=['--infra-encryption'],
arg_type=get_three_state_flag(),
help='A boolean value that indicates whether Infrastructure Encryption (Double Encryption)')

# Location
with self.argument_context('servicebus namespace replica', resource_type=ResourceType.MGMT_SERVICEBUS) as c:
c.argument('namespace_name', options_list=['--namespace-name'], id_part=None, help='Name of the Namespace')

for scope in ['servicebus namespace replica add', 'servicebus namespace replica remove']:
with self.argument_context(scope, resource_type=ResourceType.MGMT_SERVICEBUS) as c:
c.argument('geo_data_replication_config', action=AlertAddlocation, nargs='+',
help='A list of regions where replicas of the namespace are maintained Object')
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
from ._update import *
from ._wait import *
from ._exists import *
from ._failover import *
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class Create(AAZCommand):
"""

_aaz_info = {
"version": "2022-10-01-preview",
"version": "2023-01-01-preview",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.servicebus/namespaces/{}", "2022-10-01-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.servicebus/namespaces/{}", "2023-01-01-preview"],
]
}

Expand All @@ -54,7 +54,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
)
_args_schema.resource_group = AAZResourceGroupNameArg(
help="The resourceGroup name",
required=True,
)

Expand Down Expand Up @@ -139,6 +138,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
arg_group="Properties",
help="Properties of BYOK Encryption description",
)
_args_schema.geo_data_replication = AAZObjectArg(
options=["--geo-data-replication"],
arg_group="Properties",
help="Geo Data Replication settings for the namespace",
)
_args_schema.minimum_tls_version = AAZStrArg(
options=["--minimum-tls-version"],
arg_group="Properties",
Expand Down Expand Up @@ -205,6 +209,34 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="Version of KeyVault",
)

geo_data_replication = cls._args_schema.geo_data_replication
geo_data_replication.locations = AAZListArg(
options=["locations"],
help="A list of regions where replicas of the namespace are maintained.",
)
geo_data_replication.max_replication_lag_duration_in_seconds = AAZIntArg(
options=["max-lag", "max-replication-lag-duration-in-seconds"],
help="The maximum acceptable lag for data replication operations from the primary replica to a quorum of secondary replicas. When the lag exceeds the configured amount, operations on the primary replica will be failed. The allowed values are 0 and 5 minutes to 1 day.",
)

locations = cls._args_schema.geo_data_replication.locations
locations.Element = AAZObjectArg()

_element = cls._args_schema.geo_data_replication.locations.Element
_element.cluster_arm_id = AAZStrArg(
options=["cluster-arm-id"],
help="Optional property that denotes the ARM ID of the Cluster. This is required, if a namespace replica should be placed in a Dedicated Event Hub Cluster",
)
_element.location_name = AAZStrArg(
options=["location-name"],
help="Azure regions where a replica of the namespace is maintained",
)
_element.role_type = AAZStrArg(
options=["role-type"],
help="GeoDR Role Types",
enum={"Primary": "Primary", "Secondary": "Secondary"},
)

private_endpoint_connections = cls._args_schema.private_endpoint_connections
private_endpoint_connections.Element = AAZObjectArg()

Expand Down Expand Up @@ -322,7 +354,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2022-10-01-preview",
"api-version", "2023-01-01-preview",
required=True,
),
}
Expand Down Expand Up @@ -367,6 +399,7 @@ def content(self):
properties.set_prop("alternateName", AAZStrType, ".alternate_name")
properties.set_prop("disableLocalAuth", AAZBoolType, ".disable_local_auth")
properties.set_prop("encryption", AAZObjectType, ".encryption")
properties.set_prop("geoDataReplication", AAZObjectType, ".geo_data_replication")
properties.set_prop("minimumTlsVersion", AAZStrType, ".minimum_tls_version")
properties.set_prop("premiumMessagingPartitions", AAZIntType, ".premium_messaging_partitions")
properties.set_prop("privateEndpointConnections", AAZListType, ".private_endpoint_connections")
Expand Down Expand Up @@ -394,6 +427,21 @@ def content(self):
if identity is not None:
identity.set_prop("userAssignedIdentity", AAZStrType, ".user_assigned_identity")

geo_data_replication = _builder.get(".properties.geoDataReplication")
if geo_data_replication is not None:
geo_data_replication.set_prop("locations", AAZListType, ".locations")
geo_data_replication.set_prop("maxReplicationLagDurationInSeconds", AAZIntType, ".max_replication_lag_duration_in_seconds")

locations = _builder.get(".properties.geoDataReplication.locations")
if locations is not None:
locations.set_elements(AAZObjectType, ".")

_elements = _builder.get(".properties.geoDataReplication.locations[]")
if _elements is not None:
_elements.set_prop("clusterArmId", AAZStrType, ".cluster_arm_id")
_elements.set_prop("locationName", AAZStrType, ".location_name")
_elements.set_prop("roleType", AAZStrType, ".role_type")

private_endpoint_connections = _builder.get(".properties.privateEndpointConnections")
if private_endpoint_connections is not None:
private_endpoint_connections.set_elements(AAZObjectType, ".")
Expand Down Expand Up @@ -510,6 +558,9 @@ def _build_schema_on_200_201(cls):
serialized_name="disableLocalAuth",
)
properties.encryption = AAZObjectType()
properties.geo_data_replication = AAZObjectType(
serialized_name="geoDataReplication",
)
properties.metric_id = AAZStrType(
serialized_name="metricId",
flags={"read_only": True},
Expand Down Expand Up @@ -576,6 +627,26 @@ def _build_schema_on_200_201(cls):
serialized_name="userAssignedIdentity",
)

geo_data_replication = cls._schema_on_200_201.properties.geo_data_replication
geo_data_replication.locations = AAZListType()
geo_data_replication.max_replication_lag_duration_in_seconds = AAZIntType(
serialized_name="maxReplicationLagDurationInSeconds",
)

locations = cls._schema_on_200_201.properties.geo_data_replication.locations
locations.Element = AAZObjectType()

_element = cls._schema_on_200_201.properties.geo_data_replication.locations.Element
_element.cluster_arm_id = AAZStrType(
serialized_name="clusterArmId",
)
_element.location_name = AAZStrType(
serialized_name="locationName",
)
_element.role_type = AAZStrType(
serialized_name="roleType",
)

private_endpoint_connections = cls._schema_on_200_201.properties.private_endpoint_connections
private_endpoint_connections.Element = AAZObjectType()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class Delete(AAZCommand):
"""

_aaz_info = {
"version": "2022-10-01-preview",
"version": "2023-01-01-preview",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.servicebus/namespaces/{}", "2022-10-01-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.servicebus/namespaces/{}", "2023-01-01-preview"],
]
}

Expand Down Expand Up @@ -147,7 +147,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2022-10-01-preview",
"api-version", "2023-01-01-preview",
required=True,
),
}
Expand Down
Loading