diff --git a/src/webpubsub/HISTORY.rst b/src/webpubsub/HISTORY.rst index 89fa4bc8c43..803a20e493a 100644 --- a/src/webpubsub/HISTORY.rst +++ b/src/webpubsub/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +1.4.0 ++++++ +* Add `az webpubsub replica create/delete/list/show` support for replica + 1.3.0 +++++ * Add `kind` support for creating resource diff --git a/src/webpubsub/azext_webpubsub/_client_factory.py b/src/webpubsub/azext_webpubsub/_client_factory.py index 2ec9624dc31..91473bd355e 100644 --- a/src/webpubsub/azext_webpubsub/_client_factory.py +++ b/src/webpubsub/azext_webpubsub/_client_factory.py @@ -20,3 +20,7 @@ def cf_webpubsubhub(cli_ctx, *_): def cf_webpubsubhub_usage(cli_ctx, *_): return _webpubsub_client_factory(cli_ctx).usages + + +def cf_webpubsub_replicas(cli_ctx, *_): + return _webpubsub_client_factory(cli_ctx).web_pub_sub_replicas diff --git a/src/webpubsub/azext_webpubsub/_help.py b/src/webpubsub/azext_webpubsub/_help.py index 804164f3685..bad8d52bb07 100644 --- a/src/webpubsub/azext_webpubsub/_help.py +++ b/src/webpubsub/azext_webpubsub/_help.py @@ -57,6 +57,11 @@ short-summary: Commands to manage Webpubsub service permissions. """ +helps['webpubsub replica'] = """ +type: group +short-summary: Manage replica settings. +""" + helps['webpubsub create'] = """ type: command short-summary: Create a Webpubsub. @@ -263,3 +268,39 @@ type: command short-summary: Check if a connection has permission to the specified group. """ + +helps['webpubsub replica show'] = """ +type: command +short-summary: Show the details of a replica +examples: + - name: Get the detail of a replica + text: > + az webpubsub replica show --replica-name MyReplica --name MyWebPubSub -g MyResourceGroup +""" + +helps['webpubsub replica delete'] = """ +type: command +short-summary: Delete a replica of WebPubSub Service. +examples: + - name: Delete a replica + text: > + az webpubsub replica delete --replica-name MyReplica --name MyWebPubSub -g MyResourceGroup +""" + +helps['webpubsub replica list'] = """ +type: command +short-summary: List replicas of Webpubsub Service. +examples: + - name: Get the detail of a replica + text: > + az webpubsub replica list --name MyWebPubSub -g MyResourceGroup -o table +""" + +helps['webpubsub replica create'] = """ +type: command +short-summary: Create a replica of Webpubsub Service. +examples: + - name: Get the detail of a replica + text: > + az webpubsub replica create --sku Premium_P1 -l eastus --replica-name MyReplica --name MyWebPubSub -g MyResourceGroup +""" diff --git a/src/webpubsub/azext_webpubsub/_params.py b/src/webpubsub/azext_webpubsub/_params.py index 3a21221c4eb..9f4f7fe56cf 100644 --- a/src/webpubsub/azext_webpubsub/_params.py +++ b/src/webpubsub/azext_webpubsub/_params.py @@ -25,6 +25,7 @@ def load_arguments(self, _): webpubsub_name_type = CLIArgumentType(options_list='--webpubsub-name-name', help='Name of the Webpubsub.', id_part='name') webpubsubhub_name_type = CLIArgumentType(help='Name of the hub.', id_part='child_name_1') + webpubsub_replica_name_type = CLIArgumentType(help='Name of the replica.', id_part='child_name_1') with self.argument_context('webpubsub') as c: c.argument('tags', tags_type) @@ -100,3 +101,23 @@ def load_arguments(self, _): with self.argument_context('webpubsub service permission') as c: c.argument('permission', arg_type=get_enum_type(PERMISSION_TYPE), help='The permission') + + # Replica + for scope in ['webpubsub replica create', + 'webpubsub replica list', + 'webpubsub replica delete', + 'webpubsub replica show']: + with self.argument_context(scope) as c: + c.argument('sku', help='The sku name of the replica. Currently allowed values: Premium_P1') + c.argument('unit_count', help='The number of webpubsub service unit count', type=int) + c.argument('replica_name', webpubsub_replica_name_type) + + for scope in ['webpubsub replica create', + 'webpubsub replica list']: + with self.argument_context(scope) as c: + c.argument('webpubsub_name', webpubsub_name_type, options_list=['--name', '-n'], id_part=None) + + for scope in ['webpubsub replica show', + 'webpubsub replica delete']: + with self.argument_context(scope) as c: + c.argument('webpubsub_name', webpubsub_name_type, options_list=['--name', '-n']) diff --git a/src/webpubsub/azext_webpubsub/commands.py b/src/webpubsub/azext_webpubsub/commands.py index 91028f8b182..459a86b0ff3 100644 --- a/src/webpubsub/azext_webpubsub/commands.py +++ b/src/webpubsub/azext_webpubsub/commands.py @@ -6,7 +6,7 @@ # pylint: disable=line-too-long from azure.cli.core.commands import CliCommandType from azure.cli.core.util import empty_on_404 -from ._client_factory import (cf_webpubsub, cf_webpubsubhub, cf_webpubsubhub_usage) +from ._client_factory import (cf_webpubsub, cf_webpubsubhub, cf_webpubsubhub_usage, cf_webpubsub_replicas) from ._exception_handler import exception_handler @@ -47,6 +47,11 @@ def load_command_table(self, _): client_factory=cf_webpubsubhub_usage ) + webpubsub_replica_utils = CliCommandType( + operations_tmpl='azext_webpubsub.replica#{}', + client_factory=cf_webpubsub_replicas + ) + with self.command_group('webpubsub', webpubsub_general_utils) as g: g.command('create', 'webpubsub_create', exception_handler=exception_handler) g.command('delete', 'webpubsub_delete') @@ -100,3 +105,9 @@ def load_command_table(self, _): g.command('grant', 'grant_permission') g.command('revoke', 'revoke_permission') g.command('check', 'check_permission') + + with self.command_group('webpubsub replica', webpubsub_replica_utils) as g: + g.command('create', 'webpubsub_replica_create') + g.command('list', 'webpubsub_replica_list') + g.show_command('show', 'webpubsub_replica_show', exception_handler=empty_on_404) + g.show_command('delete', 'webpubsub_replica_delete') diff --git a/src/webpubsub/azext_webpubsub/replica.py b/src/webpubsub/azext_webpubsub/replica.py new file mode 100644 index 00000000000..4f6097f7f3f --- /dev/null +++ b/src/webpubsub/azext_webpubsub/replica.py @@ -0,0 +1,38 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=line-too-long + +from .vendored_sdks.azure_mgmt_webpubsub.models import ( + ResourceSku, + Replica +) + +from .vendored_sdks.azure_mgmt_webpubsub.operations import ( + WebPubSubOperations +) + + +def webpubsub_replica_list(client: WebPubSubOperations, resource_group_name, webpubsub_name): + return client.list(resource_group_name, webpubsub_name) + + +def webpubsub_replica_show(client: WebPubSubOperations, webpubsub_name, replica_name, resource_group_name): + return client.get(resource_group_name=resource_group_name, resource_name=webpubsub_name, replica_name=replica_name) + + +def webpubsub_replica_delete(client: WebPubSubOperations, webpubsub_name, replica_name, resource_group_name): + return client.delete(resource_group_name=resource_group_name, resource_name=webpubsub_name, replica_name=replica_name) + + +def webpubsub_replica_create(client: WebPubSubOperations, webpubsub_name, replica_name, resource_group_name, + sku, unit_count=1, location=None, tags=None): + sku = ResourceSku(name=sku, capacity=unit_count) + parameter = Replica(tags=tags, + sku=sku, + location=location, + ) + + return client.begin_create_or_update(resource_group_name=resource_group_name, resource_name=webpubsub_name, + replica_name=replica_name, parameters=parameter) diff --git a/src/webpubsub/azext_webpubsub/tests/latest/recordings/test_webpubsub_replica.yaml b/src/webpubsub/azext_webpubsub/tests/latest/recordings/test_webpubsub_replica.yaml new file mode 100644 index 00000000000..6b9372e4abb --- /dev/null +++ b/src/webpubsub/azext_webpubsub/tests/latest/recordings/test_webpubsub_replica.yaml @@ -0,0 +1,685 @@ +interactions: +- request: + body: '{"tags": {"key": "value"}, "location": "eastus", "sku": {"name": "Premium_P1", + "capacity": 1}, "properties": {"publicNetworkAccess": "Enabled", "disableLocalAuth": + false, "disableAadAuth": false}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub create + Connection: + - keep-alive + Content-Length: + - '196' + Content-Type: + - application/json + ParameterSetName: + - -g -n --tags -l --sku --unit-count + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002?api-version=2023-06-01-preview + response: + body: + string: '{"sku":{"name":"Premium_P1","tier":"Premium","size":"P1","capacity":1},"properties":{"provisioningState":"Creating","externalIP":null,"hostName":"webpubsub000002.webpubsub.azure.com","publicPort":443,"serverPort":443,"version":"1.0-preview","privateEndpointConnections":[],"sharedPrivateLinkResources":[],"tls":{"clientCertEnabled":false},"hostNamePrefix":"webpubsub000002","liveTraceConfiguration":null,"resourceLogConfiguration":null,"networkACLs":{"defaultAction":"Deny","publicNetwork":{"allow":["ServerConnection","ClientConnection","RESTAPI","Trace"],"deny":null},"privateEndpoints":[]},"publicNetworkAccess":"Enabled","disableLocalAuth":false,"disableAadAuth":false},"kind":"WebPubSub","location":"eastus","tags":{"key":"value"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002","name":"webpubsub000002","type":"Microsoft.SignalRService/WebPubSub","systemData":{"createdBy":"biqian@microsoft.com","createdByType":"User","createdAt":"2023-10-23T04:44:01.6573952Z","lastModifiedBy":"biqian@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2023-10-23T04:44:01.6573952Z"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45?api-version=2023-06-01-preview + cache-control: + - no-cache + content-length: + - '1189' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:44:04 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationResults/994473af-ad1a-421f-934d-378c691e0a45?api-version=2023-06-01-preview + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub create + Connection: + - keep-alive + ParameterSetName: + - -g -n --tags -l --sku --unit-count + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45?api-version=2023-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45","name":"994473af-ad1a-421f-934d-378c691e0a45","status":"Running","startTime":"2023-10-23T04:44:03.7848523Z"}' + headers: + cache-control: + - no-cache + content-length: + - '316' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:44:05 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub create + Connection: + - keep-alive + ParameterSetName: + - -g -n --tags -l --sku --unit-count + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45?api-version=2023-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45","name":"994473af-ad1a-421f-934d-378c691e0a45","status":"Running","startTime":"2023-10-23T04:44:03.7848523Z"}' + headers: + cache-control: + - no-cache + content-length: + - '316' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:44:36 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub create + Connection: + - keep-alive + ParameterSetName: + - -g -n --tags -l --sku --unit-count + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45?api-version=2023-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45","name":"994473af-ad1a-421f-934d-378c691e0a45","status":"Running","startTime":"2023-10-23T04:44:03.7848523Z"}' + headers: + cache-control: + - no-cache + content-length: + - '316' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:45:07 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub create + Connection: + - keep-alive + ParameterSetName: + - -g -n --tags -l --sku --unit-count + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45?api-version=2023-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/operationStatuses/994473af-ad1a-421f-934d-378c691e0a45","name":"994473af-ad1a-421f-934d-378c691e0a45","status":"Succeeded","startTime":"2023-10-23T04:44:03.7848523Z","endTime":"2023-10-23T04:45:12.5702529Z"}' + headers: + cache-control: + - no-cache + content-length: + - '359' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:45:37 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub create + Connection: + - keep-alive + ParameterSetName: + - -g -n --tags -l --sku --unit-count + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002?api-version=2023-06-01-preview + response: + body: + string: '{"sku":{"name":"Premium_P1","tier":"Premium","size":"P1","capacity":1},"properties":{"provisioningState":"Succeeded","externalIP":"20.88.154.129","hostName":"webpubsub000002.webpubsub.azure.com","publicPort":443,"serverPort":443,"version":"1.0","privateEndpointConnections":[],"sharedPrivateLinkResources":[],"tls":{"clientCertEnabled":false},"hostNamePrefix":"webpubsub000002","liveTraceConfiguration":null,"resourceLogConfiguration":null,"networkACLs":{"defaultAction":"Deny","publicNetwork":{"allow":["ServerConnection","ClientConnection","RESTAPI","Trace"],"deny":null},"privateEndpoints":[]},"publicNetworkAccess":"Enabled","disableLocalAuth":false,"disableAadAuth":false},"kind":"WebPubSub","location":"eastus","tags":{"key":"value"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002","name":"webpubsub000002","type":"Microsoft.SignalRService/WebPubSub","systemData":{"createdBy":"biqian@microsoft.com","createdByType":"User","createdAt":"2023-10-23T04:44:01.6573952Z","lastModifiedBy":"biqian@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2023-10-23T04:44:01.6573952Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '1193' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:45:37 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: '{"tags": {"key": "value"}, "location": "westus", "sku": {"name": "Premium_P1", + "capacity": 1}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub replica create + Connection: + - keep-alive + Content-Length: + - '94' + Content-Type: + - application/json + ParameterSetName: + - --webpubsub-name --replica-name -g --sku --unit-count -l --tags + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica?api-version=2023-06-01-preview + response: + body: + string: '{"sku":{"name":"Premium_P1","tier":"Premium","size":"P1","capacity":1},"properties":{"provisioningState":"Creating"},"location":"westus","tags":{"key":"value"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/replicas/clitestReplica","name":"clitestReplica","type":"Microsoft.SignalRService/WebPubSub/replicas","systemData":{"createdBy":"biqian@microsoft.com","createdByType":"User","createdAt":"2023-10-23T04:45:40.6956858Z","lastModifiedBy":"biqian@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2023-10-23T04:45:40.6956858Z"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica/operationStatuses/09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd?api-version=2023-06-01-preview + cache-control: + - no-cache + content-length: + - '645' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:45:44 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica/operationResults/09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd?api-version=2023-06-01-preview + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub replica create + Connection: + - keep-alive + ParameterSetName: + - --webpubsub-name --replica-name -g --sku --unit-count -l --tags + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica/operationStatuses/09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd?api-version=2023-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/replicas/clitestReplica/operationStatuses/09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd","name":"09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd","status":"Running","startTime":"2023-10-23T04:45:44.0573993Z"}' + headers: + cache-control: + - no-cache + content-length: + - '340' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:45:44 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub replica create + Connection: + - keep-alive + ParameterSetName: + - --webpubsub-name --replica-name -g --sku --unit-count -l --tags + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica/operationStatuses/09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd?api-version=2023-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/replicas/clitestReplica/operationStatuses/09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd","name":"09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd","status":"Running","startTime":"2023-10-23T04:45:44.0573993Z"}' + headers: + cache-control: + - no-cache + content-length: + - '340' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:46:15 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub replica create + Connection: + - keep-alive + ParameterSetName: + - --webpubsub-name --replica-name -g --sku --unit-count -l --tags + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica/operationStatuses/09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd?api-version=2023-06-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/replicas/clitestReplica/operationStatuses/09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd","name":"09db3f2b-eb5d-4ee7-a6ea-6d81ef120edd","status":"Succeeded","startTime":"2023-10-23T04:45:44.0573993Z","endTime":"2023-10-23T04:46:37.6430108Z"}' + headers: + cache-control: + - no-cache + content-length: + - '383' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:46:46 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub replica create + Connection: + - keep-alive + ParameterSetName: + - --webpubsub-name --replica-name -g --sku --unit-count -l --tags + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica?api-version=2023-06-01-preview + response: + body: + string: '{"sku":{"name":"Premium_P1","tier":"Premium","size":"P1","capacity":1},"properties":{"provisioningState":"Succeeded"},"location":"westus","tags":{"key":"value"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/replicas/clitestReplica","name":"clitestReplica","type":"Microsoft.SignalRService/WebPubSub/replicas","systemData":{"createdBy":"biqian@microsoft.com","createdByType":"User","createdAt":"2023-10-23T04:45:40.6956858Z","lastModifiedBy":"biqian@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2023-10-23T04:45:40.6956858Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '646' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:46:46 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub replica show + Connection: + - keep-alive + ParameterSetName: + - --webpubsub-name --replica-name -g + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica?api-version=2023-06-01-preview + response: + body: + string: '{"sku":{"name":"Premium_P1","tier":"Premium","size":"P1","capacity":1},"properties":{"provisioningState":"Succeeded"},"location":"westus","tags":{"key":"value"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/replicas/clitestReplica","name":"clitestReplica","type":"Microsoft.SignalRService/WebPubSub/replicas","systemData":{"createdBy":"biqian@microsoft.com","createdByType":"User","createdAt":"2023-10-23T04:45:40.6956858Z","lastModifiedBy":"biqian@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2023-10-23T04:45:40.6956858Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '646' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:46:48 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub replica list + Connection: + - keep-alive + ParameterSetName: + - --webpubsub-name -g + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas?api-version=2023-06-01-preview + response: + body: + string: '{"value":[{"sku":{"name":"Premium_P1","tier":"Premium","size":"P1","capacity":1},"properties":{"provisioningState":"Succeeded"},"location":"westus","tags":{"key":"value"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/WebPubSub/webpubsub000002/replicas/clitestReplica","name":"clitestReplica","type":"Microsoft.SignalRService/WebPubSub/replicas"}]}' + headers: + cache-control: + - no-cache + content-length: + - '426' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Oct 2023 04:46:50 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - webpubsub replica delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --webpubsub-name --replica-name -g + User-Agent: + - AZURECLI/2.53.0 azsdk-python-mgmt-webpubsub/2.0.0b1 Python/3.8.17 (macOS-14.0-arm64-arm-64bit) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.SignalRService/webPubSub/webpubsub000002/replicas/clitestReplica?api-version=2023-06-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + date: + - Mon, 23 Oct 2023 04:46:55 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + x-rp-server-mvid: + - 7a9fbd09-41be-4571-843d-17367567ea6a + status: + code: 204 + message: No Content +version: 1 diff --git a/src/webpubsub/azext_webpubsub/tests/latest/test_webpubsub_replica.py b/src/webpubsub/azext_webpubsub/tests/latest/test_webpubsub_replica.py new file mode 100644 index 00000000000..98771af8119 --- /dev/null +++ b/src/webpubsub/azext_webpubsub/tests/latest/test_webpubsub_replica.py @@ -0,0 +1,86 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=unused-import, line-too-long, unused-argument +import os +import unittest + +from azure.cli.testsdk.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) +from .recording_processors import KeyReplacer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +class WebpubsubScenarioTest(ScenarioTest): + + def __init__(self, method_name): + super(WebpubsubScenarioTest, self).__init__( + method_name, recording_processors=[KeyReplacer()] + ) + + @ResourceGroupPreparer(random_name_length=20) + def test_webpubsub_replica(self, resource_group): + tags_key = 'key' + tags_val = 'value' + updated_tags_val = 'value2' + replica_name = 'clitestReplica' + replica_location = 'westus' + + self.kwargs.update({ + 'name': self.create_random_name('webpubsub', 16), + 'sku': 'Premium_P1', + 'location': 'eastus', + 'tags': '{}={}'.format(tags_key, tags_val), + 'unit_count': 1, + 'updated_tags': '{}={}'.format(tags_key, updated_tags_val), + 'replica_name': replica_name, + 'replica_location': replica_location + }) + + # Test create primary + self.cmd('webpubsub create -g {rg} -n {name} --tags {tags} -l {location} --sku {sku} --unit-count {unit_count}', checks=[ + self.check('name', '{name}'), + self.check('location', '{location}'), + self.check('provisioningState', 'Succeeded'), + self.check('sku.name', '{sku}'), + self.check('sku.capacity', '{unit_count}'), + self.check('tags.{}'.format(tags_key), tags_val), + self.exists('hostName'), + self.exists('publicPort'), + self.exists('serverPort'), + self.exists('externalIp'), + ]) + + # test create replica + self.cmd('az webpubsub replica create -n {name} --replica-name {replica_name} -g {rg} --sku {sku} --unit-count {unit_count} -l {replica_location} --tags {tags}', checks=[ + self.check('name', '{replica_name}'), + self.check('location', '{replica_location}'), + self.check('provisioningState', 'Succeeded'), + self.check('sku.name', '{sku}'), + self.check('tags.{}'.format(tags_key), tags_val), + ]) + + # test show replica + self.cmd('az webpubsub replica show -n {name} --replica-name {replica_name} -g {rg}', checks=[ + self.check('name', '{replica_name}'), + self.check('location', '{replica_location}'), + self.check('provisioningState', 'Succeeded'), + self.check('sku.name', '{sku}'), + self.check('tags.{}'.format(tags_key), tags_val), + ]) + + # test list replica + self.cmd('az webpubsub replica list -n {name} -g {rg}', checks=[ + self.check('[0].name', '{replica_name}'), + self.check('[0].location', '{replica_location}'), + self.check('[0].provisioningState', 'Succeeded'), + self.check('[0].sku.name', '{sku}'), + self.check('[0].tags.{}'.format(tags_key), tags_val), + ]) + + # test remove replica + self.cmd('az webpubsub replica delete -n {name} --replica-name {replica_name} -g {rg}') diff --git a/src/webpubsub/setup.py b/src/webpubsub/setup.py index 6110a06ba40..a1b35becb25 100644 --- a/src/webpubsub/setup.py +++ b/src/webpubsub/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '1.3.0' +VERSION = '1.4.0' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers