diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/CHANGELOG.md b/sdk/webpubsub/azure-mgmt-webpubsub/CHANGELOG.md index 6d23e063059c..36034873bb0c 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/CHANGELOG.md +++ b/sdk/webpubsub/azure-mgmt-webpubsub/CHANGELOG.md @@ -1,5 +1,47 @@ # Release History +## 3.0.0b1 (2026-07-07) + +### Features Added + + - Client `WebPubSubManagementClient` added parameter `cloud_setting` in method `__init__` + - Client `WebPubSubManagementClient` added method `send_request` + - Client `WebPubSubManagementClient` added operation group `web_pub_sub_persistent_storages` + - Model `EventHandler` added property `group_presence_events` + - Model `WebPubSubHubProperties` added property `chat` + - Added model `ApplicationFirewallSettings` + - Added model `ChatSettings` + - Added model `ClientConnectionCountRule` + - Added enum `ClientConnectionCountRuleDiscriminator` + - Added model `ClientTrafficControlRule` + - Added enum `ClientTrafficControlRuleDiscriminator` + - Added model `GroupPresenceEventFilters` + - Added enum `GroupPresenceEventName` + - Added model `PersistentStorage` + - Added model `PersistentStorageProperties` + - Added model `ThrottleByJwtCustomClaimRule` + - Added model `ThrottleByJwtSignatureRule` + - Added model `ThrottleByUserIdRule` + - Added model `TrafficThrottleByJwtCustomClaimRule` + - Added model `TrafficThrottleByJwtSignatureRule` + - Added model `TrafficThrottleByUserIdRule` + - Added operation group `WebPubSubPersistentStoragesOperations` + +### Breaking Changes + + - This version introduces new hybrid models which have dual dictionary and model nature. Please follow https://aka.ms/azsdk/python/migrate/hybrid-models for migration. + - Model `CustomCertificate` moved instance variable `provisioning_state`, `key_vault_base_uri`, `key_vault_secret_name` and `key_vault_secret_version` under property `properties` whose type is `CustomCertificateProperties` + - Model `CustomDomain` moved instance variable `provisioning_state`, `domain_name` and `custom_certificate` under property `properties` whose type is `CustomDomainProperties` + - Model `PrivateEndpointConnection` moved instance variable `provisioning_state`, `private_endpoint`, `group_ids` and `private_link_service_connection_state` under property `properties` whose type is `PrivateEndpointConnectionProperties` + - Model `PrivateLinkResource` moved instance variable `group_id`, `required_members`, `required_zone_names` and `shareable_private_link_resource_types` under property `properties` whose type is `PrivateLinkResourceProperties` + - Model `Replica` moved instance variable `provisioning_state`, `region_endpoint_enabled` and `resource_stopped` under property `properties` whose type is `ReplicaProperties` + - Model `SharedPrivateLinkResource` moved instance variable `group_id`, `private_link_resource_id`, `provisioning_state`, `request_message` and `status` under property `properties` whose type is `SharedPrivateLinkResourceProperties` + - Model `WebPubSubResource` moved instance variable `provisioning_state`, `external_ip`, `host_name`, `public_port`, `server_port`, `version`, `private_endpoint_connections`, `shared_private_link_resources`, `tls`, `host_name_prefix`, `live_trace_configuration`, `resource_log_configuration`, `network_ac_ls`, `public_network_access`, `disable_local_auth`, `disable_aad_auth`, `region_endpoint_enabled`, `resource_stopped` and `socket_io` under property `properties` whose type is `WebPubSubProperties` + +### Other Changes + + - Deleted model `CustomCertificateList`/`CustomDomainList`/`OperationList`/`PrivateEndpointConnectionList`/`PrivateLinkResourceList`/`ReplicaList`/`SharedPrivateLinkResourceList`/`SignalRServiceUsageList`/`WebPubSubHubList`/`WebPubSubResourceList` which actually were not used by SDK users + ## 2.0.0 (2024-09-23) ### Features Added diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/MANIFEST.in b/sdk/webpubsub/azure-mgmt-webpubsub/MANIFEST.in index 5e6b0c05b2c5..6b39987bc2d6 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/MANIFEST.in +++ b/sdk/webpubsub/azure-mgmt-webpubsub/MANIFEST.in @@ -1,8 +1,7 @@ -include _meta.json -recursive-include tests *.py *.json -recursive-include samples *.py *.md include *.md -include azure/__init__.py -include azure/mgmt/__init__.py include LICENSE include azure/mgmt/webpubsub/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/README.md b/sdk/webpubsub/azure-mgmt-webpubsub/README.md index f5586c281b53..46a7aa7aa084 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/README.md +++ b/sdk/webpubsub/azure-mgmt-webpubsub/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure WebPubSub Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.10+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.10+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Microsoft Entra](https://learn.microsoft.com/entra/fundamentals/what-is-entra) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/_meta.json b/sdk/webpubsub/azure-mgmt-webpubsub/_meta.json deleted file mode 100644 index a16687d0e448..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "0629824cb7947f5b349c7602675432b2f29da1cb", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.19.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/webpubsub/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --tag=package-2024-03-01 --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/webpubsub/resource-manager/readme.md" -} \ No newline at end of file diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/_metadata.json b/sdk/webpubsub/azure-mgmt-webpubsub/_metadata.json new file mode 100644 index 000000000000..8a0b8f753ebd --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/_metadata.json @@ -0,0 +1,11 @@ +{ + "apiVersion": "2025-12-01-preview", + "apiVersions": { + "Microsoft.SignalRService": "2025-12-01-preview" + }, + "commit": "a7bdbe741c0ef1f1b159d8569b173757bd823ae9", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/webpubsub/resource-manager/Microsoft.SignalRService/SignalRService", + "emitterVersion": "0.63.2", + "httpClientPythonVersion": "^0.34.0" +} \ No newline at end of file diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/api.md b/sdk/webpubsub/azure-mgmt-webpubsub/api.md new file mode 100644 index 000000000000..350b8b4145b4 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/api.md @@ -0,0 +1,4047 @@ +```py +namespace azure.mgmt.webpubsub + + class azure.mgmt.webpubsub.WebPubSubManagementClient: implements ContextManager + operations: Operations + usages: UsagesOperations + web_pub_sub: WebPubSubOperations + web_pub_sub_custom_certificates: WebPubSubCustomCertificatesOperations + web_pub_sub_custom_domains: WebPubSubCustomDomainsOperations + web_pub_sub_hubs: WebPubSubHubsOperations + web_pub_sub_persistent_storages: WebPubSubPersistentStoragesOperations + web_pub_sub_private_endpoint_connections: WebPubSubPrivateEndpointConnectionsOperations + web_pub_sub_private_link_resources: WebPubSubPrivateLinkResourcesOperations + web_pub_sub_replica_shared_private_link_resources: WebPubSubReplicaSharedPrivateLinkResourcesOperations + web_pub_sub_replicas: WebPubSubReplicasOperations + web_pub_sub_shared_private_link_resources: WebPubSubSharedPrivateLinkResourcesOperations + + def __init__( + self, + credential: TokenCredential, + subscription_id: str, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + polling_interval: Optional[int] = ..., + **kwargs: Any + ) -> None: ... + + def close(self) -> None: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> HttpResponse: ... + + +namespace azure.mgmt.webpubsub.aio + + class azure.mgmt.webpubsub.aio.WebPubSubManagementClient: implements AsyncContextManager + operations: Operations + usages: UsagesOperations + web_pub_sub: WebPubSubOperations + web_pub_sub_custom_certificates: WebPubSubCustomCertificatesOperations + web_pub_sub_custom_domains: WebPubSubCustomDomainsOperations + web_pub_sub_hubs: WebPubSubHubsOperations + web_pub_sub_persistent_storages: WebPubSubPersistentStoragesOperations + web_pub_sub_private_endpoint_connections: WebPubSubPrivateEndpointConnectionsOperations + web_pub_sub_private_link_resources: WebPubSubPrivateLinkResourcesOperations + web_pub_sub_replica_shared_private_link_resources: WebPubSubReplicaSharedPrivateLinkResourcesOperations + web_pub_sub_replicas: WebPubSubReplicasOperations + web_pub_sub_shared_private_link_resources: WebPubSubSharedPrivateLinkResourcesOperations + + def __init__( + self, + credential: AsyncTokenCredential, + subscription_id: str, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + polling_interval: Optional[int] = ..., + **kwargs: Any + ) -> None: ... + + async def close(self) -> None: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: ... + + +namespace azure.mgmt.webpubsub.aio.operations + + class azure.mgmt.webpubsub.aio.operations.Operations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged[Operation]: ... + + + class azure.mgmt.webpubsub.aio.operations.UsagesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list( + self, + location: str, + **kwargs: Any + ) -> AsyncItemPaged[SignalRServiceUsage]: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubCustomCertificatesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[CustomCertificate]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[CustomCertificate]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[CustomCertificate]: ... + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> CustomCertificate: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncItemPaged[CustomCertificate]: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubCustomDomainsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[CustomDomain]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[CustomDomain]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[CustomDomain]: ... + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + resource_name: str, + name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + name: str, + **kwargs: Any + ) -> CustomDomain: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncItemPaged[CustomDomain]: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubHubsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubHub]: ... + + @overload + async def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubHub]: ... + + @overload + async def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubHub]: ... + + @distributed_trace_async + async def begin_delete( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def get( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> WebPubSubHub: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncItemPaged[WebPubSubHub]: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubResource]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubResource]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubResource]: ... + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubKeys]: ... + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubKeys]: ... + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubKeys]: ... + + @distributed_trace_async + async def begin_restart( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubResource]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubResource]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[WebPubSubResource]: ... + + @overload + async def check_name_availability( + self, + location: str, + parameters: NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> NameAvailability: ... + + @overload + async def check_name_availability( + self, + location: str, + parameters: NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> NameAvailability: ... + + @overload + async def check_name_availability( + self, + location: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> NameAvailability: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> WebPubSubResource: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncItemPaged[WebPubSubResource]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged[WebPubSubResource]: ... + + @distributed_trace_async + async def list_keys( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> WebPubSubKeys: ... + + @distributed_trace_async + async def list_replica_skus( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> SkuList: ... + + @distributed_trace_async + async def list_skus( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> SkuList: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubPersistentStoragesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: PersistentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[PersistentStorage]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: PersistentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[PersistentStorage]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[PersistentStorage]: ... + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + resource_name: str, + name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + name: str, + **kwargs: Any + ) -> PersistentStorage: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncItemPaged[PersistentStorage]: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateEndpointConnectionsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace_async + async def begin_delete( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def get( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> PrivateEndpointConnection: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncItemPaged[PrivateEndpointConnection]: ... + + @overload + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> PrivateEndpointConnection: ... + + @overload + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> PrivateEndpointConnection: ... + + @overload + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> PrivateEndpointConnection: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateLinkResourcesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncItemPaged[PrivateLinkResource]: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[SharedPrivateLinkResource]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[SharedPrivateLinkResource]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[SharedPrivateLinkResource]: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + **kwargs: Any + ) -> SharedPrivateLinkResource: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> AsyncItemPaged[SharedPrivateLinkResource]: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubReplicasOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Replica]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Replica]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Replica]: ... + + @distributed_trace_async + async def begin_restart( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Replica]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Replica]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Replica]: ... + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> Replica: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncItemPaged[Replica]: ... + + + class azure.mgmt.webpubsub.aio.operations.WebPubSubSharedPrivateLinkResourcesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[SharedPrivateLinkResource]: ... + + @overload + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[SharedPrivateLinkResource]: ... + + @overload + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[SharedPrivateLinkResource]: ... + + @distributed_trace_async + async def begin_delete( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def get( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> SharedPrivateLinkResource: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> AsyncItemPaged[SharedPrivateLinkResource]: ... + + +namespace azure.mgmt.webpubsub.models + + class azure.mgmt.webpubsub.models.ACLAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ALLOW = "Allow" + DENY = "Deny" + + + class azure.mgmt.webpubsub.models.ApplicationFirewallSettings(_Model): + client_connection_count_rules: Optional[list[ClientConnectionCountRule]] + client_traffic_control_rules: Optional[list[ClientTrafficControlRule]] + max_client_connection_lifetime_in_seconds: Optional[int] + + @overload + def __init__( + self, + *, + client_connection_count_rules: Optional[list[ClientConnectionCountRule]] = ..., + client_traffic_control_rules: Optional[list[ClientTrafficControlRule]] = ..., + max_client_connection_lifetime_in_seconds: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ChatSettings(_Model): + mode: Optional[str] + persistent_storage: Optional[ResourceReference] + + @overload + def __init__( + self, + *, + mode: Optional[str] = ..., + persistent_storage: Optional[ResourceReference] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ClientConnectionCountRule(_Model): + type: str + + @overload + def __init__( + self, + *, + type: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ClientConnectionCountRuleDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE = "ThrottleByJwtCustomClaimRule" + THROTTLE_BY_JWT_SIGNATURE_RULE = "ThrottleByJwtSignatureRule" + THROTTLE_BY_USER_ID_RULE = "ThrottleByUserIdRule" + + + class azure.mgmt.webpubsub.models.ClientTrafficControlRule(_Model): + type: str + + @overload + def __init__( + self, + *, + type: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ClientTrafficControlRuleDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE = "TrafficThrottleByJwtCustomClaimRule" + TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE = "TrafficThrottleByJwtSignatureRule" + TRAFFIC_THROTTLE_BY_USER_ID_RULE = "TrafficThrottleByUserIdRule" + + + class azure.mgmt.webpubsub.models.CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPLICATION = "Application" + KEY = "Key" + MANAGED_IDENTITY = "ManagedIdentity" + USER = "User" + + + class azure.mgmt.webpubsub.models.CustomCertificate(ProxyResource): + id: str + name: str + properties: CustomCertificateProperties + system_data: SystemData + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + properties: CustomCertificateProperties + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.webpubsub.models.CustomCertificateProperties(_Model): + key_vault_base_uri: str + key_vault_secret_name: str + key_vault_secret_version: Optional[str] + provisioning_state: Optional[Union[str, ProvisioningState]] + + @overload + def __init__( + self, + *, + key_vault_base_uri: str, + key_vault_secret_name: str, + key_vault_secret_version: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.CustomDomain(ProxyResource): + id: str + name: str + properties: CustomDomainProperties + system_data: SystemData + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + properties: CustomDomainProperties + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.webpubsub.models.CustomDomainProperties(_Model): + custom_certificate: ResourceReference + domain_name: str + provisioning_state: Optional[Union[str, ProvisioningState]] + + @overload + def __init__( + self, + *, + custom_certificate: ResourceReference, + domain_name: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.Dimension(_Model): + display_name: Optional[str] + internal_name: Optional[str] + name: Optional[str] + to_be_exported_for_shoebox: Optional[bool] + + @overload + def __init__( + self, + *, + display_name: Optional[str] = ..., + internal_name: Optional[str] = ..., + name: Optional[str] = ..., + to_be_exported_for_shoebox: Optional[bool] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ErrorAdditionalInfo(_Model): + info: Optional[Any] + type: Optional[str] + + + class azure.mgmt.webpubsub.models.ErrorDetail(_Model): + additional_info: Optional[list[ErrorAdditionalInfo]] + code: Optional[str] + details: Optional[list[ErrorDetail]] + message: Optional[str] + target: Optional[str] + + + class azure.mgmt.webpubsub.models.ErrorResponse(_Model): + error: Optional[ErrorDetail] + + @overload + def __init__( + self, + *, + error: Optional[ErrorDetail] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.EventHandler(_Model): + auth: Optional[UpstreamAuthSettings] + group_presence_events: Optional[GroupPresenceEventFilters] + system_events: Optional[list[str]] + url_template: str + user_event_pattern: Optional[str] + + @overload + def __init__( + self, + *, + auth: Optional[UpstreamAuthSettings] = ..., + group_presence_events: Optional[GroupPresenceEventFilters] = ..., + system_events: Optional[list[str]] = ..., + url_template: str, + user_event_pattern: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.EventHubEndpoint(EventListenerEndpoint, discriminator='EventHub'): + event_hub_name: str + fully_qualified_namespace: str + type: Literal[EventListenerEndpointDiscriminator.EVENT_HUB] + + @overload + def __init__( + self, + *, + event_hub_name: str, + fully_qualified_namespace: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.EventListener(_Model): + endpoint: EventListenerEndpoint + filter: EventListenerFilter + + @overload + def __init__( + self, + *, + endpoint: EventListenerEndpoint, + filter: EventListenerFilter + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.EventListenerEndpoint(_Model): + type: str + + @overload + def __init__( + self, + *, + type: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.EventListenerEndpointDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + EVENT_HUB = "EventHub" + + + class azure.mgmt.webpubsub.models.EventListenerFilter(_Model): + type: str + + @overload + def __init__( + self, + *, + type: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.EventListenerFilterDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + EVENT_NAME = "EventName" + + + class azure.mgmt.webpubsub.models.EventNameFilter(EventListenerFilter, discriminator='EventName'): + system_events: Optional[list[str]] + type: Literal[EventListenerFilterDiscriminator.EVENT_NAME] + user_event_pattern: Optional[str] + + @overload + def __init__( + self, + *, + system_events: Optional[list[str]] = ..., + user_event_pattern: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.GroupPresenceEventFilters(_Model): + event_names: list[Union[str, GroupPresenceEventName]] + group_filters: Optional[list[str]] + + @overload + def __init__( + self, + *, + event_names: list[Union[str, GroupPresenceEventName]], + group_filters: Optional[list[str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.GroupPresenceEventName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + JOINED = "joined" + LEFT = "left" + + + class azure.mgmt.webpubsub.models.IPRule(_Model): + action: Optional[Union[str, ACLAction]] + value: Optional[str] + + @overload + def __init__( + self, + *, + action: Optional[Union[str, ACLAction]] = ..., + value: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + PRIMARY = "Primary" + SALT = "Salt" + SECONDARY = "Secondary" + + + class azure.mgmt.webpubsub.models.LiveTraceCategory(_Model): + enabled: Optional[str] + name: Optional[str] + + @overload + def __init__( + self, + *, + enabled: Optional[str] = ..., + name: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.LiveTraceConfiguration(_Model): + categories: Optional[list[LiveTraceCategory]] + enabled: Optional[str] + + @overload + def __init__( + self, + *, + categories: Optional[list[LiveTraceCategory]] = ..., + enabled: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.LogSpecification(_Model): + display_name: Optional[str] + name: Optional[str] + + @overload + def __init__( + self, + *, + display_name: Optional[str] = ..., + name: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ManagedIdentity(_Model): + principal_id: Optional[str] + tenant_id: Optional[str] + type: Optional[Union[str, ManagedIdentityType]] + user_assigned_identities: Optional[dict[str, UserAssignedIdentityProperty]] + + @overload + def __init__( + self, + *, + type: Optional[Union[str, ManagedIdentityType]] = ..., + user_assigned_identities: Optional[dict[str, UserAssignedIdentityProperty]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ManagedIdentitySettings(_Model): + resource: Optional[str] + + @overload + def __init__( + self, + *, + resource: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + + + class azure.mgmt.webpubsub.models.MetricSpecification(_Model): + aggregation_type: Optional[str] + category: Optional[str] + dimensions: Optional[list[Dimension]] + display_description: Optional[str] + display_name: Optional[str] + fill_gap_with_zero: Optional[str] + name: Optional[str] + unit: Optional[str] + + @overload + def __init__( + self, + *, + aggregation_type: Optional[str] = ..., + category: Optional[str] = ..., + dimensions: Optional[list[Dimension]] = ..., + display_description: Optional[str] = ..., + display_name: Optional[str] = ..., + fill_gap_with_zero: Optional[str] = ..., + name: Optional[str] = ..., + unit: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.NameAvailability(_Model): + message: Optional[str] + name_available: Optional[bool] + reason: Optional[str] + + @overload + def __init__( + self, + *, + message: Optional[str] = ..., + name_available: Optional[bool] = ..., + reason: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.NameAvailabilityParameters(_Model): + name: str + type: str + + @overload + def __init__( + self, + *, + name: str, + type: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.NetworkACL(_Model): + allow: Optional[list[Union[str, WebPubSubRequestType]]] + deny: Optional[list[Union[str, WebPubSubRequestType]]] + + @overload + def __init__( + self, + *, + allow: Optional[list[Union[str, WebPubSubRequestType]]] = ..., + deny: Optional[list[Union[str, WebPubSubRequestType]]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.Operation(_Model): + display: Optional[OperationDisplay] + is_data_action: Optional[bool] + name: Optional[str] + origin: Optional[str] + properties: Optional[OperationProperties] + + @overload + def __init__( + self, + *, + display: Optional[OperationDisplay] = ..., + is_data_action: Optional[bool] = ..., + name: Optional[str] = ..., + origin: Optional[str] = ..., + properties: Optional[OperationProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.OperationDisplay(_Model): + description: Optional[str] + operation: Optional[str] + provider: Optional[str] + resource: Optional[str] + + @overload + def __init__( + self, + *, + description: Optional[str] = ..., + operation: Optional[str] = ..., + provider: Optional[str] = ..., + resource: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.OperationProperties(_Model): + service_specification: Optional[ServiceSpecification] + + @overload + def __init__( + self, + *, + service_specification: Optional[ServiceSpecification] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.PersistentStorage(ProxyResource): + id: str + name: str + properties: PersistentStorageProperties + system_data: SystemData + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + properties: PersistentStorageProperties + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.webpubsub.models.PersistentStorageProperties(_Model): + provisioning_state: Optional[Union[str, ProvisioningState]] + storage_account: ResourceReference + + @overload + def __init__( + self, + *, + storage_account: ResourceReference + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.PrivateEndpoint(_Model): + id: Optional[str] + + @overload + def __init__( + self, + *, + id: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.PrivateEndpointACL(NetworkACL): + allow: Union[list[str, WebPubSubRequestType]] + deny: Union[list[str, WebPubSubRequestType]] + name: str + + @overload + def __init__( + self, + *, + allow: Optional[list[Union[str, WebPubSubRequestType]]] = ..., + deny: Optional[list[Union[str, WebPubSubRequestType]]] = ..., + name: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.PrivateEndpointConnection(ProxyResource): + id: str + name: str + properties: Optional[PrivateEndpointConnectionProperties] + system_data: SystemData + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + properties: Optional[PrivateEndpointConnectionProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.webpubsub.models.PrivateEndpointConnectionProperties(_Model): + group_ids: Optional[list[str]] + private_endpoint: Optional[PrivateEndpoint] + private_link_service_connection_state: Optional[PrivateLinkServiceConnectionState] + provisioning_state: Optional[Union[str, ProvisioningState]] + + @overload + def __init__( + self, + *, + private_endpoint: Optional[PrivateEndpoint] = ..., + private_link_service_connection_state: Optional[PrivateLinkServiceConnectionState] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.PrivateLinkResource(ProxyResource): + id: str + name: str + properties: Optional[PrivateLinkResourceProperties] + system_data: SystemData + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + properties: Optional[PrivateLinkResourceProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.webpubsub.models.PrivateLinkResourceProperties(_Model): + group_id: Optional[str] + required_members: Optional[list[str]] + required_zone_names: Optional[list[str]] + shareable_private_link_resource_types: Optional[list[ShareablePrivateLinkResourceType]] + + @overload + def __init__( + self, + *, + group_id: Optional[str] = ..., + required_members: Optional[list[str]] = ..., + required_zone_names: Optional[list[str]] = ..., + shareable_private_link_resource_types: Optional[list[ShareablePrivateLinkResourceType]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionState(_Model): + actions_required: Optional[str] + description: Optional[str] + status: Optional[Union[str, PrivateLinkServiceConnectionStatus]] + + @overload + def __init__( + self, + *, + actions_required: Optional[str] = ..., + description: Optional[str] = ..., + status: Optional[Union[str, PrivateLinkServiceConnectionStatus]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPROVED = "Approved" + DISCONNECTED = "Disconnected" + PENDING = "Pending" + REJECTED = "Rejected" + + + class azure.mgmt.webpubsub.models.ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + CANCELED = "Canceled" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + MOVING = "Moving" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + UNKNOWN = "Unknown" + UPDATING = "Updating" + + + class azure.mgmt.webpubsub.models.ProxyResource(Resource): + id: str + name: str + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.models.RegenerateKeyParameters(_Model): + key_type: Optional[Union[str, KeyType]] + + @overload + def __init__( + self, + *, + key_type: Optional[Union[str, KeyType]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.Replica(TrackedResource): + id: str + location: str + name: str + properties: Optional[ReplicaProperties] + sku: Optional[ResourceSku] + system_data: SystemData + tags: dict[str, str] + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + location: str, + properties: Optional[ReplicaProperties] = ..., + sku: Optional[ResourceSku] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.webpubsub.models.ReplicaProperties(_Model): + provisioning_state: Optional[Union[str, ProvisioningState]] + region_endpoint_enabled: Optional[str] + resource_stopped: Optional[str] + + @overload + def __init__( + self, + *, + region_endpoint_enabled: Optional[str] = ..., + resource_stopped: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.Resource(_Model): + id: Optional[str] + name: Optional[str] + system_data: Optional[SystemData] + type: Optional[str] + + + class azure.mgmt.webpubsub.models.ResourceLogCategory(_Model): + enabled: Optional[str] + name: Optional[str] + + @overload + def __init__( + self, + *, + enabled: Optional[str] = ..., + name: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ResourceLogConfiguration(_Model): + categories: Optional[list[ResourceLogCategory]] + + @overload + def __init__( + self, + *, + categories: Optional[list[ResourceLogCategory]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ResourceReference(_Model): + id: Optional[str] + + @overload + def __init__( + self, + *, + id: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ResourceSku(_Model): + capacity: Optional[int] + family: Optional[str] + name: str + size: Optional[str] + tier: Optional[Union[str, WebPubSubSkuTier]] + + @overload + def __init__( + self, + *, + capacity: Optional[int] = ..., + name: str, + tier: Optional[Union[str, WebPubSubSkuTier]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + AUTOMATIC = "Automatic" + MANUAL = "Manual" + NONE = "None" + + + class azure.mgmt.webpubsub.models.ServiceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + SOCKET_IO = "SocketIO" + WEB_PUB_SUB = "WebPubSub" + + + class azure.mgmt.webpubsub.models.ServiceSpecification(_Model): + log_specifications: Optional[list[LogSpecification]] + metric_specifications: Optional[list[MetricSpecification]] + + @overload + def __init__( + self, + *, + log_specifications: Optional[list[LogSpecification]] = ..., + metric_specifications: Optional[list[MetricSpecification]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceProperties(_Model): + description: Optional[str] + group_id: Optional[str] + type: Optional[str] + + @overload + def __init__( + self, + *, + description: Optional[str] = ..., + group_id: Optional[str] = ..., + type: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceType(_Model): + name: Optional[str] + properties: Optional[ShareablePrivateLinkResourceProperties] + + @overload + def __init__( + self, + *, + name: Optional[str] = ..., + properties: Optional[ShareablePrivateLinkResourceProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.SharedPrivateLinkResource(ProxyResource): + id: str + name: str + properties: Optional[SharedPrivateLinkResourceProperties] + system_data: SystemData + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + properties: Optional[SharedPrivateLinkResourceProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.webpubsub.models.SharedPrivateLinkResourceProperties(_Model): + fqdns: Optional[list[str]] + group_id: str + private_link_resource_id: str + provisioning_state: Optional[Union[str, ProvisioningState]] + request_message: Optional[str] + status: Optional[Union[str, SharedPrivateLinkResourceStatus]] + + @overload + def __init__( + self, + *, + fqdns: Optional[list[str]] = ..., + group_id: str, + private_link_resource_id: str, + request_message: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.SharedPrivateLinkResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPROVED = "Approved" + DISCONNECTED = "Disconnected" + PENDING = "Pending" + REJECTED = "Rejected" + TIMEOUT = "Timeout" + + + class azure.mgmt.webpubsub.models.SignalRServiceUsage(_Model): + current_value: Optional[int] + id: Optional[str] + limit: Optional[int] + name: Optional[SignalRServiceUsageName] + unit: Optional[str] + + @overload + def __init__( + self, + *, + current_value: Optional[int] = ..., + id: Optional[str] = ..., + limit: Optional[int] = ..., + name: Optional[SignalRServiceUsageName] = ..., + unit: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.SignalRServiceUsageName(_Model): + localized_value: Optional[str] + value: Optional[str] + + @overload + def __init__( + self, + *, + localized_value: Optional[str] = ..., + value: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.Sku(_Model): + capacity: Optional[SkuCapacity] + resource_type: Optional[str] + sku: Optional[ResourceSku] + + + class azure.mgmt.webpubsub.models.SkuCapacity(_Model): + allowed_values: Optional[list[int]] + default: Optional[int] + maximum: Optional[int] + minimum: Optional[int] + scale_type: Optional[Union[str, ScaleType]] + + + class azure.mgmt.webpubsub.models.SkuList(_Model): + next_link: Optional[str] + value: Optional[list[Sku]] + + + class azure.mgmt.webpubsub.models.SystemData(_Model): + created_at: Optional[datetime] + created_by: Optional[str] + created_by_type: Optional[Union[str, CreatedByType]] + last_modified_at: Optional[datetime] + last_modified_by: Optional[str] + last_modified_by_type: Optional[Union[str, CreatedByType]] + + @overload + def __init__( + self, + *, + created_at: Optional[datetime] = ..., + created_by: Optional[str] = ..., + created_by_type: Optional[Union[str, CreatedByType]] = ..., + last_modified_at: Optional[datetime] = ..., + last_modified_by: Optional[str] = ..., + last_modified_by_type: Optional[Union[str, CreatedByType]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ThrottleByJwtCustomClaimRule(ClientConnectionCountRule, discriminator='ThrottleByJwtCustomClaimRule'): + claim_name: str + max_count: Optional[int] + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE] + + @overload + def __init__( + self, + *, + claim_name: str, + max_count: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ThrottleByJwtSignatureRule(ClientConnectionCountRule, discriminator='ThrottleByJwtSignatureRule'): + max_count: Optional[int] + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_SIGNATURE_RULE] + + @overload + def __init__( + self, + *, + max_count: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.ThrottleByUserIdRule(ClientConnectionCountRule, discriminator='ThrottleByUserIdRule'): + max_count: Optional[int] + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_USER_ID_RULE] + + @overload + def __init__( + self, + *, + max_count: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.TrackedResource(Resource): + id: str + location: str + name: str + system_data: SystemData + tags: Optional[dict[str, str]] + type: str + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.TrafficThrottleByJwtCustomClaimRule(ClientTrafficControlRule, discriminator='TrafficThrottleByJwtCustomClaimRule'): + aggregation_window_in_seconds: Optional[int] + claim_name: str + max_inbound_message_bytes: Optional[int] + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE] + + @overload + def __init__( + self, + *, + aggregation_window_in_seconds: Optional[int] = ..., + claim_name: str, + max_inbound_message_bytes: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.TrafficThrottleByJwtSignatureRule(ClientTrafficControlRule, discriminator='TrafficThrottleByJwtSignatureRule'): + aggregation_window_in_seconds: Optional[int] + max_inbound_message_bytes: Optional[int] + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE] + + @overload + def __init__( + self, + *, + aggregation_window_in_seconds: Optional[int] = ..., + max_inbound_message_bytes: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.TrafficThrottleByUserIdRule(ClientTrafficControlRule, discriminator='TrafficThrottleByUserIdRule'): + aggregation_window_in_seconds: Optional[int] + max_inbound_message_bytes: Optional[int] + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_USER_ID_RULE] + + @overload + def __init__( + self, + *, + aggregation_window_in_seconds: Optional[int] = ..., + max_inbound_message_bytes: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.UpstreamAuthSettings(_Model): + managed_identity: Optional[ManagedIdentitySettings] + type: Optional[Union[str, UpstreamAuthType]] + + @overload + def __init__( + self, + *, + managed_identity: Optional[ManagedIdentitySettings] = ..., + type: Optional[Union[str, UpstreamAuthType]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.UpstreamAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + MANAGED_IDENTITY = "ManagedIdentity" + NONE = "None" + + + class azure.mgmt.webpubsub.models.UserAssignedIdentityProperty(_Model): + client_id: Optional[str] + principal_id: Optional[str] + + + class azure.mgmt.webpubsub.models.WebPubSubHub(ProxyResource): + id: str + name: str + properties: WebPubSubHubProperties + system_data: SystemData + type: str + + @overload + def __init__( + self, + *, + properties: WebPubSubHubProperties + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.WebPubSubHubProperties(_Model): + anonymous_connect_policy: Optional[str] + chat: Optional[ChatSettings] + event_handlers: Optional[list[EventHandler]] + event_listeners: Optional[list[EventListener]] + web_socket_keep_alive_interval_in_seconds: Optional[int] + + @overload + def __init__( + self, + *, + anonymous_connect_policy: Optional[str] = ..., + chat: Optional[ChatSettings] = ..., + event_handlers: Optional[list[EventHandler]] = ..., + event_listeners: Optional[list[EventListener]] = ..., + web_socket_keep_alive_interval_in_seconds: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.WebPubSubKeys(_Model): + primary_connection_string: Optional[str] + primary_key: Optional[str] + secondary_connection_string: Optional[str] + secondary_key: Optional[str] + + @overload + def __init__( + self, + *, + primary_connection_string: Optional[str] = ..., + primary_key: Optional[str] = ..., + secondary_connection_string: Optional[str] = ..., + secondary_key: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.WebPubSubNetworkACLs(_Model): + default_action: Optional[Union[str, ACLAction]] + ip_rules: Optional[list[IPRule]] + private_endpoints: Optional[list[PrivateEndpointACL]] + public_network: Optional[NetworkACL] + + @overload + def __init__( + self, + *, + default_action: Optional[Union[str, ACLAction]] = ..., + ip_rules: Optional[list[IPRule]] = ..., + private_endpoints: Optional[list[PrivateEndpointACL]] = ..., + public_network: Optional[NetworkACL] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.WebPubSubProperties(_Model): + application_firewall: Optional[ApplicationFirewallSettings] + disable_aad_auth: Optional[bool] + disable_local_auth: Optional[bool] + external_ip: Optional[str] + host_name: Optional[str] + host_name_prefix: Optional[str] + live_trace_configuration: Optional[LiveTraceConfiguration] + network_ac_ls: Optional[WebPubSubNetworkACLs] + private_endpoint_connections: Optional[list[PrivateEndpointConnection]] + provisioning_state: Optional[Union[str, ProvisioningState]] + public_network_access: Optional[str] + public_port: Optional[int] + region_endpoint_enabled: Optional[str] + resource_log_configuration: Optional[ResourceLogConfiguration] + resource_stopped: Optional[str] + server_port: Optional[int] + shared_private_link_resources: Optional[list[SharedPrivateLinkResource]] + socket_io: Optional[WebPubSubSocketIOSettings] + tls: Optional[WebPubSubTlsSettings] + version: Optional[str] + + @overload + def __init__( + self, + *, + application_firewall: Optional[ApplicationFirewallSettings] = ..., + disable_aad_auth: Optional[bool] = ..., + disable_local_auth: Optional[bool] = ..., + live_trace_configuration: Optional[LiveTraceConfiguration] = ..., + network_ac_ls: Optional[WebPubSubNetworkACLs] = ..., + public_network_access: Optional[str] = ..., + region_endpoint_enabled: Optional[str] = ..., + resource_log_configuration: Optional[ResourceLogConfiguration] = ..., + resource_stopped: Optional[str] = ..., + socket_io: Optional[WebPubSubSocketIOSettings] = ..., + tls: Optional[WebPubSubTlsSettings] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.WebPubSubRequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + CLIENT_CONNECTION = "ClientConnection" + RESTAPI = "RESTAPI" + SERVER_CONNECTION = "ServerConnection" + TRACE = "Trace" + + + class azure.mgmt.webpubsub.models.WebPubSubResource(TrackedResource): + id: str + identity: Optional[ManagedIdentity] + kind: Optional[Union[str, ServiceKind]] + location: str + name: str + properties: Optional[WebPubSubProperties] + sku: Optional[ResourceSku] + system_data: SystemData + tags: dict[str, str] + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + identity: Optional[ManagedIdentity] = ..., + kind: Optional[Union[str, ServiceKind]] = ..., + location: str, + properties: Optional[WebPubSubProperties] = ..., + sku: Optional[ResourceSku] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.webpubsub.models.WebPubSubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + BASIC = "Basic" + FREE = "Free" + PREMIUM = "Premium" + STANDARD = "Standard" + + + class azure.mgmt.webpubsub.models.WebPubSubSocketIOSettings(_Model): + service_mode: Optional[str] + + @overload + def __init__( + self, + *, + service_mode: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.webpubsub.models.WebPubSubTlsSettings(_Model): + client_cert_enabled: Optional[bool] + + @overload + def __init__( + self, + *, + client_cert_enabled: Optional[bool] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + +namespace azure.mgmt.webpubsub.operations + + class azure.mgmt.webpubsub.operations.Operations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged[Operation]: ... + + + class azure.mgmt.webpubsub.operations.UsagesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list( + self, + location: str, + **kwargs: Any + ) -> ItemPaged[SignalRServiceUsage]: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubCustomCertificatesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[CustomCertificate]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[CustomCertificate]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[CustomCertificate]: ... + + @distributed_trace + def delete( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> CustomCertificate: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> ItemPaged[CustomCertificate]: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubCustomDomainsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[CustomDomain]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[CustomDomain]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[CustomDomain]: ... + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + resource_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + name: str, + **kwargs: Any + ) -> CustomDomain: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> ItemPaged[CustomDomain]: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubHubsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubHub]: ... + + @overload + def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubHub]: ... + + @overload + def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubHub]: ... + + @distributed_trace + def begin_delete( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def get( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> WebPubSubHub: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> ItemPaged[WebPubSubHub]: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubResource]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubResource]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubResource]: ... + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubKeys]: ... + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubKeys]: ... + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubKeys]: ... + + @distributed_trace + def begin_restart( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubResource]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubResource]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[WebPubSubResource]: ... + + @overload + def check_name_availability( + self, + location: str, + parameters: NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> NameAvailability: ... + + @overload + def check_name_availability( + self, + location: str, + parameters: NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> NameAvailability: ... + + @overload + def check_name_availability( + self, + location: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> NameAvailability: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> WebPubSubResource: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> ItemPaged[WebPubSubResource]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged[WebPubSubResource]: ... + + @distributed_trace + def list_keys( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> WebPubSubKeys: ... + + @distributed_trace + def list_replica_skus( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> SkuList: ... + + @distributed_trace + def list_skus( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> SkuList: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubPersistentStoragesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: PersistentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[PersistentStorage]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: PersistentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[PersistentStorage]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[PersistentStorage]: ... + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + resource_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + name: str, + **kwargs: Any + ) -> PersistentStorage: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> ItemPaged[PersistentStorage]: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubPrivateEndpointConnectionsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def begin_delete( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def get( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> PrivateEndpointConnection: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> ItemPaged[PrivateEndpointConnection]: ... + + @overload + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> PrivateEndpointConnection: ... + + @overload + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> PrivateEndpointConnection: ... + + @overload + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> PrivateEndpointConnection: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubPrivateLinkResourcesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> ItemPaged[PrivateLinkResource]: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[SharedPrivateLinkResource]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[SharedPrivateLinkResource]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[SharedPrivateLinkResource]: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + **kwargs: Any + ) -> SharedPrivateLinkResource: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> ItemPaged[SharedPrivateLinkResource]: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubReplicasOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Replica]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Replica]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Replica]: ... + + @distributed_trace + def begin_restart( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Replica]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Replica]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Replica]: ... + + @distributed_trace + def delete( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + **kwargs: Any + ) -> Replica: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> ItemPaged[Replica]: ... + + + class azure.mgmt.webpubsub.operations.WebPubSubSharedPrivateLinkResourcesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[SharedPrivateLinkResource]: ... + + @overload + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[SharedPrivateLinkResource]: ... + + @overload + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[SharedPrivateLinkResource]: ... + + @distributed_trace + def begin_delete( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def get( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> SharedPrivateLinkResource: ... + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> ItemPaged[SharedPrivateLinkResource]: ... + + +namespace azure.mgmt.webpubsub.types + + class azure.mgmt.webpubsub.types.ApplicationFirewallSettings(TypedDict, total=False): + key "maxClientConnectionLifetimeInSeconds": int + clientConnectionCountRules: list[ClientConnectionCountRule] + clientTrafficControlRules: list[ClientTrafficControlRule] + client_connection_count_rules: list[ClientConnectionCountRule] + client_traffic_control_rules: list[ClientTrafficControlRule] + max_client_connection_lifetime_in_seconds: int + + + class azure.mgmt.webpubsub.types.ChatSettings(TypedDict, total=False): + key "mode": str + key "persistentStorage": ForwardRef('ResourceReference', module='types') + mode: str + persistent_storage: ResourceReference + + + class azure.mgmt.webpubsub.types.ClientConnectionCountRuleDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE = "ThrottleByJwtCustomClaimRule" + THROTTLE_BY_JWT_SIGNATURE_RULE = "ThrottleByJwtSignatureRule" + THROTTLE_BY_USER_ID_RULE = "ThrottleByUserIdRule" + + + class azure.mgmt.webpubsub.types.ClientTrafficControlRuleDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE = "TrafficThrottleByJwtCustomClaimRule" + TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE = "TrafficThrottleByJwtSignatureRule" + TRAFFIC_THROTTLE_BY_USER_ID_RULE = "TrafficThrottleByUserIdRule" + + + class azure.mgmt.webpubsub.types.CustomCertificate(ProxyResource): + key "id": str + key "name": str + key "properties": Required[CustomCertificateProperties] + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + properties: CustomCertificateProperties + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.CustomCertificateProperties(TypedDict, total=False): + key "keyVaultBaseUri": Required[str] + key "keyVaultSecretName": Required[str] + key "keyVaultSecretVersion": str + key "provisioningState": Union[str, ProvisioningState] + key_vault_base_uri: str + key_vault_secret_name: str + key_vault_secret_version: str + provisioning_state: Union[str, ProvisioningState] + + + class azure.mgmt.webpubsub.types.CustomDomain(ProxyResource): + key "id": str + key "name": str + key "properties": Required[CustomDomainProperties] + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + properties: CustomDomainProperties + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.CustomDomainProperties(TypedDict, total=False): + key "customCertificate": Required[ResourceReference] + key "domainName": Required[str] + key "provisioningState": Union[str, ProvisioningState] + custom_certificate: ResourceReference + domain_name: str + provisioning_state: Union[str, ProvisioningState] + + + class azure.mgmt.webpubsub.types.Dimension(TypedDict, total=False): + key "displayName": str + key "internalName": str + key "name": str + key "toBeExportedForShoebox": bool + display_name: str + internal_name: str + name: str + to_be_exported_for_shoebox: bool + + + class azure.mgmt.webpubsub.types.ErrorAdditionalInfo(TypedDict, total=False): + key "info": Any + key "type": str + info: Any + type: str + + + class azure.mgmt.webpubsub.types.ErrorDetail(TypedDict, total=False): + key "code": str + key "message": str + key "target": str + additionalInfo: list[ErrorAdditionalInfo] + additional_info: list[ErrorAdditionalInfo] + code: str + details: list[ErrorDetail] + message: str + target: str + + + class azure.mgmt.webpubsub.types.ErrorResponse(TypedDict, total=False): + key "error": ForwardRef('ErrorDetail', module='types') + error: ErrorDetail + + + class azure.mgmt.webpubsub.types.EventHandler(TypedDict, total=False): + key "auth": ForwardRef('UpstreamAuthSettings', module='types') + key "groupPresenceEvents": ForwardRef('GroupPresenceEventFilters', module='types') + key "urlTemplate": Required[str] + key "userEventPattern": str + auth: UpstreamAuthSettings + group_presence_events: GroupPresenceEventFilters + systemEvents: list[str] + system_events: list[str] + url_template: str + user_event_pattern: str + + + class azure.mgmt.webpubsub.types.EventHubEndpoint(TypedDict, total=False): + key "eventHubName": Required[str] + key "fullyQualifiedNamespace": Required[str] + key "type": Required[Literal[EventListenerEndpointDiscriminator.EVENT_HUB]] + event_hub_name: str + fully_qualified_namespace: str + type: Literal[EventListenerEndpointDiscriminator.EVENT_HUB] + + + class azure.mgmt.webpubsub.types.EventListener(TypedDict, total=False): + key "endpoint": Required[EventListenerEndpoint] + key "filter": Required[EventListenerFilter] + endpoint: EventListenerEndpoint + filter: EventListenerFilter + + + class azure.mgmt.webpubsub.types.EventListenerEndpoint(TypedDict, total=False): + key "eventHubName": Required[str] + key "fullyQualifiedNamespace": Required[str] + key "type": Required[Literal[EventListenerEndpointDiscriminator.EVENT_HUB]] + event_hub_name: str + fully_qualified_namespace: str + type: Literal[EventListenerEndpointDiscriminator.EVENT_HUB] + + + class azure.mgmt.webpubsub.types.EventListenerEndpointDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + EVENT_HUB = "EventHub" + + + class azure.mgmt.webpubsub.types.EventListenerFilter(TypedDict, total=False): + key "type": Required[Literal[EventListenerFilterDiscriminator.EVENT_NAME]] + key "userEventPattern": str + systemEvents: list[str] + system_events: list[str] + type: Literal[EventListenerFilterDiscriminator.EVENT_NAME] + user_event_pattern: str + + + class azure.mgmt.webpubsub.types.EventListenerFilterDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + EVENT_NAME = "EventName" + + + class azure.mgmt.webpubsub.types.EventNameFilter(TypedDict, total=False): + key "type": Required[Literal[EventListenerFilterDiscriminator.EVENT_NAME]] + key "userEventPattern": str + systemEvents: list[str] + system_events: list[str] + type: Literal[EventListenerFilterDiscriminator.EVENT_NAME] + user_event_pattern: str + + + class azure.mgmt.webpubsub.types.GroupPresenceEventFilters(TypedDict, total=False): + key "eventNames": Required[list[Union[str, GroupPresenceEventName]]] + event_names: list[Union[str, GroupPresenceEventName]] + groupFilters: list[str] + group_filters: list[str] + + + class azure.mgmt.webpubsub.types.IPRule(TypedDict, total=False): + key "action": Union[str, ACLAction] + key "value": str + action: Union[str, ACLAction] + value: str + + + class azure.mgmt.webpubsub.types.LiveTraceCategory(TypedDict, total=False): + key "enabled": str + key "name": str + enabled: str + name: str + + + class azure.mgmt.webpubsub.types.LiveTraceConfiguration(TypedDict, total=False): + key "enabled": str + categories: list[LiveTraceCategory] + enabled: str + + + class azure.mgmt.webpubsub.types.LogSpecification(TypedDict, total=False): + key "displayName": str + key "name": str + display_name: str + name: str + + + class azure.mgmt.webpubsub.types.ManagedIdentity(TypedDict, total=False): + key "principalId": str + key "tenantId": str + key "type": Union[str, ManagedIdentityType] + principal_id: str + tenant_id: str + type: Union[str, ManagedIdentityType] + userAssignedIdentities: dict[str, UserAssignedIdentityProperty] + user_assigned_identities: dict[str, UserAssignedIdentityProperty] + + + class azure.mgmt.webpubsub.types.ManagedIdentitySettings(TypedDict, total=False): + key "resource": str + resource: str + + + class azure.mgmt.webpubsub.types.MetricSpecification(TypedDict, total=False): + key "aggregationType": str + key "category": str + key "displayDescription": str + key "displayName": str + key "fillGapWithZero": str + key "name": str + key "unit": str + aggregation_type: str + category: str + dimensions: list[Dimension] + display_description: str + display_name: str + fill_gap_with_zero: str + name: str + unit: str + + + class azure.mgmt.webpubsub.types.NameAvailability(TypedDict, total=False): + key "message": str + key "nameAvailable": bool + key "reason": str + message: str + name_available: bool + reason: str + + + class azure.mgmt.webpubsub.types.NameAvailabilityParameters(TypedDict, total=False): + key "name": Required[str] + key "type": Required[str] + name: str + type: str + + + class azure.mgmt.webpubsub.types.NetworkACL(TypedDict, total=False): + allow: list[Union[str, WebPubSubRequestType]] + deny: list[Union[str, WebPubSubRequestType]] + + + class azure.mgmt.webpubsub.types.Operation(TypedDict, total=False): + key "display": ForwardRef('OperationDisplay', module='types') + key "isDataAction": bool + key "name": str + key "origin": str + key "properties": ForwardRef('OperationProperties', module='types') + display: OperationDisplay + is_data_action: bool + name: str + origin: str + properties: OperationProperties + + + class azure.mgmt.webpubsub.types.OperationDisplay(TypedDict, total=False): + key "description": str + key "operation": str + key "provider": str + key "resource": str + description: str + operation: str + provider: str + resource: str + + + class azure.mgmt.webpubsub.types.OperationProperties(TypedDict, total=False): + key "serviceSpecification": ForwardRef('ServiceSpecification', module='types') + service_specification: ServiceSpecification + + + class azure.mgmt.webpubsub.types.PersistentStorage(ProxyResource): + key "id": str + key "name": str + key "properties": Required[PersistentStorageProperties] + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + properties: PersistentStorageProperties + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.PersistentStorageProperties(TypedDict, total=False): + key "provisioningState": Union[str, ProvisioningState] + key "storageAccount": Required[ResourceReference] + provisioning_state: Union[str, ProvisioningState] + storage_account: ResourceReference + + + class azure.mgmt.webpubsub.types.PrivateEndpoint(TypedDict, total=False): + key "id": str + id: str + + + class azure.mgmt.webpubsub.types.PrivateEndpointACL(NetworkACL): + key "name": Required[str] + allow: list[Union[str, WebPubSubRequestType]] + deny: list[Union[str, WebPubSubRequestType]] + name: str + + + class azure.mgmt.webpubsub.types.PrivateEndpointConnection(ProxyResource): + key "id": str + key "name": str + key "properties": ForwardRef('PrivateEndpointConnectionProperties', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + properties: PrivateEndpointConnectionProperties + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.PrivateEndpointConnectionProperties(TypedDict, total=False): + key "privateEndpoint": ForwardRef('PrivateEndpoint', module='types') + key "privateLinkServiceConnectionState": ForwardRef('PrivateLinkServiceConnectionState', module='types') + key "provisioningState": Union[str, ProvisioningState] + groupIds: list[str] + group_ids: list[str] + private_endpoint: PrivateEndpoint + private_link_service_connection_state: PrivateLinkServiceConnectionState + provisioning_state: Union[str, ProvisioningState] + + + class azure.mgmt.webpubsub.types.PrivateLinkResource(ProxyResource): + key "id": str + key "name": str + key "properties": ForwardRef('PrivateLinkResourceProperties', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + properties: PrivateLinkResourceProperties + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.PrivateLinkResourceProperties(TypedDict, total=False): + key "groupId": str + group_id: str + requiredMembers: list[str] + requiredZoneNames: list[str] + required_members: list[str] + required_zone_names: list[str] + shareablePrivateLinkResourceTypes: list[ShareablePrivateLinkResourceType] + shareable_private_link_resource_types: list[ShareablePrivateLinkResourceType] + + + class azure.mgmt.webpubsub.types.PrivateLinkServiceConnectionState(TypedDict, total=False): + key "actionsRequired": str + key "description": str + key "status": Union[str, PrivateLinkServiceConnectionStatus] + actions_required: str + description: str + status: Union[str, PrivateLinkServiceConnectionStatus] + + + class azure.mgmt.webpubsub.types.ProxyResource(Resource): + key "id": str + key "name": str + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.RegenerateKeyParameters(TypedDict, total=False): + key "keyType": Union[str, KeyType] + key_type: Union[str, KeyType] + + + class azure.mgmt.webpubsub.types.Replica(TrackedResource): + key "id": str + key "location": Required[str] + key "name": str + key "properties": ForwardRef('ReplicaProperties', module='types') + key "sku": ForwardRef('ResourceSku', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + location: str + name: str + properties: ReplicaProperties + sku: ResourceSku + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.webpubsub.types.ReplicaProperties(TypedDict, total=False): + key "provisioningState": Union[str, ProvisioningState] + key "regionEndpointEnabled": str + key "resourceStopped": str + provisioning_state: Union[str, ProvisioningState] + region_endpoint_enabled: str + resource_stopped: str + + + class azure.mgmt.webpubsub.types.Resource(TypedDict, total=False): + key "id": str + key "name": str + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.ResourceLogCategory(TypedDict, total=False): + key "enabled": str + key "name": str + enabled: str + name: str + + + class azure.mgmt.webpubsub.types.ResourceLogConfiguration(TypedDict, total=False): + categories: list[ResourceLogCategory] + + + class azure.mgmt.webpubsub.types.ResourceReference(TypedDict, total=False): + key "id": str + id: str + + + class azure.mgmt.webpubsub.types.ResourceSku(TypedDict, total=False): + key "capacity": int + key "family": str + key "name": Required[str] + key "size": str + key "tier": Union[str, WebPubSubSkuTier] + capacity: int + family: str + name: str + size: str + tier: Union[str, WebPubSubSkuTier] + + + class azure.mgmt.webpubsub.types.ServiceSpecification(TypedDict, total=False): + logSpecifications: list[LogSpecification] + log_specifications: list[LogSpecification] + metricSpecifications: list[MetricSpecification] + metric_specifications: list[MetricSpecification] + + + class azure.mgmt.webpubsub.types.ShareablePrivateLinkResourceProperties(TypedDict, total=False): + key "description": str + key "groupId": str + key "type": str + description: str + group_id: str + type: str + + + class azure.mgmt.webpubsub.types.ShareablePrivateLinkResourceType(TypedDict, total=False): + key "name": str + key "properties": ForwardRef('ShareablePrivateLinkResourceProperties', module='types') + name: str + properties: ShareablePrivateLinkResourceProperties + + + class azure.mgmt.webpubsub.types.SharedPrivateLinkResource(ProxyResource): + key "id": str + key "name": str + key "properties": ForwardRef('SharedPrivateLinkResourceProperties', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + properties: SharedPrivateLinkResourceProperties + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.SharedPrivateLinkResourceProperties(TypedDict, total=False): + key "groupId": Required[str] + key "privateLinkResourceId": Required[str] + key "provisioningState": Union[str, ProvisioningState] + key "requestMessage": str + key "status": Union[str, SharedPrivateLinkResourceStatus] + fqdns: list[str] + group_id: str + private_link_resource_id: str + provisioning_state: Union[str, ProvisioningState] + request_message: str + status: Union[str, SharedPrivateLinkResourceStatus] + + + class azure.mgmt.webpubsub.types.SignalRServiceUsage(TypedDict, total=False): + key "currentValue": int + key "id": str + key "limit": int + key "name": ForwardRef('SignalRServiceUsageName', module='types') + key "unit": str + current_value: int + id: str + limit: int + name: SignalRServiceUsageName + unit: str + + + class azure.mgmt.webpubsub.types.SignalRServiceUsageName(TypedDict, total=False): + key "localizedValue": str + key "value": str + localized_value: str + value: str + + + class azure.mgmt.webpubsub.types.Sku(TypedDict, total=False): + key "capacity": ForwardRef('SkuCapacity', module='types') + key "resourceType": str + key "sku": ForwardRef('ResourceSku', module='types') + capacity: SkuCapacity + resource_type: str + sku: ResourceSku + + + class azure.mgmt.webpubsub.types.SkuCapacity(TypedDict, total=False): + key "default": int + key "maximum": int + key "minimum": int + key "scaleType": Union[str, ScaleType] + allowedValues: list[int] + allowed_values: list[int] + default: int + maximum: int + minimum: int + scale_type: Union[str, ScaleType] + + + class azure.mgmt.webpubsub.types.SkuList(TypedDict, total=False): + key "nextLink": str + next_link: str + value: list[Sku] + + + class azure.mgmt.webpubsub.types.SystemData(TypedDict, total=False): + key "createdAt": str + key "createdBy": str + key "createdByType": Union[str, CreatedByType] + key "lastModifiedAt": str + key "lastModifiedBy": str + key "lastModifiedByType": Union[str, CreatedByType] + created_at: str + created_by: str + created_by_type: Union[str, CreatedByType] + last_modified_at: str + last_modified_by: str + last_modified_by_type: Union[str, CreatedByType] + + + class azure.mgmt.webpubsub.types.ThrottleByJwtCustomClaimRule(TypedDict, total=False): + key "claimName": Required[str] + key "maxCount": int + key "type": Required[Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE]] + claim_name: str + max_count: int + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE] + + + class azure.mgmt.webpubsub.types.ThrottleByJwtSignatureRule(TypedDict, total=False): + key "maxCount": int + key "type": Required[Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_SIGNATURE_RULE]] + max_count: int + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_SIGNATURE_RULE] + + + class azure.mgmt.webpubsub.types.ThrottleByUserIdRule(TypedDict, total=False): + key "maxCount": int + key "type": Required[Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_USER_ID_RULE]] + max_count: int + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_USER_ID_RULE] + + + class azure.mgmt.webpubsub.types.TrackedResource(Resource): + key "id": str + key "location": Required[str] + key "name": str + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + location: str + name: str + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.webpubsub.types.TrafficThrottleByJwtCustomClaimRule(TypedDict, total=False): + key "aggregationWindowInSeconds": int + key "claimName": Required[str] + key "maxInboundMessageBytes": int + key "type": Required[Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE]] + aggregation_window_in_seconds: int + claim_name: str + max_inbound_message_bytes: int + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE] + + + class azure.mgmt.webpubsub.types.TrafficThrottleByJwtSignatureRule(TypedDict, total=False): + key "aggregationWindowInSeconds": int + key "maxInboundMessageBytes": int + key "type": Required[Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE]] + aggregation_window_in_seconds: int + max_inbound_message_bytes: int + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE] + + + class azure.mgmt.webpubsub.types.TrafficThrottleByUserIdRule(TypedDict, total=False): + key "aggregationWindowInSeconds": int + key "maxInboundMessageBytes": int + key "type": Required[Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_USER_ID_RULE]] + aggregation_window_in_seconds: int + max_inbound_message_bytes: int + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_USER_ID_RULE] + + + class azure.mgmt.webpubsub.types.UpstreamAuthSettings(TypedDict, total=False): + key "managedIdentity": ForwardRef('ManagedIdentitySettings', module='types') + key "type": Union[str, UpstreamAuthType] + managed_identity: ManagedIdentitySettings + type: Union[str, UpstreamAuthType] + + + class azure.mgmt.webpubsub.types.UserAssignedIdentityProperty(TypedDict, total=False): + key "clientId": str + key "principalId": str + client_id: str + principal_id: str + + + class azure.mgmt.webpubsub.types.WebPubSubHub(ProxyResource): + key "id": str + key "name": str + key "properties": Required[WebPubSubHubProperties] + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + properties: WebPubSubHubProperties + system_data: SystemData + type: str + + + class azure.mgmt.webpubsub.types.WebPubSubHubProperties(TypedDict, total=False): + key "anonymousConnectPolicy": str + key "chat": ForwardRef('ChatSettings', module='types') + key "webSocketKeepAliveIntervalInSeconds": int + anonymous_connect_policy: str + chat: ChatSettings + eventHandlers: list[EventHandler] + eventListeners: list[EventListener] + event_handlers: list[EventHandler] + event_listeners: list[EventListener] + web_socket_keep_alive_interval_in_seconds: int + + + class azure.mgmt.webpubsub.types.WebPubSubKeys(TypedDict, total=False): + key "primaryConnectionString": str + key "primaryKey": str + key "secondaryConnectionString": str + key "secondaryKey": str + primary_connection_string: str + primary_key: str + secondary_connection_string: str + secondary_key: str + + + class azure.mgmt.webpubsub.types.WebPubSubNetworkACLs(TypedDict, total=False): + key "defaultAction": Union[str, ACLAction] + key "publicNetwork": ForwardRef('NetworkACL', module='types') + default_action: Union[str, ACLAction] + ipRules: list[IPRule] + ip_rules: list[IPRule] + privateEndpoints: list[PrivateEndpointACL] + private_endpoints: list[PrivateEndpointACL] + public_network: NetworkACL + + + class azure.mgmt.webpubsub.types.WebPubSubProperties(TypedDict, total=False): + key "applicationFirewall": ForwardRef('ApplicationFirewallSettings', module='types') + key "disableAadAuth": bool + key "disableLocalAuth": bool + key "externalIP": str + key "hostName": str + key "hostNamePrefix": str + key "liveTraceConfiguration": ForwardRef('LiveTraceConfiguration', module='types') + key "networkACLs": ForwardRef('WebPubSubNetworkACLs', module='types') + key "provisioningState": Union[str, ProvisioningState] + key "publicNetworkAccess": str + key "publicPort": int + key "regionEndpointEnabled": str + key "resourceLogConfiguration": ForwardRef('ResourceLogConfiguration', module='types') + key "resourceStopped": str + key "serverPort": int + key "socketIO": ForwardRef('WebPubSubSocketIOSettings', module='types') + key "tls": ForwardRef('WebPubSubTlsSettings', module='types') + key "version": str + application_firewall: ApplicationFirewallSettings + disable_aad_auth: bool + disable_local_auth: bool + external_ip: str + host_name: str + host_name_prefix: str + live_trace_configuration: LiveTraceConfiguration + network_ac_ls: WebPubSubNetworkACLs + privateEndpointConnections: list[PrivateEndpointConnection] + private_endpoint_connections: list[PrivateEndpointConnection] + provisioning_state: Union[str, ProvisioningState] + public_network_access: str + public_port: int + region_endpoint_enabled: str + resource_log_configuration: ResourceLogConfiguration + resource_stopped: str + server_port: int + sharedPrivateLinkResources: list[SharedPrivateLinkResource] + shared_private_link_resources: list[SharedPrivateLinkResource] + socket_io: WebPubSubSocketIOSettings + tls: WebPubSubTlsSettings + version: str + + + class azure.mgmt.webpubsub.types.WebPubSubResource(TrackedResource): + key "id": str + key "identity": ForwardRef('ManagedIdentity', module='types') + key "kind": Union[str, ServiceKind] + key "location": Required[str] + key "name": str + key "properties": ForwardRef('WebPubSubProperties', module='types') + key "sku": ForwardRef('ResourceSku', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + identity: ManagedIdentity + kind: Union[str, ServiceKind] + location: str + name: str + properties: WebPubSubProperties + sku: ResourceSku + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.webpubsub.types.WebPubSubSocketIOSettings(TypedDict, total=False): + key "serviceMode": str + service_mode: str + + + class azure.mgmt.webpubsub.types.WebPubSubTlsSettings(TypedDict, total=False): + key "clientCertEnabled": bool + client_cert_enabled: bool + + +``` \ No newline at end of file diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/api.metadata.yml b/sdk/webpubsub/azure-mgmt-webpubsub/api.metadata.yml new file mode 100644 index 000000000000..8f4c9731a3d2 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/api.metadata.yml @@ -0,0 +1,3 @@ +apiMdSha256: dae09598affcab8b7ff0ad7032ded13c310c3603ed2e0a75a742a8be3c5a3c2f +parserVersion: 0.3.28 +pythonVersion: 3.13.14 diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/apiview-properties.json b/sdk/webpubsub/azure-mgmt-webpubsub/apiview-properties.json new file mode 100644 index 000000000000..9905365f3e7c --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/apiview-properties.json @@ -0,0 +1,197 @@ +{ + "CrossLanguagePackageId": "Microsoft.SignalRService", + "CrossLanguageDefinitionId": { + "azure.mgmt.webpubsub.models.ApplicationFirewallSettings": "Microsoft.SignalRService.ApplicationFirewallSettings", + "azure.mgmt.webpubsub.models.ChatSettings": "Microsoft.SignalRService.ChatSettings", + "azure.mgmt.webpubsub.models.ClientConnectionCountRule": "Microsoft.SignalRService.ClientConnectionCountRule", + "azure.mgmt.webpubsub.models.ClientTrafficControlRule": "Microsoft.SignalRService.ClientTrafficControlRule", + "azure.mgmt.webpubsub.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.webpubsub.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.webpubsub.models.CustomCertificate": "Microsoft.SignalRService.CustomCertificate", + "azure.mgmt.webpubsub.models.CustomCertificateProperties": "Microsoft.SignalRService.CustomCertificateProperties", + "azure.mgmt.webpubsub.models.CustomDomain": "Microsoft.SignalRService.CustomDomain", + "azure.mgmt.webpubsub.models.CustomDomainProperties": "Microsoft.SignalRService.CustomDomainProperties", + "azure.mgmt.webpubsub.models.Dimension": "Microsoft.SignalRService.Dimension", + "azure.mgmt.webpubsub.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.webpubsub.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.webpubsub.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.webpubsub.models.EventHandler": "Microsoft.SignalRService.EventHandler", + "azure.mgmt.webpubsub.models.EventListenerEndpoint": "Microsoft.SignalRService.EventListenerEndpoint", + "azure.mgmt.webpubsub.models.EventHubEndpoint": "Microsoft.SignalRService.EventHubEndpoint", + "azure.mgmt.webpubsub.models.EventListener": "Microsoft.SignalRService.EventListener", + "azure.mgmt.webpubsub.models.EventListenerFilter": "Microsoft.SignalRService.EventListenerFilter", + "azure.mgmt.webpubsub.models.EventNameFilter": "Microsoft.SignalRService.EventNameFilter", + "azure.mgmt.webpubsub.models.GroupPresenceEventFilters": "Microsoft.SignalRService.GroupPresenceEventFilters", + "azure.mgmt.webpubsub.models.IPRule": "Microsoft.SignalRService.IPRule", + "azure.mgmt.webpubsub.models.LiveTraceCategory": "Microsoft.SignalRService.LiveTraceCategory", + "azure.mgmt.webpubsub.models.LiveTraceConfiguration": "Microsoft.SignalRService.LiveTraceConfiguration", + "azure.mgmt.webpubsub.models.LogSpecification": "Microsoft.SignalRService.LogSpecification", + "azure.mgmt.webpubsub.models.ManagedIdentity": "Microsoft.SignalRService.ManagedIdentity", + "azure.mgmt.webpubsub.models.ManagedIdentitySettings": "Microsoft.SignalRService.ManagedIdentitySettings", + "azure.mgmt.webpubsub.models.MetricSpecification": "Microsoft.SignalRService.MetricSpecification", + "azure.mgmt.webpubsub.models.NameAvailability": "Microsoft.SignalRService.NameAvailability", + "azure.mgmt.webpubsub.models.NameAvailabilityParameters": "Microsoft.SignalRService.NameAvailabilityParameters", + "azure.mgmt.webpubsub.models.NetworkACL": "Microsoft.SignalRService.NetworkACL", + "azure.mgmt.webpubsub.models.Operation": "Microsoft.SignalRService.Operation", + "azure.mgmt.webpubsub.models.OperationDisplay": "Microsoft.SignalRService.OperationDisplay", + "azure.mgmt.webpubsub.models.OperationProperties": "Microsoft.SignalRService.OperationProperties", + "azure.mgmt.webpubsub.models.PersistentStorage": "Microsoft.SignalRService.PersistentStorage", + "azure.mgmt.webpubsub.models.PersistentStorageProperties": "Microsoft.SignalRService.PersistentStorageProperties", + "azure.mgmt.webpubsub.models.PrivateEndpoint": "Microsoft.SignalRService.PrivateEndpoint", + "azure.mgmt.webpubsub.models.PrivateEndpointACL": "Microsoft.SignalRService.PrivateEndpointACL", + "azure.mgmt.webpubsub.models.PrivateEndpointConnection": "Microsoft.SignalRService.PrivateEndpointConnection", + "azure.mgmt.webpubsub.models.PrivateEndpointConnectionProperties": "Microsoft.SignalRService.PrivateEndpointConnectionProperties", + "azure.mgmt.webpubsub.models.PrivateLinkResource": "Microsoft.SignalRService.PrivateLinkResource", + "azure.mgmt.webpubsub.models.PrivateLinkResourceProperties": "Microsoft.SignalRService.PrivateLinkResourceProperties", + "azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionState": "Microsoft.SignalRService.PrivateLinkServiceConnectionState", + "azure.mgmt.webpubsub.models.RegenerateKeyParameters": "Microsoft.SignalRService.RegenerateKeyParameters", + "azure.mgmt.webpubsub.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.webpubsub.models.Replica": "Microsoft.SignalRService.Replica", + "azure.mgmt.webpubsub.models.ReplicaProperties": "Microsoft.SignalRService.ReplicaProperties", + "azure.mgmt.webpubsub.models.ResourceLogCategory": "Microsoft.SignalRService.ResourceLogCategory", + "azure.mgmt.webpubsub.models.ResourceLogConfiguration": "Microsoft.SignalRService.ResourceLogConfiguration", + "azure.mgmt.webpubsub.models.ResourceReference": "Microsoft.SignalRService.ResourceReference", + "azure.mgmt.webpubsub.models.ResourceSku": "Microsoft.SignalRService.ResourceSku", + "azure.mgmt.webpubsub.models.ServiceSpecification": "Microsoft.SignalRService.ServiceSpecification", + "azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceProperties": "Microsoft.SignalRService.ShareablePrivateLinkResourceProperties", + "azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceType": "Microsoft.SignalRService.ShareablePrivateLinkResourceType", + "azure.mgmt.webpubsub.models.SharedPrivateLinkResource": "Microsoft.SignalRService.SharedPrivateLinkResource", + "azure.mgmt.webpubsub.models.SharedPrivateLinkResourceProperties": "Microsoft.SignalRService.SharedPrivateLinkResourceProperties", + "azure.mgmt.webpubsub.models.SignalRServiceUsage": "Microsoft.SignalRService.SignalRServiceUsage", + "azure.mgmt.webpubsub.models.SignalRServiceUsageName": "Microsoft.SignalRService.SignalRServiceUsageName", + "azure.mgmt.webpubsub.models.Sku": "Microsoft.SignalRService.Sku", + "azure.mgmt.webpubsub.models.SkuCapacity": "Microsoft.SignalRService.SkuCapacity", + "azure.mgmt.webpubsub.models.SkuList": "Microsoft.SignalRService.SkuList", + "azure.mgmt.webpubsub.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.webpubsub.models.ThrottleByJwtCustomClaimRule": "Microsoft.SignalRService.ThrottleByJwtCustomClaimRule", + "azure.mgmt.webpubsub.models.ThrottleByJwtSignatureRule": "Microsoft.SignalRService.ThrottleByJwtSignatureRule", + "azure.mgmt.webpubsub.models.ThrottleByUserIdRule": "Microsoft.SignalRService.ThrottleByUserIdRule", + "azure.mgmt.webpubsub.models.TrafficThrottleByJwtCustomClaimRule": "Microsoft.SignalRService.TrafficThrottleByJwtCustomClaimRule", + "azure.mgmt.webpubsub.models.TrafficThrottleByJwtSignatureRule": "Microsoft.SignalRService.TrafficThrottleByJwtSignatureRule", + "azure.mgmt.webpubsub.models.TrafficThrottleByUserIdRule": "Microsoft.SignalRService.TrafficThrottleByUserIdRule", + "azure.mgmt.webpubsub.models.UpstreamAuthSettings": "Microsoft.SignalRService.UpstreamAuthSettings", + "azure.mgmt.webpubsub.models.UserAssignedIdentityProperty": "Microsoft.SignalRService.UserAssignedIdentityProperty", + "azure.mgmt.webpubsub.models.WebPubSubHub": "Microsoft.SignalRService.WebPubSubHub", + "azure.mgmt.webpubsub.models.WebPubSubHubProperties": "Microsoft.SignalRService.WebPubSubHubProperties", + "azure.mgmt.webpubsub.models.WebPubSubKeys": "Microsoft.SignalRService.WebPubSubKeys", + "azure.mgmt.webpubsub.models.WebPubSubNetworkACLs": "Microsoft.SignalRService.WebPubSubNetworkACLs", + "azure.mgmt.webpubsub.models.WebPubSubProperties": "Microsoft.SignalRService.WebPubSubProperties", + "azure.mgmt.webpubsub.models.WebPubSubResource": "Microsoft.SignalRService.WebPubSubResource", + "azure.mgmt.webpubsub.models.WebPubSubSocketIOSettings": "Microsoft.SignalRService.WebPubSubSocketIOSettings", + "azure.mgmt.webpubsub.models.WebPubSubTlsSettings": "Microsoft.SignalRService.WebPubSubTlsSettings", + "azure.mgmt.webpubsub.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.webpubsub.models.UpstreamAuthType": "Microsoft.SignalRService.UpstreamAuthType", + "azure.mgmt.webpubsub.models.GroupPresenceEventName": "Microsoft.SignalRService.GroupPresenceEventName", + "azure.mgmt.webpubsub.models.EventListenerFilterDiscriminator": "Microsoft.SignalRService.EventListenerFilterDiscriminator", + "azure.mgmt.webpubsub.models.EventListenerEndpointDiscriminator": "Microsoft.SignalRService.EventListenerEndpointDiscriminator", + "azure.mgmt.webpubsub.models.ProvisioningState": "Microsoft.SignalRService.ProvisioningState", + "azure.mgmt.webpubsub.models.SharedPrivateLinkResourceStatus": "Microsoft.SignalRService.SharedPrivateLinkResourceStatus", + "azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionStatus": "Microsoft.SignalRService.PrivateLinkServiceConnectionStatus", + "azure.mgmt.webpubsub.models.ACLAction": "Microsoft.SignalRService.ACLAction", + "azure.mgmt.webpubsub.models.WebPubSubRequestType": "Microsoft.SignalRService.WebPubSubRequestType", + "azure.mgmt.webpubsub.models.ClientConnectionCountRuleDiscriminator": "Microsoft.SignalRService.ClientConnectionCountRuleDiscriminator", + "azure.mgmt.webpubsub.models.ClientTrafficControlRuleDiscriminator": "Microsoft.SignalRService.ClientTrafficControlRuleDiscriminator", + "azure.mgmt.webpubsub.models.WebPubSubSkuTier": "Microsoft.SignalRService.WebPubSubSkuTier", + "azure.mgmt.webpubsub.models.ServiceKind": "Microsoft.SignalRService.ServiceKind", + "azure.mgmt.webpubsub.models.ManagedIdentityType": "Microsoft.SignalRService.ManagedIdentityType", + "azure.mgmt.webpubsub.models.KeyType": "Microsoft.SignalRService.KeyType", + "azure.mgmt.webpubsub.models.ScaleType": "Microsoft.SignalRService.ScaleType", + "azure.mgmt.webpubsub.operations.Operations.list": "Microsoft.SignalRService.Operations.list", + "azure.mgmt.webpubsub.aio.operations.Operations.list": "Microsoft.SignalRService.Operations.list", + "azure.mgmt.webpubsub.operations.WebPubSubHubsOperations.get": "Microsoft.SignalRService.WebPubSubHubs.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubHubsOperations.get": "Microsoft.SignalRService.WebPubSubHubs.get", + "azure.mgmt.webpubsub.operations.WebPubSubHubsOperations.begin_create_or_update": "Microsoft.SignalRService.WebPubSubHubs.createOrUpdate", + "azure.mgmt.webpubsub.aio.operations.WebPubSubHubsOperations.begin_create_or_update": "Microsoft.SignalRService.WebPubSubHubs.createOrUpdate", + "azure.mgmt.webpubsub.operations.WebPubSubHubsOperations.begin_delete": "Microsoft.SignalRService.WebPubSubHubs.delete", + "azure.mgmt.webpubsub.aio.operations.WebPubSubHubsOperations.begin_delete": "Microsoft.SignalRService.WebPubSubHubs.delete", + "azure.mgmt.webpubsub.operations.WebPubSubHubsOperations.list": "Microsoft.SignalRService.WebPubSubHubs.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubHubsOperations.list": "Microsoft.SignalRService.WebPubSubHubs.list", + "azure.mgmt.webpubsub.operations.WebPubSubSharedPrivateLinkResourcesOperations.get": "Microsoft.SignalRService.WebPubSubSharedPrivateLinkResources.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubSharedPrivateLinkResourcesOperations.get": "Microsoft.SignalRService.WebPubSubSharedPrivateLinkResources.get", + "azure.mgmt.webpubsub.operations.WebPubSubSharedPrivateLinkResourcesOperations.begin_create_or_update": "Microsoft.SignalRService.WebPubSubSharedPrivateLinkResources.createOrUpdate", + "azure.mgmt.webpubsub.aio.operations.WebPubSubSharedPrivateLinkResourcesOperations.begin_create_or_update": "Microsoft.SignalRService.WebPubSubSharedPrivateLinkResources.createOrUpdate", + "azure.mgmt.webpubsub.operations.WebPubSubSharedPrivateLinkResourcesOperations.begin_delete": "Microsoft.SignalRService.WebPubSubSharedPrivateLinkResources.delete", + "azure.mgmt.webpubsub.aio.operations.WebPubSubSharedPrivateLinkResourcesOperations.begin_delete": "Microsoft.SignalRService.WebPubSubSharedPrivateLinkResources.delete", + "azure.mgmt.webpubsub.operations.WebPubSubSharedPrivateLinkResourcesOperations.list": "Microsoft.SignalRService.WebPubSubSharedPrivateLinkResources.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubSharedPrivateLinkResourcesOperations.list": "Microsoft.SignalRService.WebPubSubSharedPrivateLinkResources.list", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.get": "Microsoft.SignalRService.WebPubSubResources.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.get": "Microsoft.SignalRService.WebPubSubResources.get", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.begin_create_or_update": "Microsoft.SignalRService.WebPubSubResources.createOrUpdate", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.begin_create_or_update": "Microsoft.SignalRService.WebPubSubResources.createOrUpdate", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.begin_update": "Microsoft.SignalRService.WebPubSubResources.update", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.begin_update": "Microsoft.SignalRService.WebPubSubResources.update", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.begin_delete": "Microsoft.SignalRService.WebPubSubResources.delete", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.begin_delete": "Microsoft.SignalRService.WebPubSubResources.delete", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.list_by_resource_group": "Microsoft.SignalRService.WebPubSubResources.listByResourceGroup", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.list_by_resource_group": "Microsoft.SignalRService.WebPubSubResources.listByResourceGroup", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.list_by_subscription": "Microsoft.SignalRService.WebPubSubResources.listBySubscription", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.list_by_subscription": "Microsoft.SignalRService.WebPubSubResources.listBySubscription", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.list_keys": "Microsoft.SignalRService.WebPubSubResources.listKeys", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.list_keys": "Microsoft.SignalRService.WebPubSubResources.listKeys", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.begin_regenerate_key": "Microsoft.SignalRService.WebPubSubResources.regenerateKey", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.begin_regenerate_key": "Microsoft.SignalRService.WebPubSubResources.regenerateKey", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.begin_restart": "Microsoft.SignalRService.WebPubSubResources.restart", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.begin_restart": "Microsoft.SignalRService.WebPubSubResources.restart", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.list_skus": "Microsoft.SignalRService.WebPubSubResources.listSkus", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.list_skus": "Microsoft.SignalRService.WebPubSubResources.listSkus", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.list_replica_skus": "Microsoft.SignalRService.Replicas.listReplicaSkus", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.list_replica_skus": "Microsoft.SignalRService.Replicas.listReplicaSkus", + "azure.mgmt.webpubsub.operations.WebPubSubOperations.check_name_availability": "Microsoft.SignalRService.WebPubSubOperationGroup.checkNameAvailability", + "azure.mgmt.webpubsub.aio.operations.WebPubSubOperations.check_name_availability": "Microsoft.SignalRService.WebPubSubOperationGroup.checkNameAvailability", + "azure.mgmt.webpubsub.operations.WebPubSubPrivateLinkResourcesOperations.list": "Microsoft.SignalRService.WebPubSubResources.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateLinkResourcesOperations.list": "Microsoft.SignalRService.WebPubSubResources.list", + "azure.mgmt.webpubsub.operations.WebPubSubCustomCertificatesOperations.get": "Microsoft.SignalRService.CustomCertificates.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubCustomCertificatesOperations.get": "Microsoft.SignalRService.CustomCertificates.get", + "azure.mgmt.webpubsub.operations.WebPubSubCustomCertificatesOperations.begin_create_or_update": "Microsoft.SignalRService.CustomCertificates.createOrUpdate", + "azure.mgmt.webpubsub.aio.operations.WebPubSubCustomCertificatesOperations.begin_create_or_update": "Microsoft.SignalRService.CustomCertificates.createOrUpdate", + "azure.mgmt.webpubsub.operations.WebPubSubCustomCertificatesOperations.delete": "Microsoft.SignalRService.CustomCertificates.delete", + "azure.mgmt.webpubsub.aio.operations.WebPubSubCustomCertificatesOperations.delete": "Microsoft.SignalRService.CustomCertificates.delete", + "azure.mgmt.webpubsub.operations.WebPubSubCustomCertificatesOperations.list": "Microsoft.SignalRService.CustomCertificates.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubCustomCertificatesOperations.list": "Microsoft.SignalRService.CustomCertificates.list", + "azure.mgmt.webpubsub.operations.WebPubSubCustomDomainsOperations.get": "Microsoft.SignalRService.CustomDomains.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubCustomDomainsOperations.get": "Microsoft.SignalRService.CustomDomains.get", + "azure.mgmt.webpubsub.operations.WebPubSubCustomDomainsOperations.begin_create_or_update": "Microsoft.SignalRService.CustomDomains.createOrUpdate", + "azure.mgmt.webpubsub.aio.operations.WebPubSubCustomDomainsOperations.begin_create_or_update": "Microsoft.SignalRService.CustomDomains.createOrUpdate", + "azure.mgmt.webpubsub.operations.WebPubSubCustomDomainsOperations.begin_delete": "Microsoft.SignalRService.CustomDomains.delete", + "azure.mgmt.webpubsub.aio.operations.WebPubSubCustomDomainsOperations.begin_delete": "Microsoft.SignalRService.CustomDomains.delete", + "azure.mgmt.webpubsub.operations.WebPubSubCustomDomainsOperations.list": "Microsoft.SignalRService.CustomDomains.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubCustomDomainsOperations.list": "Microsoft.SignalRService.CustomDomains.list", + "azure.mgmt.webpubsub.operations.WebPubSubPrivateEndpointConnectionsOperations.get": "Microsoft.SignalRService.PrivateEndpointConnections.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateEndpointConnectionsOperations.get": "Microsoft.SignalRService.PrivateEndpointConnections.get", + "azure.mgmt.webpubsub.operations.WebPubSubPrivateEndpointConnectionsOperations.update": "Microsoft.SignalRService.PrivateEndpointConnections.update", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateEndpointConnectionsOperations.update": "Microsoft.SignalRService.PrivateEndpointConnections.update", + "azure.mgmt.webpubsub.operations.WebPubSubPrivateEndpointConnectionsOperations.begin_delete": "Microsoft.SignalRService.PrivateEndpointConnections.delete", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateEndpointConnectionsOperations.begin_delete": "Microsoft.SignalRService.PrivateEndpointConnections.delete", + "azure.mgmt.webpubsub.operations.WebPubSubPrivateEndpointConnectionsOperations.list": "Microsoft.SignalRService.PrivateEndpointConnections.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateEndpointConnectionsOperations.list": "Microsoft.SignalRService.PrivateEndpointConnections.list", + "azure.mgmt.webpubsub.operations.WebPubSubReplicasOperations.get": "Microsoft.SignalRService.Replicas.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicasOperations.get": "Microsoft.SignalRService.Replicas.get", + "azure.mgmt.webpubsub.operations.WebPubSubReplicasOperations.begin_create_or_update": "Microsoft.SignalRService.Replicas.createOrUpdate", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicasOperations.begin_create_or_update": "Microsoft.SignalRService.Replicas.createOrUpdate", + "azure.mgmt.webpubsub.operations.WebPubSubReplicasOperations.begin_update": "Microsoft.SignalRService.Replicas.update", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicasOperations.begin_update": "Microsoft.SignalRService.Replicas.update", + "azure.mgmt.webpubsub.operations.WebPubSubReplicasOperations.delete": "Microsoft.SignalRService.Replicas.delete", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicasOperations.delete": "Microsoft.SignalRService.Replicas.delete", + "azure.mgmt.webpubsub.operations.WebPubSubReplicasOperations.list": "Microsoft.SignalRService.Replicas.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicasOperations.list": "Microsoft.SignalRService.Replicas.list", + "azure.mgmt.webpubsub.operations.WebPubSubReplicasOperations.begin_restart": "Microsoft.SignalRService.Replicas.restart", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicasOperations.begin_restart": "Microsoft.SignalRService.Replicas.restart", + "azure.mgmt.webpubsub.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations.get": "Microsoft.SignalRService.SharedPrivateLinkResources.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations.get": "Microsoft.SignalRService.SharedPrivateLinkResources.get", + "azure.mgmt.webpubsub.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations.begin_create_or_update": "Microsoft.SignalRService.SharedPrivateLinkResources.createOrUpdate", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations.begin_create_or_update": "Microsoft.SignalRService.SharedPrivateLinkResources.createOrUpdate", + "azure.mgmt.webpubsub.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations.list": "Microsoft.SignalRService.SharedPrivateLinkResources.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations.list": "Microsoft.SignalRService.SharedPrivateLinkResources.list", + "azure.mgmt.webpubsub.operations.WebPubSubPersistentStoragesOperations.get": "Microsoft.SignalRService.PersistentStorages.get", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPersistentStoragesOperations.get": "Microsoft.SignalRService.PersistentStorages.get", + "azure.mgmt.webpubsub.operations.WebPubSubPersistentStoragesOperations.begin_create_or_update": "Microsoft.SignalRService.PersistentStorages.createOrUpdate", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPersistentStoragesOperations.begin_create_or_update": "Microsoft.SignalRService.PersistentStorages.createOrUpdate", + "azure.mgmt.webpubsub.operations.WebPubSubPersistentStoragesOperations.begin_delete": "Microsoft.SignalRService.PersistentStorages.delete", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPersistentStoragesOperations.begin_delete": "Microsoft.SignalRService.PersistentStorages.delete", + "azure.mgmt.webpubsub.operations.WebPubSubPersistentStoragesOperations.list": "Microsoft.SignalRService.PersistentStorages.list", + "azure.mgmt.webpubsub.aio.operations.WebPubSubPersistentStoragesOperations.list": "Microsoft.SignalRService.PersistentStorages.list", + "azure.mgmt.webpubsub.operations.UsagesOperations.list": "Microsoft.SignalRService.UsagesOperationGroup.list", + "azure.mgmt.webpubsub.aio.operations.UsagesOperations.list": "Microsoft.SignalRService.UsagesOperationGroup.list" + }, + "CrossLanguageVersion": "f35af8a4bb82" +} \ No newline at end of file diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/__init__.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/__init__.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/__init__.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/__init__.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/__init__.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/__init__.py index a465d64c9011..d4443509ad80 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/__init__.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/__init__.py @@ -2,18 +2,24 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._web_pub_sub_management_client import WebPubSubManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import WebPubSubManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "WebPubSubManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_web_pub_sub_management_client.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_client.py similarity index 74% rename from sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_web_pub_sub_management_client.py rename to sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_client.py index ee4f83168b56..cbc3bd9e480f 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_web_pub_sub_management_client.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_client.py @@ -2,22 +2,23 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING -from typing_extensions import Self +import sys +from typing import Any, Optional, TYPE_CHECKING, cast from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models from ._configuration import WebPubSubManagementClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( Operations, UsagesOperations, @@ -25,6 +26,7 @@ WebPubSubCustomDomainsOperations, WebPubSubHubsOperations, WebPubSubOperations, + WebPubSubPersistentStoragesOperations, WebPubSubPrivateEndpointConnectionsOperations, WebPubSubPrivateLinkResourcesOperations, WebPubSubReplicaSharedPrivateLinkResourcesOperations, @@ -32,53 +34,66 @@ WebPubSubSharedPrivateLinkResourcesOperations, ) +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class WebPubSubManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class WebPubSubManagementClient: # pylint: disable=too-many-instance-attributes """REST API for Azure WebPubSub Service. :ivar operations: Operations operations :vartype operations: azure.mgmt.webpubsub.operations.Operations + :ivar web_pub_sub_hubs: WebPubSubHubsOperations operations + :vartype web_pub_sub_hubs: azure.mgmt.webpubsub.operations.WebPubSubHubsOperations + :ivar web_pub_sub_shared_private_link_resources: WebPubSubSharedPrivateLinkResourcesOperations + operations + :vartype web_pub_sub_shared_private_link_resources: + azure.mgmt.webpubsub.operations.WebPubSubSharedPrivateLinkResourcesOperations :ivar web_pub_sub: WebPubSubOperations operations :vartype web_pub_sub: azure.mgmt.webpubsub.operations.WebPubSubOperations - :ivar usages: UsagesOperations operations - :vartype usages: azure.mgmt.webpubsub.operations.UsagesOperations + :ivar web_pub_sub_private_link_resources: WebPubSubPrivateLinkResourcesOperations operations + :vartype web_pub_sub_private_link_resources: + azure.mgmt.webpubsub.operations.WebPubSubPrivateLinkResourcesOperations :ivar web_pub_sub_custom_certificates: WebPubSubCustomCertificatesOperations operations :vartype web_pub_sub_custom_certificates: azure.mgmt.webpubsub.operations.WebPubSubCustomCertificatesOperations :ivar web_pub_sub_custom_domains: WebPubSubCustomDomainsOperations operations :vartype web_pub_sub_custom_domains: azure.mgmt.webpubsub.operations.WebPubSubCustomDomainsOperations - :ivar web_pub_sub_hubs: WebPubSubHubsOperations operations - :vartype web_pub_sub_hubs: azure.mgmt.webpubsub.operations.WebPubSubHubsOperations :ivar web_pub_sub_private_endpoint_connections: WebPubSubPrivateEndpointConnectionsOperations operations :vartype web_pub_sub_private_endpoint_connections: azure.mgmt.webpubsub.operations.WebPubSubPrivateEndpointConnectionsOperations - :ivar web_pub_sub_private_link_resources: WebPubSubPrivateLinkResourcesOperations operations - :vartype web_pub_sub_private_link_resources: - azure.mgmt.webpubsub.operations.WebPubSubPrivateLinkResourcesOperations :ivar web_pub_sub_replicas: WebPubSubReplicasOperations operations :vartype web_pub_sub_replicas: azure.mgmt.webpubsub.operations.WebPubSubReplicasOperations :ivar web_pub_sub_replica_shared_private_link_resources: WebPubSubReplicaSharedPrivateLinkResourcesOperations operations :vartype web_pub_sub_replica_shared_private_link_resources: azure.mgmt.webpubsub.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations - :ivar web_pub_sub_shared_private_link_resources: WebPubSubSharedPrivateLinkResourcesOperations - operations - :vartype web_pub_sub_shared_private_link_resources: - azure.mgmt.webpubsub.operations.WebPubSubSharedPrivateLinkResourcesOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar web_pub_sub_persistent_storages: WebPubSubPersistentStoragesOperations operations + :vartype web_pub_sub_persistent_storages: + azure.mgmt.webpubsub.operations.WebPubSubPersistentStoragesOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.webpubsub.operations.UsagesOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-12-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -88,12 +103,26 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = WebPubSubManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -112,45 +141,47 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.web_pub_sub_hubs = WebPubSubHubsOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_pub_sub_shared_private_link_resources = WebPubSubSharedPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.web_pub_sub = WebPubSubOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_pub_sub_private_link_resources = WebPubSubPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.web_pub_sub_custom_certificates = WebPubSubCustomCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) self.web_pub_sub_custom_domains = WebPubSubCustomDomainsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.web_pub_sub_hubs = WebPubSubHubsOperations(self._client, self._config, self._serialize, self._deserialize) self.web_pub_sub_private_endpoint_connections = WebPubSubPrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.web_pub_sub_private_link_resources = WebPubSubPrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.web_pub_sub_replicas = WebPubSubReplicasOperations( self._client, self._config, self._serialize, self._deserialize ) self.web_pub_sub_replica_shared_private_link_resources = WebPubSubReplicaSharedPrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.web_pub_sub_shared_private_link_resources = WebPubSubSharedPrivateLinkResourcesOperations( + self.web_pub_sub_persistent_storages = WebPubSubPersistentStoragesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -163,7 +194,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_configuration.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_configuration.py index b79aef20a6df..8a42c7dea671 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_configuration.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_configuration.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -14,27 +14,41 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class WebPubSubManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class WebPubSubManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for WebPubSubManagementClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-12-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-03-01") + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2025-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -43,6 +57,8 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-webpubsub/{}".format(VERSION)) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_patch.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_patch.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/__init__.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/model_base.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/model_base.py new file mode 100644 index 000000000000..b93f5120d517 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/model_base.py @@ -0,0 +1,1770 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +from azure.core.rest import HttpResponse + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_duration(td: timedelta, format: typing.Optional[str] = None): + """Serialize a timedelta to its wire representation. + + For the ``seconds``/``milliseconds`` encodings the value is converted to a + numeric value, otherwise it falls back to an ISO 8601 duration string. + + :param timedelta td: The timedelta to serialize. + :param str format: The duration encoding format. + :rtype: int or float or str + :return: serialized duration + """ + seconds = td.total_seconds() + if format == "duration-seconds-int": + return int(seconds) + if format == "duration-seconds-float": + return seconds + if format == "duration-milliseconds-int": + return int(seconds * 1000) + if format == "duration-milliseconds-float": + return seconds * 1000 + return _timedelta_as_isostr(td) + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_duration_numeric(attr, unit): + if isinstance(attr, timedelta): + return attr + return timedelta(**{unit: float(attr)}) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, + "duration-seconds-int": functools.partial(_deserialize_duration_numeric, unit="seconds"), + "duration-seconds-float": functools.partial(_deserialize_duration_numeric, unit="seconds"), + "duration-milliseconds-int": functools.partial(_deserialize_duration_numeric, unit="milliseconds"), + "duration-milliseconds-float": functools.partial(_deserialize_duration_numeric, unit="milliseconds"), +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _serialize_duration(o, format) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +# ============================================================================ +# Fast-path scalar deserializer functions for rest_field(deserializer=...) +# These are referenced from rest_field declarations to bypass the generic +# _deserialize -> _deserialize_with_callable chain. +# Only simple/primitive types — no models or container types. +# ============================================================================ + + +def _xml_deser_str(value): + if isinstance(value, ET.Element): + return value.text or "" + return str(value) if value is not None else None + + +def _xml_deser_int(value): + if isinstance(value, ET.Element): + return int(value.text) if value.text else None + return int(value) if value is not None else None + + +def _xml_deser_float(value): + if isinstance(value, ET.Element): + return float(value.text) if value.text else None + return float(value) if value is not None else None + + +def _xml_deser_bool(value): + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + if text in (True, False): + return text + return text.lower() == "true" + + +# pylint: disable=docstring-missing-param +def _xml_deser_bytes(value): + """Deserialize bytes from XML (base64).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes(text) + + +def _xml_deser_bytes_base64url(value): + """Deserialize bytes from XML (base64url).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes_base64(text) + + +def _xml_deser_datetime(value): + """Deserialize a datetime from XML (ISO 8601 / rfc3339).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime(text) + + +def _xml_deser_datetime_rfc7231(value): + """Deserialize a datetime from XML (RFC7231 format).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_rfc7231(text) + + +def _xml_deser_datetime_unix_timestamp(value): + """Deserialize a datetime from XML (Unix timestamp).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_unix_timestamp(float(text)) + + +def _xml_deser_date(value): + """Deserialize a date from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_date(text) + + +def _xml_deser_time(value): + """Deserialize a time from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_time(text) + + +def _xml_deser_duration(value): + """Deserialize a timedelta from XML (ISO 8601 duration).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_duration(text) + + +def _xml_deser_decimal(value): + """Deserialize a Decimal from XML.""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_decimal(text) + + +def _xml_deser_enum_or_str(enum_cls, value): + """Deserialize a Union[EnumType, str] from XML.""" + text = value.text if isinstance(value, ET.Element) else value + if text is None: + return None + try: + return enum_cls(text) + except ValueError: + return text + + +def _extract_xml_model_type(rf_type): + """Extract the concrete Model class from a resolved rf._type partial chain. + + Unwraps ``Optional[Model]`` and ``_deserialize_model(Model, ...)`` + wrappers. Only handles Model and Optional[Model] — other composite + types (List, Dict, Union, etc.) return None and fall through to the + generic ``_deserialize`` path at runtime. + """ + if rf_type is None: + return None + if isinstance(rf_type, type) and _is_model(rf_type): + return rf_type + if not isinstance(rf_type, functools.partial): + return None + func = rf_type.func + args = rf_type.args + if func is _deserialize_with_optional and args: + return _extract_xml_model_type(args[0]) + if func is _deserialize_model and args: + cls = args[0] + return cls if isinstance(cls, type) and _is_model(cls) else None + return None + + +def _build_xml_field_plan( # pylint: disable=docstring-missing-return, docstring-missing-rtype, unused-variable + cls, attr_to_rest_field: dict +) -> list: + """Build a precomputed XML field plan for fast _init_from_xml iteration. + + Called once per model class in __new__. Returns a list of tuples: + (rest_name, xml_name, kind, deser, rf_type, is_optional, items_name) + + kind: 0=wrapped, 1=attribute, 2=unwrapped, 3=text + + For Model and Optional[Model] fields that lack a scalar + ``_deserializer``, this function precomputes the Model class as the + deserializer so ``_init_from_xml`` can call ``ModelClass(element)`` + directly instead of going through the expensive + ``_get_deserialize_callable_from_annotation`` chain at runtime. + """ + model_meta = getattr(cls, "_xml", {}) + model_ns = model_meta.get("ns") or model_meta.get("namespace") + plan = [] + + for rf in attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + deser = rf._deserializer + + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + is_optional = rf._is_optional + + # For Model / Optional[Model] fields without a scalar deserializer, + # precompute the Model class as the deserializer. + if deser is None and rf._type is not None: + model_cls = _extract_xml_model_type(rf._type) + if model_cls is not None: + deser = model_cls + + if prop_meta.get("attribute", False): + plan.append((rf._rest_name, xml_name, 1, deser, rf._type, is_optional, None)) + elif prop_meta.get("unwrapped", False): + items_name = prop_meta.get("itemsName") + if items_name: + items_ns = prop_meta.get("itemsNs") + if items_ns is not None: + xml_ns = items_ns + if xml_ns: + items_name = "{" + xml_ns + "}" + items_name + else: + items_name = xml_name + plan.append((rf._rest_name, xml_name, 2, deser, rf._type, is_optional, items_name)) + elif prop_meta.get("text", False): + plan.append((rf._rest_name, xml_name, 3, deser, rf._type, is_optional, None)) + else: + plan.append((rf._rest_name, xml_name, 0, deser, rf._type, is_optional, None)) + + return plan + + +# pylint: enable=docstring-missing-param +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass: dict[str, typing.Any] = {} + if args: + if isinstance(args[0], ET.Element): + dict_to_pass.update(self._init_from_xml(args[0])) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + # Apply client default values for fields the caller didn't set so that + # defaults are part of `_data` and therefore included during serialization. + for rf in self._attr_to_rest_field.values(): + if rf._default is _UNSET: + continue + if rf._rest_name in dict_to_pass: + continue + dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) + super().__init__(dict_to_pass) + + def _init_from_xml( # pylint: disable=too-many-branches, too-many-statements + self, element: ET.Element + ) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + existed_attr_keys: list[str] = [] + + field_plan = getattr(self, "_xml_field_plan", None) + if field_plan: + for rest_name, xml_name, kind, deser, rf_type, is_optional, items_name in field_plan: + if kind == 0: # wrapped element (most common) + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(item) + else: + result[rest_name] = _deserialize(rf_type, item) + elif kind == 1: # attribute + attr_val = element.get(xml_name) + if attr_val is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(attr_val) + else: + result[rest_name] = attr_val + elif kind == 2: # unwrapped array + items = element.findall(items_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(items_name) + if deser: + result[rest_name] = deser(items) + else: + result[rest_name] = _deserialize(rf_type, items) + elif not is_optional: + existed_attr_keys.append(items_name) + result[rest_name] = [] + elif kind == 3: # text + if element.text is not None: + if deser: + result[rest_name] = deser(element.text) + else: + result[rest_name] = element.text + else: + model_meta = getattr(self, "_xml", {}) + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + # Build XML field plan for fast _init_from_xml (only for XML models) + if getattr(cls, "_xml", None): + cls._xml_field_plan = _build_xml_field_plan(cls, attr_to_rest_field) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._is_optional = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + self._deserializer = deserializer + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name, _UNSET) + if item is _UNSET: + # Field not set by user; return the client default if one exists, otherwise None + return self._default if self._default is not _UNSET else None + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + # Fast path: use _deserializer directly (avoids _serialize/_deserialize chain) + if self._deserializer: + deserialized = self._deserializer(item) + else: + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + deserializer=deserializer, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) + wrapped_element = _create_xml_element( + element_name, + model_meta.get("prefix"), + _model_ns, + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + _set_xml_attribute(wrapped_element, k, v, prop_meta) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": _dict_ns, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": _items_ns, + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: + ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + if _is_model(deserializer): + return deserializer._deserialize(element, []) + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_serialization.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/serialization.py similarity index 76% rename from sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_serialization.py rename to sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/serialization.py index 8139854b97bb..75906e2eb77f 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_serialization.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_utils/serialization.py @@ -1,30 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -39,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -48,11 +29,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, - List, - Mapping, ) try: @@ -66,9 +43,13 @@ from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -91,6 +72,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +95,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -155,6 +138,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -179,80 +167,31 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: + self.additional_properties: Optional[dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -300,13 +246,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -326,7 +282,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -346,12 +306,14 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -380,12 +342,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -395,30 +360,31 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -426,9 +392,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -448,21 +416,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -501,11 +473,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -540,12 +514,16 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, "unix-time": Serializer.serialize_unix, "duration": Serializer.serialize_duration, + "duration-seconds-int": Serializer.serialize_duration_seconds_int, + "duration-seconds-float": Serializer.serialize_duration_seconds_float, + "duration-milliseconds-int": Serializer.serialize_duration_milliseconds_int, + "duration-milliseconds-float": Serializer.serialize_duration_milliseconds_float, "date": Serializer.serialize_date, "time": Serializer.serialize_time, "decimal": Serializer.serialize_decimal, @@ -556,17 +534,20 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -592,17 +573,19 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -633,7 +616,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -664,17 +648,17 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) raise SerializationError(msg) from err - else: - return serialized + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -703,7 +687,7 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: raise SerializationError("Unable to build a model: " + str(err)) from err @@ -712,11 +696,13 @@ def body(self, data, data_type, **kwargs): def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -728,21 +714,20 @@ def url(self, name, data, data_type, **kwargs): output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator @@ -759,19 +744,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -780,21 +766,20 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") @@ -805,12 +790,12 @@ def serialize_data(self, data, data_type, **kwargs): if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -821,11 +806,10 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." raise SerializationError(msg.format(data, data_type)) from err - else: - return self._serialize(data, **kwargs) + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -841,23 +825,33 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -871,8 +865,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -882,15 +875,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -945,9 +936,8 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} @@ -971,7 +961,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -979,6 +969,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -1003,7 +994,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1034,56 +1025,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1091,11 +1087,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1105,30 +1102,87 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def _serialize_duration_numeric(attr, scale, as_int): + """Serialize a TimeDelta into a numeric value scaled to the wire unit. + + :param TimeDelta attr: Object to be serialized. + :param int scale: Multiplier applied to total seconds (1 for seconds, 1000 for milliseconds). + :param bool as_int: Whether to truncate the result to an int. + :rtype: int or float + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + value = attr.total_seconds() * scale if isinstance(attr, datetime.timedelta) else attr + return int(value) if as_int else float(value) + + @staticmethod + def serialize_duration_seconds_int(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into an integer number of seconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: int + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1, True) + + @staticmethod + def serialize_duration_seconds_float(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into a floating point number of seconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: float + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1, False) + + @staticmethod + def serialize_duration_milliseconds_int(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into an integer number of milliseconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: int + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1000, True) + + @staticmethod + def serialize_duration_milliseconds_float(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into a floating point number of milliseconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: float + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1000, False) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1141,12 +1195,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1172,13 +1227,14 @@ def serialize_iso(attr, **kwargs): raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1186,17 +1242,17 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1211,7 +1267,9 @@ def rest_key_extractor(attr, attr_desc, data): return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1232,17 +1290,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1279,7 +1349,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1331,22 +1401,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1354,7 +1423,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1363,14 +1432,18 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, "unix-time": Deserializer.deserialize_unix, "duration": Deserializer.deserialize_duration, + "duration-seconds-int": Deserializer.deserialize_duration_seconds, + "duration-seconds-float": Deserializer.deserialize_duration_seconds, + "duration-milliseconds-int": Deserializer.deserialize_duration_milliseconds, + "duration-milliseconds-float": Deserializer.deserialize_duration_milliseconds, "date": Deserializer.deserialize_date, "time": Deserializer.deserialize_time, "decimal": Deserializer.deserialize_decimal, @@ -1383,9 +1456,13 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): } self.deserialize_expected_types = { "duration": (isodate.Duration, datetime.timedelta), + "duration-seconds-int": (isodate.Duration, datetime.timedelta), + "duration-seconds-float": (isodate.Duration, datetime.timedelta), + "duration-milliseconds-int": (isodate.Duration, datetime.timedelta), + "duration-milliseconds-float": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1395,33 +1472,56 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): # Otherwise, result are unexpected self.additional_properties_detection = True - def __call__(self, target_obj, response_data, content_type=None): + def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements """Call the deserializer to process a REST response. :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ + # Fast path for header deserialization: response_data is a plain str or None + # and target_obj is a simple scalar type. This avoids the expensive + # _unpack_content → _deserialize → _classify_target → deserialize_data chain. + if response_data is None: + return None + if target_obj == "str" and isinstance(response_data, str): + return response_data + if isinstance(response_data, str): + if target_obj == "int": + return int(response_data) + if target_obj == "bool": + if response_data in ("true", "1", "True"): + return True + if response_data in ("false", "0", "False"): + return False + return bool(response_data) + if target_obj == "rfc-1123": + return Deserializer.deserialize_rfc(response_data) + if target_obj == "bytearray": + return Deserializer.deserialize_bytearray(response_data) + data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1440,13 +1540,13 @@ def _deserialize(self, target_obj, data): if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1476,9 +1576,8 @@ def _deserialize(self, target_obj, data): except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore raise DeserializationError(msg) from err - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1505,6 +1604,8 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None @@ -1516,7 +1617,7 @@ def _classify_target(self, target, data): return target, target try: - target = target._classify(data, self.dependencies) # type: ignore + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1531,10 +1632,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1552,10 +1655,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1579,24 +1684,35 @@ def _unpack_content(raw_data, content_type=None): def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1605,15 +1721,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1627,7 +1744,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1647,14 +1768,14 @@ def deserialize_data(self, data, data_type): msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) raise DeserializationError(msg) from err - else: - return self._deserialize(obj_type, data) + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1671,6 +1792,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1681,13 +1803,14 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1720,11 +1843,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1732,8 +1854,9 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1743,24 +1866,27 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, str): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): @@ -1768,6 +1894,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1781,8 +1908,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1794,6 +1920,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1804,9 +1931,9 @@ def deserialize_enum(data, enum_obj): # Workaround. We might consider remove it in the future. try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1822,8 +1949,9 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1834,8 +1962,9 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1849,8 +1978,9 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text @@ -1865,8 +1995,9 @@ def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1877,8 +2008,9 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1887,16 +2019,58 @@ def deserialize_duration(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." raise DeserializationError(msg) from err - else: - return duration + return duration + + @staticmethod + def _deserialize_duration_numeric(attr, unit): + """Deserialize a numeric duration value into a TimeDelta object. + + :param float attr: response value to be deserialized. + :param str unit: The wire unit, used as the ``timedelta`` keyword + (``"seconds"`` or ``"milliseconds"``). + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = datetime.timedelta(**{unit: float(attr)}) # type: ignore + except (ValueError, OverflowError, TypeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_duration_seconds(attr): + """Deserialize a numeric number of seconds into a TimeDelta object. + + :param float attr: response value to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + return Deserializer._deserialize_duration_numeric(attr, "seconds") + + @staticmethod + def deserialize_duration_milliseconds(attr): + """Deserialize a numeric number of milliseconds into a TimeDelta object. + + :param float attr: response value to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + return Deserializer._deserialize_duration_numeric(attr, "milliseconds") @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1910,8 +2084,9 @@ def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1924,31 +2099,32 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1976,8 +2152,7 @@ def deserialize_iso(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_unix(attr): @@ -1985,8 +2160,9 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore @@ -1996,5 +2172,4 @@ def deserialize_unix(attr): except ValueError as err: msg = "Cannot deserialize to unix datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_version.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_version.py index 48944bf3938a..fd5e9189cf06 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_version.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/_version.py @@ -2,8 +2,8 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0b1" diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/__init__.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/__init__.py index 7698f47538d9..3e410315ad7b 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/__init__.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/__init__.py @@ -2,15 +2,21 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._web_pub_sub_management_client import WebPubSubManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import WebPubSubManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "WebPubSubManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_web_pub_sub_management_client.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_client.py similarity index 75% rename from sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_web_pub_sub_management_client.py rename to sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_client.py index c2e7f6dd188a..d15f19eebdf3 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_web_pub_sub_management_client.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_client.py @@ -2,21 +2,22 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING -from typing_extensions import Self +import sys +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from .. import models as _models -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import WebPubSubManagementClientConfiguration from .operations import ( Operations, @@ -25,6 +26,7 @@ WebPubSubCustomDomainsOperations, WebPubSubHubsOperations, WebPubSubOperations, + WebPubSubPersistentStoragesOperations, WebPubSubPrivateEndpointConnectionsOperations, WebPubSubPrivateLinkResourcesOperations, WebPubSubReplicaSharedPrivateLinkResourcesOperations, @@ -32,53 +34,66 @@ WebPubSubSharedPrivateLinkResourcesOperations, ) +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class WebPubSubManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class WebPubSubManagementClient: # pylint: disable=too-many-instance-attributes """REST API for Azure WebPubSub Service. :ivar operations: Operations operations :vartype operations: azure.mgmt.webpubsub.aio.operations.Operations + :ivar web_pub_sub_hubs: WebPubSubHubsOperations operations + :vartype web_pub_sub_hubs: azure.mgmt.webpubsub.aio.operations.WebPubSubHubsOperations + :ivar web_pub_sub_shared_private_link_resources: WebPubSubSharedPrivateLinkResourcesOperations + operations + :vartype web_pub_sub_shared_private_link_resources: + azure.mgmt.webpubsub.aio.operations.WebPubSubSharedPrivateLinkResourcesOperations :ivar web_pub_sub: WebPubSubOperations operations :vartype web_pub_sub: azure.mgmt.webpubsub.aio.operations.WebPubSubOperations - :ivar usages: UsagesOperations operations - :vartype usages: azure.mgmt.webpubsub.aio.operations.UsagesOperations + :ivar web_pub_sub_private_link_resources: WebPubSubPrivateLinkResourcesOperations operations + :vartype web_pub_sub_private_link_resources: + azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateLinkResourcesOperations :ivar web_pub_sub_custom_certificates: WebPubSubCustomCertificatesOperations operations :vartype web_pub_sub_custom_certificates: azure.mgmt.webpubsub.aio.operations.WebPubSubCustomCertificatesOperations :ivar web_pub_sub_custom_domains: WebPubSubCustomDomainsOperations operations :vartype web_pub_sub_custom_domains: azure.mgmt.webpubsub.aio.operations.WebPubSubCustomDomainsOperations - :ivar web_pub_sub_hubs: WebPubSubHubsOperations operations - :vartype web_pub_sub_hubs: azure.mgmt.webpubsub.aio.operations.WebPubSubHubsOperations :ivar web_pub_sub_private_endpoint_connections: WebPubSubPrivateEndpointConnectionsOperations operations :vartype web_pub_sub_private_endpoint_connections: azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateEndpointConnectionsOperations - :ivar web_pub_sub_private_link_resources: WebPubSubPrivateLinkResourcesOperations operations - :vartype web_pub_sub_private_link_resources: - azure.mgmt.webpubsub.aio.operations.WebPubSubPrivateLinkResourcesOperations :ivar web_pub_sub_replicas: WebPubSubReplicasOperations operations :vartype web_pub_sub_replicas: azure.mgmt.webpubsub.aio.operations.WebPubSubReplicasOperations :ivar web_pub_sub_replica_shared_private_link_resources: WebPubSubReplicaSharedPrivateLinkResourcesOperations operations :vartype web_pub_sub_replica_shared_private_link_resources: azure.mgmt.webpubsub.aio.operations.WebPubSubReplicaSharedPrivateLinkResourcesOperations - :ivar web_pub_sub_shared_private_link_resources: WebPubSubSharedPrivateLinkResourcesOperations - operations - :vartype web_pub_sub_shared_private_link_resources: - azure.mgmt.webpubsub.aio.operations.WebPubSubSharedPrivateLinkResourcesOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar web_pub_sub_persistent_storages: WebPubSubPersistentStoragesOperations operations + :vartype web_pub_sub_persistent_storages: + azure.mgmt.webpubsub.aio.operations.WebPubSubPersistentStoragesOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.webpubsub.aio.operations.UsagesOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-12-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -88,12 +103,26 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = WebPubSubManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -112,39 +141,43 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, _endpoint), policies=_policies, **kwargs + ) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.web_pub_sub_hubs = WebPubSubHubsOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_pub_sub_shared_private_link_resources = WebPubSubSharedPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.web_pub_sub = WebPubSubOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_pub_sub_private_link_resources = WebPubSubPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.web_pub_sub_custom_certificates = WebPubSubCustomCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) self.web_pub_sub_custom_domains = WebPubSubCustomDomainsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.web_pub_sub_hubs = WebPubSubHubsOperations(self._client, self._config, self._serialize, self._deserialize) self.web_pub_sub_private_endpoint_connections = WebPubSubPrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.web_pub_sub_private_link_resources = WebPubSubPrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.web_pub_sub_replicas = WebPubSubReplicasOperations( self._client, self._config, self._serialize, self._deserialize ) self.web_pub_sub_replica_shared_private_link_resources = WebPubSubReplicaSharedPrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.web_pub_sub_shared_private_link_resources = WebPubSubSharedPrivateLinkResourcesOperations( + self.web_pub_sub_persistent_storages = WebPubSubPersistentStoragesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -152,7 +185,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -165,7 +198,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_configuration.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_configuration.py index 5092085a6f3e..f135ed63714d 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_configuration.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_configuration.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -14,27 +14,41 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class WebPubSubManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class WebPubSubManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for WebPubSubManagementClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-12-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-03-01") + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2025-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -43,6 +57,8 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-webpubsub/{}".format(VERSION)) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_patch.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_patch.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/__init__.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/__init__.py index 2e252143d38e..cb028a0825fa 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/__init__.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/__init__.py @@ -2,40 +2,46 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._web_pub_sub_operations import WebPubSubOperations -from ._usages_operations import UsagesOperations -from ._web_pub_sub_custom_certificates_operations import WebPubSubCustomCertificatesOperations -from ._web_pub_sub_custom_domains_operations import WebPubSubCustomDomainsOperations -from ._web_pub_sub_hubs_operations import WebPubSubHubsOperations -from ._web_pub_sub_private_endpoint_connections_operations import WebPubSubPrivateEndpointConnectionsOperations -from ._web_pub_sub_private_link_resources_operations import WebPubSubPrivateLinkResourcesOperations -from ._web_pub_sub_replicas_operations import WebPubSubReplicasOperations -from ._web_pub_sub_replica_shared_private_link_resources_operations import ( - WebPubSubReplicaSharedPrivateLinkResourcesOperations, -) -from ._web_pub_sub_shared_private_link_resources_operations import WebPubSubSharedPrivateLinkResourcesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._operations import WebPubSubHubsOperations # type: ignore +from ._operations import WebPubSubSharedPrivateLinkResourcesOperations # type: ignore +from ._operations import WebPubSubOperations # type: ignore +from ._operations import WebPubSubPrivateLinkResourcesOperations # type: ignore +from ._operations import WebPubSubCustomCertificatesOperations # type: ignore +from ._operations import WebPubSubCustomDomainsOperations # type: ignore +from ._operations import WebPubSubPrivateEndpointConnectionsOperations # type: ignore +from ._operations import WebPubSubReplicasOperations # type: ignore +from ._operations import WebPubSubReplicaSharedPrivateLinkResourcesOperations # type: ignore +from ._operations import WebPubSubPersistentStoragesOperations # type: ignore +from ._operations import UsagesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", + "WebPubSubHubsOperations", + "WebPubSubSharedPrivateLinkResourcesOperations", "WebPubSubOperations", - "UsagesOperations", + "WebPubSubPrivateLinkResourcesOperations", "WebPubSubCustomCertificatesOperations", "WebPubSubCustomDomainsOperations", - "WebPubSubHubsOperations", "WebPubSubPrivateEndpointConnectionsOperations", - "WebPubSubPrivateLinkResourcesOperations", "WebPubSubReplicasOperations", "WebPubSubReplicaSharedPrivateLinkResourcesOperations", - "WebPubSubSharedPrivateLinkResourcesOperations", + "WebPubSubPersistentStoragesOperations", + "UsagesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_operations.py index 9cfe263ab36c..c6c2eefdc6a6 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_operations.py @@ -1,15 +1,18 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from collections.abc import MutableMapping +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,23 +20,77 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models as _models -from ...operations._operations import build_list_request +from ... import models as _models, types as _types +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ...operations._operations import ( + build_operations_list_request, + build_usages_list_request, + build_web_pub_sub_check_name_availability_request, + build_web_pub_sub_create_or_update_request, + build_web_pub_sub_custom_certificates_create_or_update_request, + build_web_pub_sub_custom_certificates_delete_request, + build_web_pub_sub_custom_certificates_get_request, + build_web_pub_sub_custom_certificates_list_request, + build_web_pub_sub_custom_domains_create_or_update_request, + build_web_pub_sub_custom_domains_delete_request, + build_web_pub_sub_custom_domains_get_request, + build_web_pub_sub_custom_domains_list_request, + build_web_pub_sub_delete_request, + build_web_pub_sub_get_request, + build_web_pub_sub_hubs_create_or_update_request, + build_web_pub_sub_hubs_delete_request, + build_web_pub_sub_hubs_get_request, + build_web_pub_sub_hubs_list_request, + build_web_pub_sub_list_by_resource_group_request, + build_web_pub_sub_list_by_subscription_request, + build_web_pub_sub_list_keys_request, + build_web_pub_sub_list_replica_skus_request, + build_web_pub_sub_list_skus_request, + build_web_pub_sub_persistent_storages_create_or_update_request, + build_web_pub_sub_persistent_storages_delete_request, + build_web_pub_sub_persistent_storages_get_request, + build_web_pub_sub_persistent_storages_list_request, + build_web_pub_sub_private_endpoint_connections_delete_request, + build_web_pub_sub_private_endpoint_connections_get_request, + build_web_pub_sub_private_endpoint_connections_list_request, + build_web_pub_sub_private_endpoint_connections_update_request, + build_web_pub_sub_private_link_resources_list_request, + build_web_pub_sub_regenerate_key_request, + build_web_pub_sub_replica_shared_private_link_resources_create_or_update_request, + build_web_pub_sub_replica_shared_private_link_resources_get_request, + build_web_pub_sub_replica_shared_private_link_resources_list_request, + build_web_pub_sub_replicas_create_or_update_request, + build_web_pub_sub_replicas_delete_request, + build_web_pub_sub_replicas_get_request, + build_web_pub_sub_replicas_list_request, + build_web_pub_sub_replicas_restart_request, + build_web_pub_sub_replicas_update_request, + build_web_pub_sub_restart_request, + build_web_pub_sub_shared_private_link_resources_create_or_update_request, + build_web_pub_sub_shared_private_link_resources_delete_request, + build_web_pub_sub_shared_private_link_resources_get_request, + build_web_pub_sub_shared_private_link_resources_list_request, + build_web_pub_sub_update_request, +) +from .._configuration import WebPubSubManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class Operations: @@ -46,30 +103,595 @@ class Operations: :attr:`operations` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available REST API operations of the Microsoft.SignalRService provider. + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: + """List the operations for the provider. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WebPubSubHubsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_hubs` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.WebPubSubHub: + """Get a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: WebPubSubHub. The WebPubSubHub is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.WebPubSubHub + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WebPubSubHub] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_hubs_get_request( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WebPubSubHub, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubHub, _types.WebPubSubHub, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_hubs_create_or_update_request( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.WebPubSubHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubHub]: + """Create or update a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of WebPubSubHub and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubHub + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubHub. The WebPubSubHub is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: _types.WebPubSubHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubHub]: + """Create or update a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of WebPubSubHub and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.types.WebPubSubHub + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubHub. The WebPubSubHub is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubHub]: + """Create or update a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of WebPubSubHub and its properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubHub. The WebPubSubHub is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubHub, _types.WebPubSubHub, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubHub]: + """Create or update a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of WebPubSubHub and its properties. Is either a WebPubSubHub + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubHub or + ~azure.mgmt.webpubsub.types.WebPubSubHub or IO[bytes] + :return: An instance of AsyncLROPoller that returns WebPubSubHub. The WebPubSubHub is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebPubSubHub] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WebPubSubHub, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.WebPubSubHub].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.WebPubSubHub]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_hubs_delete_request( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.WebPubSubHub"]: + """List hub settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of WebPubSubHub + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) + cls: ClsType[List[_models.WebPubSubHub]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,12 +702,20 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_web_pub_sub_hubs_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -98,18 +728,29 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationList", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WebPubSubHub], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -122,7 +763,5943 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WebPubSubSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_shared_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.SharedPrivateLinkResource: + """Get the specified shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: SharedPrivateLinkResource. The SharedPrivateLinkResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_shared_private_link_resources_get_request( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SharedPrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, _types.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_shared_private_link_resources_create_or_update_request( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: _types.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.webpubsub.types.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, _types.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource or + ~azure.mgmt.webpubsub.types.SharedPrivateLinkResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SharedPrivateLinkResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SharedPrivateLinkResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SharedPrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_shared_private_link_resources_delete_request( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the specified shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SharedPrivateLinkResource"]: + """List shared private link resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of SharedPrivateLinkResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SharedPrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_shared_private_link_resources_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SharedPrivateLinkResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WebPubSubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubResource: + """Get the resource and its properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: WebPubSubResource. The WebPubSubResource is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.WebPubSubResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WebPubSubResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubResource, _types.WebPubSubResource, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _types.WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.WebPubSubResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubResource, _types.WebPubSubResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Is either a WebPubSubResource + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource or + ~azure.mgmt.webpubsub.types.WebPubSubResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WebPubSubResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.WebPubSubResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.WebPubSubResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubResource, _types.WebPubSubResource, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _types.WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.WebPubSubResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubResource, _types.WebPubSubResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Is either a WebPubSubResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource or + ~azure.mgmt.webpubsub.types.WebPubSubResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WebPubSubResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.WebPubSubResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.WebPubSubResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Operation to delete a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.WebPubSubResource"]: + """Handles requests to list all resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of WebPubSubResource + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WebPubSubResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WebPubSubResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.WebPubSubResource"]: + """Handles requests to list all resources in a subscription. + + :return: An iterator like instance of WebPubSubResource + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WebPubSubResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WebPubSubResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubKeys: + """Get the access keys of the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: WebPubSubKeys. The WebPubSubKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.WebPubSubKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WebPubSubKeys] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_list_keys_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WebPubSubKeys, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _regenerate_key_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.RegenerateKeyParameters, _types.RegenerateKeyParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_regenerate_key_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.RegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubKeys. The WebPubSubKeys is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: _types.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.RegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubKeys. The WebPubSubKeys is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WebPubSubKeys. The WebPubSubKeys is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.RegenerateKeyParameters, _types.RegenerateKeyParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.WebPubSubKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Is either a + RegenerateKeyParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.RegenerateKeyParameters or + ~azure.mgmt.webpubsub.types.RegenerateKeyParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns WebPubSubKeys. The WebPubSubKeys is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebPubSubKeys] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._regenerate_key_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WebPubSubKeys, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.WebPubSubKeys].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.WebPubSubKeys]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _restart_initial( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_restart_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Operation to restart a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._restart_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SkuList: + """List all available skus of the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: SkuList. The SkuList is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.SkuList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_list_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SkuList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_replica_skus( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> _models.SkuList: + """List all available skus of the replica resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: SkuList. The SkuList is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.SkuList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_list_replica_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SkuList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def check_name_availability( + self, + location: str, + parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.webpubsub.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + location: str, + parameters: _types.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.webpubsub.types.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + location: str, + parameters: Union[_models.NameAvailabilityParameters, _types.NameAvailabilityParameters, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Is either a NameAvailabilityParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.NameAvailabilityParameters or + ~azure.mgmt.webpubsub.types.NameAvailabilityParameters or IO[bytes] + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_check_name_availability_request( + location=location, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NameAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class WebPubSubPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateLinkResource"]: + """Get the private link resources that need to be created for a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of PrivateLinkResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_private_link_resources_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateLinkResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WebPubSubCustomCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_custom_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CustomCertificate: + """Get a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :return: CustomCertificate. The CustomCertificate is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.CustomCertificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_custom_certificates_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CustomCertificate, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: Union[_models.CustomCertificate, _types.CustomCertificate, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_custom_certificates_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: _models.CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.webpubsub.models.CustomCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomCertificate. The CustomCertificate is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: _types.CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.webpubsub.types.CustomCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomCertificate. The CustomCertificate is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomCertificate. The CustomCertificate is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: Union[_models.CustomCertificate, _types.CustomCertificate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Is either a CustomCertificate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.CustomCertificate or + ~azure.mgmt.webpubsub.types.CustomCertificate or IO[bytes] + :return: An instance of AsyncLROPoller that returns CustomCertificate. The CustomCertificate is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomCertificate, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CustomCertificate].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CustomCertificate]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete(self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any) -> None: + """Delete a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_custom_certificates_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CustomCertificate"]: + """List all custom certificates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of CustomCertificate + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CustomCertificate]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_custom_certificates_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CustomCertificate], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WebPubSubCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_custom_domains` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.CustomDomain: + """Get a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :return: CustomDomain. The CustomDomain is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.CustomDomain + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_custom_domains_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CustomDomain, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: Union[_models.CustomDomain, _types.CustomDomain, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_custom_domains_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _models.CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.webpubsub.models.CustomDomain + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _types.CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.webpubsub.types.CustomDomain + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: Union[_models.CustomDomain, _types.CustomDomain, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Is either a CustomDomain type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.CustomDomain or + ~azure.mgmt.webpubsub.types.CustomDomain or IO[bytes] + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_custom_domains_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CustomDomain"]: + """List all custom domains. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of CustomDomain + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CustomDomain]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_custom_domains_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CustomDomain], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WebPubSubPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get the specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_private_endpoint_connections_get_request( + private_endpoint_connection_name=private_endpoint_connection_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: _types.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.types.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.PrivateEndpointConnection, _types.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection or + ~azure.mgmt.webpubsub.types.PrivateEndpointConnection or IO[bytes] + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_private_endpoint_connections_update_request( + private_endpoint_connection_name=private_endpoint_connection_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_private_endpoint_connections_delete_request( + private_endpoint_connection_name=private_endpoint_connection_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + private_endpoint_connection_name=private_endpoint_connection_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: + """List private endpoint connections. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_private_endpoint_connections_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WebPubSubReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_replicas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> _models.Replica: + """Get the replica and its properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: Replica. The Replica is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.Replica + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_replicas_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Replica, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Union[_models.Replica, _types.Replica, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_replicas_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: _models.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Create or update a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: _types.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Create or update a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Create or update a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Union[_models.Replica, _types.Replica, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Create or update a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the create or update operation. Is either a Replica type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.Replica or ~azure.mgmt.webpubsub.types.Replica + or IO[bytes] + :return: An instance of AsyncLROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Replica, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Replica].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Union[_models.Replica, _types.Replica, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_replicas_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: _models.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Operation to update an exiting replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: _types.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Operation to update an exiting replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Operation to update an exiting replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Union[_models.Replica, _types.Replica, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Replica]: + """Operation to update an exiting replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the update operation. Is either a Replica type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.Replica or ~azure.mgmt.webpubsub.types.Replica + or IO[bytes] + :return: An instance of AsyncLROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Replica, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Replica].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete(self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any) -> None: + """Operation to delete a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_replicas_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Replica"]: + """List all replicas belong to this resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of Replica + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Replica]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_replicas_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Replica], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _restart_initial( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_replicas_restart_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_restart( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Operation to restart a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._restart_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class WebPubSubReplicaSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_replica_shared_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + **kwargs: Any + ) -> _models.SharedPrivateLinkResource: + """Get the specified shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :return: SharedPrivateLinkResource. The SharedPrivateLinkResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_replica_shared_private_link_resources_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SharedPrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, _types.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_replica_shared_private_link_resources_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: _models.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: _types.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.webpubsub.types.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, _types.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource or + ~azure.mgmt.webpubsub.types.SharedPrivateLinkResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SharedPrivateLinkResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SharedPrivateLinkResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SharedPrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SharedPrivateLinkResource"]: + """List shared private link resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: An iterator like instance of SharedPrivateLinkResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SharedPrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_replica_shared_private_link_resources_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SharedPrivateLinkResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WebPubSubPersistentStoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`web_pub_sub_persistent_storages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any + ) -> _models.PersistentStorage: + """Get a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :return: PersistentStorage. The PersistentStorage is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PersistentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PersistentStorage] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_persistent_storages_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PersistentStorage, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: Union[_models.PersistentStorage, _types.PersistentStorage, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_persistent_storages_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _models.PersistentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PersistentStorage]: + """Create or update a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :param parameters: The resource of persistent storage and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.models.PersistentStorage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PersistentStorage. The PersistentStorage is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _types.PersistentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PersistentStorage]: + """Create or update a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :param parameters: The resource of persistent storage and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.types.PersistentStorage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PersistentStorage. The PersistentStorage is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PersistentStorage]: + """Create or update a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :param parameters: The resource of persistent storage and its properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PersistentStorage. The PersistentStorage is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: Union[_models.PersistentStorage, _types.PersistentStorage, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PersistentStorage]: + """Create or update a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :param parameters: The resource of persistent storage and its properties. Is either a + PersistentStorage type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.PersistentStorage or + ~azure.mgmt.webpubsub.types.PersistentStorage or IO[bytes] + :return: An instance of AsyncLROPoller that returns PersistentStorage. The PersistentStorage is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PersistentStorage] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PersistentStorage, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PersistentStorage].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PersistentStorage]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_persistent_storages_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PersistentStorage"]: + """List all persistent storages. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of PersistentStorage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PersistentStorage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_persistent_storages_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PersistentStorage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s + :attr:`usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.SignalRServiceUsage"]: + """List resource usage quotas by location. + + :param location: The location name. Required. + :type location: str + :return: An iterator like instance of SignalRServiceUsage + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.SignalRServiceUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SignalRServiceUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_usages_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SignalRServiceUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_patch.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_patch.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_usages_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_usages_operations.py deleted file mode 100644 index 0817ef94dc5d..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_usages_operations.py +++ /dev/null @@ -1,135 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ...operations._usages_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class UsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.SignalRServiceUsage"]: - """List resource usage quotas by location. - - :param location: the location like "eastus". Required. - :type location: str - :return: An iterator like instance of either SignalRServiceUsage or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.SignalRServiceUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SignalRServiceUsageList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SignalRServiceUsageList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_custom_certificates_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_custom_certificates_operations.py deleted file mode 100644 index 5de32997f823..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_custom_certificates_operations.py +++ /dev/null @@ -1,476 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._web_pub_sub_custom_certificates_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubCustomCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub_custom_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CustomCertificate"]: - """List all custom certificates. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either CustomCertificate or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.CustomCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomCertificateList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomCertificateList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any - ) -> _models.CustomCertificate: - """Get a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :return: CustomCertificate or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.CustomCertificate - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomCertificate", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - parameters: Union[_models.CustomCertificate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomCertificate") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - parameters: _models.CustomCertificate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomCertificate]: - """Create or update a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.webpubsub.models.CustomCertificate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CustomCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomCertificate]: - """Create or update a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CustomCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - parameters: Union[_models.CustomCertificate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomCertificate]: - """Create or update a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :param parameters: Is either a CustomCertificate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.CustomCertificate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CustomCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - certificate_name=certificate_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomCertificate", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CustomCertificate].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CustomCertificate]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any - ) -> None: - """Delete a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_custom_domains_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_custom_domains_operations.py deleted file mode 100644 index 2f18ff05efd0..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_custom_domains_operations.py +++ /dev/null @@ -1,529 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._web_pub_sub_custom_domains_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubCustomDomainsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub_custom_domains` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CustomDomain"]: - """List all custom domains. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either CustomDomain or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomDomainList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomDomainList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.CustomDomain: - """Get a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :return: CustomDomain or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.CustomDomain - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - name: str, - parameters: Union[_models.CustomDomain, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomDomain") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - name: str, - parameters: _models.CustomDomain, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Create or update a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.webpubsub.models.CustomDomain - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Create or update a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - name: str, - parameters: Union[_models.CustomDomain, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Create or update a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :param parameters: Is either a CustomDomain type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.CustomDomain or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_hubs_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_hubs_operations.py deleted file mode 100644 index d76c4850e5b4..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_hubs_operations.py +++ /dev/null @@ -1,532 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._web_pub_sub_hubs_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubHubsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub_hubs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WebPubSubHub"]: - """List hub settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either WebPubSubHub or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.WebPubSubHub] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubHubList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("WebPubSubHubList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.WebPubSubHub: - """Get a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: WebPubSubHub or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.WebPubSubHub - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubHub] = kwargs.pop("cls", None) - - _request = build_get_request( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WebPubSubHub", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - hub_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubHub, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "WebPubSubHub") - - _request = build_create_or_update_request( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - hub_name: str, - resource_group_name: str, - resource_name: str, - parameters: _models.WebPubSubHub, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubHub]: - """Create or update a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of WebPubSubHub and its properties. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubHub - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WebPubSubHub or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - hub_name: str, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubHub]: - """Create or update a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of WebPubSubHub and its properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WebPubSubHub or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - hub_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubHub, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubHub]: - """Create or update a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of WebPubSubHub and its properties. Is either a WebPubSubHub - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubHub or IO[bytes] - :return: An instance of AsyncLROPoller that returns either WebPubSubHub or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebPubSubHub] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WebPubSubHub", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.WebPubSubHub].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.WebPubSubHub]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_operations.py deleted file mode 100644 index fe2883a73481..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_operations.py +++ /dev/null @@ -1,1383 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._web_pub_sub_operations import ( - build_check_name_availability_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_list_keys_request, - build_list_replica_skus_request, - build_list_skus_request, - build_regenerate_key_request, - build_restart_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def check_name_availability( - self, - location: str, - parameters: _models.NameAvailabilityParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Checks that the resource name is valid and is not already in use. - - :param location: the region. Required. - :type location: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.NameAvailabilityParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailability: - """Checks that the resource name is valid and is not already in use. - - :param location: the region. Required. - :type location: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, location: str, parameters: Union[_models.NameAvailabilityParameters, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailability: - """Checks that the resource name is valid and is not already in use. - - :param location: the region. Required. - :type location: str - :param parameters: Parameters supplied to the operation. Is either a NameAvailabilityParameters - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.NameAvailabilityParameters or IO[bytes] - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "NameAvailabilityParameters") - - _request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NameAvailability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.WebPubSubResource"]: - """Handles requests to list all resources in a subscription. - - :return: An iterator like instance of either WebPubSubResource or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("WebPubSubResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WebPubSubResource"]: - """Handles requests to list all resources in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either WebPubSubResource or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("WebPubSubResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubResource: - """Get the resource and its properties. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: WebPubSubResource or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.WebPubSubResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WebPubSubResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubResource, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "WebPubSubResource") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.WebPubSubResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubResource]: - """Create or update a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the create or update operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubResource]: - """Create or update a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the create or update operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubResource, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubResource]: - """Create or update a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the create or update operation. Is either a WebPubSubResource - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WebPubSubResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.WebPubSubResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.WebPubSubResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Operation to delete a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubResource, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "WebPubSubResource") - - _request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.WebPubSubResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubResource]: - """Operation to update an exiting resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the update operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubResource]: - """Operation to update an exiting resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the update operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubResource, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubResource]: - """Operation to update an exiting resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the update operation. Is either a WebPubSubResource type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WebPubSubResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.WebPubSubResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.WebPubSubResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubKeys: - """Get the access keys of the resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: WebPubSubKeys or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.WebPubSubKeys - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubKeys] = kwargs.pop("cls", None) - - _request = build_list_keys_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WebPubSubKeys", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _regenerate_key_initial( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RegenerateKeyParameters") - - _request = build_regenerate_key_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_regenerate_key( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.RegenerateKeyParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubKeys]: - """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated - at the same time. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameter that describes the Regenerate Key Operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.RegenerateKeyParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WebPubSubKeys or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_regenerate_key( - self, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubKeys]: - """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated - at the same time. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameter that describes the Regenerate Key Operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WebPubSubKeys or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_regenerate_key( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.WebPubSubKeys]: - """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated - at the same time. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameter that describes the Regenerate Key Operation. Is either a - RegenerateKeyParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.RegenerateKeyParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either WebPubSubKeys or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebPubSubKeys] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._regenerate_key_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WebPubSubKeys", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.WebPubSubKeys].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.WebPubSubKeys]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def list_replica_skus( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> _models.SkuList: - """List all available skus of the replica resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: SkuList or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.SkuList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) - - _request = build_list_replica_skus_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SkuList", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _restart_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restart_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Operation to restart a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SkuList: - """List all available skus of the resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: SkuList or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.SkuList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) - - _request = build_list_skus_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SkuList", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_private_endpoint_connections_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_private_endpoint_connections_operations.py deleted file mode 100644 index b29a06f78e4f..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_private_endpoint_connections_operations.py +++ /dev/null @@ -1,472 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._web_pub_sub_private_endpoint_connections_operations import ( - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub_private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - """List private endpoint connections. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get the specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - private_endpoint_connection_name=private_endpoint_connection_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Update the state of specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of private endpoint and its properties. Required. - :type parameters: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Update the state of specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of private endpoint and its properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Update the state of specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of private endpoint and its properties. Is either a - PrivateEndpointConnection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection or IO[bytes] - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PrivateEndpointConnection") - - _request = build_update_request( - private_endpoint_connection_name=private_endpoint_connection_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( - self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - private_endpoint_connection_name=private_endpoint_connection_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete the specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - private_endpoint_connection_name=private_endpoint_connection_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_private_link_resources_operations.py deleted file mode 100644 index aafe6b9077b8..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_private_link_resources_operations.py +++ /dev/null @@ -1,141 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ...operations._web_pub_sub_private_link_resources_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubPrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResource"]: - """Get the private link resources that need to be created for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateLinkResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateLinkResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_replica_shared_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_replica_shared_private_link_resources_operations.py deleted file mode 100644 index 68383b3f677b..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_replica_shared_private_link_resources_operations.py +++ /dev/null @@ -1,451 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._web_pub_sub_replica_shared_private_link_resources_operations import ( - build_create_or_update_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubReplicaSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub_replica_shared_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SharedPrivateLinkResource"]: - """List shared private link resources. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: An iterator like instance of either SharedPrivateLinkResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SharedPrivateLinkResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - **kwargs: Any - ) -> _models.SharedPrivateLinkResource: - """Get the specified shared private link resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :return: SharedPrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SharedPrivateLinkResource") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - parameters: _models.SharedPrivateLinkResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param parameters: The shared private link resource. Required. - :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param parameters: The shared private link resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - shared_private_link_resource_name=shared_private_link_resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.SharedPrivateLinkResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SharedPrivateLinkResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_replicas_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_replicas_operations.py deleted file mode 100644 index 82cdde19d9d3..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_replicas_operations.py +++ /dev/null @@ -1,804 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._web_pub_sub_replicas_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, - build_restart_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubReplicasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub_replicas` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncIterable["_models.Replica"]: - """List all replicas belong to this resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either Replica or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ReplicaList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ReplicaList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> _models.Replica: - """Get the replica and its properties. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: Replica or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.Replica - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Replica", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: Union[_models.Replica, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Replica") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: _models.Replica, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Replica]: - """Create or update a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the create or update operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.Replica - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replica or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Replica]: - """Create or update a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the create or update operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replica or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: Union[_models.Replica, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Replica]: - """Create or update a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the create or update operation. Is either a Replica type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.Replica or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Replica or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Replica].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replica]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> None: - """Operation to delete a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: Union[_models.Replica, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Replica") - - _request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: _models.Replica, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Replica]: - """Operation to update an exiting replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the update operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.Replica - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replica or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Replica]: - """Operation to update an exiting replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the update operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replica or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: Union[_models.Replica, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Replica]: - """Operation to update an exiting replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the update operation. Is either a Replica type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.Replica or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Replica or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Replica].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replica]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _restart_initial( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restart_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_restart( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Operation to restart a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_shared_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_shared_private_link_resources_operations.py deleted file mode 100644 index a44c3b21fefd..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/aio/operations/_web_pub_sub_shared_private_link_resources_operations.py +++ /dev/null @@ -1,542 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ...operations._web_pub_sub_shared_private_link_resources_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WebPubSubSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.aio.WebPubSubManagementClient`'s - :attr:`web_pub_sub_shared_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SharedPrivateLinkResource"]: - """List shared private link resources. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either SharedPrivateLinkResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SharedPrivateLinkResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.SharedPrivateLinkResource: - """Get the specified shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: SharedPrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_request( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SharedPrivateLinkResource") - - _request = build_create_or_update_request( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - parameters: _models.SharedPrivateLinkResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The shared private link resource. Required. - :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The shared private link resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.SharedPrivateLinkResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SharedPrivateLinkResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete the specified shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/__init__.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/__init__.py index 5a3e3d1254da..66413f150749 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/__init__.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/__init__.py @@ -2,102 +2,130 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import CustomCertificate -from ._models_py3 import CustomCertificateList -from ._models_py3 import CustomDomain -from ._models_py3 import CustomDomainList -from ._models_py3 import Dimension -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import EventHandler -from ._models_py3 import EventHubEndpoint -from ._models_py3 import EventListener -from ._models_py3 import EventListenerEndpoint -from ._models_py3 import EventListenerFilter -from ._models_py3 import EventNameFilter -from ._models_py3 import IPRule -from ._models_py3 import LiveTraceCategory -from ._models_py3 import LiveTraceConfiguration -from ._models_py3 import LogSpecification -from ._models_py3 import ManagedIdentity -from ._models_py3 import ManagedIdentitySettings -from ._models_py3 import MetricSpecification -from ._models_py3 import NameAvailability -from ._models_py3 import NameAvailabilityParameters -from ._models_py3 import NetworkACL -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationList -from ._models_py3 import OperationProperties -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointACL -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionList -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceList -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import ProxyResource -from ._models_py3 import RegenerateKeyParameters -from ._models_py3 import Replica -from ._models_py3 import ReplicaList -from ._models_py3 import Resource -from ._models_py3 import ResourceLogCategory -from ._models_py3 import ResourceLogConfiguration -from ._models_py3 import ResourceReference -from ._models_py3 import ResourceSku -from ._models_py3 import ServiceSpecification -from ._models_py3 import ShareablePrivateLinkResourceProperties -from ._models_py3 import ShareablePrivateLinkResourceType -from ._models_py3 import SharedPrivateLinkResource -from ._models_py3 import SharedPrivateLinkResourceList -from ._models_py3 import SignalRServiceUsage -from ._models_py3 import SignalRServiceUsageList -from ._models_py3 import SignalRServiceUsageName -from ._models_py3 import Sku -from ._models_py3 import SkuCapacity -from ._models_py3 import SkuList -from ._models_py3 import SystemData -from ._models_py3 import TrackedResource -from ._models_py3 import UpstreamAuthSettings -from ._models_py3 import UserAssignedIdentityProperty -from ._models_py3 import WebPubSubHub -from ._models_py3 import WebPubSubHubList -from ._models_py3 import WebPubSubHubProperties -from ._models_py3 import WebPubSubKeys -from ._models_py3 import WebPubSubNetworkACLs -from ._models_py3 import WebPubSubResource -from ._models_py3 import WebPubSubResourceList -from ._models_py3 import WebPubSubSocketIOSettings -from ._models_py3 import WebPubSubTlsSettings +from typing import TYPE_CHECKING -from ._web_pub_sub_management_client_enums import ACLAction -from ._web_pub_sub_management_client_enums import CreatedByType -from ._web_pub_sub_management_client_enums import EventListenerEndpointDiscriminator -from ._web_pub_sub_management_client_enums import EventListenerFilterDiscriminator -from ._web_pub_sub_management_client_enums import KeyType -from ._web_pub_sub_management_client_enums import ManagedIdentityType -from ._web_pub_sub_management_client_enums import PrivateLinkServiceConnectionStatus -from ._web_pub_sub_management_client_enums import ProvisioningState -from ._web_pub_sub_management_client_enums import ScaleType -from ._web_pub_sub_management_client_enums import ServiceKind -from ._web_pub_sub_management_client_enums import SharedPrivateLinkResourceStatus -from ._web_pub_sub_management_client_enums import UpstreamAuthType -from ._web_pub_sub_management_client_enums import WebPubSubRequestType -from ._web_pub_sub_management_client_enums import WebPubSubSkuTier +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models import ( # type: ignore + ApplicationFirewallSettings, + ChatSettings, + ClientConnectionCountRule, + ClientTrafficControlRule, + CustomCertificate, + CustomCertificateProperties, + CustomDomain, + CustomDomainProperties, + Dimension, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + EventHandler, + EventHubEndpoint, + EventListener, + EventListenerEndpoint, + EventListenerFilter, + EventNameFilter, + GroupPresenceEventFilters, + IPRule, + LiveTraceCategory, + LiveTraceConfiguration, + LogSpecification, + ManagedIdentity, + ManagedIdentitySettings, + MetricSpecification, + NameAvailability, + NameAvailabilityParameters, + NetworkACL, + Operation, + OperationDisplay, + OperationProperties, + PersistentStorage, + PersistentStorageProperties, + PrivateEndpoint, + PrivateEndpointACL, + PrivateEndpointConnection, + PrivateEndpointConnectionProperties, + PrivateLinkResource, + PrivateLinkResourceProperties, + PrivateLinkServiceConnectionState, + ProxyResource, + RegenerateKeyParameters, + Replica, + ReplicaProperties, + Resource, + ResourceLogCategory, + ResourceLogConfiguration, + ResourceReference, + ResourceSku, + ServiceSpecification, + ShareablePrivateLinkResourceProperties, + ShareablePrivateLinkResourceType, + SharedPrivateLinkResource, + SharedPrivateLinkResourceProperties, + SignalRServiceUsage, + SignalRServiceUsageName, + Sku, + SkuCapacity, + SkuList, + SystemData, + ThrottleByJwtCustomClaimRule, + ThrottleByJwtSignatureRule, + ThrottleByUserIdRule, + TrackedResource, + TrafficThrottleByJwtCustomClaimRule, + TrafficThrottleByJwtSignatureRule, + TrafficThrottleByUserIdRule, + UpstreamAuthSettings, + UserAssignedIdentityProperty, + WebPubSubHub, + WebPubSubHubProperties, + WebPubSubKeys, + WebPubSubNetworkACLs, + WebPubSubProperties, + WebPubSubResource, + WebPubSubSocketIOSettings, + WebPubSubTlsSettings, +) + +from ._enums import ( # type: ignore + ACLAction, + ClientConnectionCountRuleDiscriminator, + ClientTrafficControlRuleDiscriminator, + CreatedByType, + EventListenerEndpointDiscriminator, + EventListenerFilterDiscriminator, + GroupPresenceEventName, + KeyType, + ManagedIdentityType, + PrivateLinkServiceConnectionStatus, + ProvisioningState, + ScaleType, + ServiceKind, + SharedPrivateLinkResourceStatus, + UpstreamAuthType, + WebPubSubRequestType, + WebPubSubSkuTier, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ApplicationFirewallSettings", + "ChatSettings", + "ClientConnectionCountRule", + "ClientTrafficControlRule", "CustomCertificate", - "CustomCertificateList", + "CustomCertificateProperties", "CustomDomain", - "CustomDomainList", + "CustomDomainProperties", "Dimension", "ErrorAdditionalInfo", "ErrorDetail", @@ -108,6 +136,7 @@ "EventListenerEndpoint", "EventListenerFilter", "EventNameFilter", + "GroupPresenceEventFilters", "IPRule", "LiveTraceCategory", "LiveTraceConfiguration", @@ -120,19 +149,20 @@ "NetworkACL", "Operation", "OperationDisplay", - "OperationList", "OperationProperties", + "PersistentStorage", + "PersistentStorageProperties", "PrivateEndpoint", "PrivateEndpointACL", "PrivateEndpointConnection", - "PrivateEndpointConnectionList", + "PrivateEndpointConnectionProperties", "PrivateLinkResource", - "PrivateLinkResourceList", + "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", "ProxyResource", "RegenerateKeyParameters", "Replica", - "ReplicaList", + "ReplicaProperties", "Resource", "ResourceLogCategory", "ResourceLogConfiguration", @@ -142,30 +172,37 @@ "ShareablePrivateLinkResourceProperties", "ShareablePrivateLinkResourceType", "SharedPrivateLinkResource", - "SharedPrivateLinkResourceList", + "SharedPrivateLinkResourceProperties", "SignalRServiceUsage", - "SignalRServiceUsageList", "SignalRServiceUsageName", "Sku", "SkuCapacity", "SkuList", "SystemData", + "ThrottleByJwtCustomClaimRule", + "ThrottleByJwtSignatureRule", + "ThrottleByUserIdRule", "TrackedResource", + "TrafficThrottleByJwtCustomClaimRule", + "TrafficThrottleByJwtSignatureRule", + "TrafficThrottleByUserIdRule", "UpstreamAuthSettings", "UserAssignedIdentityProperty", "WebPubSubHub", - "WebPubSubHubList", "WebPubSubHubProperties", "WebPubSubKeys", "WebPubSubNetworkACLs", + "WebPubSubProperties", "WebPubSubResource", - "WebPubSubResourceList", "WebPubSubSocketIOSettings", "WebPubSubTlsSettings", "ACLAction", + "ClientConnectionCountRuleDiscriminator", + "ClientTrafficControlRuleDiscriminator", "CreatedByType", "EventListenerEndpointDiscriminator", "EventListenerFilterDiscriminator", + "GroupPresenceEventName", "KeyType", "ManagedIdentityType", "PrivateLinkServiceConnectionStatus", @@ -177,5 +214,5 @@ "WebPubSubRequestType", "WebPubSubSkuTier", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_web_pub_sub_management_client_enums.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_enums.py similarity index 54% rename from sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_web_pub_sub_management_client_enums.py rename to sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_enums.py index cb819283bac7..763eea9f23ec 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_web_pub_sub_management_client_enums.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_enums.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -14,44 +14,89 @@ class ACLAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Azure Networking ACL Action.""" ALLOW = "Allow" + """ALLOW.""" DENY = "Deny" + """DENY.""" + + +class ClientConnectionCountRuleDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ClientConnectionCountRuleDiscriminator.""" + + THROTTLE_BY_JWT_SIGNATURE_RULE = "ThrottleByJwtSignatureRule" + """THROTTLE_BY_JWT_SIGNATURE_RULE.""" + THROTTLE_BY_USER_ID_RULE = "ThrottleByUserIdRule" + """THROTTLE_BY_USER_ID_RULE.""" + THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE = "ThrottleByJwtCustomClaimRule" + """THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE.""" + + +class ClientTrafficControlRuleDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ClientTrafficControlRuleDiscriminator.""" + + TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE = "TrafficThrottleByJwtSignatureRule" + """TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE.""" + TRAFFIC_THROTTLE_BY_USER_ID_RULE = "TrafficThrottleByUserIdRule" + """TRAFFIC_THROTTLE_BY_USER_ID_RULE.""" + TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE = "TrafficThrottleByJwtCustomClaimRule" + """TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE.""" class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" + """The kind of entity that created the resource.""" USER = "User" + """The entity was created by a user.""" APPLICATION = "Application" + """The entity was created by an application.""" MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" KEY = "Key" + """The entity was created by a key.""" class EventListenerEndpointDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """EventListenerEndpointDiscriminator.""" + """Type of EventListenerEndpointDiscriminator.""" EVENT_HUB = "EventHub" + """EVENT_HUB.""" class EventListenerFilterDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """EventListenerFilterDiscriminator.""" + """Type of EventListenerFilterDiscriminator.""" EVENT_NAME = "EventName" + """EVENT_NAME.""" + + +class GroupPresenceEventName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allowed event names for group presence events.""" + + JOINED = "joined" + """Event triggered when a connection joins a group.""" + LEFT = "left" + """Event triggered when a connection leaves a group.""" class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of access key.""" PRIMARY = "Primary" + """PRIMARY.""" SECONDARY = "Secondary" + """SECONDARY.""" SALT = "Salt" + """SALT.""" class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Represents the identity type: systemAssigned, userAssigned, None.""" NONE = "None" + """NONE.""" SYSTEM_ASSIGNED = "SystemAssigned" + """SYSTEM_ASSIGNED.""" USER_ASSIGNED = "UserAssigned" + """USER_ASSIGNED.""" class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -60,64 +105,93 @@ class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnu """ PENDING = "Pending" + """PENDING.""" APPROVED = "Approved" + """APPROVED.""" REJECTED = "Rejected" + """REJECTED.""" DISCONNECTED = "Disconnected" + """DISCONNECTED.""" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the resource.""" UNKNOWN = "Unknown" + """Unknown provisioning state.""" SUCCEEDED = "Succeeded" + """Resource successfully provisioned.""" FAILED = "Failed" + """Resource provisioning failed.""" CANCELED = "Canceled" + """Resource provisioning was canceled.""" RUNNING = "Running" + """Resource provisioning is running.""" CREATING = "Creating" + """Resource is being created.""" UPDATING = "Updating" + """Resource is being updated.""" DELETING = "Deleting" + """Resource is being deleted.""" MOVING = "Moving" + """MOVING.""" class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku.""" NONE = "None" + """NONE.""" MANUAL = "Manual" + """MANUAL.""" AUTOMATIC = "Automatic" + """AUTOMATIC.""" class ServiceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of the service.""" WEB_PUB_SUB = "WebPubSub" + """WEB_PUB_SUB.""" SOCKET_IO = "SocketIO" + """SOCKET_IO.""" class SharedPrivateLinkResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the shared private link resource.""" PENDING = "Pending" + """PENDING.""" APPROVED = "Approved" + """APPROVED.""" REJECTED = "Rejected" + """REJECTED.""" DISCONNECTED = "Disconnected" + """DISCONNECTED.""" TIMEOUT = "Timeout" + """TIMEOUT.""" class UpstreamAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Upstream auth type enum.""" NONE = "None" + """NONE.""" MANAGED_IDENTITY = "ManagedIdentity" + """MANAGED_IDENTITY.""" class WebPubSubRequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The incoming request type to the service.""" CLIENT_CONNECTION = "ClientConnection" + """CLIENT_CONNECTION.""" SERVER_CONNECTION = "ServerConnection" + """SERVER_CONNECTION.""" RESTAPI = "RESTAPI" + """RESTAPI.""" TRACE = "Trace" + """TRACE.""" class WebPubSubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -127,6 +201,10 @@ class WebPubSubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ FREE = "Free" + """Free tier for WebPubSub service.""" BASIC = "Basic" + """Basic tier for WebPubSub service (deprecated, use Standard instead).""" STANDARD = "Standard" + """Standard tier for WebPubSub service.""" PREMIUM = "Premium" + """Premium tier for WebPubSub service.""" diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_models.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_models.py new file mode 100644 index 000000000000..19f0693d37e7 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_models.py @@ -0,0 +1,3585 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_discriminator, rest_field +from ._enums import ( + ClientConnectionCountRuleDiscriminator, + ClientTrafficControlRuleDiscriminator, + EventListenerEndpointDiscriminator, + EventListenerFilterDiscriminator, +) + +if TYPE_CHECKING: + from .. import models as _models + + +class ApplicationFirewallSettings(_Model): + """Application firewall settings for the resource. + + :ivar client_connection_count_rules: Rules to control the client connection count. + :vartype client_connection_count_rules: + list[~azure.mgmt.webpubsub.models.ClientConnectionCountRule] + :ivar client_traffic_control_rules: Rules to control the client traffic. + :vartype client_traffic_control_rules: + list[~azure.mgmt.webpubsub.models.ClientTrafficControlRule] + :ivar max_client_connection_lifetime_in_seconds: Config to control the client connection + lifetime in seconds, can be set to 0 to disable the config. + :vartype max_client_connection_lifetime_in_seconds: int + """ + + client_connection_count_rules: Optional[list["_models.ClientConnectionCountRule"]] = rest_field( + name="clientConnectionCountRules", visibility=["read", "create", "update", "delete", "query"] + ) + """Rules to control the client connection count.""" + client_traffic_control_rules: Optional[list["_models.ClientTrafficControlRule"]] = rest_field( + name="clientTrafficControlRules", visibility=["read", "create", "update", "delete", "query"] + ) + """Rules to control the client traffic.""" + max_client_connection_lifetime_in_seconds: Optional[int] = rest_field( + name="maxClientConnectionLifetimeInSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """Config to control the client connection lifetime in seconds, can be set to 0 to disable the + config.""" + + @overload + def __init__( + self, + *, + client_connection_count_rules: Optional[list["_models.ClientConnectionCountRule"]] = None, + client_traffic_control_rules: Optional[list["_models.ClientTrafficControlRule"]] = None, + max_client_connection_lifetime_in_seconds: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ChatSettings(_Model): + """Chat settings. + + :ivar mode: Enable or disable the chat feature. + :vartype mode: str + :ivar persistent_storage: Reference to the the persistent storage for perisisting chat states. + :vartype persistent_storage: ~azure.mgmt.webpubsub.models.ResourceReference + """ + + mode: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Enable or disable the chat feature.""" + persistent_storage: Optional["_models.ResourceReference"] = rest_field( + name="persistentStorage", visibility=["read", "create", "update", "delete", "query"] + ) + """Reference to the the persistent storage for perisisting chat states.""" + + @overload + def __init__( + self, + *, + mode: Optional[str] = None, + persistent_storage: Optional["_models.ResourceReference"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ClientConnectionCountRule(_Model): + """A base class for client connection count rules. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ThrottleByJwtCustomClaimRule, ThrottleByJwtSignatureRule, ThrottleByUserIdRule + + :ivar type: Required. Known values are: "ThrottleByJwtSignatureRule", "ThrottleByUserIdRule", + and "ThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.webpubsub.models.ClientConnectionCountRuleDiscriminator + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"ThrottleByJwtSignatureRule\", \"ThrottleByUserIdRule\", and + \"ThrottleByJwtCustomClaimRule\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ClientTrafficControlRule(_Model): + """A base class for client traffic control rules. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + TrafficThrottleByJwtCustomClaimRule, TrafficThrottleByJwtSignatureRule, + TrafficThrottleByUserIdRule + + :ivar type: Required. Known values are: "TrafficThrottleByJwtSignatureRule", + "TrafficThrottleByUserIdRule", and "TrafficThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.webpubsub.models.ClientTrafficControlRuleDiscriminator + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"TrafficThrottleByJwtSignatureRule\", + \"TrafficThrottleByUserIdRule\", and \"TrafficThrottleByJwtCustomClaimRule\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + """ + + +class CustomCertificate(ProxyResource): + """A custom certificate. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar properties: Custom certificate properties. Required. + :vartype properties: ~azure.mgmt.webpubsub.models.CustomCertificateProperties + """ + + properties: "_models.CustomCertificateProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Custom certificate properties. Required.""" + + __flattened_items = [ + "provisioning_state", + "key_vault_base_uri", + "key_vault_secret_name", + "key_vault_secret_version", + ] + + @overload + def __init__( + self, + *, + properties: "_models.CustomCertificateProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CustomCertificateProperties(_Model): + """Custom certificate properties. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState + :ivar key_vault_base_uri: Base uri of the KeyVault that stores certificate. Required. + :vartype key_vault_base_uri: str + :ivar key_vault_secret_name: Certificate secret name. Required. + :vartype key_vault_secret_name: str + :ivar key_vault_secret_version: Certificate secret version. + :vartype key_vault_secret_version: str + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + key_vault_base_uri: str = rest_field(name="keyVaultBaseUri", visibility=["read", "create"]) + """Base uri of the KeyVault that stores certificate. Required.""" + key_vault_secret_name: str = rest_field(name="keyVaultSecretName", visibility=["read", "create"]) + """Certificate secret name. Required.""" + key_vault_secret_version: Optional[str] = rest_field(name="keyVaultSecretVersion", visibility=["read", "create"]) + """Certificate secret version.""" + + @overload + def __init__( + self, + *, + key_vault_base_uri: str, + key_vault_secret_name: str, + key_vault_secret_version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomDomain(ProxyResource): + """A custom domain. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar properties: Properties of a custom domain. Required. + :vartype properties: ~azure.mgmt.webpubsub.models.CustomDomainProperties + """ + + properties: "_models.CustomDomainProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a custom domain. Required.""" + + __flattened_items = ["provisioning_state", "domain_name", "custom_certificate"] + + @overload + def __init__( + self, + *, + properties: "_models.CustomDomainProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CustomDomainProperties(_Model): + """Properties of a custom domain. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState + :ivar domain_name: The custom domain name. Required. + :vartype domain_name: str + :ivar custom_certificate: Reference to a resource. Required. + :vartype custom_certificate: ~azure.mgmt.webpubsub.models.ResourceReference + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + domain_name: str = rest_field(name="domainName", visibility=["read", "create", "update", "delete", "query"]) + """The custom domain name. Required.""" + custom_certificate: "_models.ResourceReference" = rest_field( + name="customCertificate", visibility=["read", "create", "update", "delete", "query"] + ) + """Reference to a resource. Required.""" + + @overload + def __init__( + self, + *, + domain_name: str, + custom_certificate: "_models.ResourceReference", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Dimension(_Model): + """Specifications of the Dimension of metrics. + + :ivar name: The public facing name of the dimension. + :vartype name: str + :ivar display_name: Localized friendly display name of the dimension. + :vartype display_name: str + :ivar internal_name: Name of the dimension as it appears in MDM. + :vartype internal_name: str + :ivar to_be_exported_for_shoebox: A Boolean flag indicating whether this dimension should be + included for the shoebox export scenario. + :vartype to_be_exported_for_shoebox: bool + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The public facing name of the dimension.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Localized friendly display name of the dimension.""" + internal_name: Optional[str] = rest_field( + name="internalName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the dimension as it appears in MDM.""" + to_be_exported_for_shoebox: Optional[bool] = rest_field( + name="toBeExportedForShoebox", visibility=["read", "create", "update", "delete", "query"] + ) + """A Boolean flag indicating whether this dimension should be included for the shoebox export + scenario.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + internal_name: Optional[str] = None, + to_be_exported_for_shoebox: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_Model): + """The error detail. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.webpubsub.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.webpubsub.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.webpubsub.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EventHandler(_Model): + """Properties of event handler. + + :ivar url_template: Gets or sets the URL template for the event handler. The actual URL is + calculated when the corresponding event is triggered. The template supports predefined + parameters syntax: ``{event}``, ``{hub}``, and KeyVault reference syntax + ``{@Microsoft.KeyVault(SecretUri=_your_secret_identifier_)}`` For example, if the template is + ``http://example.com/api/{event}``, when ``connect`` event is triggered, a POST request will be + sent to the URL ``http://example.com/chat/api/connect``. Note: Parameters are not allowed in + the hostname of the URL, and curly brackets ``{}`` are reserved for parameter syntax only. If + your URL path contains literal curly brackets, please URL-encode them to ensure proper + handling. Required. + :vartype url_template: str + :ivar user_event_pattern: Gets or sets the matching pattern for event names. + There are 3 kinds of patterns supported: + + 1. "*", it matches any event name + 2. Combine multiple events with ",", for example "event1,event2", it matches event "event1" and + "event2" + 3. A single event name, for example, "event1", it matches "event1". + :vartype user_event_pattern: str + :ivar system_events: Gets or sets the list of system events. + :vartype system_events: list[str] + :ivar auth: Upstream auth settings. If not set, no auth is used for upstream messages. + :vartype auth: ~azure.mgmt.webpubsub.models.UpstreamAuthSettings + :ivar group_presence_events: The group presence events that this event handler is concerned + with. Group presence events are triggered when connections join or leave groups in the hub. If + the value is null, no presence events will be sent to this event handler. + :vartype group_presence_events: ~azure.mgmt.webpubsub.models.GroupPresenceEventFilters + """ + + url_template: str = rest_field(name="urlTemplate", visibility=["read", "create", "update", "delete", "query"]) + """Gets or sets the URL template for the event handler. The actual URL is calculated when the + corresponding event is triggered. The template supports predefined parameters syntax: + ``{event}``, ``{hub}``, and KeyVault reference syntax + ``{@Microsoft.KeyVault(SecretUri=_your_secret_identifier_)}`` For example, if the template is + ``http://example.com/api/{event}``, when ``connect`` event is triggered, a POST request will be + sent to the URL ``http://example.com/chat/api/connect``. Note: Parameters are not allowed in + the hostname of the URL, and curly brackets ``{}`` are reserved for parameter syntax only. If + your URL path contains literal curly brackets, please URL-encode them to ensure proper + handling. Required.""" + user_event_pattern: Optional[str] = rest_field( + name="userEventPattern", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the matching pattern for event names. + There are 3 kinds of patterns supported: + + 1. \"*\", it matches any event name + 2. Combine multiple events with \",\", for example \"event1,event2\", it matches event + \"event1\" and \"event2\" + 3. A single event name, for example, \"event1\", it matches \"event1\".""" + system_events: Optional[list[str]] = rest_field( + name="systemEvents", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the list of system events.""" + auth: Optional["_models.UpstreamAuthSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Upstream auth settings. If not set, no auth is used for upstream messages.""" + group_presence_events: Optional["_models.GroupPresenceEventFilters"] = rest_field( + name="groupPresenceEvents", visibility=["read", "create", "update", "delete", "query"] + ) + """The group presence events that this event handler is concerned with. Group presence events are + triggered when connections join or leave groups in the hub. If the value is null, no presence + events will be sent to this event handler.""" + + @overload + def __init__( + self, + *, + url_template: str, + user_event_pattern: Optional[str] = None, + system_events: Optional[list[str]] = None, + auth: Optional["_models.UpstreamAuthSettings"] = None, + group_presence_events: Optional["_models.GroupPresenceEventFilters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EventListenerEndpoint(_Model): + """An endpoint specifying where Web PubSub should send events to. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + EventHubEndpoint + + :ivar type: Required. "EventHub" + :vartype type: str or ~azure.mgmt.webpubsub.models.EventListenerEndpointDiscriminator + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. \"EventHub\"""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EventHubEndpoint(EventListenerEndpoint, discriminator="EventHub"): + """An Event Hub endpoint. The managed identity of Web PubSub service must be enabled, and the + identity should have the "Azure Event Hubs Data sender" role to access Event Hub. + + :ivar fully_qualified_namespace: The fully qualified namespace name of the Event Hub resource. + Required. + :vartype fully_qualified_namespace: str + :ivar event_hub_name: The name of the Event Hub. Required. + :vartype event_hub_name: str + :ivar type: Required. EVENT_HUB. + :vartype type: str or ~azure.mgmt.webpubsub.models.EVENT_HUB + """ + + fully_qualified_namespace: str = rest_field( + name="fullyQualifiedNamespace", visibility=["read", "create", "update", "delete", "query"] + ) + """The fully qualified namespace name of the Event Hub resource. Required.""" + event_hub_name: str = rest_field(name="eventHubName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the Event Hub. Required.""" + type: Literal[EventListenerEndpointDiscriminator.EVENT_HUB] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. EVENT_HUB.""" + + @overload + def __init__( + self, + *, + fully_qualified_namespace: str, + event_hub_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = EventListenerEndpointDiscriminator.EVENT_HUB # type: ignore + + +class EventListener(_Model): + """A setting defines which kinds of events should be sent to which endpoint. + + :ivar filter: A base class for event filter which determines whether an event should be sent to + an event listener. Required. + :vartype filter: ~azure.mgmt.webpubsub.models.EventListenerFilter + :ivar endpoint: An endpoint specifying where Web PubSub should send events to. Required. + :vartype endpoint: ~azure.mgmt.webpubsub.models.EventListenerEndpoint + """ + + filter: "_models.EventListenerFilter" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A base class for event filter which determines whether an event should be sent to an event + listener. Required.""" + endpoint: "_models.EventListenerEndpoint" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An endpoint specifying where Web PubSub should send events to. Required.""" + + @overload + def __init__( + self, + *, + filter: "_models.EventListenerFilter", # pylint: disable=redefined-builtin + endpoint: "_models.EventListenerEndpoint", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EventListenerFilter(_Model): + """A base class for event filter which determines whether an event should be sent to an event + listener. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + EventNameFilter + + :ivar type: Required. "EventName" + :vartype type: str or ~azure.mgmt.webpubsub.models.EventListenerFilterDiscriminator + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. \"EventName\"""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EventNameFilter(EventListenerFilter, discriminator="EventName"): + """Filter events by their name. + + :ivar system_events: Gets or sets a list of system events. Supported events: "connected" and + "disconnected". Blocking event "connect" is not supported because it requires a response. + :vartype system_events: list[str] + :ivar user_event_pattern: Gets or sets a matching pattern for event names. + There are 3 kinds of patterns supported: + + 1. "*", it matches any event name + 2. Combine multiple events with ",", for example "event1,event2", it matches events "event1" + and "event2" + 3. A single event name, for example, "event1", it matches "event1". + :vartype user_event_pattern: str + :ivar type: Required. EVENT_NAME. + :vartype type: str or ~azure.mgmt.webpubsub.models.EVENT_NAME + """ + + system_events: Optional[list[str]] = rest_field( + name="systemEvents", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets a list of system events. Supported events: \"connected\" and \"disconnected\". + Blocking event \"connect\" is not supported because it requires a response.""" + user_event_pattern: Optional[str] = rest_field( + name="userEventPattern", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets a matching pattern for event names. + There are 3 kinds of patterns supported: + + 1. \"*\", it matches any event name + 2. Combine multiple events with \",\", for example \"event1,event2\", it matches events + \"event1\" and \"event2\" + 3. A single event name, for example, \"event1\", it matches \"event1\".""" + type: Literal[EventListenerFilterDiscriminator.EVENT_NAME] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. EVENT_NAME.""" + + @overload + def __init__( + self, + *, + system_events: Optional[list[str]] = None, + user_event_pattern: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = EventListenerFilterDiscriminator.EVENT_NAME # type: ignore + + +class GroupPresenceEventFilters(_Model): + """Represents presence event filters for event handler configuration. + + :ivar event_names: The concerning event names. Valid values are "joined", "left". If the value + is null or empty, no presence events will be sent to the event handler. Required. + :vartype event_names: list[str or ~azure.mgmt.webpubsub.models.GroupPresenceEventName] + :ivar group_filters: The group filters. Only events from these groups will be sent to the event + handler. Each element is a pattern that may match multiple groups. If null or empty, events + from all groups will be sent (subject to eventNames). + :vartype group_filters: list[str] + """ + + event_names: list[Union[str, "_models.GroupPresenceEventName"]] = rest_field( + name="eventNames", visibility=["read", "create", "update", "delete", "query"] + ) + """The concerning event names. Valid values are \"joined\", \"left\". If the value is null or + empty, no presence events will be sent to the event handler. Required.""" + group_filters: Optional[list[str]] = rest_field( + name="groupFilters", visibility=["read", "create", "update", "delete", "query"] + ) + """The group filters. Only events from these groups will be sent to the event handler. Each + element is a pattern that may match multiple groups. If null or empty, events from all groups + will be sent (subject to eventNames).""" + + @overload + def __init__( + self, + *, + event_names: list[Union[str, "_models.GroupPresenceEventName"]], + group_filters: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IPRule(_Model): + """An IP rule. + + :ivar value: An IP or CIDR or ServiceTag. + :vartype value: str + :ivar action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". + :vartype action: str or ~azure.mgmt.webpubsub.models.ACLAction + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An IP or CIDR or ServiceTag.""" + action: Optional[Union[str, "_models.ACLAction"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Azure Networking ACL Action. Known values are: \"Allow\" and \"Deny\".""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + action: Optional[Union[str, "_models.ACLAction"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LiveTraceCategory(_Model): + """Live trace category configuration of a Microsoft.SignalRService resource. + + :ivar name: Gets or sets the live trace category's name. Available values: ConnectivityLogs, + MessagingLogs. Case insensitive. + :vartype name: str + :ivar enabled: Indicates whether or the live trace category is enabled. Available values: true, + false. Case insensitive. + :vartype enabled: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gets or sets the live trace category's name. Available values: ConnectivityLogs, MessagingLogs. + Case insensitive.""" + enabled: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Indicates whether or the live trace category is enabled. Available values: true, false. Case + insensitive.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + enabled: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LiveTraceConfiguration(_Model): + """Live trace configuration of a Microsoft.SignalRService resource. + + :ivar enabled: Indicates whether or not enable live trace. When it's set to true, live trace + client can connect to the service. Otherwise, live trace client can't connect to the service, + so that you are unable to receive any log, no matter what you configure in "categories". + Available values: true, false. Case insensitive. + :vartype enabled: str + :ivar categories: Gets or sets the list of category configurations. + :vartype categories: list[~azure.mgmt.webpubsub.models.LiveTraceCategory] + """ + + enabled: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Indicates whether or not enable live trace. When it's set to true, live trace client can + connect to the service. Otherwise, live trace client can't connect to the service, so that you + are unable to receive any log, no matter what you configure in \"categories\". Available + values: true, false. Case insensitive.""" + categories: Optional[list["_models.LiveTraceCategory"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the list of category configurations.""" + + @overload + def __init__( + self, + *, + enabled: Optional[str] = None, + categories: Optional[list["_models.LiveTraceCategory"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LogSpecification(_Model): + """Specifications of the Logs for Azure Monitoring. + + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Localized friendly display name of the log. + :vartype display_name: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the log.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Localized friendly display name of the log.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedIdentity(_Model): + """A class represent managed identities used for request and response. + + :ivar type: Represents the identity type: systemAssigned, userAssigned, None. Known values are: + "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.webpubsub.models.ManagedIdentityType + :ivar user_assigned_identities: Get or set the user assigned identities. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.webpubsub.models.UserAssignedIdentityProperty] + :ivar principal_id: Get the principal id for the system assigned identity. Only be used in + response. + :vartype principal_id: str + :ivar tenant_id: Get the tenant id for the system assigned identity. Only be used in response. + :vartype tenant_id: str + """ + + type: Optional[Union[str, "_models.ManagedIdentityType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Represents the identity type: systemAssigned, userAssigned, None. Known values are: \"None\", + \"SystemAssigned\", and \"UserAssigned\".""" + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentityProperty"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """Get or set the user assigned identities.""" + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """Get the principal id for the system assigned identity. Only be used in response.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """Get the tenant id for the system assigned identity. Only be used in response.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentityProperty"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedIdentitySettings(_Model): + """Managed identity settings for upstream. + + :ivar resource: The Resource indicating the App ID URI of the target resource. It also appears + in the aud (audience) claim of the issued token. + :vartype resource: str + """ + + resource: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Resource indicating the App ID URI of the target resource. It also appears in the aud + (audience) claim of the issued token.""" + + @overload + def __init__( + self, + *, + resource: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricSpecification(_Model): + """Specifications of the Metrics for Azure Monitoring. + + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Localized friendly display name of the metric. + :vartype display_name: str + :ivar display_description: Localized friendly description of the metric. + :vartype display_description: str + :ivar unit: The unit that makes sense for the metric. + :vartype unit: str + :ivar aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, + Maximum, Total, Count. + :vartype aggregation_type: str + :ivar fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. Ex. a metric that returns the number of times a + particular error code was emitted. The error code may not appear often, instead of the RP + publishing 0, Shoebox can auto fill in 0s for time periods where nothing was emitted. + :vartype fill_gap_with_zero: str + :ivar category: The name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :vartype category: str + :ivar dimensions: The dimensions of the metrics. + :vartype dimensions: list[~azure.mgmt.webpubsub.models.Dimension] + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the metric.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Localized friendly display name of the metric.""" + display_description: Optional[str] = rest_field( + name="displayDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Localized friendly description of the metric.""" + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unit that makes sense for the metric.""" + aggregation_type: Optional[str] = rest_field( + name="aggregationType", visibility=["read", "create", "update", "delete", "query"] + ) + """Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count.""" + fill_gap_with_zero: Optional[str] = rest_field( + name="fillGapWithZero", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional. If set to true, then zero will be returned for time duration where no metric is + emitted/published. Ex. a metric that returns the number of times a particular error code was + emitted. The error code may not appear often, instead of the RP publishing 0, Shoebox can auto + fill in 0s for time periods where nothing was emitted.""" + category: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the metric category that the metric belongs to. A metric can only belong to a + single category.""" + dimensions: Optional[list["_models.Dimension"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The dimensions of the metrics.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + aggregation_type: Optional[str] = None, + fill_gap_with_zero: Optional[str] = None, + category: Optional[str] = None, + dimensions: Optional[list["_models.Dimension"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NameAvailability(_Model): + """Result of the request to check name availability. It contains a flag and possible reason of + failure. + + :ivar name_available: Indicates whether the name is available or not. + :vartype name_available: bool + :ivar reason: The reason of the availability. Required if name is not available. + :vartype reason: str + :ivar message: The message of the operation. + :vartype message: str + """ + + name_available: Optional[bool] = rest_field( + name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the name is available or not.""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason of the availability. Required if name is not available.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The message of the operation.""" + + @overload + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NameAvailabilityParameters(_Model): + """Data POST-ed to the nameAvailability action. + + :ivar type: The resource type. Can be "Microsoft.SignalRService/SignalR", + "Microsoft.SignalRService/WebPubSub", "Microsoft.SignalRService/SignalR/replicas" or + "Microsoft.SignalRService/WebPubSub/replicas". Required. + :vartype type: str + :ivar name: The resource name to validate. e.g."my-resource-name". Required. + :vartype name: str + """ + + type: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource type. Can be \"Microsoft.SignalRService/SignalR\", + \"Microsoft.SignalRService/WebPubSub\", \"Microsoft.SignalRService/SignalR/replicas\" or + \"Microsoft.SignalRService/WebPubSub/replicas\". Required.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource name to validate. e.g.\"my-resource-name\". Required.""" + + @overload + def __init__( + self, + *, + type: str, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkACL(_Model): + """Network ACL. + + :ivar allow: Allowed request types. The value can be one or more of: ClientConnection, + ServerConnection, RESTAPI. + :vartype allow: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] + :ivar deny: Denied request types. The value can be one or more of: ClientConnection, + ServerConnection, RESTAPI. + :vartype deny: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] + """ + + allow: Optional[list[Union[str, "_models.WebPubSubRequestType"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, + RESTAPI.""" + deny: Optional[list[Union[str, "_models.WebPubSubRequestType"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Denied request types. The value can be one or more of: ClientConnection, ServerConnection, + RESTAPI.""" + + @overload + def __init__( + self, + *, + allow: Optional[list[Union[str, "_models.WebPubSubRequestType"]]] = None, + deny: Optional[list[Union[str, "_models.WebPubSubRequestType"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """REST API operation supported by resource provider. + + :ivar name: Name of the operation with format: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: If the operation is a data action. (for data plane rbac). + :vartype is_data_action: bool + :ivar display: The object that describes a operation. + :vartype display: ~azure.mgmt.webpubsub.models.OperationDisplay + :ivar origin: Optional. The intended executor of the operation; governs the display of the + operation in the RBAC UX and the audit logs UX. + :vartype origin: str + :ivar properties: Extra Operation properties. + :vartype properties: ~azure.mgmt.webpubsub.models.OperationProperties + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the operation with format: {provider}/{resource}/{operation}.""" + is_data_action: Optional[bool] = rest_field( + name="isDataAction", visibility=["read", "create", "update", "delete", "query"] + ) + """If the operation is a data action. (for data plane rbac).""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object that describes a operation.""" + origin: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional. The intended executor of the operation; governs the display of the operation in the + RBAC UX and the audit logs UX.""" + properties: Optional["_models.OperationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Extra Operation properties.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + properties: Optional["_models.OperationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationDisplay(_Model): + """The object that describes a operation. + + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + :ivar resource: Resource type on which the operation is performed. + :vartype resource: str + :ivar operation: The localized friendly name for the operation. + :vartype operation: str + :ivar description: The localized friendly description for the operation. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Friendly name of the resource provider.""" + resource: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource type on which the operation is performed.""" + operation: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The localized friendly name for the operation.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The localized friendly description for the operation.""" + + @overload + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationProperties(_Model): + """Extra Operation properties. + + :ivar service_specification: An object that describes a specification. + :vartype service_specification: ~azure.mgmt.webpubsub.models.ServiceSpecification + """ + + service_specification: Optional["_models.ServiceSpecification"] = rest_field( + name="serviceSpecification", visibility=["read", "create", "update", "delete", "query"] + ) + """An object that describes a specification.""" + + @overload + def __init__( + self, + *, + service_specification: Optional["_models.ServiceSpecification"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PersistentStorage(ProxyResource): + """A persistent storage. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar properties: Properties of a persistent storage. Required. + :vartype properties: ~azure.mgmt.webpubsub.models.PersistentStorageProperties + """ + + properties: "_models.PersistentStorageProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a persistent storage. Required.""" + + __flattened_items = ["provisioning_state", "storage_account"] + + @overload + def __init__( + self, + *, + properties: "_models.PersistentStorageProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PersistentStorageProperties(_Model): + """Properties of a persistent storage. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState + :ivar storage_account: Reference to the storage account to be used for persistent storage. + Required. + :vartype storage_account: ~azure.mgmt.webpubsub.models.ResourceReference + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + storage_account: "_models.ResourceReference" = rest_field( + name="storageAccount", visibility=["read", "create", "update", "delete", "query"] + ) + """Reference to the storage account to be used for persistent storage. Required.""" + + @overload + def __init__( + self, + *, + storage_account: "_models.ResourceReference", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpoint(_Model): + """Private endpoint. + + :ivar id: Full qualified Id of the private endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Full qualified Id of the private endpoint.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpointACL(NetworkACL): + """ACL for a private endpoint. + + :ivar allow: Allowed request types. The value can be one or more of: ClientConnection, + ServerConnection, RESTAPI. + :vartype allow: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] + :ivar deny: Denied request types. The value can be one or more of: ClientConnection, + ServerConnection, RESTAPI. + :vartype deny: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] + :ivar name: Name of the private endpoint connection. Required. + :vartype name: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the private endpoint connection. Required.""" + + @overload + def __init__( + self, + *, + name: str, + allow: Optional[list[Union[str, "_models.WebPubSubRequestType"]]] = None, + deny: Optional[list[Union[str, "_models.WebPubSubRequestType"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpointConnection(ProxyResource): + """A private endpoint connection to an azure resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar properties: Private endpoint connection properties. + :vartype properties: ~azure.mgmt.webpubsub.models.PrivateEndpointConnectionProperties + """ + + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Private endpoint connection properties.""" + + __flattened_items = ["provisioning_state", "private_endpoint", "group_ids", "private_link_service_connection_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateEndpointConnectionProperties(_Model): + """Private endpoint connection properties. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState + :ivar private_endpoint: Private endpoint. + :vartype private_endpoint: ~azure.mgmt.webpubsub.models.PrivateEndpoint + :ivar group_ids: Group IDs. + :vartype group_ids: list[str] + :ivar private_link_service_connection_state: Connection state of the private endpoint + connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionState + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Private endpoint.""" + group_ids: Optional[list[str]] = rest_field(name="groupIds", visibility=["read"]) + """Group IDs.""" + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """Connection state of the private endpoint connection.""" + + @overload + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResource(ProxyResource): + """Private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar properties: Private link resource properties. + :vartype properties: ~azure.mgmt.webpubsub.models.PrivateLinkResourceProperties + """ + + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Private link resource properties.""" + + __flattened_items = ["group_id", "required_members", "required_zone_names", "shareable_private_link_resource_types"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateLinkResourceProperties(_Model): + """Private link resource properties. + + :ivar group_id: Group Id of the private link resource. + :vartype group_id: str + :ivar required_members: Required members of the private link resource. + :vartype required_members: list[str] + :ivar required_zone_names: Required private DNS zone names. + :vartype required_zone_names: list[str] + :ivar shareable_private_link_resource_types: The list of resources that are onboarded to + private link service. + :vartype shareable_private_link_resource_types: + list[~azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceType] + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read", "create", "update", "delete", "query"]) + """Group Id of the private link resource.""" + required_members: Optional[list[str]] = rest_field( + name="requiredMembers", visibility=["read", "create", "update", "delete", "query"] + ) + """Required members of the private link resource.""" + required_zone_names: Optional[list[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) + """Required private DNS zone names.""" + shareable_private_link_resource_types: Optional[list["_models.ShareablePrivateLinkResourceType"]] = rest_field( + name="shareablePrivateLinkResourceTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of resources that are onboarded to private link service.""" + + @overload + def __init__( + self, + *, + group_id: Optional[str] = None, + required_members: Optional[list[str]] = None, + required_zone_names: Optional[list[str]] = None, + shareable_private_link_resource_types: Optional[list["_models.ShareablePrivateLinkResourceType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkServiceConnectionState(_Model): + """Connection state of the private endpoint connection. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". + :vartype status: str or ~azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + status: Optional[Union[str, "_models.PrivateLinkServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + service. Known values are: \"Pending\", \"Approved\", \"Rejected\", and \"Disconnected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval/rejection of the connection.""" + actions_required: Optional[str] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateLinkServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RegenerateKeyParameters(_Model): + """Parameters describes the request to regenerate access keys. + + :ivar key_type: The type of access key. Known values are: "Primary", "Secondary", and "Salt". + :vartype key_type: str or ~azure.mgmt.webpubsub.models.KeyType + """ + + key_type: Optional[Union[str, "_models.KeyType"]] = rest_field( + name="keyType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of access key. Known values are: \"Primary\", \"Secondary\", and \"Salt\".""" + + @overload + def __init__( + self, + *, + key_type: Optional[Union[str, "_models.KeyType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Replica(TrackedResource): + """A class represent a replica resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: + :vartype properties: ~azure.mgmt.webpubsub.models.ReplicaProperties + :ivar sku: The billing information of the resource. + :vartype sku: ~azure.mgmt.webpubsub.models.ResourceSku + """ + + properties: Optional["_models.ReplicaProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + sku: Optional["_models.ResourceSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The billing information of the resource.""" + + __flattened_items = ["provisioning_state", "region_endpoint_enabled", "resource_stopped"] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ReplicaProperties"] = None, + sku: Optional["_models.ResourceSku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ReplicaProperties(_Model): + """ReplicaProperties. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState + :ivar region_endpoint_enabled: Enable or disable the regional endpoint. Default to "Enabled". + When it's Disabled, new connections will not be routed to this endpoint, however existing + connections will not be affected. + :vartype region_endpoint_enabled: str + :ivar resource_stopped: Stop or start the resource. Default to "false". When it's true, the + data plane of the resource is shutdown. When it's false, the data plane of the resource is + started. + :vartype resource_stopped: str + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + region_endpoint_enabled: Optional[str] = rest_field( + name="regionEndpointEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable or disable the regional endpoint. Default to \"Enabled\". When it's Disabled, new + connections will not be routed to this endpoint, however existing connections will not be + affected.""" + resource_stopped: Optional[str] = rest_field( + name="resourceStopped", visibility=["read", "create", "update", "delete", "query"] + ) + """Stop or start the resource. Default to \"false\". When it's true, the data plane of the + resource is shutdown. When it's false, the data plane of the resource is started.""" + + @overload + def __init__( + self, + *, + region_endpoint_enabled: Optional[str] = None, + resource_stopped: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceLogCategory(_Model): + """Resource log category configuration of a Microsoft.SignalRService resource. + + :ivar name: Gets or sets the resource log category's name. Available values: ConnectivityLogs, + MessagingLogs. Case insensitive. + :vartype name: str + :ivar enabled: Indicates whether or the resource log category is enabled. Available values: + true, false. Case insensitive. + :vartype enabled: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gets or sets the resource log category's name. Available values: ConnectivityLogs, + MessagingLogs. Case insensitive.""" + enabled: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Indicates whether or the resource log category is enabled. Available values: true, false. Case + insensitive.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + enabled: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceLogConfiguration(_Model): + """Resource log configuration of a Microsoft.SignalRService resource. + + :ivar categories: Gets or sets the list of category configurations. + :vartype categories: list[~azure.mgmt.webpubsub.models.ResourceLogCategory] + """ + + categories: Optional[list["_models.ResourceLogCategory"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the list of category configurations.""" + + @overload + def __init__( + self, + *, + categories: Optional[list["_models.ResourceLogCategory"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceReference(_Model): + """Reference to a resource. + + :ivar id: Resource ID. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource ID.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceSku(_Model): + """The billing information of the resource. + + :ivar name: The name of the SKU. Required. + + Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2. Required. + :vartype name: str + :ivar tier: Optional tier of this particular SKU. 'Standard' or 'Free'. + + ``Basic`` is deprecated, use ``Standard`` instead. Known values are: "Free", "Basic", + "Standard", and "Premium". + :vartype tier: str or ~azure.mgmt.webpubsub.models.WebPubSubSkuTier + :ivar size: Not used. Retained for future use. + :vartype size: str + :ivar family: Not used. Retained for future use. + :vartype family: str + :ivar capacity: Optional, integer. The unit count of the resource. + 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default. + + If present, following values are allowed: + Free_F1: 1; + Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P2: 100,200,300,400,500,600,700,800,900,1000;. + :vartype capacity: int + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the SKU. Required. + + Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2. Required.""" + tier: Optional[Union[str, "_models.WebPubSubSkuTier"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Optional tier of this particular SKU. 'Standard' or 'Free'. + + ``Basic`` is deprecated, use ``Standard`` instead. Known values are: \"Free\", \"Basic\", + \"Standard\", and \"Premium\".""" + size: Optional[str] = rest_field(visibility=["read"]) + """Not used. Retained for future use.""" + family: Optional[str] = rest_field(visibility=["read"]) + """Not used. Retained for future use.""" + capacity: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional, integer. The unit count of the resource. + 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default. + + If present, following values are allowed: + Free_F1: 1; + Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P2: 100,200,300,400,500,600,700,800,900,1000;.""" + + @overload + def __init__( + self, + *, + name: str, + tier: Optional[Union[str, "_models.WebPubSubSkuTier"]] = None, + capacity: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServiceSpecification(_Model): + """An object that describes a specification. + + :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. + :vartype metric_specifications: list[~azure.mgmt.webpubsub.models.MetricSpecification] + :ivar log_specifications: Specifications of the Logs for Azure Monitoring. + :vartype log_specifications: list[~azure.mgmt.webpubsub.models.LogSpecification] + """ + + metric_specifications: Optional[list["_models.MetricSpecification"]] = rest_field( + name="metricSpecifications", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifications of the Metrics for Azure Monitoring.""" + log_specifications: Optional[list["_models.LogSpecification"]] = rest_field( + name="logSpecifications", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifications of the Logs for Azure Monitoring.""" + + @overload + def __init__( + self, + *, + metric_specifications: Optional[list["_models.MetricSpecification"]] = None, + log_specifications: Optional[list["_models.LogSpecification"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ShareablePrivateLinkResourceProperties(_Model): + """Describes the properties of a resource type that has been onboarded to private link service. + + :ivar description: The description of the resource type that has been onboarded to private link + service. + :vartype description: str + :ivar group_id: The resource provider group id for the resource that has been onboarded to + private link service. + :vartype group_id: str + :ivar type: The resource provider type for the resource that has been onboarded to private link + service. + :vartype type: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The description of the resource type that has been onboarded to private link service.""" + group_id: Optional[str] = rest_field(name="groupId", visibility=["read", "create", "update", "delete", "query"]) + """The resource provider group id for the resource that has been onboarded to private link + service.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource provider type for the resource that has been onboarded to private link service.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + group_id: Optional[str] = None, + type: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ShareablePrivateLinkResourceType(_Model): + """Describes a resource type that has been onboarded to private link service. + + :ivar name: The name of the resource type that has been onboarded to private link service. + :vartype name: str + :ivar properties: Describes the properties of a resource type that has been onboarded to + private link service. + :vartype properties: ~azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceProperties + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the resource type that has been onboarded to private link service.""" + properties: Optional["_models.ShareablePrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes the properties of a resource type that has been onboarded to private link service.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.ShareablePrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SharedPrivateLinkResource(ProxyResource): + """Describes a Shared Private Link Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar properties: Describes the properties of an existing Shared Private Link Resource. + :vartype properties: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResourceProperties + """ + + properties: Optional["_models.SharedPrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes the properties of an existing Shared Private Link Resource.""" + + __flattened_items = [ + "group_id", + "private_link_resource_id", + "provisioning_state", + "request_message", + "fqdns", + "status", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SharedPrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SharedPrivateLinkResourceProperties(_Model): + """Describes the properties of an existing Shared Private Link Resource. + + :ivar group_id: The group id from the provider of resource the shared private link resource is + for. Required. + :vartype group_id: str + :ivar private_link_resource_id: The resource id of the resource the shared private link + resource is for. Required. + :vartype private_link_resource_id: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState + :ivar request_message: The request message for requesting approval of the shared private link + resource. + :vartype request_message: str + :ivar fqdns: A list of FQDNs for third party private link service. + :vartype fqdns: list[str] + :ivar status: Status of the shared private link resource. Known values are: "Pending", + "Approved", "Rejected", "Disconnected", and "Timeout". + :vartype status: str or ~azure.mgmt.webpubsub.models.SharedPrivateLinkResourceStatus + """ + + group_id: str = rest_field(name="groupId", visibility=["read", "create", "update", "delete", "query"]) + """The group id from the provider of resource the shared private link resource is for. Required.""" + private_link_resource_id: str = rest_field( + name="privateLinkResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource id of the resource the shared private link resource is for. Required.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + request_message: Optional[str] = rest_field( + name="requestMessage", visibility=["read", "create", "update", "delete", "query"] + ) + """The request message for requesting approval of the shared private link resource.""" + fqdns: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A list of FQDNs for third party private link service.""" + status: Optional[Union[str, "_models.SharedPrivateLinkResourceStatus"]] = rest_field(visibility=["read"]) + """Status of the shared private link resource. Known values are: \"Pending\", \"Approved\", + \"Rejected\", \"Disconnected\", and \"Timeout\".""" + + @overload + def __init__( + self, + *, + group_id: str, + private_link_resource_id: str, + request_message: Optional[str] = None, + fqdns: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SignalRServiceUsage(_Model): + """Object that describes a specific usage of the resources. + + :ivar id: Fully qualified ARM resource id. + :vartype id: str + :ivar current_value: Current value for the usage quota. + :vartype current_value: int + :ivar limit: The maximum permitted value for the usage quota. If there is no limit, this value + will be -1. + :vartype limit: int + :ivar name: Localizable String object containing the name and a localized value. + :vartype name: ~azure.mgmt.webpubsub.models.SignalRServiceUsageName + :ivar unit: Representing the units of the usage quota. Possible values are: Count, Bytes, + Seconds, Percent, CountPerSecond, BytesPerSecond. + :vartype unit: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified ARM resource id.""" + current_value: Optional[int] = rest_field( + name="currentValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Current value for the usage quota.""" + limit: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The maximum permitted value for the usage quota. If there is no limit, this value will be -1.""" + name: Optional["_models.SignalRServiceUsageName"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Localizable String object containing the name and a localized value.""" + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, + CountPerSecond, BytesPerSecond.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + current_value: Optional[int] = None, + limit: Optional[int] = None, + name: Optional["_models.SignalRServiceUsageName"] = None, + unit: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SignalRServiceUsageName(_Model): + """Localizable String object containing the name and a localized value. + + :ivar value: The identifier of the usage. + :vartype value: str + :ivar localized_value: Localized name of the usage. + :vartype localized_value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identifier of the usage.""" + localized_value: Optional[str] = rest_field( + name="localizedValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Localized name of the usage.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + localized_value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Sku(_Model): + """Describes an available sku.". + + :ivar resource_type: The resource type that this object applies to. + :vartype resource_type: str + :ivar sku: The billing information of the resource. + :vartype sku: ~azure.mgmt.webpubsub.models.ResourceSku + :ivar capacity: Describes scaling information of a sku. + :vartype capacity: ~azure.mgmt.webpubsub.models.SkuCapacity + """ + + resource_type: Optional[str] = rest_field(name="resourceType", visibility=["read"]) + """The resource type that this object applies to.""" + sku: Optional["_models.ResourceSku"] = rest_field(visibility=["read"]) + """The billing information of the resource.""" + capacity: Optional["_models.SkuCapacity"] = rest_field(visibility=["read"]) + """Describes scaling information of a sku.""" + + +class SkuCapacity(_Model): + """Describes scaling information of a sku. + + :ivar minimum: The lowest permitted capacity for this resource. + :vartype minimum: int + :ivar maximum: The highest permitted capacity for this resource. + :vartype maximum: int + :ivar default: The default capacity. + :vartype default: int + :ivar allowed_values: Allows capacity value list. + :vartype allowed_values: list[int] + :ivar scale_type: The scale type applicable to the sku. Known values are: "None", "Manual", and + "Automatic". + :vartype scale_type: str or ~azure.mgmt.webpubsub.models.ScaleType + """ + + minimum: Optional[int] = rest_field(visibility=["read"]) + """The lowest permitted capacity for this resource.""" + maximum: Optional[int] = rest_field(visibility=["read"]) + """The highest permitted capacity for this resource.""" + default: Optional[int] = rest_field(visibility=["read"]) + """The default capacity.""" + allowed_values: Optional[list[int]] = rest_field(name="allowedValues", visibility=["read"]) + """Allows capacity value list.""" + scale_type: Optional[Union[str, "_models.ScaleType"]] = rest_field(name="scaleType", visibility=["read"]) + """The scale type applicable to the sku. Known values are: \"None\", \"Manual\", and + \"Automatic\".""" + + +class SkuList(_Model): + """The list skus operation response. + + :ivar value: The list of skus available for the resource. + :vartype value: list[~azure.mgmt.webpubsub.models.Sku] + :ivar next_link: The URL the client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + value: Optional[list["_models.Sku"]] = rest_field(visibility=["read"]) + """The list of skus available for the resource.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read"]) + """The URL the client should use to fetch the next page (per server side paging). It's null for + now, added for future use.""" + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.webpubsub.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.webpubsub.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ThrottleByJwtCustomClaimRule(ClientConnectionCountRule, discriminator="ThrottleByJwtCustomClaimRule"): + """Throttle the client connection by a custom JWT claim. + + :ivar claim_name: The name of the claim in the JWT token. The client connection with the same + claim value will be aggregated. If the claim is not found in the token, the connection will be + allowed. Required. + :vartype claim_name: str + :ivar max_count: Maximum connection count allowed for the same Jwt claim value. Clients with + the same Jwt claim will get rejected if the connection count exceeds this value. Default value + is 20. + :vartype max_count: int + :ivar type: Required. THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE. + :vartype type: str or ~azure.mgmt.webpubsub.models.THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE + """ + + claim_name: str = rest_field(name="claimName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the claim in the JWT token. The client connection with the same claim value will be + aggregated. If the claim is not found in the token, the connection will be allowed. Required.""" + max_count: Optional[int] = rest_field(name="maxCount", visibility=["read", "create", "update", "delete", "query"]) + """Maximum connection count allowed for the same Jwt claim value. Clients with the same Jwt claim + will get rejected if the connection count exceeds this value. Default value is 20.""" + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE.""" + + @overload + def __init__( + self, + *, + claim_name: str, + max_count: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE # type: ignore + + +class ThrottleByJwtSignatureRule(ClientConnectionCountRule, discriminator="ThrottleByJwtSignatureRule"): + """Throttle the client connection by the JWT signature. + + :ivar max_count: Maximum connection count allowed for the same JWT signature. Clients with the + same JWT signature will get rejected if the connection count exceeds this value. Default value + is 20. + :vartype max_count: int + :ivar type: Required. THROTTLE_BY_JWT_SIGNATURE_RULE. + :vartype type: str or ~azure.mgmt.webpubsub.models.THROTTLE_BY_JWT_SIGNATURE_RULE + """ + + max_count: Optional[int] = rest_field(name="maxCount", visibility=["read", "create", "update", "delete", "query"]) + """Maximum connection count allowed for the same JWT signature. Clients with the same JWT + signature will get rejected if the connection count exceeds this value. Default value is 20.""" + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_SIGNATURE_RULE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. THROTTLE_BY_JWT_SIGNATURE_RULE.""" + + @overload + def __init__( + self, + *, + max_count: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_SIGNATURE_RULE # type: ignore + + +class ThrottleByUserIdRule(ClientConnectionCountRule, discriminator="ThrottleByUserIdRule"): + """Throttle the client connection by the user ID. + + :ivar max_count: Maximum connection count allowed for the same user ID. Clients with the same + user ID will get rejected if the connection count exceeds this value. Default value is 20. + :vartype max_count: int + :ivar type: Required. THROTTLE_BY_USER_ID_RULE. + :vartype type: str or ~azure.mgmt.webpubsub.models.THROTTLE_BY_USER_ID_RULE + """ + + max_count: Optional[int] = rest_field(name="maxCount", visibility=["read", "create", "update", "delete", "query"]) + """Maximum connection count allowed for the same user ID. Clients with the same user ID will get + rejected if the connection count exceeds this value. Default value is 20.""" + type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_USER_ID_RULE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. THROTTLE_BY_USER_ID_RULE.""" + + @overload + def __init__( + self, + *, + max_count: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ClientConnectionCountRuleDiscriminator.THROTTLE_BY_USER_ID_RULE # type: ignore + + +class TrafficThrottleByJwtCustomClaimRule( + ClientTrafficControlRule, discriminator="TrafficThrottleByJwtCustomClaimRule" +): + """Throttle the client traffic by a custom JWT claim. + + :ivar claim_name: The name of the claim in the JWT token. The message bytes with the same claim + value will be aggregated. If the claim is not found in the token, the rule will be skipped. + Required. + :vartype claim_name: str + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + JWT signature within a time window. Clients with the same JWT claim will get disconnected if + the message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + :ivar type: Required. TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE. + :vartype type: str or ~azure.mgmt.webpubsub.models.TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE + """ + + claim_name: str = rest_field(name="claimName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the claim in the JWT token. The message bytes with the same claim value will be + aggregated. If the claim is not found in the token, the rule will be skipped. Required.""" + max_inbound_message_bytes: Optional[int] = rest_field( + name="maxInboundMessageBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum accumulated inbound message bytes allowed for the same JWT signature within a time + window. Clients with the same JWT claim will get disconnected if the message bytes exceeds this + value. Default value is 1GB.""" + aggregation_window_in_seconds: Optional[int] = rest_field( + name="aggregationWindowInSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """The aggregation window for the message bytes. The message bytes will be aggregated in this + window and be reset after the window. Default value is 60 seconds.""" + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE.""" + + @overload + def __init__( + self, + *, + claim_name: str, + max_inbound_message_bytes: Optional[int] = None, + aggregation_window_in_seconds: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE # type: ignore + + +class TrafficThrottleByJwtSignatureRule(ClientTrafficControlRule, discriminator="TrafficThrottleByJwtSignatureRule"): + """Throttle the client traffic by the JWT signature. + + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + JWT signature within a time window. Clients with the same JWT signature will get disconnected + if the message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + :ivar type: Required. TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE. + :vartype type: str or ~azure.mgmt.webpubsub.models.TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE + """ + + max_inbound_message_bytes: Optional[int] = rest_field( + name="maxInboundMessageBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum accumulated inbound message bytes allowed for the same JWT signature within a time + window. Clients with the same JWT signature will get disconnected if the message bytes exceeds + this value. Default value is 1GB.""" + aggregation_window_in_seconds: Optional[int] = rest_field( + name="aggregationWindowInSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """The aggregation window for the message bytes. The message bytes will be aggregated in this + window and be reset after the window. Default value is 60 seconds.""" + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE.""" + + @overload + def __init__( + self, + *, + max_inbound_message_bytes: Optional[int] = None, + aggregation_window_in_seconds: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE # type: ignore + + +class TrafficThrottleByUserIdRule(ClientTrafficControlRule, discriminator="TrafficThrottleByUserIdRule"): + """Throttle the client traffic by the user ID. + + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + user ID within a time window. Clients with the same user ID will get disconnected if the + message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + :ivar type: Required. TRAFFIC_THROTTLE_BY_USER_ID_RULE. + :vartype type: str or ~azure.mgmt.webpubsub.models.TRAFFIC_THROTTLE_BY_USER_ID_RULE + """ + + max_inbound_message_bytes: Optional[int] = rest_field( + name="maxInboundMessageBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum accumulated inbound message bytes allowed for the same user ID within a time window. + Clients with the same user ID will get disconnected if the message bytes exceeds this value. + Default value is 1GB.""" + aggregation_window_in_seconds: Optional[int] = rest_field( + name="aggregationWindowInSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """The aggregation window for the message bytes. The message bytes will be aggregated in this + window and be reset after the window. Default value is 60 seconds.""" + type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_USER_ID_RULE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. TRAFFIC_THROTTLE_BY_USER_ID_RULE.""" + + @overload + def __init__( + self, + *, + max_inbound_message_bytes: Optional[int] = None, + aggregation_window_in_seconds: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_USER_ID_RULE # type: ignore + + +class UpstreamAuthSettings(_Model): + """Upstream auth settings. If not set, no auth is used for upstream messages. + + :ivar type: Upstream auth type enum. Known values are: "None" and "ManagedIdentity". + :vartype type: str or ~azure.mgmt.webpubsub.models.UpstreamAuthType + :ivar managed_identity: Managed identity settings for upstream. + :vartype managed_identity: ~azure.mgmt.webpubsub.models.ManagedIdentitySettings + """ + + type: Optional[Union[str, "_models.UpstreamAuthType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Upstream auth type enum. Known values are: \"None\" and \"ManagedIdentity\".""" + managed_identity: Optional["_models.ManagedIdentitySettings"] = rest_field( + name="managedIdentity", visibility=["read", "create", "update", "delete", "query"] + ) + """Managed identity settings for upstream.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.UpstreamAuthType"]] = None, + managed_identity: Optional["_models.ManagedIdentitySettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserAssignedIdentityProperty(_Model): + """Properties of user assigned identity. + + :ivar principal_id: Get the principal id for the user assigned identity. + :vartype principal_id: str + :ivar client_id: Get the client id for the user assigned identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """Get the principal id for the user assigned identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """Get the client id for the user assigned identity.""" + + +class WebPubSubHub(ProxyResource): + """A hub setting. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar properties: Properties of a hub. Required. + :vartype properties: ~azure.mgmt.webpubsub.models.WebPubSubHubProperties + """ + + properties: "_models.WebPubSubHubProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of a hub. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.WebPubSubHubProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WebPubSubHubProperties(_Model): + """Properties of a hub. + + :ivar event_handlers: Event handler of a hub. + :vartype event_handlers: list[~azure.mgmt.webpubsub.models.EventHandler] + :ivar event_listeners: Event listener settings for forwarding your client events to listeners. + Event listener is transparent to Web PubSub clients, and it doesn't return any result to + clients nor interrupt the lifetime of clients. One event can be sent to multiple listeners, as + long as it matches the filters in those listeners. The order of the array elements doesn't + matter. Maximum count of event listeners among all hubs is 10. + :vartype event_listeners: list[~azure.mgmt.webpubsub.models.EventListener] + :ivar anonymous_connect_policy: The settings for configuring if anonymous connections are + allowed for this hub: "allow" or "deny". Default to "deny". + :vartype anonymous_connect_policy: str + :ivar web_socket_keep_alive_interval_in_seconds: The settings for configuring the WebSocket + ping-pong interval in seconds for all clients in the hub. Valid range: 1 to 120. Default to 20 + seconds. + :vartype web_socket_keep_alive_interval_in_seconds: int + :ivar chat: The chat settings for the hub. + :vartype chat: ~azure.mgmt.webpubsub.models.ChatSettings + """ + + event_handlers: Optional[list["_models.EventHandler"]] = rest_field( + name="eventHandlers", visibility=["read", "create", "update", "delete", "query"] + ) + """Event handler of a hub.""" + event_listeners: Optional[list["_models.EventListener"]] = rest_field( + name="eventListeners", visibility=["read", "create", "update", "delete", "query"] + ) + """Event listener settings for forwarding your client events to listeners. Event listener is + transparent to Web PubSub clients, and it doesn't return any result to clients nor interrupt + the lifetime of clients. One event can be sent to multiple listeners, as long as it matches the + filters in those listeners. The order of the array elements doesn't matter. Maximum count of + event listeners among all hubs is 10.""" + anonymous_connect_policy: Optional[str] = rest_field( + name="anonymousConnectPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The settings for configuring if anonymous connections are allowed for this hub: \"allow\" or + \"deny\". Default to \"deny\".""" + web_socket_keep_alive_interval_in_seconds: Optional[int] = rest_field( + name="webSocketKeepAliveIntervalInSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """The settings for configuring the WebSocket ping-pong interval in seconds for all clients in the + hub. Valid range: 1 to 120. Default to 20 seconds.""" + chat: Optional["_models.ChatSettings"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The chat settings for the hub.""" + + @overload + def __init__( + self, + *, + event_handlers: Optional[list["_models.EventHandler"]] = None, + event_listeners: Optional[list["_models.EventListener"]] = None, + anonymous_connect_policy: Optional[str] = None, + web_socket_keep_alive_interval_in_seconds: Optional[int] = None, + chat: Optional["_models.ChatSettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WebPubSubKeys(_Model): + """A class represents the access keys of the resource. + + :ivar primary_key: The primary access key. + :vartype primary_key: str + :ivar secondary_key: The secondary access key. + :vartype secondary_key: str + :ivar primary_connection_string: Connection string constructed via the primaryKey. + :vartype primary_connection_string: str + :ivar secondary_connection_string: Connection string constructed via the secondaryKey. + :vartype secondary_connection_string: str + """ + + primary_key: Optional[str] = rest_field( + name="primaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """The primary access key.""" + secondary_key: Optional[str] = rest_field( + name="secondaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """The secondary access key.""" + primary_connection_string: Optional[str] = rest_field( + name="primaryConnectionString", visibility=["read", "create", "update", "delete", "query"] + ) + """Connection string constructed via the primaryKey.""" + secondary_connection_string: Optional[str] = rest_field( + name="secondaryConnectionString", visibility=["read", "create", "update", "delete", "query"] + ) + """Connection string constructed via the secondaryKey.""" + + @overload + def __init__( + self, + *, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + primary_connection_string: Optional[str] = None, + secondary_connection_string: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WebPubSubNetworkACLs(_Model): + """Network ACLs for the resource. + + :ivar default_action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". + :vartype default_action: str or ~azure.mgmt.webpubsub.models.ACLAction + :ivar public_network: Network ACL. + :vartype public_network: ~azure.mgmt.webpubsub.models.NetworkACL + :ivar private_endpoints: ACLs for requests from private endpoints. + :vartype private_endpoints: list[~azure.mgmt.webpubsub.models.PrivateEndpointACL] + :ivar ip_rules: IP rules for filtering public traffic. + :vartype ip_rules: list[~azure.mgmt.webpubsub.models.IPRule] + """ + + default_action: Optional[Union[str, "_models.ACLAction"]] = rest_field( + name="defaultAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Azure Networking ACL Action. Known values are: \"Allow\" and \"Deny\".""" + public_network: Optional["_models.NetworkACL"] = rest_field( + name="publicNetwork", visibility=["read", "create", "update", "delete", "query"] + ) + """Network ACL.""" + private_endpoints: Optional[list["_models.PrivateEndpointACL"]] = rest_field( + name="privateEndpoints", visibility=["read", "create", "update", "delete", "query"] + ) + """ACLs for requests from private endpoints.""" + ip_rules: Optional[list["_models.IPRule"]] = rest_field( + name="ipRules", visibility=["read", "create", "update", "delete", "query"] + ) + """IP rules for filtering public traffic.""" + + @overload + def __init__( + self, + *, + default_action: Optional[Union[str, "_models.ACLAction"]] = None, + public_network: Optional["_models.NetworkACL"] = None, + private_endpoints: Optional[list["_models.PrivateEndpointACL"]] = None, + ip_rules: Optional[list["_models.IPRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WebPubSubProperties(_Model): + """A class that describes the properties of the resource. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState + :ivar external_ip: The publicly accessible IP of the resource. + :vartype external_ip: str + :ivar host_name: FQDN of the service instance. + :vartype host_name: str + :ivar public_port: The publicly accessible port of the resource which is designed for + browser/client side usage. + :vartype public_port: int + :ivar server_port: The publicly accessible port of the resource which is designed for customer + server side usage. + :vartype server_port: int + :ivar version: Version of the resource. Probably you need the same or higher version of client + SDKs. + :vartype version: str + :ivar private_endpoint_connections: Private endpoint connections to the resource. + :vartype private_endpoint_connections: + list[~azure.mgmt.webpubsub.models.PrivateEndpointConnection] + :ivar shared_private_link_resources: The list of shared private link resources. + :vartype shared_private_link_resources: + list[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :ivar tls: TLS settings for the resource. + :vartype tls: ~azure.mgmt.webpubsub.models.WebPubSubTlsSettings + :ivar host_name_prefix: Deprecated. + :vartype host_name_prefix: str + :ivar live_trace_configuration: Live trace configuration of a Microsoft.SignalRService + resource. + :vartype live_trace_configuration: ~azure.mgmt.webpubsub.models.LiveTraceConfiguration + :ivar resource_log_configuration: Resource log configuration of a Microsoft.SignalRService + resource. + :vartype resource_log_configuration: ~azure.mgmt.webpubsub.models.ResourceLogConfiguration + :ivar network_ac_ls: Network ACLs for the resource. + :vartype network_ac_ls: ~azure.mgmt.webpubsub.models.WebPubSubNetworkACLs + :ivar application_firewall: Application firewall settings for the resource. + :vartype application_firewall: ~azure.mgmt.webpubsub.models.ApplicationFirewallSettings + :ivar public_network_access: Enable or disable public network access. Default to "Enabled". + When it's Enabled, network ACLs still apply. When it's Disabled, public network access is + always disabled no matter what you set in network ACLs. + :vartype public_network_access: str + :ivar disable_local_auth: DisableLocalAuth Enable or disable local auth with AccessKey When set + as true, connection with AccessKey=xxx won't work. + :vartype disable_local_auth: bool + :ivar disable_aad_auth: DisableLocalAuth Enable or disable aad auth When set as true, + connection with AuthType=aad won't work. + :vartype disable_aad_auth: bool + :ivar region_endpoint_enabled: Enable or disable the regional endpoint. Default to "Enabled". + When it's Disabled, new connections will not be routed to this endpoint, however existing + connections will not be affected. This property is replica specific. Disable the regional + endpoint without replica is not allowed. + :vartype region_endpoint_enabled: str + :ivar resource_stopped: Stop or start the resource. Default to "False". When it's true, the + data plane of the resource is shutdown. When it's false, the data plane of the resource is + started. + :vartype resource_stopped: str + :ivar socket_io: SocketIO settings for the resource. + :vartype socket_io: ~azure.mgmt.webpubsub.models.WebPubSubSocketIOSettings + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + external_ip: Optional[str] = rest_field(name="externalIP", visibility=["read"]) + """The publicly accessible IP of the resource.""" + host_name: Optional[str] = rest_field(name="hostName", visibility=["read"]) + """FQDN of the service instance.""" + public_port: Optional[int] = rest_field(name="publicPort", visibility=["read"]) + """The publicly accessible port of the resource which is designed for browser/client side usage.""" + server_port: Optional[int] = rest_field(name="serverPort", visibility=["read"]) + """The publicly accessible port of the resource which is designed for customer server side usage.""" + version: Optional[str] = rest_field(visibility=["read"]) + """Version of the resource. Probably you need the same or higher version of client SDKs.""" + private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """Private endpoint connections to the resource.""" + shared_private_link_resources: Optional[list["_models.SharedPrivateLinkResource"]] = rest_field( + name="sharedPrivateLinkResources", visibility=["read"] + ) + """The list of shared private link resources.""" + tls: Optional["_models.WebPubSubTlsSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """TLS settings for the resource.""" + host_name_prefix: Optional[str] = rest_field(name="hostNamePrefix", visibility=["read"]) + """Deprecated.""" + live_trace_configuration: Optional["_models.LiveTraceConfiguration"] = rest_field( + name="liveTraceConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """Live trace configuration of a Microsoft.SignalRService resource.""" + resource_log_configuration: Optional["_models.ResourceLogConfiguration"] = rest_field( + name="resourceLogConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource log configuration of a Microsoft.SignalRService resource.""" + network_ac_ls: Optional["_models.WebPubSubNetworkACLs"] = rest_field( + name="networkACLs", visibility=["read", "create", "update", "delete", "query"] + ) + """Network ACLs for the resource.""" + application_firewall: Optional["_models.ApplicationFirewallSettings"] = rest_field( + name="applicationFirewall", visibility=["read", "create", "update", "delete", "query"] + ) + """Application firewall settings for the resource.""" + public_network_access: Optional[str] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable or disable public network access. Default to \"Enabled\". When it's Enabled, network + ACLs still apply. When it's Disabled, public network access is always disabled no matter what + you set in network ACLs.""" + disable_local_auth: Optional[bool] = rest_field( + name="disableLocalAuth", visibility=["read", "create", "update", "delete", "query"] + ) + """DisableLocalAuth Enable or disable local auth with AccessKey When set as true, connection with + AccessKey=xxx won't work.""" + disable_aad_auth: Optional[bool] = rest_field( + name="disableAadAuth", visibility=["read", "create", "update", "delete", "query"] + ) + """DisableLocalAuth Enable or disable aad auth When set as true, connection with AuthType=aad + won't work.""" + region_endpoint_enabled: Optional[str] = rest_field( + name="regionEndpointEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable or disable the regional endpoint. Default to \"Enabled\". When it's Disabled, new + connections will not be routed to this endpoint, however existing connections will not be + affected. This property is replica specific. Disable the regional endpoint without replica is + not allowed.""" + resource_stopped: Optional[str] = rest_field( + name="resourceStopped", visibility=["read", "create", "update", "delete", "query"] + ) + """Stop or start the resource. Default to \"False\". When it's true, the data plane of the + resource is shutdown. When it's false, the data plane of the resource is started.""" + socket_io: Optional["_models.WebPubSubSocketIOSettings"] = rest_field( + name="socketIO", visibility=["read", "create", "update", "delete", "query"] + ) + """SocketIO settings for the resource.""" + + @overload + def __init__( + self, + *, + tls: Optional["_models.WebPubSubTlsSettings"] = None, + live_trace_configuration: Optional["_models.LiveTraceConfiguration"] = None, + resource_log_configuration: Optional["_models.ResourceLogConfiguration"] = None, + network_ac_ls: Optional["_models.WebPubSubNetworkACLs"] = None, + application_firewall: Optional["_models.ApplicationFirewallSettings"] = None, + public_network_access: Optional[str] = None, + disable_local_auth: Optional[bool] = None, + disable_aad_auth: Optional[bool] = None, + region_endpoint_enabled: Optional[str] = None, + resource_stopped: Optional[str] = None, + socket_io: Optional["_models.WebPubSubSocketIOSettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WebPubSubResource(TrackedResource): + """A class represent a resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: A class that describes the properties of the resource. + :vartype properties: ~azure.mgmt.webpubsub.models.WebPubSubProperties + :ivar sku: The billing information of the resource. + :vartype sku: ~azure.mgmt.webpubsub.models.ResourceSku + :ivar kind: The kind of the service. Known values are: "WebPubSub" and "SocketIO". + :vartype kind: str or ~azure.mgmt.webpubsub.models.ServiceKind + :ivar identity: A class represent managed identities used for request and response. + :vartype identity: ~azure.mgmt.webpubsub.models.ManagedIdentity + """ + + properties: Optional["_models.WebPubSubProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A class that describes the properties of the resource.""" + sku: Optional["_models.ResourceSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The billing information of the resource.""" + kind: Optional[Union[str, "_models.ServiceKind"]] = rest_field(visibility=["read", "create"]) + """The kind of the service. Known values are: \"WebPubSub\" and \"SocketIO\".""" + identity: Optional["_models.ManagedIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A class represent managed identities used for request and response.""" + + __flattened_items = [ + "provisioning_state", + "external_ip", + "host_name", + "public_port", + "server_port", + "version", + "private_endpoint_connections", + "shared_private_link_resources", + "tls", + "host_name_prefix", + "live_trace_configuration", + "resource_log_configuration", + "network_ac_ls", + "application_firewall", + "public_network_access", + "disable_local_auth", + "disable_aad_auth", + "region_endpoint_enabled", + "resource_stopped", + "socket_io", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.WebPubSubProperties"] = None, + sku: Optional["_models.ResourceSku"] = None, + kind: Optional[Union[str, "_models.ServiceKind"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class WebPubSubSocketIOSettings(_Model): + """SocketIO settings for the resource. + + :ivar service_mode: The service mode of Web PubSub for Socket.IO. Values allowed: "Default": + have your own backend Socket.IO server "Serverless": your application doesn't have a backend + server. + :vartype service_mode: str + """ + + service_mode: Optional[str] = rest_field( + name="serviceMode", visibility=["read", "create", "update", "delete", "query"] + ) + """The service mode of Web PubSub for Socket.IO. Values allowed: \"Default\": have your own + backend Socket.IO server \"Serverless\": your application doesn't have a backend server.""" + + @overload + def __init__( + self, + *, + service_mode: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WebPubSubTlsSettings(_Model): + """TLS settings for the resource. + + :ivar client_cert_enabled: Request client certificate during TLS handshake if enabled. Not + supported for free tier. Any input will be ignored for free tier. + :vartype client_cert_enabled: bool + """ + + client_cert_enabled: Optional[bool] = rest_field( + name="clientCertEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Request client certificate during TLS handshake if enabled. Not supported for free tier. Any + input will be ignored for free tier.""" + + @overload + def __init__( + self, + *, + client_cert_enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_models_py3.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_models_py3.py deleted file mode 100644 index 2ca9e1a2f05c..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_models_py3.py +++ /dev/null @@ -1,3068 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .. import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - """ - - -class CustomCertificate(ProxyResource): - """A custom certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", - "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". - :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState - :ivar key_vault_base_uri: Base uri of the KeyVault that stores certificate. Required. - :vartype key_vault_base_uri: str - :ivar key_vault_secret_name: Certificate secret name. Required. - :vartype key_vault_secret_name: str - :ivar key_vault_secret_version: Certificate secret version. - :vartype key_vault_secret_version: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "key_vault_base_uri": {"required": True}, - "key_vault_secret_name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "key_vault_base_uri": {"key": "properties.keyVaultBaseUri", "type": "str"}, - "key_vault_secret_name": {"key": "properties.keyVaultSecretName", "type": "str"}, - "key_vault_secret_version": {"key": "properties.keyVaultSecretVersion", "type": "str"}, - } - - def __init__( - self, - *, - key_vault_base_uri: str, - key_vault_secret_name: str, - key_vault_secret_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword key_vault_base_uri: Base uri of the KeyVault that stores certificate. Required. - :paramtype key_vault_base_uri: str - :keyword key_vault_secret_name: Certificate secret name. Required. - :paramtype key_vault_secret_name: str - :keyword key_vault_secret_version: Certificate secret version. - :paramtype key_vault_secret_version: str - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.key_vault_base_uri = key_vault_base_uri - self.key_vault_secret_name = key_vault_secret_name - self.key_vault_secret_version = key_vault_secret_version - - -class CustomCertificateList(_serialization.Model): - """Custom certificates list. - - :ivar value: List of custom certificates of this resource. - :vartype value: list[~azure.mgmt.webpubsub.models.CustomCertificate] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[CustomCertificate]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.CustomCertificate"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: List of custom certificates of this resource. - :paramtype value: list[~azure.mgmt.webpubsub.models.CustomCertificate] - :keyword next_link: The URL the client should use to fetch the next page (per server side - paging). - It's null for now, added for future use. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CustomDomain(ProxyResource): - """A custom domain. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", - "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". - :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState - :ivar domain_name: The custom domain name. Required. - :vartype domain_name: str - :ivar custom_certificate: Reference to a resource. Required. - :vartype custom_certificate: ~azure.mgmt.webpubsub.models.ResourceReference - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "domain_name": {"required": True}, - "custom_certificate": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "domain_name": {"key": "properties.domainName", "type": "str"}, - "custom_certificate": {"key": "properties.customCertificate", "type": "ResourceReference"}, - } - - def __init__(self, *, domain_name: str, custom_certificate: "_models.ResourceReference", **kwargs: Any) -> None: - """ - :keyword domain_name: The custom domain name. Required. - :paramtype domain_name: str - :keyword custom_certificate: Reference to a resource. Required. - :paramtype custom_certificate: ~azure.mgmt.webpubsub.models.ResourceReference - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.domain_name = domain_name - self.custom_certificate = custom_certificate - - -class CustomDomainList(_serialization.Model): - """Custom domains list. - - :ivar value: List of custom domains that bind to this resource. - :vartype value: list[~azure.mgmt.webpubsub.models.CustomDomain] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[CustomDomain]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.CustomDomain"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of custom domains that bind to this resource. - :paramtype value: list[~azure.mgmt.webpubsub.models.CustomDomain] - :keyword next_link: The URL the client should use to fetch the next page (per server side - paging). - It's null for now, added for future use. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Dimension(_serialization.Model): - """Specifications of the Dimension of metrics. - - :ivar name: The public facing name of the dimension. - :vartype name: str - :ivar display_name: Localized friendly display name of the dimension. - :vartype display_name: str - :ivar internal_name: Name of the dimension as it appears in MDM. - :vartype internal_name: str - :ivar to_be_exported_for_shoebox: A Boolean flag indicating whether this dimension should be - included for the shoebox export scenario. - :vartype to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "internal_name": {"key": "internalName", "type": "str"}, - "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - internal_name: Optional[str] = None, - to_be_exported_for_shoebox: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The public facing name of the dimension. - :paramtype name: str - :keyword display_name: Localized friendly display name of the dimension. - :paramtype display_name: str - :keyword internal_name: Name of the dimension as it appears in MDM. - :paramtype internal_name: str - :keyword to_be_exported_for_shoebox: A Boolean flag indicating whether this dimension should be - included for the shoebox export scenario. - :paramtype to_be_exported_for_shoebox: bool - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.internal_name = internal_name - self.to_be_exported_for_shoebox = to_be_exported_for_shoebox - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.webpubsub.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.webpubsub.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.webpubsub.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.webpubsub.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class EventHandler(_serialization.Model): - """Properties of event handler. - - All required parameters must be populated in order to send to server. - - :ivar url_template: Gets or sets the EventHandler URL template. You can use a predefined - parameter {hub} and {event} inside the template, the value of the EventHandler URL is - dynamically calculated when the client request comes in. - For example, UrlTemplate can be ``http://example.com/api/{hub}/{event}``. The host part can't - contains parameters. Required. - :vartype url_template: str - :ivar user_event_pattern: Gets or sets the matching pattern for event names. - There are 3 kinds of patterns supported: - - .. code-block:: - - 1. "*", it matches any event name - 2. Combine multiple events with ",", for example "event1,event2", it matches event "event1" - and "event2" - 3. A single event name, for example, "event1", it matches "event1". - :vartype user_event_pattern: str - :ivar system_events: Gets or sets the list of system events. - :vartype system_events: list[str] - :ivar auth: Upstream auth settings. If not set, no auth is used for upstream messages. - :vartype auth: ~azure.mgmt.webpubsub.models.UpstreamAuthSettings - """ - - _validation = { - "url_template": {"required": True}, - } - - _attribute_map = { - "url_template": {"key": "urlTemplate", "type": "str"}, - "user_event_pattern": {"key": "userEventPattern", "type": "str"}, - "system_events": {"key": "systemEvents", "type": "[str]"}, - "auth": {"key": "auth", "type": "UpstreamAuthSettings"}, - } - - def __init__( - self, - *, - url_template: str, - user_event_pattern: Optional[str] = None, - system_events: Optional[List[str]] = None, - auth: Optional["_models.UpstreamAuthSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword url_template: Gets or sets the EventHandler URL template. You can use a predefined - parameter {hub} and {event} inside the template, the value of the EventHandler URL is - dynamically calculated when the client request comes in. - For example, UrlTemplate can be ``http://example.com/api/{hub}/{event}``. The host part can't - contains parameters. Required. - :paramtype url_template: str - :keyword user_event_pattern: Gets or sets the matching pattern for event names. - There are 3 kinds of patterns supported: - - .. code-block:: - - 1. "*", it matches any event name - 2. Combine multiple events with ",", for example "event1,event2", it matches event "event1" - and "event2" - 3. A single event name, for example, "event1", it matches "event1". - :paramtype user_event_pattern: str - :keyword system_events: Gets or sets the list of system events. - :paramtype system_events: list[str] - :keyword auth: Upstream auth settings. If not set, no auth is used for upstream messages. - :paramtype auth: ~azure.mgmt.webpubsub.models.UpstreamAuthSettings - """ - super().__init__(**kwargs) - self.url_template = url_template - self.user_event_pattern = user_event_pattern - self.system_events = system_events - self.auth = auth - - -class EventListenerEndpoint(_serialization.Model): - """An endpoint specifying where Web PubSub should send events to. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EventHubEndpoint - - All required parameters must be populated in order to send to server. - - :ivar type: Required. "EventHub" - :vartype type: str or ~azure.mgmt.webpubsub.models.EventListenerEndpointDiscriminator - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = {"type": {"EventHub": "EventHubEndpoint"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - - -class EventHubEndpoint(EventListenerEndpoint): - """An Event Hub endpoint. - The managed identity of Web PubSub service must be enabled, and the identity should have the - "Azure Event Hubs Data sender" role to access Event Hub. - - All required parameters must be populated in order to send to server. - - :ivar type: Required. "EventHub" - :vartype type: str or ~azure.mgmt.webpubsub.models.EventListenerEndpointDiscriminator - :ivar fully_qualified_namespace: The fully qualified namespace name of the Event Hub resource. - For example, "example.servicebus.windows.net". Required. - :vartype fully_qualified_namespace: str - :ivar event_hub_name: The name of the Event Hub. Required. - :vartype event_hub_name: str - """ - - _validation = { - "type": {"required": True}, - "fully_qualified_namespace": {"required": True}, - "event_hub_name": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "fully_qualified_namespace": {"key": "fullyQualifiedNamespace", "type": "str"}, - "event_hub_name": {"key": "eventHubName", "type": "str"}, - } - - def __init__(self, *, fully_qualified_namespace: str, event_hub_name: str, **kwargs: Any) -> None: - """ - :keyword fully_qualified_namespace: The fully qualified namespace name of the Event Hub - resource. For example, "example.servicebus.windows.net". Required. - :paramtype fully_qualified_namespace: str - :keyword event_hub_name: The name of the Event Hub. Required. - :paramtype event_hub_name: str - """ - super().__init__(**kwargs) - self.type: str = "EventHub" - self.fully_qualified_namespace = fully_qualified_namespace - self.event_hub_name = event_hub_name - - -class EventListener(_serialization.Model): - """A setting defines which kinds of events should be sent to which endpoint. - - All required parameters must be populated in order to send to server. - - :ivar filter: A base class for event filter which determines whether an event should be sent to - an event listener. Required. - :vartype filter: ~azure.mgmt.webpubsub.models.EventListenerFilter - :ivar endpoint: An endpoint specifying where Web PubSub should send events to. Required. - :vartype endpoint: ~azure.mgmt.webpubsub.models.EventListenerEndpoint - """ - - _validation = { - "filter": {"required": True}, - "endpoint": {"required": True}, - } - - _attribute_map = { - "filter": {"key": "filter", "type": "EventListenerFilter"}, - "endpoint": {"key": "endpoint", "type": "EventListenerEndpoint"}, - } - - def __init__( - self, - *, - filter: "_models.EventListenerFilter", # pylint: disable=redefined-builtin - endpoint: "_models.EventListenerEndpoint", - **kwargs: Any - ) -> None: - """ - :keyword filter: A base class for event filter which determines whether an event should be sent - to an event listener. Required. - :paramtype filter: ~azure.mgmt.webpubsub.models.EventListenerFilter - :keyword endpoint: An endpoint specifying where Web PubSub should send events to. Required. - :paramtype endpoint: ~azure.mgmt.webpubsub.models.EventListenerEndpoint - """ - super().__init__(**kwargs) - self.filter = filter - self.endpoint = endpoint - - -class EventListenerFilter(_serialization.Model): - """A base class for event filter which determines whether an event should be sent to an event - listener. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EventNameFilter - - All required parameters must be populated in order to send to server. - - :ivar type: Required. "EventName" - :vartype type: str or ~azure.mgmt.webpubsub.models.EventListenerFilterDiscriminator - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = {"type": {"EventName": "EventNameFilter"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - - -class EventNameFilter(EventListenerFilter): - """Filter events by their name. - - All required parameters must be populated in order to send to server. - - :ivar type: Required. "EventName" - :vartype type: str or ~azure.mgmt.webpubsub.models.EventListenerFilterDiscriminator - :ivar system_events: Gets or sets a list of system events. Supported events: "connected" and - "disconnected". Blocking event "connect" is not supported because it requires a response. - :vartype system_events: list[str] - :ivar user_event_pattern: Gets or sets a matching pattern for event names. - There are 3 kinds of patterns supported: - - .. code-block:: - - 1. "*", it matches any event name - 2. Combine multiple events with ",", for example "event1,event2", it matches events - "event1" and "event2" - 3. A single event name, for example, "event1", it matches "event1". - :vartype user_event_pattern: str - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "system_events": {"key": "systemEvents", "type": "[str]"}, - "user_event_pattern": {"key": "userEventPattern", "type": "str"}, - } - - def __init__( - self, *, system_events: Optional[List[str]] = None, user_event_pattern: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword system_events: Gets or sets a list of system events. Supported events: "connected" and - "disconnected". Blocking event "connect" is not supported because it requires a response. - :paramtype system_events: list[str] - :keyword user_event_pattern: Gets or sets a matching pattern for event names. - There are 3 kinds of patterns supported: - - .. code-block:: - - 1. "*", it matches any event name - 2. Combine multiple events with ",", for example "event1,event2", it matches events - "event1" and "event2" - 3. A single event name, for example, "event1", it matches "event1". - :paramtype user_event_pattern: str - """ - super().__init__(**kwargs) - self.type: str = "EventName" - self.system_events = system_events - self.user_event_pattern = user_event_pattern - - -class IPRule(_serialization.Model): - """An IP rule. - - :ivar value: An IP or CIDR or ServiceTag. - :vartype value: str - :ivar action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". - :vartype action: str or ~azure.mgmt.webpubsub.models.ACLAction - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "action": {"key": "action", "type": "str"}, - } - - def __init__( - self, *, value: Optional[str] = None, action: Optional[Union[str, "_models.ACLAction"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: An IP or CIDR or ServiceTag. - :paramtype value: str - :keyword action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". - :paramtype action: str or ~azure.mgmt.webpubsub.models.ACLAction - """ - super().__init__(**kwargs) - self.value = value - self.action = action - - -class LiveTraceCategory(_serialization.Model): - """Live trace category configuration of a Microsoft.SignalRService resource. - - :ivar name: Gets or sets the live trace category's name. - Available values: ConnectivityLogs, MessagingLogs. - Case insensitive. - :vartype name: str - :ivar enabled: Indicates whether or the live trace category is enabled. - Available values: true, false. - Case insensitive. - :vartype enabled: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "enabled": {"key": "enabled", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, enabled: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: Gets or sets the live trace category's name. - Available values: ConnectivityLogs, MessagingLogs. - Case insensitive. - :paramtype name: str - :keyword enabled: Indicates whether or the live trace category is enabled. - Available values: true, false. - Case insensitive. - :paramtype enabled: str - """ - super().__init__(**kwargs) - self.name = name - self.enabled = enabled - - -class LiveTraceConfiguration(_serialization.Model): - """Live trace configuration of a Microsoft.SignalRService resource. - - :ivar enabled: Indicates whether or not enable live trace. - When it's set to true, live trace client can connect to the service. - Otherwise, live trace client can't connect to the service, so that you are unable to receive - any log, no matter what you configure in "categories". - Available values: true, false. - Case insensitive. - :vartype enabled: str - :ivar categories: Gets or sets the list of category configurations. - :vartype categories: list[~azure.mgmt.webpubsub.models.LiveTraceCategory] - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "str"}, - "categories": {"key": "categories", "type": "[LiveTraceCategory]"}, - } - - def __init__( - self, *, enabled: str = "false", categories: Optional[List["_models.LiveTraceCategory"]] = None, **kwargs: Any - ) -> None: - """ - :keyword enabled: Indicates whether or not enable live trace. - When it's set to true, live trace client can connect to the service. - Otherwise, live trace client can't connect to the service, so that you are unable to receive - any log, no matter what you configure in "categories". - Available values: true, false. - Case insensitive. - :paramtype enabled: str - :keyword categories: Gets or sets the list of category configurations. - :paramtype categories: list[~azure.mgmt.webpubsub.models.LiveTraceCategory] - """ - super().__init__(**kwargs) - self.enabled = enabled - self.categories = categories - - -class LogSpecification(_serialization.Model): - """Specifications of the Logs for Azure Monitoring. - - :ivar name: Name of the log. - :vartype name: str - :ivar display_name: Localized friendly display name of the log. - :vartype display_name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: Name of the log. - :paramtype name: str - :keyword display_name: Localized friendly display name of the log. - :paramtype display_name: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - - -class ManagedIdentity(_serialization.Model): - """A class represent managed identities used for request and response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Represents the identity type: systemAssigned, userAssigned, None. Known values are: - "None", "SystemAssigned", and "UserAssigned". - :vartype type: str or ~azure.mgmt.webpubsub.models.ManagedIdentityType - :ivar user_assigned_identities: Get or set the user assigned identities. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.webpubsub.models.UserAssignedIdentityProperty] - :ivar principal_id: Get the principal id for the system assigned identity. - Only be used in response. - :vartype principal_id: str - :ivar tenant_id: Get the tenant id for the system assigned identity. - Only be used in response. - :vartype tenant_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentityProperty}"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentityProperty"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Represents the identity type: systemAssigned, userAssigned, None. Known values - are: "None", "SystemAssigned", and "UserAssigned". - :paramtype type: str or ~azure.mgmt.webpubsub.models.ManagedIdentityType - :keyword user_assigned_identities: Get or set the user assigned identities. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.webpubsub.models.UserAssignedIdentityProperty] - """ - super().__init__(**kwargs) - self.type = type - self.user_assigned_identities = user_assigned_identities - self.principal_id = None - self.tenant_id = None - - -class ManagedIdentitySettings(_serialization.Model): - """Managed identity settings for upstream. - - :ivar resource: The Resource indicating the App ID URI of the target resource. - It also appears in the aud (audience) claim of the issued token. - :vartype resource: str - """ - - _attribute_map = { - "resource": {"key": "resource", "type": "str"}, - } - - def __init__(self, *, resource: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword resource: The Resource indicating the App ID URI of the target resource. - It also appears in the aud (audience) claim of the issued token. - :paramtype resource: str - """ - super().__init__(**kwargs) - self.resource = resource - - -class MetricSpecification(_serialization.Model): - """Specifications of the Metrics for Azure Monitoring. - - :ivar name: Name of the metric. - :vartype name: str - :ivar display_name: Localized friendly display name of the metric. - :vartype display_name: str - :ivar display_description: Localized friendly description of the metric. - :vartype display_description: str - :ivar unit: The unit that makes sense for the metric. - :vartype unit: str - :ivar aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, - Maximum, Total, Count. - :vartype aggregation_type: str - :ivar fill_gap_with_zero: Optional. If set to true, then zero will be returned for time - duration where no metric is emitted/published. - Ex. a metric that returns the number of times a particular error code was emitted. The error - code may not appear - often, instead of the RP publishing 0, Shoebox can auto fill in 0s for time periods where - nothing was emitted. - :vartype fill_gap_with_zero: str - :ivar category: The name of the metric category that the metric belongs to. A metric can only - belong to a single category. - :vartype category: str - :ivar dimensions: The dimensions of the metrics. - :vartype dimensions: list[~azure.mgmt.webpubsub.models.Dimension] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "aggregation_type": {"key": "aggregationType", "type": "str"}, - "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[Dimension]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - display_description: Optional[str] = None, - unit: Optional[str] = None, - aggregation_type: Optional[str] = None, - fill_gap_with_zero: Optional[str] = None, - category: Optional[str] = None, - dimensions: Optional[List["_models.Dimension"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of the metric. - :paramtype name: str - :keyword display_name: Localized friendly display name of the metric. - :paramtype display_name: str - :keyword display_description: Localized friendly description of the metric. - :paramtype display_description: str - :keyword unit: The unit that makes sense for the metric. - :paramtype unit: str - :keyword aggregation_type: Only provide one value for this field. Valid values: Average, - Minimum, Maximum, Total, Count. - :paramtype aggregation_type: str - :keyword fill_gap_with_zero: Optional. If set to true, then zero will be returned for time - duration where no metric is emitted/published. - Ex. a metric that returns the number of times a particular error code was emitted. The error - code may not appear - often, instead of the RP publishing 0, Shoebox can auto fill in 0s for time periods where - nothing was emitted. - :paramtype fill_gap_with_zero: str - :keyword category: The name of the metric category that the metric belongs to. A metric can - only belong to a single category. - :paramtype category: str - :keyword dimensions: The dimensions of the metrics. - :paramtype dimensions: list[~azure.mgmt.webpubsub.models.Dimension] - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.display_description = display_description - self.unit = unit - self.aggregation_type = aggregation_type - self.fill_gap_with_zero = fill_gap_with_zero - self.category = category - self.dimensions = dimensions - - -class NameAvailability(_serialization.Model): - """Result of the request to check name availability. It contains a flag and possible reason of - failure. - - :ivar name_available: Indicates whether the name is available or not. - :vartype name_available: bool - :ivar reason: The reason of the availability. Required if name is not available. - :vartype reason: str - :ivar message: The message of the operation. - :vartype message: str - """ - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - name_available: Optional[bool] = None, - reason: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name_available: Indicates whether the name is available or not. - :paramtype name_available: bool - :keyword reason: The reason of the availability. Required if name is not available. - :paramtype reason: str - :keyword message: The message of the operation. - :paramtype message: str - """ - super().__init__(**kwargs) - self.name_available = name_available - self.reason = reason - self.message = message - - -class NameAvailabilityParameters(_serialization.Model): - """Data POST-ed to the nameAvailability action. - - All required parameters must be populated in order to send to server. - - :ivar type: The resource type. Can be "Microsoft.SignalRService/SignalR", - "Microsoft.SignalRService/WebPubSub", "Microsoft.SignalRService/SignalR/replicas" or - "Microsoft.SignalRService/WebPubSub/replicas". Required. - :vartype type: str - :ivar name: The resource name to validate. e.g."my-resource-name". Required. - :vartype name: str - """ - - _validation = { - "type": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, type: str, name: str, **kwargs: Any) -> None: - """ - :keyword type: The resource type. Can be "Microsoft.SignalRService/SignalR", - "Microsoft.SignalRService/WebPubSub", "Microsoft.SignalRService/SignalR/replicas" or - "Microsoft.SignalRService/WebPubSub/replicas". Required. - :paramtype type: str - :keyword name: The resource name to validate. e.g."my-resource-name". Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.type = type - self.name = name - - -class NetworkACL(_serialization.Model): - """Network ACL. - - :ivar allow: Allowed request types. The value can be one or more of: ClientConnection, - ServerConnection, RESTAPI. - :vartype allow: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] - :ivar deny: Denied request types. The value can be one or more of: ClientConnection, - ServerConnection, RESTAPI. - :vartype deny: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] - """ - - _attribute_map = { - "allow": {"key": "allow", "type": "[str]"}, - "deny": {"key": "deny", "type": "[str]"}, - } - - def __init__( - self, - *, - allow: Optional[List[Union[str, "_models.WebPubSubRequestType"]]] = None, - deny: Optional[List[Union[str, "_models.WebPubSubRequestType"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword allow: Allowed request types. The value can be one or more of: ClientConnection, - ServerConnection, RESTAPI. - :paramtype allow: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] - :keyword deny: Denied request types. The value can be one or more of: ClientConnection, - ServerConnection, RESTAPI. - :paramtype deny: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] - """ - super().__init__(**kwargs) - self.allow = allow - self.deny = deny - - -class Operation(_serialization.Model): - """REST API operation supported by resource provider. - - :ivar name: Name of the operation with format: {provider}/{resource}/{operation}. - :vartype name: str - :ivar is_data_action: If the operation is a data action. (for data plane rbac). - :vartype is_data_action: bool - :ivar display: The object that describes a operation. - :vartype display: ~azure.mgmt.webpubsub.models.OperationDisplay - :ivar origin: Optional. The intended executor of the operation; governs the display of the - operation in the RBAC UX and the audit logs UX. - :vartype origin: str - :ivar properties: Extra Operation properties. - :vartype properties: ~azure.mgmt.webpubsub.models.OperationProperties - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "properties": {"key": "properties", "type": "OperationProperties"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - origin: Optional[str] = None, - properties: Optional["_models.OperationProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of the operation with format: {provider}/{resource}/{operation}. - :paramtype name: str - :keyword is_data_action: If the operation is a data action. (for data plane rbac). - :paramtype is_data_action: bool - :keyword display: The object that describes a operation. - :paramtype display: ~azure.mgmt.webpubsub.models.OperationDisplay - :keyword origin: Optional. The intended executor of the operation; governs the display of the - operation in the RBAC UX and the audit logs UX. - :paramtype origin: str - :keyword properties: Extra Operation properties. - :paramtype properties: ~azure.mgmt.webpubsub.models.OperationProperties - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.display = display - self.origin = origin - self.properties = properties - - -class OperationDisplay(_serialization.Model): - """The object that describes a operation. - - :ivar provider: Friendly name of the resource provider. - :vartype provider: str - :ivar resource: Resource type on which the operation is performed. - :vartype resource: str - :ivar operation: The localized friendly name for the operation. - :vartype operation: str - :ivar description: The localized friendly description for the operation. - :vartype description: str - """ - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provider: Friendly name of the resource provider. - :paramtype provider: str - :keyword resource: Resource type on which the operation is performed. - :paramtype resource: str - :keyword operation: The localized friendly name for the operation. - :paramtype operation: str - :keyword description: The localized friendly description for the operation. - :paramtype description: str - """ - super().__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class OperationList(_serialization.Model): - """Result of the request to list REST API operations. It contains a list of operations. - - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.webpubsub.models.Operation] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of operations supported by the resource provider. - :paramtype value: list[~azure.mgmt.webpubsub.models.Operation] - :keyword next_link: The URL the client should use to fetch the next page (per server side - paging). - It's null for now, added for future use. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OperationProperties(_serialization.Model): - """Extra Operation properties. - - :ivar service_specification: An object that describes a specification. - :vartype service_specification: ~azure.mgmt.webpubsub.models.ServiceSpecification - """ - - _attribute_map = { - "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, - } - - def __init__( - self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs: Any - ) -> None: - """ - :keyword service_specification: An object that describes a specification. - :paramtype service_specification: ~azure.mgmt.webpubsub.models.ServiceSpecification - """ - super().__init__(**kwargs) - self.service_specification = service_specification - - -class PrivateEndpoint(_serialization.Model): - """Private endpoint. - - :ivar id: Full qualified Id of the private endpoint. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Full qualified Id of the private endpoint. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class PrivateEndpointACL(NetworkACL): - """ACL for a private endpoint. - - All required parameters must be populated in order to send to server. - - :ivar allow: Allowed request types. The value can be one or more of: ClientConnection, - ServerConnection, RESTAPI. - :vartype allow: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] - :ivar deny: Denied request types. The value can be one or more of: ClientConnection, - ServerConnection, RESTAPI. - :vartype deny: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] - :ivar name: Name of the private endpoint connection. Required. - :vartype name: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "allow": {"key": "allow", "type": "[str]"}, - "deny": {"key": "deny", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - allow: Optional[List[Union[str, "_models.WebPubSubRequestType"]]] = None, - deny: Optional[List[Union[str, "_models.WebPubSubRequestType"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword allow: Allowed request types. The value can be one or more of: ClientConnection, - ServerConnection, RESTAPI. - :paramtype allow: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] - :keyword deny: Denied request types. The value can be one or more of: ClientConnection, - ServerConnection, RESTAPI. - :paramtype deny: list[str or ~azure.mgmt.webpubsub.models.WebPubSubRequestType] - :keyword name: Name of the private endpoint connection. Required. - :paramtype name: str - """ - super().__init__(allow=allow, deny=deny, **kwargs) - self.name = name - - -class PrivateEndpointConnection(ProxyResource): - """A private endpoint connection to an azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", - "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". - :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState - :ivar private_endpoint: Private endpoint. - :vartype private_endpoint: ~azure.mgmt.webpubsub.models.PrivateEndpoint - :ivar group_ids: Group IDs. - :vartype group_ids: list[str] - :ivar private_link_service_connection_state: Connection state of the private endpoint - connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "group_ids": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "group_ids": {"key": "properties.groupIds", "type": "[str]"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: Private endpoint. - :paramtype private_endpoint: ~azure.mgmt.webpubsub.models.PrivateEndpoint - :keyword private_link_service_connection_state: Connection state of the private endpoint - connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.private_endpoint = private_endpoint - self.group_ids = None - self.private_link_service_connection_state = private_link_service_connection_state - - -class PrivateEndpointConnectionList(_serialization.Model): - """A list of private endpoint connections. - - :ivar value: The list of the private endpoint connections. - :vartype value: list[~azure.mgmt.webpubsub.models.PrivateEndpointConnection] - :ivar next_link: Request URL that can be used to query next page of private endpoint - connections. Returned when the total number of requested private endpoint connections exceed - maximum page size. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of the private endpoint connections. - :paramtype value: list[~azure.mgmt.webpubsub.models.PrivateEndpointConnection] - :keyword next_link: Request URL that can be used to query next page of private endpoint - connections. Returned when the total number of requested private endpoint connections exceed - maximum page size. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class PrivateLinkResource(ProxyResource): - """Private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar group_id: Group Id of the private link resource. - :vartype group_id: str - :ivar required_members: Required members of the private link resource. - :vartype required_members: list[str] - :ivar required_zone_names: Required private DNS zone names. - :vartype required_zone_names: list[str] - :ivar shareable_private_link_resource_types: The list of resources that are onboarded to - private link service. - :vartype shareable_private_link_resource_types: - list[~azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceType] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - "shareable_private_link_resource_types": { - "key": "properties.shareablePrivateLinkResourceTypes", - "type": "[ShareablePrivateLinkResourceType]", - }, - } - - def __init__( - self, - *, - group_id: Optional[str] = None, - required_members: Optional[List[str]] = None, - required_zone_names: Optional[List[str]] = None, - shareable_private_link_resource_types: Optional[List["_models.ShareablePrivateLinkResourceType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: Group Id of the private link resource. - :paramtype group_id: str - :keyword required_members: Required members of the private link resource. - :paramtype required_members: list[str] - :keyword required_zone_names: Required private DNS zone names. - :paramtype required_zone_names: list[str] - :keyword shareable_private_link_resource_types: The list of resources that are onboarded to - private link service. - :paramtype shareable_private_link_resource_types: - list[~azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceType] - """ - super().__init__(**kwargs) - self.group_id = group_id - self.required_members = required_members - self.required_zone_names = required_zone_names - self.shareable_private_link_resource_types = shareable_private_link_resource_types - - -class PrivateLinkResourceList(_serialization.Model): - """Contains a list of PrivateLinkResource and a possible link to query more results. - - :ivar value: List of PrivateLinkResource. - :vartype value: list[~azure.mgmt.webpubsub.models.PrivateLinkResource] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: List of PrivateLinkResource. - :paramtype value: list[~azure.mgmt.webpubsub.models.PrivateLinkResource] - :keyword next_link: The URL the client should use to fetch the next page (per server side - paging). - It's null for now, added for future use. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """Connection state of the private endpoint connection. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or ~azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateLinkServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or ~azure.mgmt.webpubsub.models.PrivateLinkServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class RegenerateKeyParameters(_serialization.Model): - """Parameters describes the request to regenerate access keys. - - :ivar key_type: The type of access key. Known values are: "Primary", "Secondary", and "Salt". - :vartype key_type: str or ~azure.mgmt.webpubsub.models.KeyType - """ - - _attribute_map = { - "key_type": {"key": "keyType", "type": "str"}, - } - - def __init__(self, *, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs: Any) -> None: - """ - :keyword key_type: The type of access key. Known values are: "Primary", "Secondary", and - "Salt". - :paramtype key_type: str or ~azure.mgmt.webpubsub.models.KeyType - """ - super().__init__(**kwargs) - self.key_type = key_type - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class Replica(TrackedResource): - """A class represent a replica resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar sku: The billing information of the resource. - :vartype sku: ~azure.mgmt.webpubsub.models.ResourceSku - :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", - "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". - :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState - :ivar region_endpoint_enabled: Enable or disable the regional endpoint. Default to "Enabled". - When it's Disabled, new connections will not be routed to this endpoint, however existing - connections will not be affected. - :vartype region_endpoint_enabled: str - :ivar resource_stopped: Stop or start the resource. Default to "false". - When it's true, the data plane of the resource is shutdown. - When it's false, the data plane of the resource is started. - :vartype resource_stopped: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "ResourceSku"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "str"}, - "resource_stopped": {"key": "properties.resourceStopped", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.ResourceSku"] = None, - region_endpoint_enabled: str = "Enabled", - resource_stopped: str = "false", - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword sku: The billing information of the resource. - :paramtype sku: ~azure.mgmt.webpubsub.models.ResourceSku - :keyword region_endpoint_enabled: Enable or disable the regional endpoint. Default to - "Enabled". - When it's Disabled, new connections will not be routed to this endpoint, however existing - connections will not be affected. - :paramtype region_endpoint_enabled: str - :keyword resource_stopped: Stop or start the resource. Default to "false". - When it's true, the data plane of the resource is shutdown. - When it's false, the data plane of the resource is started. - :paramtype resource_stopped: str - """ - super().__init__(tags=tags, location=location, **kwargs) - self.sku = sku - self.provisioning_state = None - self.region_endpoint_enabled = region_endpoint_enabled - self.resource_stopped = resource_stopped - - -class ReplicaList(_serialization.Model): - """ReplicaList. - - :ivar value: List of the replica. - :vartype value: list[~azure.mgmt.webpubsub.models.Replica] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Replica]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Replica"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of the replica. - :paramtype value: list[~azure.mgmt.webpubsub.models.Replica] - :keyword next_link: The URL the client should use to fetch the next page (per server side - paging). - It's null for now, added for future use. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceLogCategory(_serialization.Model): - """Resource log category configuration of a Microsoft.SignalRService resource. - - :ivar name: Gets or sets the resource log category's name. - Available values: ConnectivityLogs, MessagingLogs. - Case insensitive. - :vartype name: str - :ivar enabled: Indicates whether or the resource log category is enabled. - Available values: true, false. - Case insensitive. - :vartype enabled: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "enabled": {"key": "enabled", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, enabled: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: Gets or sets the resource log category's name. - Available values: ConnectivityLogs, MessagingLogs. - Case insensitive. - :paramtype name: str - :keyword enabled: Indicates whether or the resource log category is enabled. - Available values: true, false. - Case insensitive. - :paramtype enabled: str - """ - super().__init__(**kwargs) - self.name = name - self.enabled = enabled - - -class ResourceLogConfiguration(_serialization.Model): - """Resource log configuration of a Microsoft.SignalRService resource. - - :ivar categories: Gets or sets the list of category configurations. - :vartype categories: list[~azure.mgmt.webpubsub.models.ResourceLogCategory] - """ - - _attribute_map = { - "categories": {"key": "categories", "type": "[ResourceLogCategory]"}, - } - - def __init__(self, *, categories: Optional[List["_models.ResourceLogCategory"]] = None, **kwargs: Any) -> None: - """ - :keyword categories: Gets or sets the list of category configurations. - :paramtype categories: list[~azure.mgmt.webpubsub.models.ResourceLogCategory] - """ - super().__init__(**kwargs) - self.categories = categories - - -class ResourceReference(_serialization.Model): - """Reference to a resource. - - :ivar id: Resource ID. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource ID. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ResourceSku(_serialization.Model): - """The billing information of the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the SKU. Required. - - Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2. Required. - :vartype name: str - :ivar tier: Optional tier of this particular SKU. 'Standard' or 'Free'. - - ``Basic`` is deprecated, use ``Standard`` instead. Known values are: "Free", "Basic", - "Standard", and "Premium". - :vartype tier: str or ~azure.mgmt.webpubsub.models.WebPubSubSkuTier - :ivar size: Not used. Retained for future use. - :vartype size: str - :ivar family: Not used. Retained for future use. - :vartype family: str - :ivar capacity: Optional, integer. The unit count of the resource. - 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default. - - If present, following values are allowed: - Free_F1: 1; - Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; - Premium_P1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; - Premium_P2: 100,200,300,400,500,600,700,800,900,1000;. - :vartype capacity: int - """ - - _validation = { - "name": {"required": True}, - "size": {"readonly": True}, - "family": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "size": {"key": "size", "type": "str"}, - "family": {"key": "family", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, - *, - name: str, - tier: Optional[Union[str, "_models.WebPubSubSkuTier"]] = None, - capacity: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the SKU. Required. - - Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2. Required. - :paramtype name: str - :keyword tier: Optional tier of this particular SKU. 'Standard' or 'Free'. - - ``Basic`` is deprecated, use ``Standard`` instead. Known values are: "Free", "Basic", - "Standard", and "Premium". - :paramtype tier: str or ~azure.mgmt.webpubsub.models.WebPubSubSkuTier - :keyword capacity: Optional, integer. The unit count of the resource. - 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default. - - If present, following values are allowed: - Free_F1: 1; - Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; - Premium_P1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; - Premium_P2: 100,200,300,400,500,600,700,800,900,1000;. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.size = None - self.family = None - self.capacity = capacity - - -class ServiceSpecification(_serialization.Model): - """An object that describes a specification. - - :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. - :vartype metric_specifications: list[~azure.mgmt.webpubsub.models.MetricSpecification] - :ivar log_specifications: Specifications of the Logs for Azure Monitoring. - :vartype log_specifications: list[~azure.mgmt.webpubsub.models.LogSpecification] - """ - - _attribute_map = { - "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, - "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, - } - - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - log_specifications: Optional[List["_models.LogSpecification"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric_specifications: Specifications of the Metrics for Azure Monitoring. - :paramtype metric_specifications: list[~azure.mgmt.webpubsub.models.MetricSpecification] - :keyword log_specifications: Specifications of the Logs for Azure Monitoring. - :paramtype log_specifications: list[~azure.mgmt.webpubsub.models.LogSpecification] - """ - super().__init__(**kwargs) - self.metric_specifications = metric_specifications - self.log_specifications = log_specifications - - -class ShareablePrivateLinkResourceProperties(_serialization.Model): - """Describes the properties of a resource type that has been onboarded to private link service. - - :ivar description: The description of the resource type that has been onboarded to private link - service. - :vartype description: str - :ivar group_id: The resource provider group id for the resource that has been onboarded to - private link service. - :vartype group_id: str - :ivar type: The resource provider type for the resource that has been onboarded to private link - service. - :vartype type: str - """ - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "group_id": {"key": "groupId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - group_id: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: The description of the resource type that has been onboarded to private - link service. - :paramtype description: str - :keyword group_id: The resource provider group id for the resource that has been onboarded to - private link service. - :paramtype group_id: str - :keyword type: The resource provider type for the resource that has been onboarded to private - link service. - :paramtype type: str - """ - super().__init__(**kwargs) - self.description = description - self.group_id = group_id - self.type = type - - -class ShareablePrivateLinkResourceType(_serialization.Model): - """Describes a resource type that has been onboarded to private link service. - - :ivar name: The name of the resource type that has been onboarded to private link service. - :vartype name: str - :ivar properties: Describes the properties of a resource type that has been onboarded to - private link service. - :vartype properties: ~azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceProperties - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "ShareablePrivateLinkResourceProperties"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - properties: Optional["_models.ShareablePrivateLinkResourceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the resource type that has been onboarded to private link service. - :paramtype name: str - :keyword properties: Describes the properties of a resource type that has been onboarded to - private link service. - :paramtype properties: ~azure.mgmt.webpubsub.models.ShareablePrivateLinkResourceProperties - """ - super().__init__(**kwargs) - self.name = name - self.properties = properties - - -class SharedPrivateLinkResource(ProxyResource): - """Describes a Shared Private Link Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar group_id: The group id from the provider of resource the shared private link resource is - for. - :vartype group_id: str - :ivar private_link_resource_id: The resource id of the resource the shared private link - resource is for. - :vartype private_link_resource_id: str - :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", - "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". - :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState - :ivar request_message: The request message for requesting approval of the shared private link - resource. - :vartype request_message: str - :ivar status: Status of the shared private link resource. Known values are: "Pending", - "Approved", "Rejected", "Disconnected", and "Timeout". - :vartype status: str or ~azure.mgmt.webpubsub.models.SharedPrivateLinkResourceStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "private_link_resource_id": {"key": "properties.privateLinkResourceId", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "request_message": {"key": "properties.requestMessage", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - } - - def __init__( - self, - *, - group_id: Optional[str] = None, - private_link_resource_id: Optional[str] = None, - request_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: The group id from the provider of resource the shared private link resource - is for. - :paramtype group_id: str - :keyword private_link_resource_id: The resource id of the resource the shared private link - resource is for. - :paramtype private_link_resource_id: str - :keyword request_message: The request message for requesting approval of the shared private - link resource. - :paramtype request_message: str - """ - super().__init__(**kwargs) - self.group_id = group_id - self.private_link_resource_id = private_link_resource_id - self.provisioning_state = None - self.request_message = request_message - self.status = None - - -class SharedPrivateLinkResourceList(_serialization.Model): - """A list of shared private link resources. - - :ivar value: The list of the shared private link resources. - :vartype value: list[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :ivar next_link: Request URL that can be used to query next page of private endpoint - connections. Returned when the total number of requested private endpoint connections exceed - maximum page size. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[SharedPrivateLinkResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.SharedPrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of the shared private link resources. - :paramtype value: list[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :keyword next_link: Request URL that can be used to query next page of private endpoint - connections. Returned when the total number of requested private endpoint connections exceed - maximum page size. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SignalRServiceUsage(_serialization.Model): - """Object that describes a specific usage of the resources. - - :ivar id: Fully qualified ARM resource id. - :vartype id: str - :ivar current_value: Current value for the usage quota. - :vartype current_value: int - :ivar limit: The maximum permitted value for the usage quota. If there is no limit, this value - will be -1. - :vartype limit: int - :ivar name: Localizable String object containing the name and a localized value. - :vartype name: ~azure.mgmt.webpubsub.models.SignalRServiceUsageName - :ivar unit: Representing the units of the usage quota. Possible values are: Count, Bytes, - Seconds, Percent, CountPerSecond, BytesPerSecond. - :vartype unit: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "SignalRServiceUsageName"}, - "unit": {"key": "unit", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - current_value: Optional[int] = None, - limit: Optional[int] = None, - name: Optional["_models.SignalRServiceUsageName"] = None, - unit: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Fully qualified ARM resource id. - :paramtype id: str - :keyword current_value: Current value for the usage quota. - :paramtype current_value: int - :keyword limit: The maximum permitted value for the usage quota. If there is no limit, this - value will be -1. - :paramtype limit: int - :keyword name: Localizable String object containing the name and a localized value. - :paramtype name: ~azure.mgmt.webpubsub.models.SignalRServiceUsageName - :keyword unit: Representing the units of the usage quota. Possible values are: Count, Bytes, - Seconds, Percent, CountPerSecond, BytesPerSecond. - :paramtype unit: str - """ - super().__init__(**kwargs) - self.id = id - self.current_value = current_value - self.limit = limit - self.name = name - self.unit = unit - - -class SignalRServiceUsageList(_serialization.Model): - """Object that includes an array of the resource usages and a possible link for next set. - - :ivar value: List of the resource usages. - :vartype value: list[~azure.mgmt.webpubsub.models.SignalRServiceUsage] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[SignalRServiceUsage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.SignalRServiceUsage"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: List of the resource usages. - :paramtype value: list[~azure.mgmt.webpubsub.models.SignalRServiceUsage] - :keyword next_link: The URL the client should use to fetch the next page (per server side - paging). - It's null for now, added for future use. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SignalRServiceUsageName(_serialization.Model): - """Localizable String object containing the name and a localized value. - - :ivar value: The identifier of the usage. - :vartype value: str - :ivar localized_value: Localized name of the usage. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The identifier of the usage. - :paramtype value: str - :keyword localized_value: Localized name of the usage. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class Sku(_serialization.Model): - """Describes an available sku.". - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The resource type that this object applies to. - :vartype resource_type: str - :ivar sku: The billing information of the resource. - :vartype sku: ~azure.mgmt.webpubsub.models.ResourceSku - :ivar capacity: Describes scaling information of a sku. - :vartype capacity: ~azure.mgmt.webpubsub.models.SkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "ResourceSku"}, - "capacity": {"key": "capacity", "type": "SkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type = None - self.sku = None - self.capacity = None - - -class SkuCapacity(_serialization.Model): - """Describes scaling information of a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The lowest permitted capacity for this resource. - :vartype minimum: int - :ivar maximum: The highest permitted capacity for this resource. - :vartype maximum: int - :ivar default: The default capacity. - :vartype default: int - :ivar allowed_values: Allows capacity value list. - :vartype allowed_values: list[int] - :ivar scale_type: The scale type applicable to the sku. Known values are: "None", "Manual", and - "Automatic". - :vartype scale_type: str or ~azure.mgmt.webpubsub.models.ScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default": {"readonly": True}, - "allowed_values": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default": {"key": "default", "type": "int"}, - "allowed_values": {"key": "allowedValues", "type": "[int]"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.allowed_values = None - self.scale_type = None - - -class SkuList(_serialization.Model): - """The list skus operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of skus available for the resource. - :vartype value: list[~azure.mgmt.webpubsub.models.Sku] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Sku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.webpubsub.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.webpubsub.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.webpubsub.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.webpubsub.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class UpstreamAuthSettings(_serialization.Model): - """Upstream auth settings. If not set, no auth is used for upstream messages. - - :ivar type: Upstream auth type enum. Known values are: "None" and "ManagedIdentity". - :vartype type: str or ~azure.mgmt.webpubsub.models.UpstreamAuthType - :ivar managed_identity: Managed identity settings for upstream. - :vartype managed_identity: ~azure.mgmt.webpubsub.models.ManagedIdentitySettings - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "managed_identity": {"key": "managedIdentity", "type": "ManagedIdentitySettings"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.UpstreamAuthType"]] = None, - managed_identity: Optional["_models.ManagedIdentitySettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Upstream auth type enum. Known values are: "None" and "ManagedIdentity". - :paramtype type: str or ~azure.mgmt.webpubsub.models.UpstreamAuthType - :keyword managed_identity: Managed identity settings for upstream. - :paramtype managed_identity: ~azure.mgmt.webpubsub.models.ManagedIdentitySettings - """ - super().__init__(**kwargs) - self.type = type - self.managed_identity = managed_identity - - -class UserAssignedIdentityProperty(_serialization.Model): - """Properties of user assigned identity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: Get the principal id for the user assigned identity. - :vartype principal_id: str - :ivar client_id: Get the client id for the user assigned identity. - :vartype client_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class WebPubSubHub(ProxyResource): - """A hub setting. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar properties: Properties of a hub. Required. - :vartype properties: ~azure.mgmt.webpubsub.models.WebPubSubHubProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "WebPubSubHubProperties"}, - } - - def __init__(self, *, properties: "_models.WebPubSubHubProperties", **kwargs: Any) -> None: - """ - :keyword properties: Properties of a hub. Required. - :paramtype properties: ~azure.mgmt.webpubsub.models.WebPubSubHubProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class WebPubSubHubList(_serialization.Model): - """Hub setting list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of hub settings to this resource. - :vartype value: list[~azure.mgmt.webpubsub.models.WebPubSubHub] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[WebPubSubHub]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.WebPubSubHub"]] = None, **kwargs: Any) -> None: - """ - :keyword value: List of hub settings to this resource. - :paramtype value: list[~azure.mgmt.webpubsub.models.WebPubSubHub] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class WebPubSubHubProperties(_serialization.Model): - """Properties of a hub. - - :ivar event_handlers: Event handler of a hub. - :vartype event_handlers: list[~azure.mgmt.webpubsub.models.EventHandler] - :ivar event_listeners: Event listener settings for forwarding your client events to listeners. - Event listener is transparent to Web PubSub clients, and it doesn't return any result to - clients nor interrupt the lifetime of clients. - One event can be sent to multiple listeners, as long as it matches the filters in those - listeners. The order of the array elements doesn't matter. - Maximum count of event listeners among all hubs is 10. - :vartype event_listeners: list[~azure.mgmt.webpubsub.models.EventListener] - :ivar anonymous_connect_policy: The settings for configuring if anonymous connections are - allowed for this hub: "allow" or "deny". Default to "deny". - :vartype anonymous_connect_policy: str - :ivar web_socket_keep_alive_interval_in_seconds: The settings for configuring the WebSocket - ping-pong interval in seconds for all clients in the hub. Valid range: 1 to 120. Default to 20 - seconds. - :vartype web_socket_keep_alive_interval_in_seconds: int - """ - - _validation = { - "web_socket_keep_alive_interval_in_seconds": {"maximum": 120, "minimum": 1}, - } - - _attribute_map = { - "event_handlers": {"key": "eventHandlers", "type": "[EventHandler]"}, - "event_listeners": {"key": "eventListeners", "type": "[EventListener]"}, - "anonymous_connect_policy": {"key": "anonymousConnectPolicy", "type": "str"}, - "web_socket_keep_alive_interval_in_seconds": {"key": "webSocketKeepAliveIntervalInSeconds", "type": "int"}, - } - - def __init__( - self, - *, - event_handlers: Optional[List["_models.EventHandler"]] = None, - event_listeners: Optional[List["_models.EventListener"]] = None, - anonymous_connect_policy: str = "deny", - web_socket_keep_alive_interval_in_seconds: int = 20, - **kwargs: Any - ) -> None: - """ - :keyword event_handlers: Event handler of a hub. - :paramtype event_handlers: list[~azure.mgmt.webpubsub.models.EventHandler] - :keyword event_listeners: Event listener settings for forwarding your client events to - listeners. - Event listener is transparent to Web PubSub clients, and it doesn't return any result to - clients nor interrupt the lifetime of clients. - One event can be sent to multiple listeners, as long as it matches the filters in those - listeners. The order of the array elements doesn't matter. - Maximum count of event listeners among all hubs is 10. - :paramtype event_listeners: list[~azure.mgmt.webpubsub.models.EventListener] - :keyword anonymous_connect_policy: The settings for configuring if anonymous connections are - allowed for this hub: "allow" or "deny". Default to "deny". - :paramtype anonymous_connect_policy: str - :keyword web_socket_keep_alive_interval_in_seconds: The settings for configuring the WebSocket - ping-pong interval in seconds for all clients in the hub. Valid range: 1 to 120. Default to 20 - seconds. - :paramtype web_socket_keep_alive_interval_in_seconds: int - """ - super().__init__(**kwargs) - self.event_handlers = event_handlers - self.event_listeners = event_listeners - self.anonymous_connect_policy = anonymous_connect_policy - self.web_socket_keep_alive_interval_in_seconds = web_socket_keep_alive_interval_in_seconds - - -class WebPubSubKeys(_serialization.Model): - """A class represents the access keys of the resource. - - :ivar primary_key: The primary access key. - :vartype primary_key: str - :ivar secondary_key: The secondary access key. - :vartype secondary_key: str - :ivar primary_connection_string: Connection string constructed via the primaryKey. - :vartype primary_connection_string: str - :ivar secondary_connection_string: Connection string constructed via the secondaryKey. - :vartype secondary_connection_string: str - """ - - _attribute_map = { - "primary_key": {"key": "primaryKey", "type": "str"}, - "secondary_key": {"key": "secondaryKey", "type": "str"}, - "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, - "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, - } - - def __init__( - self, - *, - primary_key: Optional[str] = None, - secondary_key: Optional[str] = None, - primary_connection_string: Optional[str] = None, - secondary_connection_string: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword primary_key: The primary access key. - :paramtype primary_key: str - :keyword secondary_key: The secondary access key. - :paramtype secondary_key: str - :keyword primary_connection_string: Connection string constructed via the primaryKey. - :paramtype primary_connection_string: str - :keyword secondary_connection_string: Connection string constructed via the secondaryKey. - :paramtype secondary_connection_string: str - """ - super().__init__(**kwargs) - self.primary_key = primary_key - self.secondary_key = secondary_key - self.primary_connection_string = primary_connection_string - self.secondary_connection_string = secondary_connection_string - - -class WebPubSubNetworkACLs(_serialization.Model): - """Network ACLs for the resource. - - :ivar default_action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". - :vartype default_action: str or ~azure.mgmt.webpubsub.models.ACLAction - :ivar public_network: Network ACL. - :vartype public_network: ~azure.mgmt.webpubsub.models.NetworkACL - :ivar private_endpoints: ACLs for requests from private endpoints. - :vartype private_endpoints: list[~azure.mgmt.webpubsub.models.PrivateEndpointACL] - :ivar ip_rules: IP rules for filtering public traffic. - :vartype ip_rules: list[~azure.mgmt.webpubsub.models.IPRule] - """ - - _validation = { - "ip_rules": {"max_items": 30, "min_items": 0}, - } - - _attribute_map = { - "default_action": {"key": "defaultAction", "type": "str"}, - "public_network": {"key": "publicNetwork", "type": "NetworkACL"}, - "private_endpoints": {"key": "privateEndpoints", "type": "[PrivateEndpointACL]"}, - "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, - } - - def __init__( - self, - *, - default_action: Optional[Union[str, "_models.ACLAction"]] = None, - public_network: Optional["_models.NetworkACL"] = None, - private_endpoints: Optional[List["_models.PrivateEndpointACL"]] = None, - ip_rules: Optional[List["_models.IPRule"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword default_action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". - :paramtype default_action: str or ~azure.mgmt.webpubsub.models.ACLAction - :keyword public_network: Network ACL. - :paramtype public_network: ~azure.mgmt.webpubsub.models.NetworkACL - :keyword private_endpoints: ACLs for requests from private endpoints. - :paramtype private_endpoints: list[~azure.mgmt.webpubsub.models.PrivateEndpointACL] - :keyword ip_rules: IP rules for filtering public traffic. - :paramtype ip_rules: list[~azure.mgmt.webpubsub.models.IPRule] - """ - super().__init__(**kwargs) - self.default_action = default_action - self.public_network = public_network - self.private_endpoints = private_endpoints - self.ip_rules = ip_rules - - -class WebPubSubResource(TrackedResource): # pylint: disable=too-many-instance-attributes - """A class represent a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.webpubsub.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar sku: The billing information of the resource. - :vartype sku: ~azure.mgmt.webpubsub.models.ResourceSku - :ivar kind: The kind of the service. Known values are: "WebPubSub" and "SocketIO". - :vartype kind: str or ~azure.mgmt.webpubsub.models.ServiceKind - :ivar identity: A class represent managed identities used for request and response. - :vartype identity: ~azure.mgmt.webpubsub.models.ManagedIdentity - :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", - "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". - :vartype provisioning_state: str or ~azure.mgmt.webpubsub.models.ProvisioningState - :ivar external_ip: The publicly accessible IP of the resource. - :vartype external_ip: str - :ivar host_name: FQDN of the service instance. - :vartype host_name: str - :ivar public_port: The publicly accessible port of the resource which is designed for - browser/client side usage. - :vartype public_port: int - :ivar server_port: The publicly accessible port of the resource which is designed for customer - server side usage. - :vartype server_port: int - :ivar version: Version of the resource. Probably you need the same or higher version of client - SDKs. - :vartype version: str - :ivar private_endpoint_connections: Private endpoint connections to the resource. - :vartype private_endpoint_connections: - list[~azure.mgmt.webpubsub.models.PrivateEndpointConnection] - :ivar shared_private_link_resources: The list of shared private link resources. - :vartype shared_private_link_resources: - list[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :ivar tls: TLS settings for the resource. - :vartype tls: ~azure.mgmt.webpubsub.models.WebPubSubTlsSettings - :ivar host_name_prefix: Deprecated. - :vartype host_name_prefix: str - :ivar live_trace_configuration: Live trace configuration of a Microsoft.SignalRService - resource. - :vartype live_trace_configuration: ~azure.mgmt.webpubsub.models.LiveTraceConfiguration - :ivar resource_log_configuration: Resource log configuration of a Microsoft.SignalRService - resource. - :vartype resource_log_configuration: ~azure.mgmt.webpubsub.models.ResourceLogConfiguration - :ivar network_ac_ls: Network ACLs for the resource. - :vartype network_ac_ls: ~azure.mgmt.webpubsub.models.WebPubSubNetworkACLs - :ivar public_network_access: Enable or disable public network access. Default to "Enabled". - When it's Enabled, network ACLs still apply. - When it's Disabled, public network access is always disabled no matter what you set in network - ACLs. - :vartype public_network_access: str - :ivar disable_local_auth: DisableLocalAuth - Enable or disable local auth with AccessKey - When set as true, connection with AccessKey=xxx won't work. - :vartype disable_local_auth: bool - :ivar disable_aad_auth: DisableLocalAuth - Enable or disable aad auth - When set as true, connection with AuthType=aad won't work. - :vartype disable_aad_auth: bool - :ivar region_endpoint_enabled: Enable or disable the regional endpoint. Default to "Enabled". - When it's Disabled, new connections will not be routed to this endpoint, however existing - connections will not be affected. - This property is replica specific. Disable the regional endpoint without replica is not - allowed. - :vartype region_endpoint_enabled: str - :ivar resource_stopped: Stop or start the resource. Default to "False". - When it's true, the data plane of the resource is shutdown. - When it's false, the data plane of the resource is started. - :vartype resource_stopped: str - :ivar socket_io: SocketIO settings for the resource. - :vartype socket_io: ~azure.mgmt.webpubsub.models.WebPubSubSocketIOSettings - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "external_ip": {"readonly": True}, - "host_name": {"readonly": True}, - "public_port": {"readonly": True}, - "server_port": {"readonly": True}, - "version": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - "shared_private_link_resources": {"readonly": True}, - "host_name_prefix": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "ResourceSku"}, - "kind": {"key": "kind", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedIdentity"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "external_ip": {"key": "properties.externalIP", "type": "str"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "public_port": {"key": "properties.publicPort", "type": "int"}, - "server_port": {"key": "properties.serverPort", "type": "int"}, - "version": {"key": "properties.version", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "shared_private_link_resources": { - "key": "properties.sharedPrivateLinkResources", - "type": "[SharedPrivateLinkResource]", - }, - "tls": {"key": "properties.tls", "type": "WebPubSubTlsSettings"}, - "host_name_prefix": {"key": "properties.hostNamePrefix", "type": "str"}, - "live_trace_configuration": {"key": "properties.liveTraceConfiguration", "type": "LiveTraceConfiguration"}, - "resource_log_configuration": { - "key": "properties.resourceLogConfiguration", - "type": "ResourceLogConfiguration", - }, - "network_ac_ls": {"key": "properties.networkACLs", "type": "WebPubSubNetworkACLs"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, - "disable_aad_auth": {"key": "properties.disableAadAuth", "type": "bool"}, - "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "str"}, - "resource_stopped": {"key": "properties.resourceStopped", "type": "str"}, - "socket_io": {"key": "properties.socketIO", "type": "WebPubSubSocketIOSettings"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.ResourceSku"] = None, - kind: Optional[Union[str, "_models.ServiceKind"]] = None, - identity: Optional["_models.ManagedIdentity"] = None, - tls: Optional["_models.WebPubSubTlsSettings"] = None, - live_trace_configuration: Optional["_models.LiveTraceConfiguration"] = None, - resource_log_configuration: Optional["_models.ResourceLogConfiguration"] = None, - network_ac_ls: Optional["_models.WebPubSubNetworkACLs"] = None, - public_network_access: str = "Enabled", - disable_local_auth: bool = False, - disable_aad_auth: bool = False, - region_endpoint_enabled: str = "Enabled", - resource_stopped: str = "false", - socket_io: Optional["_models.WebPubSubSocketIOSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword sku: The billing information of the resource. - :paramtype sku: ~azure.mgmt.webpubsub.models.ResourceSku - :keyword kind: The kind of the service. Known values are: "WebPubSub" and "SocketIO". - :paramtype kind: str or ~azure.mgmt.webpubsub.models.ServiceKind - :keyword identity: A class represent managed identities used for request and response. - :paramtype identity: ~azure.mgmt.webpubsub.models.ManagedIdentity - :keyword tls: TLS settings for the resource. - :paramtype tls: ~azure.mgmt.webpubsub.models.WebPubSubTlsSettings - :keyword live_trace_configuration: Live trace configuration of a Microsoft.SignalRService - resource. - :paramtype live_trace_configuration: ~azure.mgmt.webpubsub.models.LiveTraceConfiguration - :keyword resource_log_configuration: Resource log configuration of a Microsoft.SignalRService - resource. - :paramtype resource_log_configuration: ~azure.mgmt.webpubsub.models.ResourceLogConfiguration - :keyword network_ac_ls: Network ACLs for the resource. - :paramtype network_ac_ls: ~azure.mgmt.webpubsub.models.WebPubSubNetworkACLs - :keyword public_network_access: Enable or disable public network access. Default to "Enabled". - When it's Enabled, network ACLs still apply. - When it's Disabled, public network access is always disabled no matter what you set in network - ACLs. - :paramtype public_network_access: str - :keyword disable_local_auth: DisableLocalAuth - Enable or disable local auth with AccessKey - When set as true, connection with AccessKey=xxx won't work. - :paramtype disable_local_auth: bool - :keyword disable_aad_auth: DisableLocalAuth - Enable or disable aad auth - When set as true, connection with AuthType=aad won't work. - :paramtype disable_aad_auth: bool - :keyword region_endpoint_enabled: Enable or disable the regional endpoint. Default to - "Enabled". - When it's Disabled, new connections will not be routed to this endpoint, however existing - connections will not be affected. - This property is replica specific. Disable the regional endpoint without replica is not - allowed. - :paramtype region_endpoint_enabled: str - :keyword resource_stopped: Stop or start the resource. Default to "False". - When it's true, the data plane of the resource is shutdown. - When it's false, the data plane of the resource is started. - :paramtype resource_stopped: str - :keyword socket_io: SocketIO settings for the resource. - :paramtype socket_io: ~azure.mgmt.webpubsub.models.WebPubSubSocketIOSettings - """ - super().__init__(tags=tags, location=location, **kwargs) - self.sku = sku - self.kind = kind - self.identity = identity - self.provisioning_state = None - self.external_ip = None - self.host_name = None - self.public_port = None - self.server_port = None - self.version = None - self.private_endpoint_connections = None - self.shared_private_link_resources = None - self.tls = tls - self.host_name_prefix = None - self.live_trace_configuration = live_trace_configuration - self.resource_log_configuration = resource_log_configuration - self.network_ac_ls = network_ac_ls - self.public_network_access = public_network_access - self.disable_local_auth = disable_local_auth - self.disable_aad_auth = disable_aad_auth - self.region_endpoint_enabled = region_endpoint_enabled - self.resource_stopped = resource_stopped - self.socket_io = socket_io - - -class WebPubSubResourceList(_serialization.Model): - """Object that includes an array of resources and a possible link for next set. - - :ivar value: List of the resources. - :vartype value: list[~azure.mgmt.webpubsub.models.WebPubSubResource] - :ivar next_link: The URL the client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[WebPubSubResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.WebPubSubResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: List of the resources. - :paramtype value: list[~azure.mgmt.webpubsub.models.WebPubSubResource] - :keyword next_link: The URL the client should use to fetch the next page (per server side - paging). - It's null for now, added for future use. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class WebPubSubSocketIOSettings(_serialization.Model): - """SocketIO settings for the resource. - - :ivar service_mode: The service mode of Web PubSub for Socket.IO. Values allowed: - "Default": have your own backend Socket.IO server - "Serverless": your application doesn't have a backend server. - :vartype service_mode: str - """ - - _attribute_map = { - "service_mode": {"key": "serviceMode", "type": "str"}, - } - - def __init__(self, *, service_mode: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword service_mode: The service mode of Web PubSub for Socket.IO. Values allowed: - "Default": have your own backend Socket.IO server - "Serverless": your application doesn't have a backend server. - :paramtype service_mode: str - """ - super().__init__(**kwargs) - self.service_mode = service_mode - - -class WebPubSubTlsSettings(_serialization.Model): - """TLS settings for the resource. - - :ivar client_cert_enabled: Request client certificate during TLS handshake if enabled. Not - supported for free tier. Any input will be ignored for free tier. - :vartype client_cert_enabled: bool - """ - - _attribute_map = { - "client_cert_enabled": {"key": "clientCertEnabled", "type": "bool"}, - } - - def __init__(self, *, client_cert_enabled: bool = False, **kwargs: Any) -> None: - """ - :keyword client_cert_enabled: Request client certificate during TLS handshake if enabled. Not - supported for free tier. Any input will be ignored for free tier. - :paramtype client_cert_enabled: bool - """ - super().__init__(**kwargs) - self.client_cert_enabled = client_cert_enabled diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_patch.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_patch.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/models/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/__init__.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/__init__.py index 2e252143d38e..cb028a0825fa 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/__init__.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/__init__.py @@ -2,40 +2,46 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._web_pub_sub_operations import WebPubSubOperations -from ._usages_operations import UsagesOperations -from ._web_pub_sub_custom_certificates_operations import WebPubSubCustomCertificatesOperations -from ._web_pub_sub_custom_domains_operations import WebPubSubCustomDomainsOperations -from ._web_pub_sub_hubs_operations import WebPubSubHubsOperations -from ._web_pub_sub_private_endpoint_connections_operations import WebPubSubPrivateEndpointConnectionsOperations -from ._web_pub_sub_private_link_resources_operations import WebPubSubPrivateLinkResourcesOperations -from ._web_pub_sub_replicas_operations import WebPubSubReplicasOperations -from ._web_pub_sub_replica_shared_private_link_resources_operations import ( - WebPubSubReplicaSharedPrivateLinkResourcesOperations, -) -from ._web_pub_sub_shared_private_link_resources_operations import WebPubSubSharedPrivateLinkResourcesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._operations import WebPubSubHubsOperations # type: ignore +from ._operations import WebPubSubSharedPrivateLinkResourcesOperations # type: ignore +from ._operations import WebPubSubOperations # type: ignore +from ._operations import WebPubSubPrivateLinkResourcesOperations # type: ignore +from ._operations import WebPubSubCustomCertificatesOperations # type: ignore +from ._operations import WebPubSubCustomDomainsOperations # type: ignore +from ._operations import WebPubSubPrivateEndpointConnectionsOperations # type: ignore +from ._operations import WebPubSubReplicasOperations # type: ignore +from ._operations import WebPubSubReplicaSharedPrivateLinkResourcesOperations # type: ignore +from ._operations import WebPubSubPersistentStoragesOperations # type: ignore +from ._operations import UsagesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", + "WebPubSubHubsOperations", + "WebPubSubSharedPrivateLinkResourcesOperations", "WebPubSubOperations", - "UsagesOperations", + "WebPubSubPrivateLinkResourcesOperations", "WebPubSubCustomCertificatesOperations", "WebPubSubCustomDomainsOperations", - "WebPubSubHubsOperations", "WebPubSubPrivateEndpointConnectionsOperations", - "WebPubSubPrivateLinkResourcesOperations", "WebPubSubReplicasOperations", "WebPubSubReplicaSharedPrivateLinkResourcesOperations", - "WebPubSubSharedPrivateLinkResourcesOperations", + "WebPubSubPersistentStoragesOperations", + "UsagesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_operations.py index 5950f036ad29..c6cbc20da2fa 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_operations.py @@ -1,53 +1,1428 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from collections.abc import MutableMapping +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models as _models -from .._serialization import Serializer +from .. import models as _models, types as _types +from .._configuration import WebPubSubManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.SignalRService/operations") + _url = "/providers/Microsoft.SignalRService/operations" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_hubs_get_request( + hub_name: str, resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs/{hubName}" + path_format_arguments = { + "hubName": _SERIALIZER.url("hub_name", hub_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_hubs_create_or_update_request( # pylint: disable=name-too-long + hub_name: str, resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs/{hubName}" + path_format_arguments = { + "hubName": _SERIALIZER.url("hub_name", hub_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_hubs_delete_request( + hub_name: str, resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs/{hubName}" + path_format_arguments = { + "hubName": _SERIALIZER.url("hub_name", hub_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_hubs_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_shared_private_link_resources_get_request( # pylint: disable=name-too-long + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" + path_format_arguments = { + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", shared_private_link_resource_name, "str" + ), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_shared_private_link_resources_create_or_update_request( # pylint: disable=name-too-long + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" + path_format_arguments = { + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", shared_private_link_resource_name, "str" + ), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_shared_private_link_resources_delete_request( # pylint: disable=name-too-long + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" + path_format_arguments = { + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", shared_private_link_resource_name, "str" + ), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_shared_private_link_resources_list_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_get_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/webPubSub" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_list_keys_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/listKeys" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_regenerate_key_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/regenerateKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_restart_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/restart" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_list_skus_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/skus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_list_replica_skus_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/skus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_check_name_availability_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_private_link_resources_list_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_custom_certificates_get_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customCertificates/{certificateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_custom_certificates_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customCertificates/{certificateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_custom_certificates_delete_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customCertificates/{certificateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_custom_certificates_list_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customCertificates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_custom_domains_get_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customDomains/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_custom_domains_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customDomains/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_custom_domains_delete_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customDomains/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_custom_domains_list_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customDomains" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_private_endpoint_connections_get_request( # pylint: disable=name-too-long + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_private_endpoint_connections_update_request( # pylint: disable=name-too-long + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_private_endpoint_connections_delete_request( # pylint: disable=name-too-long + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_private_endpoint_connections_list_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_replicas_get_request( + resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_replicas_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_replicas_update_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_replicas_delete_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_replicas_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_replicas_restart_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/restart" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_replica_shared_private_link_resources_get_request( # pylint: disable=name-too-long + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", shared_private_link_resource_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_replica_shared_private_link_resources_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", shared_private_link_resource_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_replica_shared_private_link_resources_list_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_persistent_storages_get_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/persistentStorages/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_persistent_storages_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/persistentStorages/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_persistent_storages_delete_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/persistentStorages/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_web_pub_sub_persistent_storages_list_request( # pylint: disable=name-too-long + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/persistentStorages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_usages_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,33 +1440,6503 @@ class Operations: Instead, you should access the following operations through :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`operations` attribute. + :attr:`operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WebPubSubHubsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_hubs` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubHub: + """Get a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: WebPubSubHub. The WebPubSubHub is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.WebPubSubHub + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WebPubSubHub] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_hubs_get_request( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WebPubSubHub, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubHub, _types.WebPubSubHub, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_hubs_create_or_update_request( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.WebPubSubHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubHub]: + """Create or update a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of WebPubSubHub and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubHub + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubHub. The WebPubSubHub is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: _types.WebPubSubHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubHub]: + """Create or update a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of WebPubSubHub and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.types.WebPubSubHub + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubHub. The WebPubSubHub is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubHub]: + """Create or update a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of WebPubSubHub and its properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubHub. The WebPubSubHub is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + hub_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubHub, _types.WebPubSubHub, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.WebPubSubHub]: + """Create or update a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of WebPubSubHub and its properties. Is either a WebPubSubHub + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubHub or + ~azure.mgmt.webpubsub.types.WebPubSubHub or IO[bytes] + :return: An instance of LROPoller that returns WebPubSubHub. The WebPubSubHub is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebPubSubHub] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WebPubSubHub, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.WebPubSubHub].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.WebPubSubHub]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_hubs_delete_request( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a hub setting. + + :param hub_name: The hub name. Required. + :type hub_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + hub_name=hub_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> ItemPaged["_models.WebPubSubHub"]: + """List hub settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of WebPubSubHub + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.WebPubSubHub] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WebPubSubHub]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_hubs_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WebPubSubHub], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WebPubSubSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_shared_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.SharedPrivateLinkResource: + """Get the specified shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: SharedPrivateLinkResource. The SharedPrivateLinkResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_shared_private_link_resources_get_request( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SharedPrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, _types.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_shared_private_link_resources_create_or_update_request( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: _types.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.webpubsub.types.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, _types.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource or + ~azure.mgmt.webpubsub.types.SharedPrivateLinkResource or IO[bytes] + :return: An instance of LROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SharedPrivateLinkResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SharedPrivateLinkResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SharedPrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_shared_private_link_resources_delete_request( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the specified shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + shared_private_link_resource_name=shared_private_link_resource_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.SharedPrivateLinkResource"]: + """List shared private link resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of SharedPrivateLinkResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SharedPrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_shared_private_link_resources_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SharedPrivateLinkResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WebPubSubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubResource: + """Get the resource and its properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: WebPubSubResource. The WebPubSubResource is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.WebPubSubResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WebPubSubResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubResource, _types.WebPubSubResource, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _types.WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.WebPubSubResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubResource, _types.WebPubSubResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.WebPubSubResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Is either a WebPubSubResource + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource or + ~azure.mgmt.webpubsub.types.WebPubSubResource or IO[bytes] + :return: An instance of LROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WebPubSubResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.WebPubSubResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.WebPubSubResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubResource, _types.WebPubSubResource, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _types.WebPubSubResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.WebPubSubResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.WebPubSubResource, _types.WebPubSubResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.WebPubSubResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Is either a WebPubSubResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource or + ~azure.mgmt.webpubsub.types.WebPubSubResource or IO[bytes] + :return: An instance of LROPoller that returns WebPubSubResource. The WebPubSubResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WebPubSubResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.WebPubSubResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.WebPubSubResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: + """Operation to delete a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.WebPubSubResource"]: + """Handles requests to list all resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of WebPubSubResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WebPubSubResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WebPubSubResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.WebPubSubResource"]: + """Handles requests to list all resources in a subscription. + + :return: An iterator like instance of WebPubSubResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.WebPubSubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WebPubSubResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WebPubSubResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubKeys: + """Get the access keys of the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: WebPubSubKeys. The WebPubSubKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.WebPubSubKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WebPubSubKeys] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_list_keys_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WebPubSubKeys, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _regenerate_key_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.RegenerateKeyParameters, _types.RegenerateKeyParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_regenerate_key_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.RegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubKeys. The WebPubSubKeys is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: _types.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.RegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubKeys. The WebPubSubKeys is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WebPubSubKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WebPubSubKeys. The WebPubSubKeys is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.RegenerateKeyParameters, _types.RegenerateKeyParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.WebPubSubKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Is either a + RegenerateKeyParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.RegenerateKeyParameters or + ~azure.mgmt.webpubsub.types.RegenerateKeyParameters or IO[bytes] + :return: An instance of LROPoller that returns WebPubSubKeys. The WebPubSubKeys is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebPubSubKeys] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._regenerate_key_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WebPubSubKeys, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.WebPubSubKeys].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.WebPubSubKeys]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _restart_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_restart_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: + """Operation to restart a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._restart_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SkuList: + """List all available skus of the resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: SkuList. The SkuList is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.SkuList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_list_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SkuList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_replica_skus( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> _models.SkuList: + """List all available skus of the replica resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: SkuList. The SkuList is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.SkuList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_list_replica_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SkuList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def check_name_availability( + self, + location: str, + parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.webpubsub.models.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + location: str, + parameters: _types.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.webpubsub.types.NameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + location: str, + parameters: Union[_models.NameAvailabilityParameters, _types.NameAvailabilityParameters, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Is either a NameAvailabilityParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.NameAvailabilityParameters or + ~azure.mgmt.webpubsub.types.NameAvailabilityParameters or IO[bytes] + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_check_name_availability_request( + location=location, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NameAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class WebPubSubPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateLinkResource"]: + """Get the private link resources that need to be created for a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of PrivateLinkResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_private_link_resources_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateLinkResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WebPubSubCustomCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_custom_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CustomCertificate: + """Get a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :return: CustomCertificate. The CustomCertificate is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.CustomCertificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_custom_certificates_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CustomCertificate, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: Union[_models.CustomCertificate, _types.CustomCertificate, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_custom_certificates_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: _models.CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.webpubsub.models.CustomCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomCertificate. The CustomCertificate is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: _types.CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.webpubsub.types.CustomCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomCertificate. The CustomCertificate is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomCertificate. The CustomCertificate is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: Union[_models.CustomCertificate, _types.CustomCertificate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Is either a CustomCertificate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.CustomCertificate or + ~azure.mgmt.webpubsub.types.CustomCertificate or IO[bytes] + :return: An instance of LROPoller that returns CustomCertificate. The CustomCertificate is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomCertificate, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CustomCertificate].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CustomCertificate]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> None: + """Delete a custom certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_custom_certificates_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.CustomCertificate"]: + """List all custom certificates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of CustomCertificate + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CustomCertificate]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_custom_certificates_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CustomCertificate], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WebPubSubCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_custom_domains` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.CustomDomain: + """Get a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :return: CustomDomain. The CustomDomain is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.CustomDomain + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_custom_domains_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CustomDomain, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: Union[_models.CustomDomain, _types.CustomDomain, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_custom_domains_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _models.CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.webpubsub.models.CustomDomain + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _types.CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.webpubsub.types.CustomDomain + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: Union[_models.CustomDomain, _types.CustomDomain, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Is either a CustomDomain type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.CustomDomain or + ~azure.mgmt.webpubsub.types.CustomDomain or IO[bytes] + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_custom_domains_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a custom domain. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> ItemPaged["_models.CustomDomain"]: + """List all custom domains. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of CustomDomain + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CustomDomain]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_custom_domains_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CustomDomain], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WebPubSubPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get the specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_private_endpoint_connections_get_request( + private_endpoint_connection_name=private_endpoint_connection_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: _types.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.types.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.PrivateEndpointConnection, _types.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection or + ~azure.mgmt.webpubsub.types.PrivateEndpointConnection or IO[bytes] + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_private_endpoint_connections_update_request( + private_endpoint_connection_name=private_endpoint_connection_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_private_endpoint_connections_delete_request( + private_endpoint_connection_name=private_endpoint_connection_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + private_endpoint_connection_name=private_endpoint_connection_name, + resource_group_name=resource_group_name, + resource_name=resource_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateEndpointConnection"]: + """List private endpoint connections. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_private_endpoint_connections_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WebPubSubReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_replicas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any) -> _models.Replica: + """Get the replica and its properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: Replica. The Replica is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.Replica + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_replicas_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Replica, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Union[_models.Replica, _types.Replica, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_replicas_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: _models.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Create or update a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: _types.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Create or update a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Create or update a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Union[_models.Replica, _types.Replica, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Create or update a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the create or update operation. Is either a Replica type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.Replica or ~azure.mgmt.webpubsub.types.Replica + or IO[bytes] + :return: An instance of LROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Replica, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Replica].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Union[_models.Replica, _types.Replica, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_replicas_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: _models.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Operation to update an exiting replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.models.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: _types.Replica, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Operation to update an exiting replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.webpubsub.types.Replica + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Operation to update an exiting replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + parameters: Union[_models.Replica, _types.Replica, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Replica]: + """Operation to update an exiting replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param parameters: Parameters for the update operation. Is either a Replica type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.Replica or ~azure.mgmt.webpubsub.types.Replica + or IO[bytes] + :return: An instance of LROPoller that returns Replica. The Replica is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Replica, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Replica].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> None: + """Operation to delete a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_replicas_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> ItemPaged["_models.Replica"]: + """List all replicas belong to this resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of Replica + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Replica]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_replicas_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Replica], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _restart_initial( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_replicas_restart_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_restart( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Operation to restart a replica. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._restart_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class WebPubSubReplicaSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_replica_shared_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + **kwargs: Any + ) -> _models.SharedPrivateLinkResource: + """Get the specified shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :return: SharedPrivateLinkResource. The SharedPrivateLinkResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_replica_shared_private_link_resources_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SharedPrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, _types.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_replica_shared_private_link_resources_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: _models.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: _types.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.webpubsub.types.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, _types.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource or + ~azure.mgmt.webpubsub.types.SharedPrivateLinkResource or IO[bytes] + :return: An instance of LROPoller that returns SharedPrivateLinkResource. The + SharedPrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SharedPrivateLinkResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SharedPrivateLinkResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SharedPrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any + ) -> ItemPaged["_models.SharedPrivateLinkResource"]: + """List shared private link resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: An iterator like instance of SharedPrivateLinkResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SharedPrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_replica_shared_private_link_resources_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SharedPrivateLinkResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WebPubSubPersistentStoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`web_pub_sub_persistent_storages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.PersistentStorage: + """Get a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :return: PersistentStorage. The PersistentStorage is compatible with MutableMapping + :rtype: ~azure.mgmt.webpubsub.models.PersistentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PersistentStorage] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_persistent_storages_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PersistentStorage, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: Union[_models.PersistentStorage, _types.PersistentStorage, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_persistent_storages_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _models.PersistentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PersistentStorage]: + """Create or update a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :param parameters: The resource of persistent storage and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.models.PersistentStorage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PersistentStorage. The PersistentStorage is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _types.PersistentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PersistentStorage]: + """Create or update a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :param parameters: The resource of persistent storage and its properties. Required. + :type parameters: ~azure.mgmt.webpubsub.types.PersistentStorage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PersistentStorage. The PersistentStorage is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PersistentStorage]: + """Create or update a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :param parameters: The resource of persistent storage and its properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PersistentStorage. The PersistentStorage is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: Union[_models.PersistentStorage, _types.PersistentStorage, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PersistentStorage]: + """Create or update a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :param parameters: The resource of persistent storage and its properties. Is either a + PersistentStorage type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.webpubsub.models.PersistentStorage or + ~azure.mgmt.webpubsub.types.PersistentStorage or IO[bytes] + :return: An instance of LROPoller that returns PersistentStorage. The PersistentStorage is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PersistentStorage] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PersistentStorage, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PersistentStorage].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PersistentStorage]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_persistent_storages_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a persistent storage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Persistent storage name. Required. + :type name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + name=name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.PersistentStorage"]: + """List all persistent storages. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :return: An iterator like instance of PersistentStorage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.PersistentStorage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PersistentStorage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_persistent_storages_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PersistentStorage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class UsagesOperations: """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s + :attr:`usages` attribute. + """ - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: WebPubSubManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available REST API operations of the Microsoft.SignalRService provider. + def list(self, location: str, **kwargs: Any) -> ItemPaged["_models.SignalRServiceUsage"]: + """List resource usage quotas by location. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.Operation] + :param location: The location name. Required. + :type location: str + :return: An iterator like instance of SignalRServiceUsage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.SignalRServiceUsage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) + cls: ClsType[List[_models.SignalRServiceUsage]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,12 +7947,19 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_usages_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -120,18 +7972,29 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OperationList", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SignalRServiceUsage], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -144,7 +8007,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_patch.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_patch.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_usages_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_usages_operations.py deleted file mode 100644 index 0a33cd4bfcda..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_usages_operations.py +++ /dev/null @@ -1,164 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages" - ) # pylint: disable=line-too-long - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class UsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, location: str, **kwargs: Any) -> Iterable["_models.SignalRServiceUsage"]: - """List resource usage quotas by location. - - :param location: the location like "eastus". Required. - :type location: str - :return: An iterator like instance of either SignalRServiceUsage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.SignalRServiceUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SignalRServiceUsageList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SignalRServiceUsageList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_custom_certificates_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_custom_certificates_operations.py deleted file mode 100644 index 096a18b7d570..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_custom_certificates_operations.py +++ /dev/null @@ -1,638 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customCertificates", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customCertificates/{certificateName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customCertificates/{certificateName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customCertificates/{certificateName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubCustomCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub_custom_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.CustomCertificate"]: - """List all custom certificates. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either CustomCertificate or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.CustomCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomCertificateList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomCertificateList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any - ) -> _models.CustomCertificate: - """Get a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :return: CustomCertificate or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.CustomCertificate - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomCertificate", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - parameters: Union[_models.CustomCertificate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomCertificate") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - parameters: _models.CustomCertificate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomCertificate]: - """Create or update a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.webpubsub.models.CustomCertificate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CustomCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomCertificate]: - """Create or update a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CustomCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - parameters: Union[_models.CustomCertificate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CustomCertificate]: - """Create or update a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :param parameters: Is either a CustomCertificate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.CustomCertificate or IO[bytes] - :return: An instance of LROPoller that returns either CustomCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - certificate_name=certificate_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomCertificate", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CustomCertificate].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CustomCertificate]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any - ) -> None: - """Delete a custom certificate. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param certificate_name: Custom certificate name. Required. - :type certificate_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_custom_domains_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_custom_domains_operations.py deleted file mode 100644 index adc302c52111..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_custom_domains_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customDomains", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customDomains/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customDomains/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/customDomains/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubCustomDomainsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub_custom_domains` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.CustomDomain"]: - """List all custom domains. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either CustomDomain or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomDomainList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomDomainList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.CustomDomain: - """Get a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :return: CustomDomain or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.CustomDomain - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - name: str, - parameters: Union[_models.CustomDomain, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CustomDomain") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - name: str, - parameters: _models.CustomDomain, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Create or update a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.webpubsub.models.CustomDomain - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Create or update a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - name: str, - parameters: Union[_models.CustomDomain, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Create or update a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :param parameters: Is either a CustomDomain type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.CustomDomain or IO[bytes] - :return: An instance of LROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> LROPoller[None]: - """Delete a custom domain. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param name: Custom domain name. Required. - :type name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - name=name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_hubs_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_hubs_operations.py deleted file mode 100644 index 42bbaf849886..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_hubs_operations.py +++ /dev/null @@ -1,690 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - hub_name: str, resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs/{hubName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "hubName": _SERIALIZER.url("hub_name", hub_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - hub_name: str, resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs/{hubName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "hubName": _SERIALIZER.url("hub_name", hub_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - hub_name: str, resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs/{hubName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "hubName": _SERIALIZER.url("hub_name", hub_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubHubsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub_hubs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.WebPubSubHub"]: - """List hub settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either WebPubSubHub or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.WebPubSubHub] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubHubList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("WebPubSubHubList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubHub: - """Get a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: WebPubSubHub or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.WebPubSubHub - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubHub] = kwargs.pop("cls", None) - - _request = build_get_request( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WebPubSubHub", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - hub_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubHub, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "WebPubSubHub") - - _request = build_create_or_update_request( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - hub_name: str, - resource_group_name: str, - resource_name: str, - parameters: _models.WebPubSubHub, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WebPubSubHub]: - """Create or update a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of WebPubSubHub and its properties. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubHub - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WebPubSubHub or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - hub_name: str, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WebPubSubHub]: - """Create or update a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of WebPubSubHub and its properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WebPubSubHub or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - hub_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubHub, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.WebPubSubHub]: - """Create or update a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of WebPubSubHub and its properties. Is either a WebPubSubHub - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubHub or IO[bytes] - :return: An instance of LROPoller that returns either WebPubSubHub or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubHub] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebPubSubHub] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WebPubSubHub", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.WebPubSubHub].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.WebPubSubHub]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, hub_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete a hub setting. - - :param hub_name: The hub name. Required. - :type hub_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - hub_name=hub_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_operations.py deleted file mode 100644 index e074cf742a88..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_operations.py +++ /dev/null @@ -1,1825 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/webPubSub") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_keys_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/listKeys", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_regenerate_key_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/regenerateKey", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_replica_skus_request( - resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/skus", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_restart_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/restart", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_skus_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/skus", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def check_name_availability( - self, - location: str, - parameters: _models.NameAvailabilityParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Checks that the resource name is valid and is not already in use. - - :param location: the region. Required. - :type location: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.NameAvailabilityParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailability: - """Checks that the resource name is valid and is not already in use. - - :param location: the region. Required. - :type location: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, location: str, parameters: Union[_models.NameAvailabilityParameters, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailability: - """Checks that the resource name is valid and is not already in use. - - :param location: the region. Required. - :type location: str - :param parameters: Parameters supplied to the operation. Is either a NameAvailabilityParameters - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.NameAvailabilityParameters or IO[bytes] - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "NameAvailabilityParameters") - - _request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NameAvailability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.WebPubSubResource"]: - """Handles requests to list all resources in a subscription. - - :return: An iterator like instance of either WebPubSubResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("WebPubSubResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.WebPubSubResource"]: - """Handles requests to list all resources in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either WebPubSubResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("WebPubSubResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubResource: - """Get the resource and its properties. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: WebPubSubResource or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.WebPubSubResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WebPubSubResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubResource, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "WebPubSubResource") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.WebPubSubResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WebPubSubResource]: - """Create or update a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the create or update operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WebPubSubResource]: - """Create or update a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the create or update operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubResource, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.WebPubSubResource]: - """Create or update a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the create or update operation. Is either a WebPubSubResource - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource or IO[bytes] - :return: An instance of LROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WebPubSubResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.WebPubSubResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.WebPubSubResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: - """Operation to delete a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubResource, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "WebPubSubResource") - - _request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.WebPubSubResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WebPubSubResource]: - """Operation to update an exiting resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the update operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WebPubSubResource]: - """Operation to update an exiting resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the update operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.WebPubSubResource, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.WebPubSubResource]: - """Operation to update an exiting resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameters for the update operation. Is either a WebPubSubResource type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.WebPubSubResource or IO[bytes] - :return: An instance of LROPoller that returns either WebPubSubResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebPubSubResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WebPubSubResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.WebPubSubResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.WebPubSubResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WebPubSubKeys: - """Get the access keys of the resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: WebPubSubKeys or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.WebPubSubKeys - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WebPubSubKeys] = kwargs.pop("cls", None) - - _request = build_list_keys_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WebPubSubKeys", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _regenerate_key_initial( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RegenerateKeyParameters") - - _request = build_regenerate_key_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_regenerate_key( - self, - resource_group_name: str, - resource_name: str, - parameters: _models.RegenerateKeyParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WebPubSubKeys]: - """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated - at the same time. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameter that describes the Regenerate Key Operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.RegenerateKeyParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WebPubSubKeys or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_regenerate_key( - self, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WebPubSubKeys]: - """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated - at the same time. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameter that describes the Regenerate Key Operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WebPubSubKeys or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_regenerate_key( - self, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.WebPubSubKeys]: - """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated - at the same time. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: Parameter that describes the Regenerate Key Operation. Is either a - RegenerateKeyParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.RegenerateKeyParameters or IO[bytes] - :return: An instance of LROPoller that returns either WebPubSubKeys or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.WebPubSubKeys] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebPubSubKeys] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._regenerate_key_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WebPubSubKeys", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.WebPubSubKeys].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.WebPubSubKeys]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_replica_skus( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> _models.SkuList: - """List all available skus of the replica resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: SkuList or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.SkuList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) - - _request = build_list_replica_skus_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SkuList", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _restart_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restart_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: - """Operation to restart a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SkuList: - """List all available skus of the resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: SkuList or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.SkuList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) - - _request = build_list_skus_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SkuList", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_private_endpoint_connections_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_private_endpoint_connections_operations.py deleted file mode 100644 index 1b5579f54a10..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_private_endpoint_connections_operations.py +++ /dev/null @@ -1,652 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub_private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - """List private endpoint connections. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Get the specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - private_endpoint_connection_name=private_endpoint_connection_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Update the state of specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of private endpoint and its properties. Required. - :type parameters: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Update the state of specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of private endpoint and its properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Update the state of specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The resource of private endpoint and its properties. Is either a - PrivateEndpointConnection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection or IO[bytes] - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PrivateEndpointConnection") - - _request = build_update_request( - private_endpoint_connection_name=private_endpoint_connection_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( - self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - private_endpoint_connection_name=private_endpoint_connection_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete the specified private endpoint connection. - - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - private_endpoint_connection_name=private_endpoint_connection_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_private_link_resources_operations.py deleted file mode 100644 index f7e90f63264b..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_private_link_resources_operations.py +++ /dev/null @@ -1,183 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubPrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateLinkResource"]: - """Get the private link resources that need to be created for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateLinkResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateLinkResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_replica_shared_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_replica_shared_private_link_resources_operations.py deleted file mode 100644 index 15f020c81188..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_replica_shared_private_link_resources_operations.py +++ /dev/null @@ -1,617 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "sharedPrivateLinkResourceName": _SERIALIZER.url( - "shared_private_link_resource_name", - shared_private_link_resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "sharedPrivateLinkResourceName": _SERIALIZER.url( - "shared_private_link_resource_name", - shared_private_link_resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubReplicaSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub_replica_shared_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> Iterable["_models.SharedPrivateLinkResource"]: - """List shared private link resources. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: An iterator like instance of either SharedPrivateLinkResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SharedPrivateLinkResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - **kwargs: Any - ) -> _models.SharedPrivateLinkResource: - """Get the specified shared private link resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :return: SharedPrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SharedPrivateLinkResource") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - parameters: _models.SharedPrivateLinkResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param parameters: The shared private link resource. Required. - :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param parameters: The shared private link resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - shared_private_link_resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource or IO[bytes] - :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - shared_private_link_resource_name=shared_private_link_resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.SharedPrivateLinkResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SharedPrivateLinkResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_replicas_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_replicas_operations.py deleted file mode 100644 index 81ba83e427d6..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_replicas_operations.py +++ /dev/null @@ -1,1076 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_restart_request( - resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/replicas/{replicaName}/restart", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "replicaName": _SERIALIZER.url( - "replica_name", - replica_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubReplicasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub_replicas` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.Replica"]: - """List all replicas belong to this resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either Replica or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ReplicaList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ReplicaList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any) -> _models.Replica: - """Get the replica and its properties. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: Replica or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.Replica - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Replica", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: Union[_models.Replica, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Replica") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: _models.Replica, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Replica]: - """Create or update a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the create or update operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.Replica - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replica or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Replica]: - """Create or update a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the create or update operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replica or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: Union[_models.Replica, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Replica]: - """Create or update a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the create or update operation. Is either a Replica type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.Replica or IO[bytes] - :return: An instance of LROPoller that returns either Replica or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Replica].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replica]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> None: - """Operation to delete a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: Union[_models.Replica, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Replica") - - _request = build_update_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: _models.Replica, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Replica]: - """Operation to update an exiting replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the update operation. Required. - :type parameters: ~azure.mgmt.webpubsub.models.Replica - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replica or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Replica]: - """Operation to update an exiting replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the update operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replica or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - resource_name: str, - replica_name: str, - parameters: Union[_models.Replica, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Replica]: - """Operation to update an exiting replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :param parameters: Parameters for the update operation. Is either a Replica type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.Replica or IO[bytes] - :return: An instance of LROPoller that returns either Replica or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.Replica] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Replica].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replica]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _restart_initial( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restart_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Operation to restart a replica. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param replica_name: The name of the replica. Required. - :type replica_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - resource_name=resource_name, - replica_name=replica_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_shared_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_shared_private_link_resources_operations.py deleted file mode 100644 index c8d2fe3ad4e7..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/operations/_web_pub_sub_shared_private_link_resources_operations.py +++ /dev/null @@ -1,733 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "sharedPrivateLinkResourceName": _SERIALIZER.url( - "shared_private_link_resource_name", - shared_private_link_resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "sharedPrivateLinkResourceName": _SERIALIZER.url( - "shared_private_link_resource_name", - shared_private_link_resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "sharedPrivateLinkResourceName": _SERIALIZER.url( - "shared_private_link_resource_name", - shared_private_link_resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceName": _SERIALIZER.url( - "resource_name", - resource_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class WebPubSubSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.webpubsub.WebPubSubManagementClient`'s - :attr:`web_pub_sub_shared_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.SharedPrivateLinkResource"]: - """List shared private link resources. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An iterator like instance of either SharedPrivateLinkResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SharedPrivateLinkResourceList] = kwargs.pop("cls", None) - - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResourceList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> _models.SharedPrivateLinkResource: - """Get the specified shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: SharedPrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_request( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SharedPrivateLinkResource") - - _request = build_create_or_update_request( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - parameters: _models.SharedPrivateLinkResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The shared private link resource. Required. - :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The shared private link resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.SharedPrivateLinkResource]: - """Create or update a shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.webpubsub.models.SharedPrivateLinkResource or IO[bytes] - :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.webpubsub.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.SharedPrivateLinkResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SharedPrivateLinkResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete the specified shared private link resource. - - :param shared_private_link_resource_name: The name of the shared private link resource. - Required. - :type shared_private_link_resource_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - shared_private_link_resource_name=shared_private_link_resource_name, - resource_group_name=resource_group_name, - resource_name=resource_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/types.py b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/types.py new file mode 100644 index 000000000000..bd2b259f02e6 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/azure/mgmt/webpubsub/types.py @@ -0,0 +1,1812 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Literal, TYPE_CHECKING, Union +from typing_extensions import Required, TypedDict + +from .models._enums import ( + ClientConnectionCountRuleDiscriminator, + ClientTrafficControlRuleDiscriminator, + EventListenerEndpointDiscriminator, + EventListenerFilterDiscriminator, +) + +if TYPE_CHECKING: + from .models import ( + ACLAction, + CreatedByType, + GroupPresenceEventName, + KeyType, + ManagedIdentityType, + PrivateLinkServiceConnectionStatus, + ProvisioningState, + ScaleType, + ServiceKind, + SharedPrivateLinkResourceStatus, + UpstreamAuthType, + WebPubSubRequestType, + WebPubSubSkuTier, + ) + + +class ApplicationFirewallSettings(TypedDict, total=False): + """Application firewall settings for the resource. + + :ivar client_connection_count_rules: Rules to control the client connection count. + :vartype client_connection_count_rules: list["ClientConnectionCountRule"] + :ivar client_traffic_control_rules: Rules to control the client traffic. + :vartype client_traffic_control_rules: list["ClientTrafficControlRule"] + :ivar max_client_connection_lifetime_in_seconds: Config to control the client connection + lifetime in seconds, can be set to 0 to disable the config. + :vartype max_client_connection_lifetime_in_seconds: int + """ + + clientConnectionCountRules: list["ClientConnectionCountRule"] + """Rules to control the client connection count.""" + clientTrafficControlRules: list["ClientTrafficControlRule"] + """Rules to control the client traffic.""" + maxClientConnectionLifetimeInSeconds: int + """Config to control the client connection lifetime in seconds, can be set to 0 to disable the + config.""" + + +class ChatSettings(TypedDict, total=False): + """Chat settings. + + :ivar mode: Enable or disable the chat feature. + :vartype mode: str + :ivar persistent_storage: Reference to the the persistent storage for perisisting chat states. + :vartype persistent_storage: "ResourceReference" + """ + + mode: str + """Enable or disable the chat feature.""" + persistentStorage: "ResourceReference" + """Reference to the the persistent storage for perisisting chat states.""" + + +class Resource(TypedDict, total=False): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + """ + + id: str + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: str + """The name of the resource.""" + type: str + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + systemData: "SystemData" + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + """ + + +class CustomCertificate(ProxyResource): + """A custom certificate. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar properties: Custom certificate properties. Required. + :vartype properties: "CustomCertificateProperties" + """ + + properties: Required["CustomCertificateProperties"] + """Custom certificate properties. Required.""" + + +class CustomCertificateProperties(TypedDict, total=False): + """Custom certificate properties. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar key_vault_base_uri: Base uri of the KeyVault that stores certificate. Required. + :vartype key_vault_base_uri: str + :ivar key_vault_secret_name: Certificate secret name. Required. + :vartype key_vault_secret_name: str + :ivar key_vault_secret_version: Certificate secret version. + :vartype key_vault_secret_version: str + """ + + provisioningState: Union[str, "ProvisioningState"] + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + keyVaultBaseUri: Required[str] + """Base uri of the KeyVault that stores certificate. Required.""" + keyVaultSecretName: Required[str] + """Certificate secret name. Required.""" + keyVaultSecretVersion: str + """Certificate secret version.""" + + +class CustomDomain(ProxyResource): + """A custom domain. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar properties: Properties of a custom domain. Required. + :vartype properties: "CustomDomainProperties" + """ + + properties: Required["CustomDomainProperties"] + """Properties of a custom domain. Required.""" + + +class CustomDomainProperties(TypedDict, total=False): + """Properties of a custom domain. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar domain_name: The custom domain name. Required. + :vartype domain_name: str + :ivar custom_certificate: Reference to a resource. Required. + :vartype custom_certificate: "ResourceReference" + """ + + provisioningState: Union[str, "ProvisioningState"] + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + domainName: Required[str] + """The custom domain name. Required.""" + customCertificate: Required["ResourceReference"] + """Reference to a resource. Required.""" + + +class Dimension(TypedDict, total=False): + """Specifications of the Dimension of metrics. + + :ivar name: The public facing name of the dimension. + :vartype name: str + :ivar display_name: Localized friendly display name of the dimension. + :vartype display_name: str + :ivar internal_name: Name of the dimension as it appears in MDM. + :vartype internal_name: str + :ivar to_be_exported_for_shoebox: A Boolean flag indicating whether this dimension should be + included for the shoebox export scenario. + :vartype to_be_exported_for_shoebox: bool + """ + + name: str + """The public facing name of the dimension.""" + displayName: str + """Localized friendly display name of the dimension.""" + internalName: str + """Name of the dimension as it appears in MDM.""" + toBeExportedForShoebox: bool + """A Boolean flag indicating whether this dimension should be included for the shoebox export + scenario.""" + + +class ErrorAdditionalInfo(TypedDict, total=False): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: Any + """ + + type: str + """The additional info type.""" + info: Any + """The additional info.""" + + +class ErrorDetail(TypedDict, total=False): + """The error detail. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list["ErrorDetail"] + :ivar additional_info: The error additional info. + :vartype additional_info: list["ErrorAdditionalInfo"] + """ + + code: str + """The error code.""" + message: str + """The error message.""" + target: str + """The error target.""" + details: list["ErrorDetail"] + """The error details.""" + additionalInfo: list["ErrorAdditionalInfo"] + """The error additional info.""" + + +class ErrorResponse(TypedDict, total=False): + """Error response. + + :ivar error: The error object. + :vartype error: "ErrorDetail" + """ + + error: "ErrorDetail" + """The error object.""" + + +class EventHandler(TypedDict, total=False): + """Properties of event handler. + + :ivar url_template: Gets or sets the URL template for the event handler. The actual URL is + calculated when the corresponding event is triggered. The template supports predefined + parameters syntax: ``{event}``, ``{hub}``, and KeyVault reference syntax + ``{@Microsoft.KeyVault(SecretUri=_your_secret_identifier_)}`` For example, if the template is + ``http://example.com/api/{event}``, when ``connect`` event is triggered, a POST request will be + sent to the URL ``http://example.com/chat/api/connect``. Note: Parameters are not allowed in + the hostname of the URL, and curly brackets ``{}`` are reserved for parameter syntax only. If + your URL path contains literal curly brackets, please URL-encode them to ensure proper + handling. Required. + :vartype url_template: str + :ivar user_event_pattern: Gets or sets the matching pattern for event names. + There are 3 kinds of patterns supported: + + 1. "*", it matches any event name + 2. Combine multiple events with ",", for example "event1,event2", it matches event "event1" and + "event2" + 3. A single event name, for example, "event1", it matches "event1". + :vartype user_event_pattern: str + :ivar system_events: Gets or sets the list of system events. + :vartype system_events: list[str] + :ivar auth: Upstream auth settings. If not set, no auth is used for upstream messages. + :vartype auth: "UpstreamAuthSettings" + :ivar group_presence_events: The group presence events that this event handler is concerned + with. Group presence events are triggered when connections join or leave groups in the hub. If + the value is null, no presence events will be sent to this event handler. + :vartype group_presence_events: "GroupPresenceEventFilters" + """ + + urlTemplate: Required[str] + """Gets or sets the URL template for the event handler. The actual URL is calculated when the + corresponding event is triggered. The template supports predefined parameters syntax: + ``{event}``, ``{hub}``, and KeyVault reference syntax + ``{@Microsoft.KeyVault(SecretUri=_your_secret_identifier_)}`` For example, if the template is + ``http://example.com/api/{event}``, when ``connect`` event is triggered, a POST request will be + sent to the URL ``http://example.com/chat/api/connect``. Note: Parameters are not allowed in + the hostname of the URL, and curly brackets ``{}`` are reserved for parameter syntax only. If + your URL path contains literal curly brackets, please URL-encode them to ensure proper + handling. Required.""" + userEventPattern: str + """Gets or sets the matching pattern for event names. + There are 3 kinds of patterns supported: + + 1. \"*\", it matches any event name + 2. Combine multiple events with \",\", for example \"event1,event2\", it matches event + \"event1\" and \"event2\" + 3. A single event name, for example, \"event1\", it matches \"event1\".""" + systemEvents: list[str] + """Gets or sets the list of system events.""" + auth: "UpstreamAuthSettings" + """Upstream auth settings. If not set, no auth is used for upstream messages.""" + groupPresenceEvents: "GroupPresenceEventFilters" + """The group presence events that this event handler is concerned with. Group presence events are + triggered when connections join or leave groups in the hub. If the value is null, no presence + events will be sent to this event handler.""" + + +class EventHubEndpoint(TypedDict, total=False): + """An Event Hub endpoint. The managed identity of Web PubSub service must be enabled, and the + identity should have the "Azure Event Hubs Data sender" role to access Event Hub. + + :ivar fully_qualified_namespace: The fully qualified namespace name of the Event Hub resource. + Required. + :vartype fully_qualified_namespace: str + :ivar event_hub_name: The name of the Event Hub. Required. + :vartype event_hub_name: str + :ivar type: Required. EVENT_HUB. + :vartype type: Literal[EventListenerEndpointDiscriminator.EVENT_HUB] + """ + + fullyQualifiedNamespace: Required[str] + """The fully qualified namespace name of the Event Hub resource. Required.""" + eventHubName: Required[str] + """The name of the Event Hub. Required.""" + type: Required[Literal[EventListenerEndpointDiscriminator.EVENT_HUB]] + """Required. EVENT_HUB.""" + + +class EventListener(TypedDict, total=False): + """A setting defines which kinds of events should be sent to which endpoint. + + :ivar filter: A base class for event filter which determines whether an event should be sent to + an event listener. Required. + :vartype filter: "EventListenerFilter" + :ivar endpoint: An endpoint specifying where Web PubSub should send events to. Required. + :vartype endpoint: "EventListenerEndpoint" + """ + + filter: Required["EventListenerFilter"] + """A base class for event filter which determines whether an event should be sent to an event + listener. Required.""" + endpoint: Required["EventListenerEndpoint"] + """An endpoint specifying where Web PubSub should send events to. Required.""" + + +class EventNameFilter(TypedDict, total=False): + """Filter events by their name. + + :ivar system_events: Gets or sets a list of system events. Supported events: "connected" and + "disconnected". Blocking event "connect" is not supported because it requires a response. + :vartype system_events: list[str] + :ivar user_event_pattern: Gets or sets a matching pattern for event names. + There are 3 kinds of patterns supported: + + 1. "*", it matches any event name + 2. Combine multiple events with ",", for example "event1,event2", it matches events "event1" + and "event2" + 3. A single event name, for example, "event1", it matches "event1". + :vartype user_event_pattern: str + :ivar type: Required. EVENT_NAME. + :vartype type: Literal[EventListenerFilterDiscriminator.EVENT_NAME] + """ + + systemEvents: list[str] + """Gets or sets a list of system events. Supported events: \"connected\" and \"disconnected\". + Blocking event \"connect\" is not supported because it requires a response.""" + userEventPattern: str + """Gets or sets a matching pattern for event names. + There are 3 kinds of patterns supported: + + 1. \"*\", it matches any event name + 2. Combine multiple events with \",\", for example \"event1,event2\", it matches events + \"event1\" and \"event2\" + 3. A single event name, for example, \"event1\", it matches \"event1\".""" + type: Required[Literal[EventListenerFilterDiscriminator.EVENT_NAME]] + """Required. EVENT_NAME.""" + + +class GroupPresenceEventFilters(TypedDict, total=False): + """Represents presence event filters for event handler configuration. + + :ivar event_names: The concerning event names. Valid values are "joined", "left". If the value + is null or empty, no presence events will be sent to the event handler. Required. + :vartype event_names: list[Union[str, "GroupPresenceEventName"]] + :ivar group_filters: The group filters. Only events from these groups will be sent to the event + handler. Each element is a pattern that may match multiple groups. If null or empty, events + from all groups will be sent (subject to eventNames). + :vartype group_filters: list[str] + """ + + eventNames: Required[list[Union[str, "GroupPresenceEventName"]]] + """The concerning event names. Valid values are \"joined\", \"left\". If the value is null or + empty, no presence events will be sent to the event handler. Required.""" + groupFilters: list[str] + """The group filters. Only events from these groups will be sent to the event handler. Each + element is a pattern that may match multiple groups. If null or empty, events from all groups + will be sent (subject to eventNames).""" + + +class IPRule(TypedDict, total=False): + """An IP rule. + + :ivar value: An IP or CIDR or ServiceTag. + :vartype value: str + :ivar action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". + :vartype action: Union[str, "ACLAction"] + """ + + value: str + """An IP or CIDR or ServiceTag.""" + action: Union[str, "ACLAction"] + """Azure Networking ACL Action. Known values are: \"Allow\" and \"Deny\".""" + + +class LiveTraceCategory(TypedDict, total=False): + """Live trace category configuration of a Microsoft.SignalRService resource. + + :ivar name: Gets or sets the live trace category's name. Available values: ConnectivityLogs, + MessagingLogs. Case insensitive. + :vartype name: str + :ivar enabled: Indicates whether or the live trace category is enabled. Available values: true, + false. Case insensitive. + :vartype enabled: str + """ + + name: str + """Gets or sets the live trace category's name. Available values: ConnectivityLogs, MessagingLogs. + Case insensitive.""" + enabled: str + """Indicates whether or the live trace category is enabled. Available values: true, false. Case + insensitive.""" + + +class LiveTraceConfiguration(TypedDict, total=False): + """Live trace configuration of a Microsoft.SignalRService resource. + + :ivar enabled: Indicates whether or not enable live trace. When it's set to true, live trace + client can connect to the service. Otherwise, live trace client can't connect to the service, + so that you are unable to receive any log, no matter what you configure in "categories". + Available values: true, false. Case insensitive. + :vartype enabled: str + :ivar categories: Gets or sets the list of category configurations. + :vartype categories: list["LiveTraceCategory"] + """ + + enabled: str + """Indicates whether or not enable live trace. When it's set to true, live trace client can + connect to the service. Otherwise, live trace client can't connect to the service, so that you + are unable to receive any log, no matter what you configure in \"categories\". Available + values: true, false. Case insensitive.""" + categories: list["LiveTraceCategory"] + """Gets or sets the list of category configurations.""" + + +class LogSpecification(TypedDict, total=False): + """Specifications of the Logs for Azure Monitoring. + + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Localized friendly display name of the log. + :vartype display_name: str + """ + + name: str + """Name of the log.""" + displayName: str + """Localized friendly display name of the log.""" + + +class ManagedIdentity(TypedDict, total=False): + """A class represent managed identities used for request and response. + + :ivar type: Represents the identity type: systemAssigned, userAssigned, None. Known values are: + "None", "SystemAssigned", and "UserAssigned". + :vartype type: Union[str, "ManagedIdentityType"] + :ivar user_assigned_identities: Get or set the user assigned identities. + :vartype user_assigned_identities: dict[str, "UserAssignedIdentityProperty"] + :ivar principal_id: Get the principal id for the system assigned identity. Only be used in + response. + :vartype principal_id: str + :ivar tenant_id: Get the tenant id for the system assigned identity. Only be used in response. + :vartype tenant_id: str + """ + + type: Union[str, "ManagedIdentityType"] + """Represents the identity type: systemAssigned, userAssigned, None. Known values are: \"None\", + \"SystemAssigned\", and \"UserAssigned\".""" + userAssignedIdentities: dict[str, "UserAssignedIdentityProperty"] + """Get or set the user assigned identities.""" + principalId: str + """Get the principal id for the system assigned identity. Only be used in response.""" + tenantId: str + """Get the tenant id for the system assigned identity. Only be used in response.""" + + +class ManagedIdentitySettings(TypedDict, total=False): + """Managed identity settings for upstream. + + :ivar resource: The Resource indicating the App ID URI of the target resource. It also appears + in the aud (audience) claim of the issued token. + :vartype resource: str + """ + + resource: str + """The Resource indicating the App ID URI of the target resource. It also appears in the aud + (audience) claim of the issued token.""" + + +class MetricSpecification(TypedDict, total=False): + """Specifications of the Metrics for Azure Monitoring. + + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Localized friendly display name of the metric. + :vartype display_name: str + :ivar display_description: Localized friendly description of the metric. + :vartype display_description: str + :ivar unit: The unit that makes sense for the metric. + :vartype unit: str + :ivar aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, + Maximum, Total, Count. + :vartype aggregation_type: str + :ivar fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. Ex. a metric that returns the number of times a + particular error code was emitted. The error code may not appear often, instead of the RP + publishing 0, Shoebox can auto fill in 0s for time periods where nothing was emitted. + :vartype fill_gap_with_zero: str + :ivar category: The name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :vartype category: str + :ivar dimensions: The dimensions of the metrics. + :vartype dimensions: list["Dimension"] + """ + + name: str + """Name of the metric.""" + displayName: str + """Localized friendly display name of the metric.""" + displayDescription: str + """Localized friendly description of the metric.""" + unit: str + """The unit that makes sense for the metric.""" + aggregationType: str + """Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count.""" + fillGapWithZero: str + """Optional. If set to true, then zero will be returned for time duration where no metric is + emitted/published. Ex. a metric that returns the number of times a particular error code was + emitted. The error code may not appear often, instead of the RP publishing 0, Shoebox can auto + fill in 0s for time periods where nothing was emitted.""" + category: str + """The name of the metric category that the metric belongs to. A metric can only belong to a + single category.""" + dimensions: list["Dimension"] + """The dimensions of the metrics.""" + + +class NameAvailability(TypedDict, total=False): + """Result of the request to check name availability. It contains a flag and possible reason of + failure. + + :ivar name_available: Indicates whether the name is available or not. + :vartype name_available: bool + :ivar reason: The reason of the availability. Required if name is not available. + :vartype reason: str + :ivar message: The message of the operation. + :vartype message: str + """ + + nameAvailable: bool + """Indicates whether the name is available or not.""" + reason: str + """The reason of the availability. Required if name is not available.""" + message: str + """The message of the operation.""" + + +class NameAvailabilityParameters(TypedDict, total=False): + """Data POST-ed to the nameAvailability action. + + :ivar type: The resource type. Can be "Microsoft.SignalRService/SignalR", + "Microsoft.SignalRService/WebPubSub", "Microsoft.SignalRService/SignalR/replicas" or + "Microsoft.SignalRService/WebPubSub/replicas". Required. + :vartype type: str + :ivar name: The resource name to validate. e.g."my-resource-name". Required. + :vartype name: str + """ + + type: Required[str] + """The resource type. Can be \"Microsoft.SignalRService/SignalR\", + \"Microsoft.SignalRService/WebPubSub\", \"Microsoft.SignalRService/SignalR/replicas\" or + \"Microsoft.SignalRService/WebPubSub/replicas\". Required.""" + name: Required[str] + """The resource name to validate. e.g.\"my-resource-name\". Required.""" + + +class NetworkACL(TypedDict, total=False): + """Network ACL. + + :ivar allow: Allowed request types. The value can be one or more of: ClientConnection, + ServerConnection, RESTAPI. + :vartype allow: list[Union[str, "WebPubSubRequestType"]] + :ivar deny: Denied request types. The value can be one or more of: ClientConnection, + ServerConnection, RESTAPI. + :vartype deny: list[Union[str, "WebPubSubRequestType"]] + """ + + allow: list[Union[str, "WebPubSubRequestType"]] + """Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, + RESTAPI.""" + deny: list[Union[str, "WebPubSubRequestType"]] + """Denied request types. The value can be one or more of: ClientConnection, ServerConnection, + RESTAPI.""" + + +class Operation(TypedDict, total=False): + """REST API operation supported by resource provider. + + :ivar name: Name of the operation with format: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: If the operation is a data action. (for data plane rbac). + :vartype is_data_action: bool + :ivar display: The object that describes a operation. + :vartype display: "OperationDisplay" + :ivar origin: Optional. The intended executor of the operation; governs the display of the + operation in the RBAC UX and the audit logs UX. + :vartype origin: str + :ivar properties: Extra Operation properties. + :vartype properties: "OperationProperties" + """ + + name: str + """Name of the operation with format: {provider}/{resource}/{operation}.""" + isDataAction: bool + """If the operation is a data action. (for data plane rbac).""" + display: "OperationDisplay" + """The object that describes a operation.""" + origin: str + """Optional. The intended executor of the operation; governs the display of the operation in the + RBAC UX and the audit logs UX.""" + properties: "OperationProperties" + """Extra Operation properties.""" + + +class OperationDisplay(TypedDict, total=False): + """The object that describes a operation. + + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + :ivar resource: Resource type on which the operation is performed. + :vartype resource: str + :ivar operation: The localized friendly name for the operation. + :vartype operation: str + :ivar description: The localized friendly description for the operation. + :vartype description: str + """ + + provider: str + """Friendly name of the resource provider.""" + resource: str + """Resource type on which the operation is performed.""" + operation: str + """The localized friendly name for the operation.""" + description: str + """The localized friendly description for the operation.""" + + +class OperationProperties(TypedDict, total=False): + """Extra Operation properties. + + :ivar service_specification: An object that describes a specification. + :vartype service_specification: "ServiceSpecification" + """ + + serviceSpecification: "ServiceSpecification" + """An object that describes a specification.""" + + +class PersistentStorage(ProxyResource): + """A persistent storage. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar properties: Properties of a persistent storage. Required. + :vartype properties: "PersistentStorageProperties" + """ + + properties: Required["PersistentStorageProperties"] + """Properties of a persistent storage. Required.""" + + +class PersistentStorageProperties(TypedDict, total=False): + """Properties of a persistent storage. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar storage_account: Reference to the storage account to be used for persistent storage. + Required. + :vartype storage_account: "ResourceReference" + """ + + provisioningState: Union[str, "ProvisioningState"] + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + storageAccount: Required["ResourceReference"] + """Reference to the storage account to be used for persistent storage. Required.""" + + +class PrivateEndpoint(TypedDict, total=False): + """Private endpoint. + + :ivar id: Full qualified Id of the private endpoint. + :vartype id: str + """ + + id: str + """Full qualified Id of the private endpoint.""" + + +class PrivateEndpointACL(NetworkACL): + """ACL for a private endpoint. + + :ivar allow: Allowed request types. The value can be one or more of: ClientConnection, + ServerConnection, RESTAPI. + :vartype allow: list[Union[str, "WebPubSubRequestType"]] + :ivar deny: Denied request types. The value can be one or more of: ClientConnection, + ServerConnection, RESTAPI. + :vartype deny: list[Union[str, "WebPubSubRequestType"]] + :ivar name: Name of the private endpoint connection. Required. + :vartype name: str + """ + + name: Required[str] + """Name of the private endpoint connection. Required.""" + + +class PrivateEndpointConnection(ProxyResource): + """A private endpoint connection to an azure resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar properties: Private endpoint connection properties. + :vartype properties: "PrivateEndpointConnectionProperties" + """ + + properties: "PrivateEndpointConnectionProperties" + """Private endpoint connection properties.""" + + +class PrivateEndpointConnectionProperties(TypedDict, total=False): + """Private endpoint connection properties. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar private_endpoint: Private endpoint. + :vartype private_endpoint: "PrivateEndpoint" + :ivar group_ids: Group IDs. + :vartype group_ids: list[str] + :ivar private_link_service_connection_state: Connection state of the private endpoint + connection. + :vartype private_link_service_connection_state: "PrivateLinkServiceConnectionState" + """ + + provisioningState: Union[str, "ProvisioningState"] + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + privateEndpoint: "PrivateEndpoint" + """Private endpoint.""" + groupIds: list[str] + """Group IDs.""" + privateLinkServiceConnectionState: "PrivateLinkServiceConnectionState" + """Connection state of the private endpoint connection.""" + + +class PrivateLinkResource(ProxyResource): + """Private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar properties: Private link resource properties. + :vartype properties: "PrivateLinkResourceProperties" + """ + + properties: "PrivateLinkResourceProperties" + """Private link resource properties.""" + + +class PrivateLinkResourceProperties(TypedDict, total=False): + """Private link resource properties. + + :ivar group_id: Group Id of the private link resource. + :vartype group_id: str + :ivar required_members: Required members of the private link resource. + :vartype required_members: list[str] + :ivar required_zone_names: Required private DNS zone names. + :vartype required_zone_names: list[str] + :ivar shareable_private_link_resource_types: The list of resources that are onboarded to + private link service. + :vartype shareable_private_link_resource_types: list["ShareablePrivateLinkResourceType"] + """ + + groupId: str + """Group Id of the private link resource.""" + requiredMembers: list[str] + """Required members of the private link resource.""" + requiredZoneNames: list[str] + """Required private DNS zone names.""" + shareablePrivateLinkResourceTypes: list["ShareablePrivateLinkResourceType"] + """The list of resources that are onboarded to private link service.""" + + +class PrivateLinkServiceConnectionState(TypedDict, total=False): + """Connection state of the private endpoint connection. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". + :vartype status: Union[str, "PrivateLinkServiceConnectionStatus"] + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + status: Union[str, "PrivateLinkServiceConnectionStatus"] + """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + service. Known values are: \"Pending\", \"Approved\", \"Rejected\", and \"Disconnected\".""" + description: str + """The reason for approval/rejection of the connection.""" + actionsRequired: str + """A message indicating if changes on the service provider require any updates on the consumer.""" + + +class RegenerateKeyParameters(TypedDict, total=False): + """Parameters describes the request to regenerate access keys. + + :ivar key_type: The type of access key. Known values are: "Primary", "Secondary", and "Salt". + :vartype key_type: Union[str, "KeyType"] + """ + + keyType: Union[str, "KeyType"] + """The type of access key. Known values are: \"Primary\", \"Secondary\", and \"Salt\".""" + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: dict[str, str] + """Resource tags.""" + location: Required[str] + """The geo-location where the resource lives. Required.""" + + +class Replica(TrackedResource): + """A class represent a replica resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: + :vartype properties: "ReplicaProperties" + :ivar sku: The billing information of the resource. + :vartype sku: "ResourceSku" + """ + + properties: "ReplicaProperties" + sku: "ResourceSku" + """The billing information of the resource.""" + + +class ReplicaProperties(TypedDict, total=False): + """ReplicaProperties. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar region_endpoint_enabled: Enable or disable the regional endpoint. Default to "Enabled". + When it's Disabled, new connections will not be routed to this endpoint, however existing + connections will not be affected. + :vartype region_endpoint_enabled: str + :ivar resource_stopped: Stop or start the resource. Default to "false". When it's true, the + data plane of the resource is shutdown. When it's false, the data plane of the resource is + started. + :vartype resource_stopped: str + """ + + provisioningState: Union[str, "ProvisioningState"] + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + regionEndpointEnabled: str + """Enable or disable the regional endpoint. Default to \"Enabled\". When it's Disabled, new + connections will not be routed to this endpoint, however existing connections will not be + affected.""" + resourceStopped: str + """Stop or start the resource. Default to \"false\". When it's true, the data plane of the + resource is shutdown. When it's false, the data plane of the resource is started.""" + + +class ResourceLogCategory(TypedDict, total=False): + """Resource log category configuration of a Microsoft.SignalRService resource. + + :ivar name: Gets or sets the resource log category's name. Available values: ConnectivityLogs, + MessagingLogs. Case insensitive. + :vartype name: str + :ivar enabled: Indicates whether or the resource log category is enabled. Available values: + true, false. Case insensitive. + :vartype enabled: str + """ + + name: str + """Gets or sets the resource log category's name. Available values: ConnectivityLogs, + MessagingLogs. Case insensitive.""" + enabled: str + """Indicates whether or the resource log category is enabled. Available values: true, false. Case + insensitive.""" + + +class ResourceLogConfiguration(TypedDict, total=False): + """Resource log configuration of a Microsoft.SignalRService resource. + + :ivar categories: Gets or sets the list of category configurations. + :vartype categories: list["ResourceLogCategory"] + """ + + categories: list["ResourceLogCategory"] + """Gets or sets the list of category configurations.""" + + +class ResourceReference(TypedDict, total=False): + """Reference to a resource. + + :ivar id: Resource ID. + :vartype id: str + """ + + id: str + """Resource ID.""" + + +class ResourceSku(TypedDict, total=False): + """The billing information of the resource. + + :ivar name: The name of the SKU. Required. + + Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2. Required. + :vartype name: str + :ivar tier: Optional tier of this particular SKU. 'Standard' or 'Free'. + + ``Basic`` is deprecated, use ``Standard`` instead. Known values are: "Free", "Basic", + "Standard", and "Premium". + :vartype tier: Union[str, "WebPubSubSkuTier"] + :ivar size: Not used. Retained for future use. + :vartype size: str + :ivar family: Not used. Retained for future use. + :vartype family: str + :ivar capacity: Optional, integer. The unit count of the resource. + 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default. + + If present, following values are allowed: + Free_F1: 1; + Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P2: 100,200,300,400,500,600,700,800,900,1000;. + :vartype capacity: int + """ + + name: Required[str] + """The name of the SKU. Required. + + Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2. Required.""" + tier: Union[str, "WebPubSubSkuTier"] + """Optional tier of this particular SKU. 'Standard' or 'Free'. + + ``Basic`` is deprecated, use ``Standard`` instead. Known values are: \"Free\", \"Basic\", + \"Standard\", and \"Premium\".""" + size: str + """Not used. Retained for future use.""" + family: str + """Not used. Retained for future use.""" + capacity: int + """Optional, integer. The unit count of the resource. + 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default. + + If present, following values are allowed: + Free_F1: 1; + Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P2: 100,200,300,400,500,600,700,800,900,1000;.""" + + +class ServiceSpecification(TypedDict, total=False): + """An object that describes a specification. + + :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. + :vartype metric_specifications: list["MetricSpecification"] + :ivar log_specifications: Specifications of the Logs for Azure Monitoring. + :vartype log_specifications: list["LogSpecification"] + """ + + metricSpecifications: list["MetricSpecification"] + """Specifications of the Metrics for Azure Monitoring.""" + logSpecifications: list["LogSpecification"] + """Specifications of the Logs for Azure Monitoring.""" + + +class ShareablePrivateLinkResourceProperties(TypedDict, total=False): + """Describes the properties of a resource type that has been onboarded to private link service. + + :ivar description: The description of the resource type that has been onboarded to private link + service. + :vartype description: str + :ivar group_id: The resource provider group id for the resource that has been onboarded to + private link service. + :vartype group_id: str + :ivar type: The resource provider type for the resource that has been onboarded to private link + service. + :vartype type: str + """ + + description: str + """The description of the resource type that has been onboarded to private link service.""" + groupId: str + """The resource provider group id for the resource that has been onboarded to private link + service.""" + type: str + """The resource provider type for the resource that has been onboarded to private link service.""" + + +class ShareablePrivateLinkResourceType(TypedDict, total=False): + """Describes a resource type that has been onboarded to private link service. + + :ivar name: The name of the resource type that has been onboarded to private link service. + :vartype name: str + :ivar properties: Describes the properties of a resource type that has been onboarded to + private link service. + :vartype properties: "ShareablePrivateLinkResourceProperties" + """ + + name: str + """The name of the resource type that has been onboarded to private link service.""" + properties: "ShareablePrivateLinkResourceProperties" + """Describes the properties of a resource type that has been onboarded to private link service.""" + + +class SharedPrivateLinkResource(ProxyResource): + """Describes a Shared Private Link Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar properties: Describes the properties of an existing Shared Private Link Resource. + :vartype properties: "SharedPrivateLinkResourceProperties" + """ + + properties: "SharedPrivateLinkResourceProperties" + """Describes the properties of an existing Shared Private Link Resource.""" + + +class SharedPrivateLinkResourceProperties(TypedDict, total=False): + """Describes the properties of an existing Shared Private Link Resource. + + :ivar group_id: The group id from the provider of resource the shared private link resource is + for. Required. + :vartype group_id: str + :ivar private_link_resource_id: The resource id of the resource the shared private link + resource is for. Required. + :vartype private_link_resource_id: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar request_message: The request message for requesting approval of the shared private link + resource. + :vartype request_message: str + :ivar fqdns: A list of FQDNs for third party private link service. + :vartype fqdns: list[str] + :ivar status: Status of the shared private link resource. Known values are: "Pending", + "Approved", "Rejected", "Disconnected", and "Timeout". + :vartype status: Union[str, "SharedPrivateLinkResourceStatus"] + """ + + groupId: Required[str] + """The group id from the provider of resource the shared private link resource is for. Required.""" + privateLinkResourceId: Required[str] + """The resource id of the resource the shared private link resource is for. Required.""" + provisioningState: Union[str, "ProvisioningState"] + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + requestMessage: str + """The request message for requesting approval of the shared private link resource.""" + fqdns: list[str] + """A list of FQDNs for third party private link service.""" + status: Union[str, "SharedPrivateLinkResourceStatus"] + """Status of the shared private link resource. Known values are: \"Pending\", \"Approved\", + \"Rejected\", \"Disconnected\", and \"Timeout\".""" + + +class SignalRServiceUsage(TypedDict, total=False): + """Object that describes a specific usage of the resources. + + :ivar id: Fully qualified ARM resource id. + :vartype id: str + :ivar current_value: Current value for the usage quota. + :vartype current_value: int + :ivar limit: The maximum permitted value for the usage quota. If there is no limit, this value + will be -1. + :vartype limit: int + :ivar name: Localizable String object containing the name and a localized value. + :vartype name: "SignalRServiceUsageName" + :ivar unit: Representing the units of the usage quota. Possible values are: Count, Bytes, + Seconds, Percent, CountPerSecond, BytesPerSecond. + :vartype unit: str + """ + + id: str + """Fully qualified ARM resource id.""" + currentValue: int + """Current value for the usage quota.""" + limit: int + """The maximum permitted value for the usage quota. If there is no limit, this value will be -1.""" + name: "SignalRServiceUsageName" + """Localizable String object containing the name and a localized value.""" + unit: str + """Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, + CountPerSecond, BytesPerSecond.""" + + +class SignalRServiceUsageName(TypedDict, total=False): + """Localizable String object containing the name and a localized value. + + :ivar value: The identifier of the usage. + :vartype value: str + :ivar localized_value: Localized name of the usage. + :vartype localized_value: str + """ + + value: str + """The identifier of the usage.""" + localizedValue: str + """Localized name of the usage.""" + + +class Sku(TypedDict, total=False): + """Describes an available sku.". + + :ivar resource_type: The resource type that this object applies to. + :vartype resource_type: str + :ivar sku: The billing information of the resource. + :vartype sku: "ResourceSku" + :ivar capacity: Describes scaling information of a sku. + :vartype capacity: "SkuCapacity" + """ + + resourceType: str + """The resource type that this object applies to.""" + sku: "ResourceSku" + """The billing information of the resource.""" + capacity: "SkuCapacity" + """Describes scaling information of a sku.""" + + +class SkuCapacity(TypedDict, total=False): + """Describes scaling information of a sku. + + :ivar minimum: The lowest permitted capacity for this resource. + :vartype minimum: int + :ivar maximum: The highest permitted capacity for this resource. + :vartype maximum: int + :ivar default: The default capacity. + :vartype default: int + :ivar allowed_values: Allows capacity value list. + :vartype allowed_values: list[int] + :ivar scale_type: The scale type applicable to the sku. Known values are: "None", "Manual", and + "Automatic". + :vartype scale_type: Union[str, "ScaleType"] + """ + + minimum: int + """The lowest permitted capacity for this resource.""" + maximum: int + """The highest permitted capacity for this resource.""" + default: int + """The default capacity.""" + allowedValues: list[int] + """Allows capacity value list.""" + scaleType: Union[str, "ScaleType"] + """The scale type applicable to the sku. Known values are: \"None\", \"Manual\", and + \"Automatic\".""" + + +class SkuList(TypedDict, total=False): + """The list skus operation response. + + :ivar value: The list of skus available for the resource. + :vartype value: list["Sku"] + :ivar next_link: The URL the client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + value: list["Sku"] + """The list of skus available for the resource.""" + nextLink: str + """The URL the client should use to fetch the next page (per server side paging). It's null for + now, added for future use.""" + + +class SystemData(TypedDict, total=False): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: Union[str, "CreatedByType"] + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: str + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: Union[str, "CreatedByType"] + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: str + """ + + createdBy: str + """The identity that created the resource.""" + createdByType: Union[str, "CreatedByType"] + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + createdAt: str + """The timestamp of resource creation (UTC).""" + lastModifiedBy: str + """The identity that last modified the resource.""" + lastModifiedByType: Union[str, "CreatedByType"] + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + lastModifiedAt: str + """The timestamp of resource last modification (UTC).""" + + +class ThrottleByJwtCustomClaimRule(TypedDict, total=False): + """Throttle the client connection by a custom JWT claim. + + :ivar claim_name: The name of the claim in the JWT token. The client connection with the same + claim value will be aggregated. If the claim is not found in the token, the connection will be + allowed. Required. + :vartype claim_name: str + :ivar max_count: Maximum connection count allowed for the same Jwt claim value. Clients with + the same Jwt claim will get rejected if the connection count exceeds this value. Default value + is 20. + :vartype max_count: int + :ivar type: Required. THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE. + :vartype type: + Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE] + """ + + claimName: Required[str] + """The name of the claim in the JWT token. The client connection with the same claim value will be + aggregated. If the claim is not found in the token, the connection will be allowed. Required.""" + maxCount: int + """Maximum connection count allowed for the same Jwt claim value. Clients with the same Jwt claim + will get rejected if the connection count exceeds this value. Default value is 20.""" + type: Required[Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE]] + """Required. THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE.""" + + +class ThrottleByJwtSignatureRule(TypedDict, total=False): + """Throttle the client connection by the JWT signature. + + :ivar max_count: Maximum connection count allowed for the same JWT signature. Clients with the + same JWT signature will get rejected if the connection count exceeds this value. Default value + is 20. + :vartype max_count: int + :ivar type: Required. THROTTLE_BY_JWT_SIGNATURE_RULE. + :vartype type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_SIGNATURE_RULE] + """ + + maxCount: int + """Maximum connection count allowed for the same JWT signature. Clients with the same JWT + signature will get rejected if the connection count exceeds this value. Default value is 20.""" + type: Required[Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_JWT_SIGNATURE_RULE]] + """Required. THROTTLE_BY_JWT_SIGNATURE_RULE.""" + + +class ThrottleByUserIdRule(TypedDict, total=False): + """Throttle the client connection by the user ID. + + :ivar max_count: Maximum connection count allowed for the same user ID. Clients with the same + user ID will get rejected if the connection count exceeds this value. Default value is 20. + :vartype max_count: int + :ivar type: Required. THROTTLE_BY_USER_ID_RULE. + :vartype type: Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_USER_ID_RULE] + """ + + maxCount: int + """Maximum connection count allowed for the same user ID. Clients with the same user ID will get + rejected if the connection count exceeds this value. Default value is 20.""" + type: Required[Literal[ClientConnectionCountRuleDiscriminator.THROTTLE_BY_USER_ID_RULE]] + """Required. THROTTLE_BY_USER_ID_RULE.""" + + +class TrafficThrottleByJwtCustomClaimRule(TypedDict, total=False): + """Throttle the client traffic by a custom JWT claim. + + :ivar claim_name: The name of the claim in the JWT token. The message bytes with the same claim + value will be aggregated. If the claim is not found in the token, the rule will be skipped. + Required. + :vartype claim_name: str + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + JWT signature within a time window. Clients with the same JWT claim will get disconnected if + the message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + :ivar type: Required. TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE. + :vartype type: + Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE] + """ + + claimName: Required[str] + """The name of the claim in the JWT token. The message bytes with the same claim value will be + aggregated. If the claim is not found in the token, the rule will be skipped. Required.""" + maxInboundMessageBytes: int + """Maximum accumulated inbound message bytes allowed for the same JWT signature within a time + window. Clients with the same JWT claim will get disconnected if the message bytes exceeds this + value. Default value is 1GB.""" + aggregationWindowInSeconds: int + """The aggregation window for the message bytes. The message bytes will be aggregated in this + window and be reset after the window. Default value is 60 seconds.""" + type: Required[Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE]] + """Required. TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE.""" + + +class TrafficThrottleByJwtSignatureRule(TypedDict, total=False): + """Throttle the client traffic by the JWT signature. + + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + JWT signature within a time window. Clients with the same JWT signature will get disconnected + if the message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + :ivar type: Required. TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE. + :vartype type: + Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE] + """ + + maxInboundMessageBytes: int + """Maximum accumulated inbound message bytes allowed for the same JWT signature within a time + window. Clients with the same JWT signature will get disconnected if the message bytes exceeds + this value. Default value is 1GB.""" + aggregationWindowInSeconds: int + """The aggregation window for the message bytes. The message bytes will be aggregated in this + window and be reset after the window. Default value is 60 seconds.""" + type: Required[Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE]] + """Required. TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE.""" + + +class TrafficThrottleByUserIdRule(TypedDict, total=False): + """Throttle the client traffic by the user ID. + + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + user ID within a time window. Clients with the same user ID will get disconnected if the + message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + :ivar type: Required. TRAFFIC_THROTTLE_BY_USER_ID_RULE. + :vartype type: Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_USER_ID_RULE] + """ + + maxInboundMessageBytes: int + """Maximum accumulated inbound message bytes allowed for the same user ID within a time window. + Clients with the same user ID will get disconnected if the message bytes exceeds this value. + Default value is 1GB.""" + aggregationWindowInSeconds: int + """The aggregation window for the message bytes. The message bytes will be aggregated in this + window and be reset after the window. Default value is 60 seconds.""" + type: Required[Literal[ClientTrafficControlRuleDiscriminator.TRAFFIC_THROTTLE_BY_USER_ID_RULE]] + """Required. TRAFFIC_THROTTLE_BY_USER_ID_RULE.""" + + +class UpstreamAuthSettings(TypedDict, total=False): + """Upstream auth settings. If not set, no auth is used for upstream messages. + + :ivar type: Upstream auth type enum. Known values are: "None" and "ManagedIdentity". + :vartype type: Union[str, "UpstreamAuthType"] + :ivar managed_identity: Managed identity settings for upstream. + :vartype managed_identity: "ManagedIdentitySettings" + """ + + type: Union[str, "UpstreamAuthType"] + """Upstream auth type enum. Known values are: \"None\" and \"ManagedIdentity\".""" + managedIdentity: "ManagedIdentitySettings" + """Managed identity settings for upstream.""" + + +class UserAssignedIdentityProperty(TypedDict, total=False): + """Properties of user assigned identity. + + :ivar principal_id: Get the principal id for the user assigned identity. + :vartype principal_id: str + :ivar client_id: Get the client id for the user assigned identity. + :vartype client_id: str + """ + + principalId: str + """Get the principal id for the user assigned identity.""" + clientId: str + """Get the client id for the user assigned identity.""" + + +class WebPubSubHub(ProxyResource): + """A hub setting. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar properties: Properties of a hub. Required. + :vartype properties: "WebPubSubHubProperties" + """ + + properties: Required["WebPubSubHubProperties"] + """Properties of a hub. Required.""" + + +class WebPubSubHubProperties(TypedDict, total=False): + """Properties of a hub. + + :ivar event_handlers: Event handler of a hub. + :vartype event_handlers: list["EventHandler"] + :ivar event_listeners: Event listener settings for forwarding your client events to listeners. + Event listener is transparent to Web PubSub clients, and it doesn't return any result to + clients nor interrupt the lifetime of clients. One event can be sent to multiple listeners, as + long as it matches the filters in those listeners. The order of the array elements doesn't + matter. Maximum count of event listeners among all hubs is 10. + :vartype event_listeners: list["EventListener"] + :ivar anonymous_connect_policy: The settings for configuring if anonymous connections are + allowed for this hub: "allow" or "deny". Default to "deny". + :vartype anonymous_connect_policy: str + :ivar web_socket_keep_alive_interval_in_seconds: The settings for configuring the WebSocket + ping-pong interval in seconds for all clients in the hub. Valid range: 1 to 120. Default to 20 + seconds. + :vartype web_socket_keep_alive_interval_in_seconds: int + :ivar chat: The chat settings for the hub. + :vartype chat: "ChatSettings" + """ + + eventHandlers: list["EventHandler"] + """Event handler of a hub.""" + eventListeners: list["EventListener"] + """Event listener settings for forwarding your client events to listeners. Event listener is + transparent to Web PubSub clients, and it doesn't return any result to clients nor interrupt + the lifetime of clients. One event can be sent to multiple listeners, as long as it matches the + filters in those listeners. The order of the array elements doesn't matter. Maximum count of + event listeners among all hubs is 10.""" + anonymousConnectPolicy: str + """The settings for configuring if anonymous connections are allowed for this hub: \"allow\" or + \"deny\". Default to \"deny\".""" + webSocketKeepAliveIntervalInSeconds: int + """The settings for configuring the WebSocket ping-pong interval in seconds for all clients in the + hub. Valid range: 1 to 120. Default to 20 seconds.""" + chat: "ChatSettings" + """The chat settings for the hub.""" + + +class WebPubSubKeys(TypedDict, total=False): + """A class represents the access keys of the resource. + + :ivar primary_key: The primary access key. + :vartype primary_key: str + :ivar secondary_key: The secondary access key. + :vartype secondary_key: str + :ivar primary_connection_string: Connection string constructed via the primaryKey. + :vartype primary_connection_string: str + :ivar secondary_connection_string: Connection string constructed via the secondaryKey. + :vartype secondary_connection_string: str + """ + + primaryKey: str + """The primary access key.""" + secondaryKey: str + """The secondary access key.""" + primaryConnectionString: str + """Connection string constructed via the primaryKey.""" + secondaryConnectionString: str + """Connection string constructed via the secondaryKey.""" + + +class WebPubSubNetworkACLs(TypedDict, total=False): + """Network ACLs for the resource. + + :ivar default_action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". + :vartype default_action: Union[str, "ACLAction"] + :ivar public_network: Network ACL. + :vartype public_network: "NetworkACL" + :ivar private_endpoints: ACLs for requests from private endpoints. + :vartype private_endpoints: list["PrivateEndpointACL"] + :ivar ip_rules: IP rules for filtering public traffic. + :vartype ip_rules: list["IPRule"] + """ + + defaultAction: Union[str, "ACLAction"] + """Azure Networking ACL Action. Known values are: \"Allow\" and \"Deny\".""" + publicNetwork: "NetworkACL" + """Network ACL.""" + privateEndpoints: list["PrivateEndpointACL"] + """ACLs for requests from private endpoints.""" + ipRules: list["IPRule"] + """IP rules for filtering public traffic.""" + + +class WebPubSubProperties(TypedDict, total=False): + """A class that describes the properties of the resource. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar external_ip: The publicly accessible IP of the resource. + :vartype external_ip: str + :ivar host_name: FQDN of the service instance. + :vartype host_name: str + :ivar public_port: The publicly accessible port of the resource which is designed for + browser/client side usage. + :vartype public_port: int + :ivar server_port: The publicly accessible port of the resource which is designed for customer + server side usage. + :vartype server_port: int + :ivar version: Version of the resource. Probably you need the same or higher version of client + SDKs. + :vartype version: str + :ivar private_endpoint_connections: Private endpoint connections to the resource. + :vartype private_endpoint_connections: list["PrivateEndpointConnection"] + :ivar shared_private_link_resources: The list of shared private link resources. + :vartype shared_private_link_resources: list["SharedPrivateLinkResource"] + :ivar tls: TLS settings for the resource. + :vartype tls: "WebPubSubTlsSettings" + :ivar host_name_prefix: Deprecated. + :vartype host_name_prefix: str + :ivar live_trace_configuration: Live trace configuration of a Microsoft.SignalRService + resource. + :vartype live_trace_configuration: "LiveTraceConfiguration" + :ivar resource_log_configuration: Resource log configuration of a Microsoft.SignalRService + resource. + :vartype resource_log_configuration: "ResourceLogConfiguration" + :ivar network_ac_ls: Network ACLs for the resource. + :vartype network_ac_ls: "WebPubSubNetworkACLs" + :ivar application_firewall: Application firewall settings for the resource. + :vartype application_firewall: "ApplicationFirewallSettings" + :ivar public_network_access: Enable or disable public network access. Default to "Enabled". + When it's Enabled, network ACLs still apply. When it's Disabled, public network access is + always disabled no matter what you set in network ACLs. + :vartype public_network_access: str + :ivar disable_local_auth: DisableLocalAuth Enable or disable local auth with AccessKey When set + as true, connection with AccessKey=xxx won't work. + :vartype disable_local_auth: bool + :ivar disable_aad_auth: DisableLocalAuth Enable or disable aad auth When set as true, + connection with AuthType=aad won't work. + :vartype disable_aad_auth: bool + :ivar region_endpoint_enabled: Enable or disable the regional endpoint. Default to "Enabled". + When it's Disabled, new connections will not be routed to this endpoint, however existing + connections will not be affected. This property is replica specific. Disable the regional + endpoint without replica is not allowed. + :vartype region_endpoint_enabled: str + :ivar resource_stopped: Stop or start the resource. Default to "False". When it's true, the + data plane of the resource is shutdown. When it's false, the data plane of the resource is + started. + :vartype resource_stopped: str + :ivar socket_io: SocketIO settings for the resource. + :vartype socket_io: "WebPubSubSocketIOSettings" + """ + + provisioningState: Union[str, "ProvisioningState"] + """Provisioning state of the resource. Known values are: \"Unknown\", \"Succeeded\", \"Failed\", + \"Canceled\", \"Running\", \"Creating\", \"Updating\", \"Deleting\", and \"Moving\".""" + externalIP: str + """The publicly accessible IP of the resource.""" + hostName: str + """FQDN of the service instance.""" + publicPort: int + """The publicly accessible port of the resource which is designed for browser/client side usage.""" + serverPort: int + """The publicly accessible port of the resource which is designed for customer server side usage.""" + version: str + """Version of the resource. Probably you need the same or higher version of client SDKs.""" + privateEndpointConnections: list["PrivateEndpointConnection"] + """Private endpoint connections to the resource.""" + sharedPrivateLinkResources: list["SharedPrivateLinkResource"] + """The list of shared private link resources.""" + tls: "WebPubSubTlsSettings" + """TLS settings for the resource.""" + hostNamePrefix: str + """Deprecated.""" + liveTraceConfiguration: "LiveTraceConfiguration" + """Live trace configuration of a Microsoft.SignalRService resource.""" + resourceLogConfiguration: "ResourceLogConfiguration" + """Resource log configuration of a Microsoft.SignalRService resource.""" + networkACLs: "WebPubSubNetworkACLs" + """Network ACLs for the resource.""" + applicationFirewall: "ApplicationFirewallSettings" + """Application firewall settings for the resource.""" + publicNetworkAccess: str + """Enable or disable public network access. Default to \"Enabled\". When it's Enabled, network + ACLs still apply. When it's Disabled, public network access is always disabled no matter what + you set in network ACLs.""" + disableLocalAuth: bool + """DisableLocalAuth Enable or disable local auth with AccessKey When set as true, connection with + AccessKey=xxx won't work.""" + disableAadAuth: bool + """DisableLocalAuth Enable or disable aad auth When set as true, connection with AuthType=aad + won't work.""" + regionEndpointEnabled: str + """Enable or disable the regional endpoint. Default to \"Enabled\". When it's Disabled, new + connections will not be routed to this endpoint, however existing connections will not be + affected. This property is replica specific. Disable the regional endpoint without replica is + not allowed.""" + resourceStopped: str + """Stop or start the resource. Default to \"False\". When it's true, the data plane of the + resource is shutdown. When it's false, the data plane of the resource is started.""" + socketIO: "WebPubSubSocketIOSettings" + """SocketIO settings for the resource.""" + + +class WebPubSubResource(TrackedResource): + """A class represent a resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: "SystemData" + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: A class that describes the properties of the resource. + :vartype properties: "WebPubSubProperties" + :ivar sku: The billing information of the resource. + :vartype sku: "ResourceSku" + :ivar kind: The kind of the service. Known values are: "WebPubSub" and "SocketIO". + :vartype kind: Union[str, "ServiceKind"] + :ivar identity: A class represent managed identities used for request and response. + :vartype identity: "ManagedIdentity" + """ + + properties: "WebPubSubProperties" + """A class that describes the properties of the resource.""" + sku: "ResourceSku" + """The billing information of the resource.""" + kind: Union[str, "ServiceKind"] + """The kind of the service. Known values are: \"WebPubSub\" and \"SocketIO\".""" + identity: "ManagedIdentity" + """A class represent managed identities used for request and response.""" + + +class WebPubSubSocketIOSettings(TypedDict, total=False): + """SocketIO settings for the resource. + + :ivar service_mode: The service mode of Web PubSub for Socket.IO. Values allowed: "Default": + have your own backend Socket.IO server "Serverless": your application doesn't have a backend + server. + :vartype service_mode: str + """ + + serviceMode: str + """The service mode of Web PubSub for Socket.IO. Values allowed: \"Default\": have your own + backend Socket.IO server \"Serverless\": your application doesn't have a backend server.""" + + +class WebPubSubTlsSettings(TypedDict, total=False): + """TLS settings for the resource. + + :ivar client_cert_enabled: Request client certificate during TLS handshake if enabled. Not + supported for free tier. Any input will be ignored for free tier. + :vartype client_cert_enabled: bool + """ + + clientCertEnabled: bool + """Request client certificate during TLS handshake if enabled. Not supported for free tier. Any + input will be ignored for free tier.""" + + +ClientConnectionCountRule = Union[ThrottleByJwtCustomClaimRule, ThrottleByJwtSignatureRule, ThrottleByUserIdRule] +ClientTrafficControlRule = Union[ + TrafficThrottleByJwtCustomClaimRule, TrafficThrottleByJwtSignatureRule, TrafficThrottleByUserIdRule +] +EventListenerEndpoint = Union[EventHubEndpoint] +EventListenerFilter = Union[EventNameFilter] diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/operations_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/operations_list.py index 194f9c3ed4eb..a565f9e47d21 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/operations_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/operations_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/Operations_List.json +# x-ms-original-file: 2025-12-01-preview/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/usages_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/usages_list.py index 2c9258637608..3b344dcc97e0 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/usages_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/usages_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.usages.list( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/Usages_List.json +# x-ms-original-file: 2025-12-01-preview/Usages_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_check_name_availability.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_check_name_availability.py index e015ea9f259b..5add7175098a 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_check_name_availability.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_check_name_availability.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.check_name_availability( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_CheckNameAvailability.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_create_or_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_create_or_update.py index fd6bc2ceaae6..029a67d6fcb5 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_create_or_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_create_or_update.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.begin_create_or_update( @@ -65,6 +65,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_CreateOrUpdate.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_create_or_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_create_or_update.py index 20b85c4c00c6..cafc3cb25ef4 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_create_or_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_create_or_update.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_custom_certificates.begin_create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubCustomCertificates_CreateOrUpdate.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubCustomCertificates_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_delete.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_delete.py index dd69213ba9ed..5bdbe849682f 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_delete.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub_custom_certificates.delete( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubCustomCertificates_Delete.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubCustomCertificates_Delete.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_get.py index c9808771b43b..be41a350fcb0 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_get.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_custom_certificates.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubCustomCertificates_Get.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubCustomCertificates_Get.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_list.py index 29d05b7bb9c5..ad5430ffa45c 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_certificates_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_custom_certificates.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubCustomCertificates_List.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubCustomCertificates_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_create_or_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_create_or_update.py index ce2a253a1cb5..908f4f94c256 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_create_or_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_create_or_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_custom_domains.begin_create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubCustomDomains_CreateOrUpdate.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubCustomDomains_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_delete.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_delete.py index 69cebc6bf40d..472656d3b70e 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_delete.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub_custom_domains.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubCustomDomains_Delete.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubCustomDomains_Delete.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_get.py index 70909835d56c..0c5d951dc344 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_get.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_custom_domains.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubCustomDomains_Get.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubCustomDomains_Get.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_list.py index 014a88f70d50..cee6c9c510ea 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_custom_domains_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_custom_domains.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubCustomDomains_List.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubCustomDomains_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_delete.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_delete.py index c13de59ee7b0..b2e715a94473 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_delete.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub.begin_delete( @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_Delete.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_Delete.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_get.py index 214997c73134..26031ecc9543 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_get.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_Get.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_Get.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_create_or_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_create_or_update.py index e64cdb37ea49..4bce46e5d5ff 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_create_or_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_create_or_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_hubs.begin_create_or_update( @@ -37,9 +38,16 @@ def main(): parameters={ "properties": { "anonymousConnectPolicy": "allow", + "chat": { + "mode": "Enabled", + "persistentStorage": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/WebPubSub/myWebPubSubService/persistentStorages/myStor" + }, + }, "eventHandlers": [ { "auth": {"managedIdentity": {"resource": "abc"}, "type": "ManagedIdentity"}, + "groupPresenceEvents": {"eventNames": ["joined", "left"], "groupFilters": ["chat*"]}, "systemEvents": ["connect", "connected"], "urlTemplate": "http://host.com", "userEventPattern": "*", @@ -66,6 +74,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubHubs_CreateOrUpdate.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubHubs_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_delete.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_delete.py index 4bb4dc5eba40..6e9e98591e48 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_delete.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub_hubs.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubHubs_Delete.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubHubs_Delete.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_get.py index 4465a02fa37d..4055ac2e6ee6 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_get.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_hubs.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubHubs_Get.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubHubs_Get.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_list.py index 772fca2276e8..c3949c6c2a8a 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_hubs_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_hubs.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubHubs_List.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubHubs_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_by_resource_group.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_by_resource_group.py index 587252d308a9..fb601179f07c 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_by_resource_group.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_by_resource_group.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.list_by_resource_group( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_ListByResourceGroup.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_by_subscription.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_by_subscription.py index 3782a7a0efbe..c414153d8760 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_by_subscription.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_by_subscription.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.list_by_subscription() @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_ListBySubscription.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_keys.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_keys.py index e443c22922e4..5f22ea31ba61 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_keys.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_keys.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.list_keys( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_ListKeys.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_ListKeys.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_replica_skus.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_replica_skus.py index 30f95c1bca41..3d1dc58a229b 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_replica_skus.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_replica_skus.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.list_replica_skus( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_ListReplicaSkus.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_ListReplicaSkus.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_skus.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_skus.py index 976c4c13f114..659ad48991fb 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_skus.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_list_skus.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.list_skus( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_ListSkus.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_ListSkus.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_create_or_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_create_or_update.py new file mode 100644 index 000000000000..4e146cd49c57 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_create_or_update.py @@ -0,0 +1,51 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.webpubsub import WebPubSubManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-webpubsub +# USAGE + python web_pub_sub_persistent_storages_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.web_pub_sub_persistent_storages.begin_create_or_update( + resource_group_name="myResourceGroup", + resource_name="myWebPubSubService", + name="myStor", + parameters={ + "properties": { + "storageAccount": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount" + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-12-01-preview/WebPubSubPersistentStorages_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_delete.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_delete.py new file mode 100644 index 000000000000..664c4788f91f --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.webpubsub import WebPubSubManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-webpubsub +# USAGE + python web_pub_sub_persistent_storages_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.web_pub_sub_persistent_storages.begin_delete( + resource_group_name="myResourceGroup", + resource_name="myWebPubSubService", + name="example", + ).result() + + +# x-ms-original-file: 2025-12-01-preview/WebPubSubPersistentStorages_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_get.py new file mode 100644 index 000000000000..31d3b9b532b3 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.webpubsub import WebPubSubManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-webpubsub +# USAGE + python web_pub_sub_persistent_storages_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.web_pub_sub_persistent_storages.get( + resource_group_name="myResourceGroup", + resource_name="myWebPubSubService", + name="example", + ) + print(response) + + +# x-ms-original-file: 2025-12-01-preview/WebPubSubPersistentStorages_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_list.py new file mode 100644 index 000000000000..3b1f907cdad8 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_persistent_storages_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.webpubsub import WebPubSubManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-webpubsub +# USAGE + python web_pub_sub_persistent_storages_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.web_pub_sub_persistent_storages.list( + resource_group_name="myResourceGroup", + resource_name="myWebPubSubService", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-12-01-preview/WebPubSubPersistentStorages_List.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_delete.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_delete.py index 186efb088ae7..fa517223ecf5 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_delete.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub_private_endpoint_connections.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubPrivateEndpointConnections_Delete.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubPrivateEndpointConnections_Delete.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_get.py index b90e2dfd0a24..f2fd2027fa7a 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_get.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_private_endpoint_connections.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubPrivateEndpointConnections_Get.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubPrivateEndpointConnections_Get.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_list.py index 897d28f3ecf2..ae1aad931699 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_private_endpoint_connections.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubPrivateEndpointConnections_List.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubPrivateEndpointConnections_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_update.py index ffc49f62e8dc..f296045ab1a0 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_endpoint_connections_update.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_private_endpoint_connections.update( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubPrivateEndpointConnections_Update.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubPrivateEndpointConnections_Update.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_link_resources_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_link_resources_list.py index 63e88026b613..9d199a47e3f9 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_link_resources_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_private_link_resources_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_private_link_resources.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubPrivateLinkResources_List.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubPrivateLinkResources_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_regenerate_key.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_regenerate_key.py index 974bf3c5e0e8..056460455959 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_regenerate_key.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_regenerate_key.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.begin_regenerate_key( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_RegenerateKey.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_RegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_create_or_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_create_or_update.py index 8c9d717c9e63..6df033797716 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_create_or_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_create_or_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_replica_shared_private_link_resources.begin_create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicaSharedPrivateLinkResources_CreateOrUpdate.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicaSharedPrivateLinkResources_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_get.py index 77b94a341f97..a055336156ee 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_get.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_replica_shared_private_link_resources.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicaSharedPrivateLinkResources_Get.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicaSharedPrivateLinkResources_Get.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_list.py index f992aaa9a346..8de71adb845c 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replica_shared_private_link_resources_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_replica_shared_private_link_resources.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicaSharedPrivateLinkResources_List.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicaSharedPrivateLinkResources_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_create_or_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_create_or_update.py index 5599f726ca20..522c01784e5c 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_create_or_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_create_or_update.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_replicas.begin_create_or_update( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicas_CreateOrUpdate.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicas_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_delete.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_delete.py index a1c75ea782e7..0aef4f68709f 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_delete.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub_replicas.delete( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicas_Delete.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicas_Delete.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_get.py index bcdecaeae7c2..e94f253d4daf 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_get.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_replicas.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicas_Get.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicas_Get.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_list.py index 6310430a68c6..d5f314892083 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_replicas.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicas_List.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicas_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_restart.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_restart.py index 16355aaae698..731b98bfe64b 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_restart.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_restart.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub_replicas.begin_restart( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicas_Restart.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicas_Restart.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_update.py index 3f634abb51bf..ea2ec38186cd 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_replicas_update.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_replicas.begin_update( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubReplicas_Update.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubReplicas_Update.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_restart.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_restart.py index ea098dfbc451..6517fc761116 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_restart.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_restart.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub.begin_restart( @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_Restart.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_Restart.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_create_or_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_create_or_update.py index 85349e26ecee..7164c7254ec1 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_create_or_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_create_or_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_shared_private_link_resources.begin_create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubSharedPrivateLinkResources_CreateOrUpdate.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubSharedPrivateLinkResources_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_delete.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_delete.py index 6e14225d2854..a0089883d7e1 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_delete.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.web_pub_sub_shared_private_link_resources.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubSharedPrivateLinkResources_Delete.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubSharedPrivateLinkResources_Delete.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_get.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_get.py index 1fb0183d50fa..d80dccfa7ec5 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_get.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_shared_private_link_resources.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubSharedPrivateLinkResources_Get.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubSharedPrivateLinkResources_Get.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_list.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_list.py index 82bf722c62d2..2a993247346f 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_list.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_shared_private_link_resources_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub_shared_private_link_resources.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSubSharedPrivateLinkResources_List.json +# x-ms-original-file: 2025-12-01-preview/WebPubSubSharedPrivateLinkResources_List.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_update.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_update.py index 8d06b2bd685d..98152d20007a 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_update.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_samples/web_pub_sub_update.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = WebPubSubManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.web_pub_sub.begin_update( @@ -65,6 +65,6 @@ def main(): print(response) -# x-ms-original-file: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2024-03-01/examples/WebPubSub_Update.json +# x-ms-original-file: 2025-12-01-preview/WebPubSub_Update.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/conftest.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/conftest.py index 56c7de2ec6b0..b43f186ebfad 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/conftest.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/conftest.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import os @@ -18,7 +18,7 @@ load_dotenv() -# aovid record sensitive identity information in recordings +# For security, please avoid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): webpubsubmanagement_subscription_id = os.environ.get( diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_operations.py index d03cb453d480..097f4a066bcd 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,10 +20,8 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): - response = self.client.operations.list( - api_version="2024-03-01", - ) + def test_operations_list(self, resource_group): + response = self.client.operations.list() result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_operations_async.py index ced08684556c..e91eed1ab621 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,10 +21,8 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): - response = self.client.operations.list( - api_version="2024-03-01", - ) + async def test_operations_list(self, resource_group): + response = self.client.operations.list() result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_usages_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_usages_operations.py index 484d50663277..83d5edb2a6e9 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_usages_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_usages_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,10 +20,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_usages_list(self, resource_group): response = self.client.usages.list( location="str", - api_version="2024-03-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_usages_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_usages_operations_async.py index 696078cdbd1a..f4c223a29684 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_usages_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_usages_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,10 +21,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_usages_list(self, resource_group): response = self.client.usages.list( location="str", - api_version="2024-03-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_certificates_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_certificates_operations.py index 0b7d83f8fd33..55dded531c11 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_certificates_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_certificates_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): - response = self.client.web_pub_sub_custom_certificates.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_get(self, resource_group): + def test_web_pub_sub_custom_certificates_get(self, resource_group): response = self.client.web_pub_sub_custom_certificates.get( resource_group_name=resource_group.name, resource_name="str", certificate_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -45,18 +32,20 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_web_pub_sub_custom_certificates_begin_create_or_update(self, resource_group): response = self.client.web_pub_sub_custom_certificates.begin_create_or_update( resource_group_name=resource_group.name, resource_name="str", certificate_name="str", parameters={ - "keyVaultBaseUri": "str", - "keyVaultSecretName": "str", + "properties": { + "keyVaultBaseUri": "str", + "keyVaultSecretName": "str", + "keyVaultSecretVersion": "str", + "provisioningState": "str", + }, "id": "str", - "keyVaultSecretVersion": "str", "name": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -67,7 +56,6 @@ def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -75,13 +63,23 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delete(self, resource_group): + def test_web_pub_sub_custom_certificates_delete(self, resource_group): response = self.client.web_pub_sub_custom_certificates.delete( resource_group_name=resource_group.name, resource_name="str", certificate_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_custom_certificates_list(self, resource_group): + response = self.client.web_pub_sub_custom_certificates.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_certificates_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_certificates_operations_async.py index 316204ea30a9..a8dd75e2f170 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_certificates_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_certificates_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): - response = self.client.web_pub_sub_custom_certificates.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_web_pub_sub_custom_certificates_get(self, resource_group): response = await self.client.web_pub_sub_custom_certificates.get( resource_group_name=resource_group.name, resource_name="str", certificate_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -46,19 +33,21 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_web_pub_sub_custom_certificates_begin_create_or_update(self, resource_group): response = await ( await self.client.web_pub_sub_custom_certificates.begin_create_or_update( resource_group_name=resource_group.name, resource_name="str", certificate_name="str", parameters={ - "keyVaultBaseUri": "str", - "keyVaultSecretName": "str", + "properties": { + "keyVaultBaseUri": "str", + "keyVaultSecretName": "str", + "keyVaultSecretVersion": "str", + "provisioningState": "str", + }, "id": "str", - "keyVaultSecretVersion": "str", "name": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -69,7 +58,6 @@ async def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -78,13 +66,23 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delete(self, resource_group): + async def test_web_pub_sub_custom_certificates_delete(self, resource_group): response = await self.client.web_pub_sub_custom_certificates.delete( resource_group_name=resource_group.name, resource_name="str", certificate_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_custom_certificates_list(self, resource_group): + response = self.client.web_pub_sub_custom_certificates.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_domains_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_domains_operations.py index 96f8daab4cb6..9a174b52e1a1 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_domains_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_domains_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): - response = self.client.web_pub_sub_custom_domains.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_get(self, resource_group): + def test_web_pub_sub_custom_domains_get(self, resource_group): response = self.client.web_pub_sub_custom_domains.get( resource_group_name=resource_group.name, resource_name="str", name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -45,17 +32,15 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_web_pub_sub_custom_domains_begin_create_or_update(self, resource_group): response = self.client.web_pub_sub_custom_domains.begin_create_or_update( resource_group_name=resource_group.name, resource_name="str", name="str", parameters={ - "customCertificate": {"id": "str"}, - "domainName": "str", + "properties": {"customCertificate": {"id": "str"}, "domainName": "str", "provisioningState": "str"}, "id": "str", "name": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -66,7 +51,6 @@ def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -74,13 +58,23 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_web_pub_sub_custom_domains_begin_delete(self, resource_group): response = self.client.web_pub_sub_custom_domains.begin_delete( resource_group_name=resource_group.name, resource_name="str", name="str", - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_custom_domains_list(self, resource_group): + response = self.client.web_pub_sub_custom_domains.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_domains_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_domains_operations_async.py index 1929ef439dba..213dfed2f71d 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_domains_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_custom_domains_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): - response = self.client.web_pub_sub_custom_domains.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_web_pub_sub_custom_domains_get(self, resource_group): response = await self.client.web_pub_sub_custom_domains.get( resource_group_name=resource_group.name, resource_name="str", name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -46,18 +33,16 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_web_pub_sub_custom_domains_begin_create_or_update(self, resource_group): response = await ( await self.client.web_pub_sub_custom_domains.begin_create_or_update( resource_group_name=resource_group.name, resource_name="str", name="str", parameters={ - "customCertificate": {"id": "str"}, - "domainName": "str", + "properties": {"customCertificate": {"id": "str"}, "domainName": "str", "provisioningState": "str"}, "id": "str", "name": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -68,7 +53,6 @@ async def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -77,15 +61,25 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_web_pub_sub_custom_domains_begin_delete(self, resource_group): response = await ( await self.client.web_pub_sub_custom_domains.begin_delete( resource_group_name=resource_group.name, resource_name="str", name="str", - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_custom_domains_list(self, resource_group): + response = self.client.web_pub_sub_custom_domains.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_hubs_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_hubs_operations.py index d0e2c36c04bd..1c2d2575d23f 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_hubs_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_hubs_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): - response = self.client.web_pub_sub_hubs.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_get(self, resource_group): + def test_web_pub_sub_hubs_get(self, resource_group): response = self.client.web_pub_sub_hubs.get( hub_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -45,24 +32,26 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_web_pub_sub_hubs_begin_create_or_update(self, resource_group): response = self.client.web_pub_sub_hubs.begin_create_or_update( hub_name="str", resource_group_name=resource_group.name, resource_name="str", parameters={ "properties": { - "anonymousConnectPolicy": "deny", + "anonymousConnectPolicy": "str", + "chat": {"mode": "str", "persistentStorage": {"id": "str"}}, "eventHandlers": [ { "urlTemplate": "str", "auth": {"managedIdentity": {"resource": "str"}, "type": "str"}, + "groupPresenceEvents": {"eventNames": ["str"], "groupFilters": ["str"]}, "systemEvents": ["str"], "userEventPattern": "str", } ], "eventListeners": [{"endpoint": "event_listener_endpoint", "filter": "event_listener_filter"}], - "webSocketKeepAliveIntervalInSeconds": 20, + "webSocketKeepAliveIntervalInSeconds": 0, }, "id": "str", "name": "str", @@ -76,7 +65,6 @@ def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -84,13 +72,23 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_web_pub_sub_hubs_begin_delete(self, resource_group): response = self.client.web_pub_sub_hubs.begin_delete( hub_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_hubs_list(self, resource_group): + response = self.client.web_pub_sub_hubs.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_hubs_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_hubs_operations_async.py index 5eb15adcb6f3..2da5a35edfbd 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_hubs_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_hubs_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): - response = self.client.web_pub_sub_hubs.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_web_pub_sub_hubs_get(self, resource_group): response = await self.client.web_pub_sub_hubs.get( hub_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -46,7 +33,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_web_pub_sub_hubs_begin_create_or_update(self, resource_group): response = await ( await self.client.web_pub_sub_hubs.begin_create_or_update( hub_name="str", @@ -54,17 +41,19 @@ async def test_begin_create_or_update(self, resource_group): resource_name="str", parameters={ "properties": { - "anonymousConnectPolicy": "deny", + "anonymousConnectPolicy": "str", + "chat": {"mode": "str", "persistentStorage": {"id": "str"}}, "eventHandlers": [ { "urlTemplate": "str", "auth": {"managedIdentity": {"resource": "str"}, "type": "str"}, + "groupPresenceEvents": {"eventNames": ["str"], "groupFilters": ["str"]}, "systemEvents": ["str"], "userEventPattern": "str", } ], "eventListeners": [{"endpoint": "event_listener_endpoint", "filter": "event_listener_filter"}], - "webSocketKeepAliveIntervalInSeconds": 20, + "webSocketKeepAliveIntervalInSeconds": 0, }, "id": "str", "name": "str", @@ -78,7 +67,6 @@ async def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -87,15 +75,25 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_web_pub_sub_hubs_begin_delete(self, resource_group): response = await ( await self.client.web_pub_sub_hubs.begin_delete( hub_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_hubs_list(self, resource_group): + response = self.client.web_pub_sub_hubs.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_operations.py index 4bb3eba7615f..f3985dcc14d4 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,44 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_check_name_availability(self, resource_group): - response = self.client.web_pub_sub.check_name_availability( - location="str", - parameters={"name": "str", "type": "str"}, - api_version="2024-03-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_list_by_subscription(self, resource_group): - response = self.client.web_pub_sub.list_by_subscription( - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): - response = self.client.web_pub_sub.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_get(self, resource_group): + def test_web_pub_sub_get(self, resource_group): response = self.client.web_pub_sub.get( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -65,17 +31,12 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_web_pub_sub_begin_create_or_update(self, resource_group): response = self.client.web_pub_sub.begin_create_or_update( resource_group_name=resource_group.name, resource_name="str", parameters={ "location": "str", - "disableAadAuth": False, - "disableLocalAuth": False, - "externalIP": "str", - "hostName": "str", - "hostNamePrefix": "str", "id": "str", "identity": { "principalId": "str", @@ -84,66 +45,85 @@ def test_begin_create_or_update(self, resource_group): "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, "kind": "str", - "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "false"}, "name": "str", - "networkACLs": { - "defaultAction": "str", - "ipRules": [{"action": "str", "value": "str"}], - "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], - "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + "properties": { + "applicationFirewall": { + "clientConnectionCountRules": ["client_connection_count_rule"], + "clientTrafficControlRules": ["client_traffic_control_rule"], + "maxClientConnectionLifetimeInSeconds": 0, + }, + "disableAadAuth": bool, + "disableLocalAuth": bool, + "externalIP": "str", + "hostName": "str", + "hostNamePrefix": "str", + "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "str"}, + "networkACLs": { + "defaultAction": "str", + "ipRules": [{"action": "str", "value": "str"}], + "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], + "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + }, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "publicPort": 0, + "regionEndpointEnabled": "str", + "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, + "resourceStopped": "str", + "serverPort": 0, + "sharedPrivateLinkResources": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "fqdns": ["str"], + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "socketIO": {"serviceMode": "str"}, + "tls": {"clientCertEnabled": bool}, + "version": "str", }, - "privateEndpointConnections": [ - { - "groupIds": ["str"], - "id": "str", - "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", - }, - "provisioningState": "str", - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - } - ], - "provisioningState": "str", - "publicNetworkAccess": "Enabled", - "publicPort": 0, - "regionEndpointEnabled": "Enabled", - "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, - "resourceStopped": "false", - "serverPort": 0, - "sharedPrivateLinkResources": [ - { - "groupId": "str", - "id": "str", - "name": "str", - "privateLinkResourceId": "str", - "provisioningState": "str", - "requestMessage": "str", - "status": "str", - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - } - ], "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "socketIO": {"serviceMode": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -153,11 +133,8 @@ def test_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "tags": {"str": "str"}, - "tls": {"clientCertEnabled": False}, "type": "str", - "version": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -165,29 +142,12 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): - response = self.client.web_pub_sub.begin_delete( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_begin_update(self, resource_group): + def test_web_pub_sub_begin_update(self, resource_group): response = self.client.web_pub_sub.begin_update( resource_group_name=resource_group.name, resource_name="str", parameters={ "location": "str", - "disableAadAuth": False, - "disableLocalAuth": False, - "externalIP": "str", - "hostName": "str", - "hostNamePrefix": "str", "id": "str", "identity": { "principalId": "str", @@ -196,66 +156,85 @@ def test_begin_update(self, resource_group): "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, "kind": "str", - "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "false"}, "name": "str", - "networkACLs": { - "defaultAction": "str", - "ipRules": [{"action": "str", "value": "str"}], - "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], - "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + "properties": { + "applicationFirewall": { + "clientConnectionCountRules": ["client_connection_count_rule"], + "clientTrafficControlRules": ["client_traffic_control_rule"], + "maxClientConnectionLifetimeInSeconds": 0, + }, + "disableAadAuth": bool, + "disableLocalAuth": bool, + "externalIP": "str", + "hostName": "str", + "hostNamePrefix": "str", + "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "str"}, + "networkACLs": { + "defaultAction": "str", + "ipRules": [{"action": "str", "value": "str"}], + "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], + "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + }, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "publicPort": 0, + "regionEndpointEnabled": "str", + "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, + "resourceStopped": "str", + "serverPort": 0, + "sharedPrivateLinkResources": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "fqdns": ["str"], + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "socketIO": {"serviceMode": "str"}, + "tls": {"clientCertEnabled": bool}, + "version": "str", }, - "privateEndpointConnections": [ - { - "groupIds": ["str"], - "id": "str", - "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", - }, - "provisioningState": "str", - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - } - ], - "provisioningState": "str", - "publicNetworkAccess": "Enabled", - "publicPort": 0, - "regionEndpointEnabled": "Enabled", - "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, - "resourceStopped": "false", - "serverPort": 0, - "sharedPrivateLinkResources": [ - { - "groupId": "str", - "id": "str", - "name": "str", - "privateLinkResourceId": "str", - "provisioningState": "str", - "requestMessage": "str", - "status": "str", - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - } - ], "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "socketIO": {"serviceMode": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -265,11 +244,8 @@ def test_begin_update(self, resource_group): "lastModifiedByType": "str", }, "tags": {"str": "str"}, - "tls": {"clientCertEnabled": False}, "type": "str", - "version": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -277,11 +253,39 @@ def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_keys(self, resource_group): + def test_web_pub_sub_begin_delete(self, resource_group): + response = self.client.web_pub_sub.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_list_by_resource_group(self, resource_group): + response = self.client.web_pub_sub.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_list_by_subscription(self, resource_group): + response = self.client.web_pub_sub.list_by_subscription() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_list_keys(self, resource_group): response = self.client.web_pub_sub.list_keys( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -289,12 +293,11 @@ def test_list_keys(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_regenerate_key(self, resource_group): + def test_web_pub_sub_begin_regenerate_key(self, resource_group): response = self.client.web_pub_sub.begin_regenerate_key( resource_group_name=resource_group.name, resource_name="str", parameters={"keyType": "str"}, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -302,36 +305,44 @@ def test_begin_regenerate_key(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_replica_skus(self, resource_group): - response = self.client.web_pub_sub.list_replica_skus( + def test_web_pub_sub_begin_restart(self, resource_group): + response = self.client.web_pub_sub.begin_restart( resource_group_name=resource_group.name, resource_name="str", - replica_name="str", - api_version="2024-03-01", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_restart(self, resource_group): - response = self.client.web_pub_sub.begin_restart( + def test_web_pub_sub_list_skus(self, resource_group): + response = self.client.web_pub_sub.list_skus( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_skus(self, resource_group): - response = self.client.web_pub_sub.list_skus( + def test_web_pub_sub_list_replica_skus(self, resource_group): + response = self.client.web_pub_sub.list_replica_skus( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", + replica_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_check_name_availability(self, resource_group): + response = self.client.web_pub_sub.check_name_availability( + location="str", + parameters={"name": "str", "type": "str"}, ) # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_operations_async.py index 48e585c0716a..59dbbc919532 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,44 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_check_name_availability(self, resource_group): - response = await self.client.web_pub_sub.check_name_availability( - location="str", - parameters={"name": "str", "type": "str"}, - api_version="2024-03-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_list_by_subscription(self, resource_group): - response = self.client.web_pub_sub.list_by_subscription( - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_list_by_resource_group(self, resource_group): - response = self.client.web_pub_sub.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_web_pub_sub_get(self, resource_group): response = await self.client.web_pub_sub.get( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -66,18 +32,13 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_web_pub_sub_begin_create_or_update(self, resource_group): response = await ( await self.client.web_pub_sub.begin_create_or_update( resource_group_name=resource_group.name, resource_name="str", parameters={ "location": "str", - "disableAadAuth": False, - "disableLocalAuth": False, - "externalIP": "str", - "hostName": "str", - "hostNamePrefix": "str", "id": "str", "identity": { "principalId": "str", @@ -86,66 +47,85 @@ async def test_begin_create_or_update(self, resource_group): "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, "kind": "str", - "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "false"}, "name": "str", - "networkACLs": { - "defaultAction": "str", - "ipRules": [{"action": "str", "value": "str"}], - "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], - "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + "properties": { + "applicationFirewall": { + "clientConnectionCountRules": ["client_connection_count_rule"], + "clientTrafficControlRules": ["client_traffic_control_rule"], + "maxClientConnectionLifetimeInSeconds": 0, + }, + "disableAadAuth": bool, + "disableLocalAuth": bool, + "externalIP": "str", + "hostName": "str", + "hostNamePrefix": "str", + "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "str"}, + "networkACLs": { + "defaultAction": "str", + "ipRules": [{"action": "str", "value": "str"}], + "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], + "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + }, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "publicPort": 0, + "regionEndpointEnabled": "str", + "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, + "resourceStopped": "str", + "serverPort": 0, + "sharedPrivateLinkResources": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "fqdns": ["str"], + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "socketIO": {"serviceMode": "str"}, + "tls": {"clientCertEnabled": bool}, + "version": "str", }, - "privateEndpointConnections": [ - { - "groupIds": ["str"], - "id": "str", - "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", - }, - "provisioningState": "str", - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - } - ], - "provisioningState": "str", - "publicNetworkAccess": "Enabled", - "publicPort": 0, - "regionEndpointEnabled": "Enabled", - "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, - "resourceStopped": "false", - "serverPort": 0, - "sharedPrivateLinkResources": [ - { - "groupId": "str", - "id": "str", - "name": "str", - "privateLinkResourceId": "str", - "provisioningState": "str", - "requestMessage": "str", - "status": "str", - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - } - ], "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "socketIO": {"serviceMode": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -155,25 +135,8 @@ async def test_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "tags": {"str": "str"}, - "tls": {"clientCertEnabled": False}, "type": "str", - "version": "str", }, - api_version="2024-03-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): - response = await ( - await self.client.web_pub_sub.begin_delete( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -182,18 +145,13 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_update(self, resource_group): + async def test_web_pub_sub_begin_update(self, resource_group): response = await ( await self.client.web_pub_sub.begin_update( resource_group_name=resource_group.name, resource_name="str", parameters={ "location": "str", - "disableAadAuth": False, - "disableLocalAuth": False, - "externalIP": "str", - "hostName": "str", - "hostNamePrefix": "str", "id": "str", "identity": { "principalId": "str", @@ -202,66 +160,85 @@ async def test_begin_update(self, resource_group): "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, "kind": "str", - "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "false"}, "name": "str", - "networkACLs": { - "defaultAction": "str", - "ipRules": [{"action": "str", "value": "str"}], - "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], - "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + "properties": { + "applicationFirewall": { + "clientConnectionCountRules": ["client_connection_count_rule"], + "clientTrafficControlRules": ["client_traffic_control_rule"], + "maxClientConnectionLifetimeInSeconds": 0, + }, + "disableAadAuth": bool, + "disableLocalAuth": bool, + "externalIP": "str", + "hostName": "str", + "hostNamePrefix": "str", + "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "str"}, + "networkACLs": { + "defaultAction": "str", + "ipRules": [{"action": "str", "value": "str"}], + "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], + "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + }, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "publicPort": 0, + "regionEndpointEnabled": "str", + "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, + "resourceStopped": "str", + "serverPort": 0, + "sharedPrivateLinkResources": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "fqdns": ["str"], + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "socketIO": {"serviceMode": "str"}, + "tls": {"clientCertEnabled": bool}, + "version": "str", }, - "privateEndpointConnections": [ - { - "groupIds": ["str"], - "id": "str", - "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", - }, - "provisioningState": "str", - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - } - ], - "provisioningState": "str", - "publicNetworkAccess": "Enabled", - "publicPort": 0, - "regionEndpointEnabled": "Enabled", - "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, - "resourceStopped": "false", - "serverPort": 0, - "sharedPrivateLinkResources": [ - { - "groupId": "str", - "id": "str", - "name": "str", - "privateLinkResourceId": "str", - "provisioningState": "str", - "requestMessage": "str", - "status": "str", - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - } - ], "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "socketIO": {"serviceMode": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -271,11 +248,8 @@ async def test_begin_update(self, resource_group): "lastModifiedByType": "str", }, "tags": {"str": "str"}, - "tls": {"clientCertEnabled": False}, "type": "str", - "version": "str", }, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -284,11 +258,41 @@ async def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_keys(self, resource_group): + async def test_web_pub_sub_begin_delete(self, resource_group): + response = await ( + await self.client.web_pub_sub.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_list_by_resource_group(self, resource_group): + response = self.client.web_pub_sub.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_list_by_subscription(self, resource_group): + response = self.client.web_pub_sub.list_by_subscription() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_list_keys(self, resource_group): response = await self.client.web_pub_sub.list_keys( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -296,13 +300,12 @@ async def test_list_keys(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_regenerate_key(self, resource_group): + async def test_web_pub_sub_begin_regenerate_key(self, resource_group): response = await ( await self.client.web_pub_sub.begin_regenerate_key( resource_group_name=resource_group.name, resource_name="str", parameters={"keyType": "str"}, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -311,25 +314,11 @@ async def test_begin_regenerate_key(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_replica_skus(self, resource_group): - response = await self.client.web_pub_sub.list_replica_skus( - resource_group_name=resource_group.name, - resource_name="str", - replica_name="str", - api_version="2024-03-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_begin_restart(self, resource_group): + async def test_web_pub_sub_begin_restart(self, resource_group): response = await ( await self.client.web_pub_sub.begin_restart( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -338,11 +327,33 @@ async def test_begin_restart(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_skus(self, resource_group): + async def test_web_pub_sub_list_skus(self, resource_group): response = await self.client.web_pub_sub.list_skus( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_list_replica_skus(self, resource_group): + response = await self.client.web_pub_sub.list_replica_skus( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_check_name_availability(self, resource_group): + response = await self.client.web_pub_sub.check_name_availability( + location="str", + parameters={"name": "str", "type": "str"}, ) # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_persistent_storages_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_persistent_storages_operations.py new file mode 100644 index 000000000000..8a816aa21df8 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_persistent_storages_operations.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.webpubsub import WebPubSubManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestWebPubSubManagementWebPubSubPersistentStoragesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(WebPubSubManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_persistent_storages_get(self, resource_group): + response = self.client.web_pub_sub_persistent_storages.get( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_persistent_storages_begin_create_or_update(self, resource_group): + response = self.client.web_pub_sub_persistent_storages.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + parameters={ + "properties": {"storageAccount": {"id": "str"}, "provisioningState": "str"}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_persistent_storages_begin_delete(self, resource_group): + response = self.client.web_pub_sub_persistent_storages.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_persistent_storages_list(self, resource_group): + response = self.client.web_pub_sub_persistent_storages.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_persistent_storages_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_persistent_storages_operations_async.py new file mode 100644 index 000000000000..1cf2f576a7e6 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_persistent_storages_operations_async.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.webpubsub.aio import WebPubSubManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestWebPubSubManagementWebPubSubPersistentStoragesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(WebPubSubManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_persistent_storages_get(self, resource_group): + response = await self.client.web_pub_sub_persistent_storages.get( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_persistent_storages_begin_create_or_update(self, resource_group): + response = await ( + await self.client.web_pub_sub_persistent_storages.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + parameters={ + "properties": {"storageAccount": {"id": "str"}, "provisioningState": "str"}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_persistent_storages_begin_delete(self, resource_group): + response = await ( + await self.client.web_pub_sub_persistent_storages.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_persistent_storages_list(self, resource_group): + response = self.client.web_pub_sub_persistent_storages.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_endpoint_connections_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_endpoint_connections_operations.py index dbc3522f1f97..774b8dfb9018 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_endpoint_connections_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_endpoint_connections_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): - response = self.client.web_pub_sub_private_endpoint_connections.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_get(self, resource_group): + def test_web_pub_sub_private_endpoint_connections_get(self, resource_group): response = self.client.web_pub_sub_private_endpoint_connections.get( private_endpoint_connection_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -45,18 +32,24 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_update(self, resource_group): + def test_web_pub_sub_private_endpoint_connections_update(self, resource_group): response = self.client.web_pub_sub_private_endpoint_connections.update( private_endpoint_connection_name="str", resource_group_name=resource_group.name, resource_name="str", parameters={ - "groupIds": ["str"], "id": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, - "provisioningState": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -67,7 +60,6 @@ def test_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -75,13 +67,23 @@ def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_web_pub_sub_private_endpoint_connections_begin_delete(self, resource_group): response = self.client.web_pub_sub_private_endpoint_connections.begin_delete( private_endpoint_connection_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_private_endpoint_connections_list(self, resource_group): + response = self.client.web_pub_sub_private_endpoint_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_endpoint_connections_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_endpoint_connections_operations_async.py index 0b459698af82..a0f9be1e6616 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_endpoint_connections_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_endpoint_connections_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): - response = self.client.web_pub_sub_private_endpoint_connections.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_web_pub_sub_private_endpoint_connections_get(self, resource_group): response = await self.client.web_pub_sub_private_endpoint_connections.get( private_endpoint_connection_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -46,18 +33,24 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_update(self, resource_group): + async def test_web_pub_sub_private_endpoint_connections_update(self, resource_group): response = await self.client.web_pub_sub_private_endpoint_connections.update( private_endpoint_connection_name="str", resource_group_name=resource_group.name, resource_name="str", parameters={ - "groupIds": ["str"], "id": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, - "provisioningState": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -68,7 +61,6 @@ async def test_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -76,15 +68,25 @@ async def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_web_pub_sub_private_endpoint_connections_begin_delete(self, resource_group): response = await ( await self.client.web_pub_sub_private_endpoint_connections.begin_delete( private_endpoint_connection_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_private_endpoint_connections_list(self, resource_group): + response = self.client.web_pub_sub_private_endpoint_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_link_resources_operations.py index 38818fa33d8e..99bf6eb0e54f 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_link_resources_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_link_resources_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,11 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_web_pub_sub_private_link_resources_list(self, resource_group): response = self.client.web_pub_sub_private_link_resources.list( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_link_resources_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_link_resources_operations_async.py index 8692764d3650..544129e1f1c5 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_link_resources_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_private_link_resources_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,11 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_web_pub_sub_private_link_resources_list(self, resource_group): response = self.client.web_pub_sub_private_link_resources.list( resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replica_shared_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replica_shared_private_link_resources_operations.py index 274b2e6e4a98..32680ceb174e 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replica_shared_private_link_resources_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replica_shared_private_link_resources_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): - response = self.client.web_pub_sub_replica_shared_private_link_resources.list( - resource_group_name=resource_group.name, - resource_name="str", - replica_name="str", - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_get(self, resource_group): + def test_web_pub_sub_replica_shared_private_link_resources_get(self, resource_group): response = self.client.web_pub_sub_replica_shared_private_link_resources.get( resource_group_name=resource_group.name, resource_name="str", replica_name="str", shared_private_link_resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -47,20 +33,23 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_web_pub_sub_replica_shared_private_link_resources_begin_create_or_update(self, resource_group): response = self.client.web_pub_sub_replica_shared_private_link_resources.begin_create_or_update( resource_group_name=resource_group.name, resource_name="str", replica_name="str", shared_private_link_resource_name="str", parameters={ - "groupId": "str", "id": "str", "name": "str", - "privateLinkResourceId": "str", - "provisioningState": "str", - "requestMessage": "str", - "status": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "fqdns": ["str"], + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -71,8 +60,19 @@ def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_replica_shared_private_link_resources_list(self, resource_group): + response = self.client.web_pub_sub_replica_shared_private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replica_shared_private_link_resources_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replica_shared_private_link_resources_operations_async.py index e1f896ebc5d2..758c9e582fe4 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replica_shared_private_link_resources_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replica_shared_private_link_resources_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): - response = self.client.web_pub_sub_replica_shared_private_link_resources.list( - resource_group_name=resource_group.name, - resource_name="str", - replica_name="str", - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_web_pub_sub_replica_shared_private_link_resources_get(self, resource_group): response = await self.client.web_pub_sub_replica_shared_private_link_resources.get( resource_group_name=resource_group.name, resource_name="str", replica_name="str", shared_private_link_resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -48,7 +34,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_web_pub_sub_replica_shared_private_link_resources_begin_create_or_update(self, resource_group): response = await ( await self.client.web_pub_sub_replica_shared_private_link_resources.begin_create_or_update( resource_group_name=resource_group.name, @@ -56,13 +42,16 @@ async def test_begin_create_or_update(self, resource_group): replica_name="str", shared_private_link_resource_name="str", parameters={ - "groupId": "str", "id": "str", "name": "str", - "privateLinkResourceId": "str", - "provisioningState": "str", - "requestMessage": "str", - "status": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "fqdns": ["str"], + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -73,9 +62,20 @@ async def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_replica_shared_private_link_resources_list(self, resource_group): + response = self.client.web_pub_sub_replica_shared_private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replicas_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replicas_operations.py index 46dd50093229..a65f63ca193c 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replicas_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replicas_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): - response = self.client.web_pub_sub_replicas.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_get(self, resource_group): + def test_web_pub_sub_replicas_get(self, resource_group): response = self.client.web_pub_sub_replicas.get( resource_group_name=resource_group.name, resource_name="str", replica_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -45,7 +32,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_web_pub_sub_replicas_begin_create_or_update(self, resource_group): response = self.client.web_pub_sub_replicas.begin_create_or_update( resource_group_name=resource_group.name, resource_name="str", @@ -54,9 +41,7 @@ def test_begin_create_or_update(self, resource_group): "location": "str", "id": "str", "name": "str", - "provisioningState": "str", - "regionEndpointEnabled": "Enabled", - "resourceStopped": "false", + "properties": {"provisioningState": "str", "regionEndpointEnabled": "str", "resourceStopped": "str"}, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", @@ -69,7 +54,6 @@ def test_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -77,20 +61,7 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delete(self, resource_group): - response = self.client.web_pub_sub_replicas.delete( - resource_group_name=resource_group.name, - resource_name="str", - replica_name="str", - api_version="2024-03-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_begin_update(self, resource_group): + def test_web_pub_sub_replicas_begin_update(self, resource_group): response = self.client.web_pub_sub_replicas.begin_update( resource_group_name=resource_group.name, resource_name="str", @@ -99,9 +70,7 @@ def test_begin_update(self, resource_group): "location": "str", "id": "str", "name": "str", - "provisioningState": "str", - "regionEndpointEnabled": "Enabled", - "resourceStopped": "false", + "properties": {"provisioningState": "str", "regionEndpointEnabled": "str", "resourceStopped": "str"}, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", @@ -114,7 +83,6 @@ def test_begin_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -122,12 +90,34 @@ def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_restart(self, resource_group): + def test_web_pub_sub_replicas_delete(self, resource_group): + response = self.client.web_pub_sub_replicas.delete( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_replicas_list(self, resource_group): + response = self.client.web_pub_sub_replicas.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_replicas_begin_restart(self, resource_group): response = self.client.web_pub_sub_replicas.begin_restart( resource_group_name=resource_group.name, resource_name="str", replica_name="str", - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replicas_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replicas_operations_async.py index ef965f81e60d..58975fac3f6d 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replicas_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_replicas_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): - response = self.client.web_pub_sub_replicas.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_web_pub_sub_replicas_get(self, resource_group): response = await self.client.web_pub_sub_replicas.get( resource_group_name=resource_group.name, resource_name="str", replica_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -46,7 +33,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_web_pub_sub_replicas_begin_create_or_update(self, resource_group): response = await ( await self.client.web_pub_sub_replicas.begin_create_or_update( resource_group_name=resource_group.name, @@ -56,9 +43,11 @@ async def test_begin_create_or_update(self, resource_group): "location": "str", "id": "str", "name": "str", - "provisioningState": "str", - "regionEndpointEnabled": "Enabled", - "resourceStopped": "false", + "properties": { + "provisioningState": "str", + "regionEndpointEnabled": "str", + "resourceStopped": "str", + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", @@ -71,7 +60,6 @@ async def test_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -80,20 +68,7 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delete(self, resource_group): - response = await self.client.web_pub_sub_replicas.delete( - resource_group_name=resource_group.name, - resource_name="str", - replica_name="str", - api_version="2024-03-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_begin_update(self, resource_group): + async def test_web_pub_sub_replicas_begin_update(self, resource_group): response = await ( await self.client.web_pub_sub_replicas.begin_update( resource_group_name=resource_group.name, @@ -103,9 +78,11 @@ async def test_begin_update(self, resource_group): "location": "str", "id": "str", "name": "str", - "provisioningState": "str", - "regionEndpointEnabled": "Enabled", - "resourceStopped": "false", + "properties": { + "provisioningState": "str", + "regionEndpointEnabled": "str", + "resourceStopped": "str", + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", @@ -118,7 +95,6 @@ async def test_begin_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -127,13 +103,35 @@ async def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_restart(self, resource_group): + async def test_web_pub_sub_replicas_delete(self, resource_group): + response = await self.client.web_pub_sub_replicas.delete( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_replicas_list(self, resource_group): + response = self.client.web_pub_sub_replicas.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_replicas_begin_restart(self, resource_group): response = await ( await self.client.web_pub_sub_replicas.begin_restart( resource_group_name=resource_group.name, resource_name="str", replica_name="str", - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_shared_private_link_resources_operations.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_shared_private_link_resources_operations.py index 17b5b9616e4d..ea310fe2bf9f 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_shared_private_link_resources_operations.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_shared_private_link_resources_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): - response = self.client.web_pub_sub_shared_private_link_resources.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_get(self, resource_group): + def test_web_pub_sub_shared_private_link_resources_get(self, resource_group): response = self.client.web_pub_sub_shared_private_link_resources.get( shared_private_link_resource_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -45,19 +32,22 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_web_pub_sub_shared_private_link_resources_begin_create_or_update(self, resource_group): response = self.client.web_pub_sub_shared_private_link_resources.begin_create_or_update( shared_private_link_resource_name="str", resource_group_name=resource_group.name, resource_name="str", parameters={ - "groupId": "str", "id": "str", "name": "str", - "privateLinkResourceId": "str", - "provisioningState": "str", - "requestMessage": "str", - "status": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "fqdns": ["str"], + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -68,7 +58,6 @@ def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -76,13 +65,23 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_web_pub_sub_shared_private_link_resources_begin_delete(self, resource_group): response = self.client.web_pub_sub_shared_private_link_resources.begin_delete( shared_private_link_resource_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_web_pub_sub_shared_private_link_resources_list(self, resource_group): + response = self.client.web_pub_sub_shared_private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_shared_private_link_resources_operations_async.py b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_shared_private_link_resources_operations_async.py index 1e3966dbc327..818928c592fb 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_shared_private_link_resources_operations_async.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/generated_tests/test_web_pub_sub_management_web_pub_sub_shared_private_link_resources_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): - response = self.client.web_pub_sub_shared_private_link_resources.list( - resource_group_name=resource_group.name, - resource_name="str", - api_version="2024-03-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_web_pub_sub_shared_private_link_resources_get(self, resource_group): response = await self.client.web_pub_sub_shared_private_link_resources.get( shared_private_link_resource_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) # please add some check logic here by yourself @@ -46,20 +33,23 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_web_pub_sub_shared_private_link_resources_begin_create_or_update(self, resource_group): response = await ( await self.client.web_pub_sub_shared_private_link_resources.begin_create_or_update( shared_private_link_resource_name="str", resource_group_name=resource_group.name, resource_name="str", parameters={ - "groupId": "str", "id": "str", "name": "str", - "privateLinkResourceId": "str", - "provisioningState": "str", - "requestMessage": "str", - "status": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "fqdns": ["str"], + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -70,7 +60,6 @@ async def test_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result @@ -79,15 +68,25 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_web_pub_sub_shared_private_link_resources_begin_delete(self, resource_group): response = await ( await self.client.web_pub_sub_shared_private_link_resources.begin_delete( shared_private_link_resource_name="str", resource_group_name=resource_group.name, resource_name="str", - api_version="2024-03-01", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_web_pub_sub_shared_private_link_resources_list(self, resource_group): + response = self.client.web_pub_sub_shared_private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/pyproject.toml b/sdk/webpubsub/azure-mgmt-webpubsub/pyproject.toml index 540da07d41af..ea794fc90250 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/pyproject.toml +++ b/sdk/webpubsub/azure-mgmt-webpubsub/pyproject.toml @@ -1,6 +1,88 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-webpubsub" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Webpubsub Management Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +requires-python = ">=3.10" +keywords = [ + "azure", + "azure sdk", +] +dependencies = [ + "isodate>=0.6.1", + "azure-mgmt-core>=1.6.0", + "typing-extensions>=4.6.0", +] +dynamic = [ + "version", + "readme", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic.version] +attr = "azure.mgmt.webpubsub._version.VERSION" + +[tool.setuptools.dynamic.readme] +file = [ + "README.md", + "CHANGELOG.md", +] +content-type = "text/markdown" + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.mgmt", +] + +[tool.setuptools.package-data] +pytyped = [ + "py.typed", +] + [tool.azure-sdk-build] breaking = false mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-webpubsub" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "WebPubSub Management" +package_doc_id = "" +is_stable = false +is_arm = true +title = "WebPubSubManagementClient" +need_msrestazure = false +need_azuremgmtcore = true +sample_link = "" +exclude_folders = "" diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/sdk_packaging.toml b/sdk/webpubsub/azure-mgmt-webpubsub/sdk_packaging.toml deleted file mode 100644 index 987188e6f4b4..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/sdk_packaging.toml +++ /dev/null @@ -1,8 +0,0 @@ -[packaging] -package_name = "azure-mgmt-webpubsub" -package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "WebPubSub Management" -package_doc_id = "" -is_stable = true -is_arm = true -title = "WebPubSubManagementClient" diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/setup.py b/sdk/webpubsub/azure-mgmt-webpubsub/setup.py deleted file mode 100644 index 11a667e33935..000000000000 --- a/sdk/webpubsub/azure-mgmt-webpubsub/setup.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -import re -import os.path -from io import open -from setuptools import find_packages, setup - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-mgmt-webpubsub" -PACKAGE_PPRINT_NAME = "WebPubSub Management" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") - -# Version extraction inspired from 'requests' -with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), - "r", -) as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -with open("README.md", encoding="utf-8") as f: - readme = f.read() -with open("CHANGELOG.md", encoding="utf-8") as f: - changelog = f.read() - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=readme + "\n\n" + changelog, - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.mgmt", - ] - ), - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "typing-extensions>=4.6.0", - "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", - ], - python_requires=">=3.8", -) diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_operations_async_test.py b/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_operations_async_test.py index faa0f9666a48..896be90fa867 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_operations_async_test.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_operations_async_test.py @@ -25,4 +25,3 @@ async def test_list(self, resource_group): response = self.client.operations.list() result = [r async for r in response] assert result - diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_operations_test.py b/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_operations_test.py index 6ea3dd12ab28..1b3c30791c78 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_operations_test.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_operations_test.py @@ -24,4 +24,3 @@ def test_list(self, resource_group): response = self.client.operations.list() result = [r for r in response] assert result - diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_web_pub_sub_operations_async_test.py b/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_web_pub_sub_operations_async_test.py index cf2e31d1b5b3..1258f9566bc5 100644 --- a/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_web_pub_sub_operations_async_test.py +++ b/sdk/webpubsub/azure-mgmt-webpubsub/tests/test_web_pub_sub_management_web_pub_sub_operations_async_test.py @@ -17,7 +17,7 @@ @pytest.mark.live_test_only class TestWebPubSubManagementWebPubSubOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.client = self.create_mgmt_client(WebPubSubManagementClient, is_async=True) + self.client = self.create_mgmt_client(WebPubSubManagementClient, is_async=True) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async @@ -27,4 +27,3 @@ async def test_list_by_resource_group(self, resource_group): ) result = [r async for r in response] assert result == [] - \ No newline at end of file diff --git a/sdk/webpubsub/azure-mgmt-webpubsub/tsp-location.yaml b/sdk/webpubsub/azure-mgmt-webpubsub/tsp-location.yaml new file mode 100644 index 000000000000..908da962e827 --- /dev/null +++ b/sdk/webpubsub/azure-mgmt-webpubsub/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/webpubsub/resource-manager/Microsoft.SignalRService/SignalRService +commit: a7bdbe741c0ef1f1b159d8569b173757bd823ae9 +repo: Azure/azure-rest-api-specs +additionalDirectories: