From e3745a6939333dd794d5b8cbc3ecdda7b6016206 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 9 Nov 2023 22:26:19 +0000 Subject: [PATCH] CodeGen from PR 26638 in Azure/azure-rest-api-specs Merge f9dca7781bdde443bce5eb3473c0412633050ffd into 000a628a549b6a6060b2f88326acb0a3a096ae3d --- .../azure-mgmt-communication/_meta.json | 4 +- ...communication_service_management_client.py | 17 +- .../mgmt/communication/_configuration.py | 4 +- .../azure/mgmt/communication/_version.py | 2 +- ...communication_service_management_client.py | 17 +- .../mgmt/communication/aio/_configuration.py | 4 +- .../communication/aio/operations/__init__.py | 4 + .../_suppression_list_addresses_operations.py | 510 +++++++++++++ .../_suppression_lists_operations.py | 487 ++++++++++++ .../mgmt/communication/models/__init__.py | 8 + .../mgmt/communication/models/_models_py3.py | 211 +++++ .../mgmt/communication/operations/__init__.py | 4 + .../_communication_services_operations.py | 20 +- .../operations/_domains_operations.py | 14 +- .../operations/_email_services_operations.py | 14 +- .../communication/operations/_operations.py | 2 +- .../_sender_usernames_operations.py | 8 +- .../_suppression_list_addresses_operations.py | 718 ++++++++++++++++++ .../_suppression_lists_operations.py | 669 ++++++++++++++++ .../check_name_availability_available.py | 2 +- .../check_name_availability_unavailable.py | 2 +- .../create_or_update.py | 2 +- ...or_update_with_system_assigned_identity.py | 2 +- .../communication_services/delete.py | 2 +- .../communication_services/get.py | 2 +- .../link_notification_hub.py | 2 +- .../list_by_resource_group.py | 2 +- .../list_by_subscription.py | 2 +- .../communication_services/list_keys.py | 2 +- .../communication_services/operations_list.py | 2 +- .../communication_services/regenerate_key.py | 2 +- .../communication_services/update.py | 4 +- .../update_remove_system_identity.py | 4 +- .../update_with_system_and_user_identity.py | 2 +- .../update_with_system_assigned_identity.py | 2 +- .../update_with_user_assigned_identity.py | 2 +- .../domains/cancel_verification.py | 2 +- .../domains/create_or_update.py | 2 +- .../generated_samples/domains/delete.py | 2 +- .../generated_samples/domains/get.py | 2 +- .../domains/initiate_verification.py | 2 +- .../domains/list_by_email_service.py | 2 +- .../generated_samples/domains/update.py | 2 +- .../email_services/create_or_update.py | 2 +- .../email_services/delete.py | 2 +- .../generated_samples/email_services/get.py | 2 +- .../get_verified_exchange_online_domains.py | 2 +- .../email_services/list_by_resource_group.py | 2 +- .../email_services/list_by_subscription.py | 2 +- .../email_services/update.py | 2 +- .../sender_usernames/create_or_update.py | 2 +- .../sender_usernames/delete.py | 2 +- .../generated_samples/sender_usernames/get.py | 2 +- .../sender_usernames/list_by_domain.py | 2 +- .../create_or_update_address.py | 45 ++ .../create_or_update_suppression_list.py | 44 ++ .../suppression_lists/delete_address.py | 43 ++ .../delete_suppression_list.py | 42 + .../suppression_lists/get_address.py | 44 ++ .../suppression_lists/get_addresses.py | 44 ++ .../suppression_lists/get_suppression_list.py | 43 ++ .../get_suppression_lists.py | 43 ++ 62 files changed, 3062 insertions(+), 77 deletions(-) create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/_suppression_list_addresses_operations.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/_suppression_lists_operations.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_suppression_list_addresses_operations.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_suppression_lists_operations.py create mode 100644 sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/create_or_update_address.py create mode 100644 sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/create_or_update_suppression_list.py create mode 100644 sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/delete_address.py create mode 100644 sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/delete_suppression_list.py create mode 100644 sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_address.py create mode 100644 sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_addresses.py create mode 100644 sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_suppression_list.py create mode 100644 sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_suppression_lists.py diff --git a/sdk/communication/azure-mgmt-communication/_meta.json b/sdk/communication/azure-mgmt-communication/_meta.json index 4bab6980afc1..f300b30fed34 100644 --- a/sdk/communication/azure-mgmt-communication/_meta.json +++ b/sdk/communication/azure-mgmt-communication/_meta.json @@ -1,11 +1,11 @@ { - "commit": "5dd1107d5f2be8d600325d795450e1d854fbe7e8", + "commit": "410af06116dc5ca3e1cf06c12603af2e3b2bbfb8", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.7", "use": [ "@autorest/python@6.7.1", "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/communication/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/communication/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/communication/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_communication_service_management_client.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_communication_service_management_client.py index 5c5ac9871bab..8b3cf667b4c3 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_communication_service_management_client.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_communication_service_management_client.py @@ -21,6 +21,8 @@ EmailServicesOperations, Operations, SenderUsernamesOperations, + SuppressionListAddressesOperations, + SuppressionListsOperations, ) if TYPE_CHECKING: @@ -28,7 +30,7 @@ from azure.core.credentials import TokenCredential -class CommunicationServiceManagementClient: # pylint: disable=client-accepts-api-version-keyword +class CommunicationServiceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Communication Services. :ivar operations: Operations operations @@ -42,13 +44,18 @@ class CommunicationServiceManagementClient: # pylint: disable=client-accepts-ap :vartype email_services: azure.mgmt.communication.operations.EmailServicesOperations :ivar sender_usernames: SenderUsernamesOperations operations :vartype sender_usernames: azure.mgmt.communication.operations.SenderUsernamesOperations + :ivar suppression_lists: SuppressionListsOperations operations + :vartype suppression_lists: azure.mgmt.communication.operations.SuppressionListsOperations + :ivar suppression_list_addresses: SuppressionListAddressesOperations operations + :vartype suppression_list_addresses: + azure.mgmt.communication.operations.SuppressionListAddressesOperations :param credential: Credential needed for the client to connect to Azure. 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". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-04-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-06-01-preview". 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 @@ -80,6 +87,12 @@ def __init__( self.sender_usernames = SenderUsernamesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.suppression_lists = SuppressionListsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.suppression_list_addresses = SuppressionListAddressesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_configuration.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_configuration.py index 8a706723cb19..33e8a142c82a 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_configuration.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_configuration.py @@ -29,14 +29,14 @@ class CommunicationServiceManagementClientConfiguration(Configuration): # pylin :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 "2023-04-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-06-01-preview". 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: super(CommunicationServiceManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-04-01-preview") + api_version: str = kwargs.pop("api_version", "2023-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_version.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_version.py index b82e03a368ff..c47f66669f1b 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_version.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0b1" +VERSION = "1.0.0" diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/_communication_service_management_client.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/_communication_service_management_client.py index a1bac0b3b608..b550edc92634 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/_communication_service_management_client.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/_communication_service_management_client.py @@ -21,6 +21,8 @@ EmailServicesOperations, Operations, SenderUsernamesOperations, + SuppressionListAddressesOperations, + SuppressionListsOperations, ) if TYPE_CHECKING: @@ -28,7 +30,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class CommunicationServiceManagementClient: # pylint: disable=client-accepts-api-version-keyword +class CommunicationServiceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure Communication Services. :ivar operations: Operations operations @@ -42,13 +44,18 @@ class CommunicationServiceManagementClient: # pylint: disable=client-accepts-ap :vartype email_services: azure.mgmt.communication.aio.operations.EmailServicesOperations :ivar sender_usernames: SenderUsernamesOperations operations :vartype sender_usernames: azure.mgmt.communication.aio.operations.SenderUsernamesOperations + :ivar suppression_lists: SuppressionListsOperations operations + :vartype suppression_lists: azure.mgmt.communication.aio.operations.SuppressionListsOperations + :ivar suppression_list_addresses: SuppressionListAddressesOperations operations + :vartype suppression_list_addresses: + azure.mgmt.communication.aio.operations.SuppressionListAddressesOperations :param credential: Credential needed for the client to connect to Azure. 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". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-04-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-06-01-preview". 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 @@ -80,6 +87,12 @@ def __init__( self.sender_usernames = SenderUsernamesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.suppression_lists = SuppressionListsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.suppression_list_addresses = SuppressionListAddressesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/_configuration.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/_configuration.py index 55cc732782c5..523d99eb566a 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/_configuration.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/_configuration.py @@ -29,14 +29,14 @@ class CommunicationServiceManagementClientConfiguration(Configuration): # pylin :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 "2023-04-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-06-01-preview". 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: super(CommunicationServiceManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-04-01-preview") + api_version: str = kwargs.pop("api_version", "2023-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/__init__.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/__init__.py index 0c55fb0d31b2..205d6b40ef33 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/__init__.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/__init__.py @@ -11,6 +11,8 @@ from ._domains_operations import DomainsOperations from ._email_services_operations import EmailServicesOperations from ._sender_usernames_operations import SenderUsernamesOperations +from ._suppression_lists_operations import SuppressionListsOperations +from ._suppression_list_addresses_operations import SuppressionListAddressesOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -22,6 +24,8 @@ "DomainsOperations", "EmailServicesOperations", "SenderUsernamesOperations", + "SuppressionListsOperations", + "SuppressionListAddressesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/_suppression_list_addresses_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/_suppression_list_addresses_operations.py new file mode 100644 index 000000000000..a78858c2164d --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/_suppression_list_addresses_operations.py @@ -0,0 +1,510 @@ +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import 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 ... import models as _models +from ..._vendor import _convert_request +from ...operations._suppression_list_addresses_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SuppressionListAddressesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.communication.aio.CommunicationServiceManagementClient`'s + :attr:`suppression_list_addresses` 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, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.SuppressionListAddressResource"]: + """Get. + + Get all the addresses in a suppression list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SuppressionListAddressResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.communication.models.SuppressionListAddressResource] + :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.SuppressionListAddressResourceCollection] = kwargs.pop("cls", None) + + error_map = { + 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, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SuppressionListAddressResourceCollection", 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) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + **kwargs: Any + ) -> _models.SuppressionListAddressResource: + """Get. + + Get a SuppressionListAddress. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListAddressResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListAddressResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.SuppressionListAddressResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + address_id=address_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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("SuppressionListAddressResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + parameters: _models.SuppressionListAddressResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SuppressionListAddressResource: + """Create Or Update. + + Create or update a SuppressionListAddress. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.communication.models.SuppressionListAddressResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListAddressResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListAddressResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SuppressionListAddressResource: + """Create Or Update. + + Create or update a SuppressionListAddress. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListAddressResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListAddressResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + parameters: Union[_models.SuppressionListAddressResource, IO], + **kwargs: Any + ) -> _models.SuppressionListAddressResource: + """Create Or Update. + + Create or update a SuppressionListAddress. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :param parameters: Parameters for the create or update operation. Is either a + SuppressionListAddressResource type or a IO type. Required. + :type parameters: ~azure.mgmt.communication.models.SuppressionListAddressResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListAddressResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListAddressResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.SuppressionListAddressResource] = 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, "SuppressionListAddressResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + address_id=address_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 201]: + 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 response.status_code == 200: + deserialized = self._deserialize("SuppressionListAddressResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SuppressionListAddressResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + **kwargs: Any + ) -> None: + """Delete. + + Operation to delete a single address from a suppression list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + address_id=address_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}" + } diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/_suppression_lists_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/_suppression_lists_operations.py new file mode 100644 index 000000000000..5cbe49cab7a2 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/aio/operations/_suppression_lists_operations.py @@ -0,0 +1,487 @@ +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import 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 ... import models as _models +from ..._vendor import _convert_request +from ...operations._suppression_lists_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_domain_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SuppressionListsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.communication.aio.CommunicationServiceManagementClient`'s + :attr:`suppression_lists` 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_by_domain( + self, resource_group_name: str, email_service_name: str, domain_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SuppressionListResource"]: + """List. + + List all suppression lists for a domains resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SuppressionListResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.communication.models.SuppressionListResource] + :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.SuppressionListResourceCollection] = kwargs.pop("cls", None) + + error_map = { + 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_domain_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_domain.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SuppressionListResourceCollection", 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) + + list_by_domain.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + **kwargs: Any + ) -> _models.SuppressionListResource: + """Get. + + Get a SuppressionList resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.SuppressionListResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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("SuppressionListResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + parameters: _models.SuppressionListResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SuppressionListResource: + """Create Or Update. + + Add a new SuppressionList resource under the parent Domains resource or update an existing + SuppressionList resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.communication.models.SuppressionListResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SuppressionListResource: + """Create Or Update. + + Add a new SuppressionList resource under the parent Domains resource or update an existing + SuppressionList resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + parameters: Union[_models.SuppressionListResource, IO], + **kwargs: Any + ) -> _models.SuppressionListResource: + """Create Or Update. + + Add a new SuppressionList resource under the parent Domains resource or update an existing + SuppressionList resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param parameters: Parameters for the create or update operation. Is either a + SuppressionListResource type or a IO type. Required. + :type parameters: ~azure.mgmt.communication.models.SuppressionListResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.SuppressionListResource] = 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, "SuppressionListResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 201]: + 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 response.status_code == 200: + deserialized = self._deserialize("SuppressionListResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SuppressionListResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + **kwargs: Any + ) -> None: + """Delete. + + Delete a SuppressionList. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}" + } diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/__init__.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/__init__.py index 26514fd40b00..e0a44cc316e5 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/__init__.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/__init__.py @@ -35,6 +35,10 @@ from ._models_py3 import Resource from ._models_py3 import SenderUsernameResource from ._models_py3 import SenderUsernameResourceCollection +from ._models_py3 import SuppressionListAddressResource +from ._models_py3 import SuppressionListAddressResourceCollection +from ._models_py3 import SuppressionListResource +from ._models_py3 import SuppressionListResourceCollection from ._models_py3 import SystemData from ._models_py3 import TaggedResource from ._models_py3 import TrackedResource @@ -91,6 +95,10 @@ "Resource", "SenderUsernameResource", "SenderUsernameResourceCollection", + "SuppressionListAddressResource", + "SuppressionListAddressResourceCollection", + "SuppressionListResource", + "SuppressionListResourceCollection", "SystemData", "TaggedResource", "TrackedResource", diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models_py3.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models_py3.py index 86f8eec0032b..6b081e912a2a 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models_py3.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models_py3.py @@ -1356,6 +1356,217 @@ def __init__( self.next_link = next_link +class SuppressionListAddressResource(ProxyResource): + """A object that represents a SuppressionList record. + + 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}". + :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.communication.models.SystemData + :ivar email: Email address of the recipient. + :vartype email: str + :ivar first_name: The first name of the email recipient. + :vartype first_name: str + :ivar last_name: The last name of the email recipient. + :vartype last_name: str + :ivar notes: An optional property to provide contextual notes or a description for an address. + :vartype notes: str + :ivar last_modified: The date the address was last updated in a suppression list. + :vartype last_modified: ~datetime.datetime + :ivar data_location: The location where the SuppressionListAddress data is stored at rest. This + value is inherited from the parent Domains resource. + :vartype data_location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified": {"readonly": True}, + "data_location": {"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"}, + "email": {"key": "properties.email", "type": "str"}, + "first_name": {"key": "properties.firstName", "type": "str"}, + "last_name": {"key": "properties.lastName", "type": "str"}, + "notes": {"key": "properties.notes", "type": "str"}, + "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, + "data_location": {"key": "properties.dataLocation", "type": "str"}, + } + + def __init__( + self, + *, + email: Optional[str] = None, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + notes: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword email: Email address of the recipient. + :paramtype email: str + :keyword first_name: The first name of the email recipient. + :paramtype first_name: str + :keyword last_name: The last name of the email recipient. + :paramtype last_name: str + :keyword notes: An optional property to provide contextual notes or a description for an + address. + :paramtype notes: str + """ + super().__init__(**kwargs) + self.email = email + self.first_name = first_name + self.last_name = last_name + self.notes = notes + self.last_modified = None + self.data_location = None + + +class SuppressionListAddressResourceCollection(_serialization.Model): + """Collection of addresses in a suppression list. Response will include a nextLink if response + contains more pages. + + :ivar value: List of suppressed email addresses. + :vartype value: list[~azure.mgmt.communication.models.SuppressionListAddressResource] + :ivar next_link: The URL the client should use to fetch the next page (per server side paging). + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SuppressionListAddressResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SuppressionListAddressResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: List of suppressed email addresses. + :paramtype value: list[~azure.mgmt.communication.models.SuppressionListAddressResource] + :keyword next_link: The URL the client should use to fetch the next page (per server side + paging). + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SuppressionListResource(ProxyResource): + """A class representing a SuppressionList 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}". + :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.communication.models.SystemData + :ivar list_name: The the name of the suppression list. This value must match one of the valid + sender usernames of the sending domain. + :vartype list_name: str + :ivar last_updated_time_stamp: The date the resource was last updated. + :vartype last_updated_time_stamp: str + :ivar created_time_stamp: The date the resource was created. + :vartype created_time_stamp: str + :ivar data_location: The location where the SuppressionListAddress data is stored at rest. This + value is inherited from the parent Domains resource. + :vartype data_location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_updated_time_stamp": {"readonly": True}, + "created_time_stamp": {"readonly": True}, + "data_location": {"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"}, + "list_name": {"key": "properties.listName", "type": "str"}, + "last_updated_time_stamp": {"key": "properties.lastUpdatedTimeStamp", "type": "str"}, + "created_time_stamp": {"key": "properties.createdTimeStamp", "type": "str"}, + "data_location": {"key": "properties.dataLocation", "type": "str"}, + } + + def __init__(self, *, list_name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword list_name: The the name of the suppression list. This value must match one of the + valid sender usernames of the sending domain. + :paramtype list_name: str + """ + super().__init__(**kwargs) + self.list_name = list_name + self.last_updated_time_stamp = None + self.created_time_stamp = None + self.data_location = None + + +class SuppressionListResourceCollection(_serialization.Model): + """A class representing a Domains SuppressionListResource collection. + + :ivar value: List of SuppressionListResource. + :vartype value: list[~azure.mgmt.communication.models.SuppressionListResource] + :ivar next_link: The URL the client should use to fetch the next page (per server side paging). + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SuppressionListResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.SuppressionListResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: List of SuppressionListResource. + :paramtype value: list[~azure.mgmt.communication.models.SuppressionListResource] + :keyword next_link: The URL the client should use to fetch the next page (per server side + paging). + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/__init__.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/__init__.py index 0c55fb0d31b2..205d6b40ef33 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/__init__.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/__init__.py @@ -11,6 +11,8 @@ from ._domains_operations import DomainsOperations from ._email_services_operations import EmailServicesOperations from ._sender_usernames_operations import SenderUsernamesOperations +from ._suppression_lists_operations import SuppressionListsOperations +from ._suppression_list_addresses_operations import SuppressionListAddressesOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -22,6 +24,8 @@ "DomainsOperations", "EmailServicesOperations", "SenderUsernamesOperations", + "SuppressionListsOperations", + "SuppressionListAddressesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_communication_services_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_communication_services_operations.py index cb743ad310d7..0477b09a7664 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_communication_services_operations.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_communication_services_operations.py @@ -43,7 +43,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -74,7 +74,7 @@ def build_link_notification_hub_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -115,7 +115,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -141,7 +141,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -173,7 +173,7 @@ def build_update_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -216,7 +216,7 @@ def build_get_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -256,7 +256,7 @@ def build_create_or_update_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -299,7 +299,7 @@ def build_delete_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -339,7 +339,7 @@ def build_list_keys_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -379,7 +379,7 @@ def build_regenerate_key_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_domains_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_domains_operations.py index f98afc391e8d..00f6e608451e 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_domains_operations.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_domains_operations.py @@ -45,7 +45,7 @@ def build_get_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +81,7 @@ def build_create_or_update_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -120,7 +120,7 @@ def build_delete_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -156,7 +156,7 @@ def build_update_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -195,7 +195,7 @@ def build_list_by_email_service_resource_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -230,7 +230,7 @@ def build_initiate_verification_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -269,7 +269,7 @@ def build_cancel_verification_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_email_services_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_email_services_operations.py index ef2916d5bc32..53fd81f1a502 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_email_services_operations.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_email_services_operations.py @@ -45,7 +45,7 @@ def build_get_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +80,7 @@ def build_create_or_update_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -118,7 +118,7 @@ def build_delete_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -153,7 +153,7 @@ def build_update_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -189,7 +189,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -213,7 +213,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -243,7 +243,7 @@ def build_list_verified_exchange_online_domains_request(subscription_id: str, ** _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operations.py index a4234302ae59..a2b53de3323e 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operations.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operations.py @@ -40,7 +40,7 @@ def build_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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_sender_usernames_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_sender_usernames_operations.py index 79277fc43a1a..b0a5450e24c8 100644 --- a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_sender_usernames_operations.py +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_sender_usernames_operations.py @@ -43,7 +43,7 @@ def build_list_by_domains_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -126,7 +126,7 @@ def build_create_or_update_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -171,7 +171,7 @@ def build_delete_request( _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", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_suppression_list_addresses_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_suppression_list_addresses_operations.py new file mode 100644 index 000000000000..18026ab53fe4 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_suppression_list_addresses_operations.py @@ -0,0 +1,718 @@ +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +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.pipeline.transport import HttpResponse +from azure.core.rest import 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 .._serialization import Serializer +from .._vendor import _convert_request + +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, + email_service_name: str, + domain_name: str, + suppression_list_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", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses", + ) # 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 + ), + "emailServiceName": _SERIALIZER.url( + "email_service_name", email_service_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z0-9-]+$" + ), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str", max_length=253, min_length=1, pattern=r".*"), + "suppressionListName": _SERIALIZER.url( + "suppression_list_name", + suppression_list_name, + "str", + max_length=253, + min_length=1, + pattern=r"^[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, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: 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", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}", + ) # 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 + ), + "emailServiceName": _SERIALIZER.url( + "email_service_name", email_service_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z0-9-]+$" + ), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str", max_length=253, min_length=1, pattern=r".*"), + "suppressionListName": _SERIALIZER.url( + "suppression_list_name", + suppression_list_name, + "str", + max_length=253, + min_length=1, + pattern=r"^[a-zA-Z0-9-]+$", + ), + "addressId": _SERIALIZER.url( + "address_id", address_id, "str", max_length=253, min_length=1, pattern=r"^[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, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: 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", "2023-06-01-preview")) + 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.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}", + ) # 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 + ), + "emailServiceName": _SERIALIZER.url( + "email_service_name", email_service_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z0-9-]+$" + ), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str", max_length=253, min_length=1, pattern=r".*"), + "suppressionListName": _SERIALIZER.url( + "suppression_list_name", + suppression_list_name, + "str", + max_length=253, + min_length=1, + pattern=r"^[a-zA-Z0-9-]+$", + ), + "addressId": _SERIALIZER.url( + "address_id", address_id, "str", max_length=253, min_length=1, pattern=r"^[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, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: 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", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}", + ) # 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 + ), + "emailServiceName": _SERIALIZER.url( + "email_service_name", email_service_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z0-9-]+$" + ), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str", max_length=253, min_length=1, pattern=r".*"), + "suppressionListName": _SERIALIZER.url( + "suppression_list_name", + suppression_list_name, + "str", + max_length=253, + min_length=1, + pattern=r"^[a-zA-Z0-9-]+$", + ), + "addressId": _SERIALIZER.url( + "address_id", address_id, "str", max_length=253, min_length=1, pattern=r"^[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 SuppressionListAddressesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.communication.CommunicationServiceManagementClient`'s + :attr:`suppression_list_addresses` 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, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + **kwargs: Any + ) -> Iterable["_models.SuppressionListAddressResource"]: + """Get. + + Get all the addresses in a suppression list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SuppressionListAddressResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.communication.models.SuppressionListAddressResource] + :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.SuppressionListAddressResourceCollection] = kwargs.pop("cls", None) + + error_map = { + 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, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SuppressionListAddressResourceCollection", 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) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + **kwargs: Any + ) -> _models.SuppressionListAddressResource: + """Get. + + Get a SuppressionListAddress. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListAddressResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListAddressResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.SuppressionListAddressResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + address_id=address_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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("SuppressionListAddressResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + parameters: _models.SuppressionListAddressResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SuppressionListAddressResource: + """Create Or Update. + + Create or update a SuppressionListAddress. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.communication.models.SuppressionListAddressResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListAddressResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListAddressResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SuppressionListAddressResource: + """Create Or Update. + + Create or update a SuppressionListAddress. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListAddressResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListAddressResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + parameters: Union[_models.SuppressionListAddressResource, IO], + **kwargs: Any + ) -> _models.SuppressionListAddressResource: + """Create Or Update. + + Create or update a SuppressionListAddress. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :param parameters: Parameters for the create or update operation. Is either a + SuppressionListAddressResource type or a IO type. Required. + :type parameters: ~azure.mgmt.communication.models.SuppressionListAddressResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListAddressResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListAddressResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.SuppressionListAddressResource] = 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, "SuppressionListAddressResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + address_id=address_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 201]: + 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 response.status_code == 200: + deserialized = self._deserialize("SuppressionListAddressResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SuppressionListAddressResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + address_id: str, + **kwargs: Any + ) -> None: + """Delete. + + Operation to delete a single address from a suppression list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param address_id: The id of the address in a suppression list. Required. + :type address_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + address_id=address_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}/suppressionListAddresses/{addressId}" + } diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_suppression_lists_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_suppression_lists_operations.py new file mode 100644 index 000000000000..e85383bb6314 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_suppression_lists_operations.py @@ -0,0 +1,669 @@ +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +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.pipeline.transport import HttpResponse +from azure.core.rest import 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 .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_domain_request( + resource_group_name: str, email_service_name: str, domain_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", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists", + ) # 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 + ), + "emailServiceName": _SERIALIZER.url( + "email_service_name", email_service_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z0-9-]+$" + ), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str", max_length=253, min_length=1, pattern=r".*"), + } + + _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, + email_service_name: str, + domain_name: str, + suppression_list_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", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}", + ) # 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 + ), + "emailServiceName": _SERIALIZER.url( + "email_service_name", email_service_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z0-9-]+$" + ), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str", max_length=253, min_length=1, pattern=r".*"), + "suppressionListName": _SERIALIZER.url( + "suppression_list_name", + suppression_list_name, + "str", + max_length=253, + min_length=1, + pattern=r"^[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, + email_service_name: str, + domain_name: str, + suppression_list_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", "2023-06-01-preview")) + 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.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}", + ) # 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 + ), + "emailServiceName": _SERIALIZER.url( + "email_service_name", email_service_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z0-9-]+$" + ), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str", max_length=253, min_length=1, pattern=r".*"), + "suppressionListName": _SERIALIZER.url( + "suppression_list_name", + suppression_list_name, + "str", + max_length=253, + min_length=1, + pattern=r"^[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, + email_service_name: str, + domain_name: str, + suppression_list_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", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}", + ) # 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 + ), + "emailServiceName": _SERIALIZER.url( + "email_service_name", email_service_name, "str", max_length=63, min_length=1, pattern=r"^[a-zA-Z0-9-]+$" + ), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str", max_length=253, min_length=1, pattern=r".*"), + "suppressionListName": _SERIALIZER.url( + "suppression_list_name", + suppression_list_name, + "str", + max_length=253, + min_length=1, + pattern=r"^[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 SuppressionListsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.communication.CommunicationServiceManagementClient`'s + :attr:`suppression_lists` 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_by_domain( + self, resource_group_name: str, email_service_name: str, domain_name: str, **kwargs: Any + ) -> Iterable["_models.SuppressionListResource"]: + """List. + + List all suppression lists for a domains resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SuppressionListResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.communication.models.SuppressionListResource] + :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.SuppressionListResourceCollection] = kwargs.pop("cls", None) + + error_map = { + 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_domain_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_domain.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SuppressionListResourceCollection", 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) + + list_by_domain.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + **kwargs: Any + ) -> _models.SuppressionListResource: + """Get. + + Get a SuppressionList resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.SuppressionListResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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("SuppressionListResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + parameters: _models.SuppressionListResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SuppressionListResource: + """Create Or Update. + + Add a new SuppressionList resource under the parent Domains resource or update an existing + SuppressionList resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.communication.models.SuppressionListResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SuppressionListResource: + """Create Or Update. + + Add a new SuppressionList resource under the parent Domains resource or update an existing + SuppressionList resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + parameters: Union[_models.SuppressionListResource, IO], + **kwargs: Any + ) -> _models.SuppressionListResource: + """Create Or Update. + + Add a new SuppressionList resource under the parent Domains resource or update an existing + SuppressionList resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :param parameters: Parameters for the create or update operation. Is either a + SuppressionListResource type or a IO type. Required. + :type parameters: ~azure.mgmt.communication.models.SuppressionListResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SuppressionListResource or the result of cls(response) + :rtype: ~azure.mgmt.communication.models.SuppressionListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.SuppressionListResource] = 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, "SuppressionListResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 201]: + 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 response.status_code == 200: + deserialized = self._deserialize("SuppressionListResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SuppressionListResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + email_service_name: str, + domain_name: str, + suppression_list_name: str, + **kwargs: Any + ) -> None: + """Delete. + + Delete a SuppressionList. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param email_service_name: The name of the EmailService resource. Required. + :type email_service_name: str + :param domain_name: The name of the Domains resource. Required. + :type domain_name: str + :param suppression_list_name: The name of the suppression list. Required. + :type suppression_list_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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, + email_service_name=email_service_name, + domain_name=domain_name, + suppression_list_name=suppression_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/emailServices/{emailServiceName}/domains/{domainName}/suppressionLists/{suppressionListName}" + } diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/check_name_availability_available.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/check_name_availability_available.py index 04e4f439aaa4..7041a275b19c 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/check_name_availability_available.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/check_name_availability_available.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/checkNameAvailabilityAvailable.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/checkNameAvailabilityAvailable.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/check_name_availability_unavailable.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/check_name_availability_unavailable.py index 777241fe7416..e188960cd500 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/check_name_availability_unavailable.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/check_name_availability_unavailable.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/checkNameAvailabilityUnavailable.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/checkNameAvailabilityUnavailable.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/create_or_update.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/create_or_update.py index 12def68da45b..c82997f3f4c5 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/create_or_update.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/create_or_update.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/createOrUpdate.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/createOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/create_or_update_with_system_assigned_identity.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/create_or_update_with_system_assigned_identity.py index 9d2067ebc900..5c4351cff252 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/create_or_update_with_system_assigned_identity.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/create_or_update_with_system_assigned_identity.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/createOrUpdateWithSystemAssignedIdentity.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/createOrUpdateWithSystemAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/delete.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/delete.py index a0a64a3f5667..7f22e49023c7 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/delete.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/delete.py @@ -35,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/delete.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/delete.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/get.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/get.py index 6d3ac6b8834a..abaded26763e 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/get.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/get.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/get.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/link_notification_hub.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/link_notification_hub.py index e14363691a9a..185707729f6f 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/link_notification_hub.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/link_notification_hub.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/linkNotificationHub.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/linkNotificationHub.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_by_resource_group.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_by_resource_group.py index 7c1510ecd3ee..85ce315f0379 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_by_resource_group.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/listByResourceGroup.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/listByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_by_subscription.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_by_subscription.py index f81b74ab8532..834cb8f57f2a 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_by_subscription.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_by_subscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/listBySubscription.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/listBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_keys.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_keys.py index aa60bde65c5a..953827183cbe 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_keys.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/list_keys.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/listKeys.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/listKeys.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/operations_list.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/operations_list.py index 160d30fe6eb5..a26fcccc0109 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/operations_list.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/operations_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/operationsList.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/operationsList.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/regenerate_key.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/regenerate_key.py index fd593e12991d..16421a543552 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/regenerate_key.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/regenerate_key.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/regenerateKey.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/regenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update.py index b008a61c9027..e798a3bd4f7b 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update.py @@ -32,11 +32,11 @@ def main(): response = client.communication_services.update( resource_group_name="MyResourceGroup", communication_service_name="MyCommunicationResource", - parameters={"tags": {"newTag": "newVal"}}, + parameters={"identity": {"type": "SystemAssigned"}, "tags": {"newTag": "newVal"}}, ) print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/update.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/update.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_remove_system_identity.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_remove_system_identity.py index 940fae134f0e..657ff88a9d14 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_remove_system_identity.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_remove_system_identity.py @@ -32,11 +32,11 @@ def main(): response = client.communication_services.update( resource_group_name="MyResourceGroup", communication_service_name="MyCommunicationResource", - parameters={"identity": {"type": "None"}, "tags": {"newTag": "newVal"}}, + parameters={"identity": {"type": "None"}}, ) print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/updateRemoveSystemIdentity.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/updateRemoveSystemIdentity.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_system_and_user_identity.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_system_and_user_identity.py index 7c0c378e918a..09841717e10f 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_system_and_user_identity.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_system_and_user_identity.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/updateWithSystemAndUserIdentity.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/updateWithSystemAndUserIdentity.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_system_assigned_identity.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_system_assigned_identity.py index cb8d0bc9ee7e..66ecc6cecff0 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_system_assigned_identity.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_system_assigned_identity.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/updateWithSystemAssignedIdentity.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/updateWithSystemAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_user_assigned_identity.py b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_user_assigned_identity.py index 4bd2302b88a3..32a75179d4ca 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_user_assigned_identity.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/communication_services/update_with_user_assigned_identity.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/communicationServices/updateWithUserAssignedIdentity.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/communicationServices/updateWithUserAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/domains/cancel_verification.py b/sdk/communication/azure-mgmt-communication/generated_samples/domains/cancel_verification.py index 592c794e9ee6..56120f78635a 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/domains/cancel_verification.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/domains/cancel_verification.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/domains/cancelVerification.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/domains/cancelVerification.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/domains/create_or_update.py b/sdk/communication/azure-mgmt-communication/generated_samples/domains/create_or_update.py index 12ad3763b437..bbe52174c044 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/domains/create_or_update.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/domains/create_or_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/domains/createOrUpdate.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/domains/createOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/domains/delete.py b/sdk/communication/azure-mgmt-communication/generated_samples/domains/delete.py index 2a71530c45bd..7ef38e23747f 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/domains/delete.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/domains/delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/domains/delete.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/domains/delete.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/domains/get.py b/sdk/communication/azure-mgmt-communication/generated_samples/domains/get.py index 75f5204fa3c5..2556c521627d 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/domains/get.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/domains/get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/domains/get.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/domains/get.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/domains/initiate_verification.py b/sdk/communication/azure-mgmt-communication/generated_samples/domains/initiate_verification.py index ec75c5de9a03..38eb2fa73d1e 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/domains/initiate_verification.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/domains/initiate_verification.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/domains/initiateVerification.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/domains/initiateVerification.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/domains/list_by_email_service.py b/sdk/communication/azure-mgmt-communication/generated_samples/domains/list_by_email_service.py index bd266a9ad098..493b272292c1 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/domains/list_by_email_service.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/domains/list_by_email_service.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/domains/listByEmailService.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/domains/listByEmailService.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/domains/update.py b/sdk/communication/azure-mgmt-communication/generated_samples/domains/update.py index c6e4e07f8350..ff5fb0e9c976 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/domains/update.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/domains/update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/domains/update.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/domains/update.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/create_or_update.py b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/create_or_update.py index 7c8bcb3abe62..039131906609 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/create_or_update.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/create_or_update.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/emailServices/createOrUpdate.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/emailServices/createOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/delete.py b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/delete.py index 01e563095ea8..d7dd26dc17b0 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/delete.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/delete.py @@ -35,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/emailServices/delete.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/emailServices/delete.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/get.py b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/get.py index 1c7a3cf0d888..1461ec0b3973 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/get.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/emailServices/get.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/emailServices/get.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/get_verified_exchange_online_domains.py b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/get_verified_exchange_online_domains.py index 7ad835d1d105..495eef99b0df 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/get_verified_exchange_online_domains.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/get_verified_exchange_online_domains.py @@ -33,6 +33,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/emailServices/getVerifiedExchangeOnlineDomains.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/emailServices/getVerifiedExchangeOnlineDomains.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/list_by_resource_group.py b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/list_by_resource_group.py index 3531e07b93f7..aaf584ebc115 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/list_by_resource_group.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/list_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/emailServices/listByResourceGroup.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/emailServices/listByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/list_by_subscription.py b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/list_by_subscription.py index dc68c22f8111..c3d37a3319d4 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/list_by_subscription.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/list_by_subscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/emailServices/listBySubscription.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/emailServices/listBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/update.py b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/update.py index 52410efdc429..c4da0e925e95 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/email_services/update.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/email_services/update.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/emailServices/update.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/emailServices/update.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/create_or_update.py b/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/create_or_update.py index b804039adfaf..93c74e564482 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/create_or_update.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/create_or_update.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/senderUsernames/createOrUpdate.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/senderUsernames/createOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/delete.py b/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/delete.py index 97c95dcbbb72..1eb6a37f4ce4 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/delete.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/delete.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/senderUsernames/delete.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/senderUsernames/delete.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/get.py b/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/get.py index 6b6a66af361e..e201f8b12f3d 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/get.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/senderUsernames/get.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/senderUsernames/get.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/list_by_domain.py b/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/list_by_domain.py index d482fa5937a8..61f1da608714 100644 --- a/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/list_by_domain.py +++ b/sdk/communication/azure-mgmt-communication/generated_samples/sender_usernames/list_by_domain.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-04-01-preview/examples/senderUsernames/listByDomain.json +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/senderUsernames/listByDomain.json if __name__ == "__main__": main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/create_or_update_address.py b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/create_or_update_address.py new file mode 100644 index 000000000000..c343eb5df352 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/create_or_update_address.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.communication import CommunicationServiceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-communication +# USAGE + python create_or_update_address.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 = CommunicationServiceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="11112222-3333-4444-5555-666677778888", + ) + + response = client.suppression_list_addresses.create_or_update( + resource_group_name="contosoResourceGroup", + email_service_name="contosoEmailService", + domain_name="contoso.com", + suppression_list_name="aaaa1111-bbbb-2222-3333-aaaa11112222", + address_id="11112222-3333-4444-5555-aaaabbbbcccc", + parameters={"properties": {"email": "newuser1@fabrikam.com", "firstName": "updatedFirstName"}}, + ) + print(response) + + +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/suppressionLists/createOrUpdateAddress.json +if __name__ == "__main__": + main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/create_or_update_suppression_list.py b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/create_or_update_suppression_list.py new file mode 100644 index 000000000000..efc841fead73 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/create_or_update_suppression_list.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.communication import CommunicationServiceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-communication +# USAGE + python create_or_update_suppression_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 = CommunicationServiceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="11112222-3333-4444-5555-666677778888", + ) + + response = client.suppression_lists.create_or_update( + resource_group_name="contosoResourceGroup", + email_service_name="contosoEmailService", + domain_name="contoso.com", + suppression_list_name="aaaa1111-bbbb-2222-3333-aaaa11112222", + parameters={"properties": {"listName": "contosoNewsAlerts"}}, + ) + print(response) + + +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/suppressionLists/createOrUpdateSuppressionList.json +if __name__ == "__main__": + main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/delete_address.py b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/delete_address.py new file mode 100644 index 000000000000..70c0b9e6c701 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/delete_address.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.communication import CommunicationServiceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-communication +# USAGE + python delete_address.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 = CommunicationServiceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="11112222-3333-4444-5555-666677778888", + ) + + client.suppression_list_addresses.delete( + resource_group_name="MyResourceGroup", + email_service_name="MyEmailServiceResource", + domain_name="mydomain.com", + suppression_list_name="aaaa1111-bbbb-2222-3333-aaaa11112222", + address_id="11112222-3333-4444-5555-999999999999", + ) + + +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/suppressionLists/deleteAddress.json +if __name__ == "__main__": + main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/delete_suppression_list.py b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/delete_suppression_list.py new file mode 100644 index 000000000000..abe6c3c31acd --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/delete_suppression_list.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.communication import CommunicationServiceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-communication +# USAGE + python delete_suppression_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 = CommunicationServiceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="11112222-3333-4444-5555-666677778888", + ) + + client.suppression_lists.delete( + resource_group_name="MyResourceGroup", + email_service_name="MyEmailServiceResource", + domain_name="mydomain.com", + suppression_list_name="aaaa1111-bbbb-2222-3333-aaaa11112222", + ) + + +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/suppressionLists/deleteSuppressionList.json +if __name__ == "__main__": + main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_address.py b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_address.py new file mode 100644 index 000000000000..bb9baaea3a1c --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_address.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.communication import CommunicationServiceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-communication +# USAGE + python get_address.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 = CommunicationServiceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="11112222-3333-4444-5555-666677778888", + ) + + response = client.suppression_list_addresses.get( + resource_group_name="contosoResourceGroup", + email_service_name="contosoEmailService", + domain_name="contoso.com", + suppression_list_name="aaaa1111-bbbb-2222-3333-aaaa11112222", + address_id="11112222-3333-4444-5555-aaaabbbbcccc", + ) + print(response) + + +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/suppressionLists/getAddress.json +if __name__ == "__main__": + main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_addresses.py b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_addresses.py new file mode 100644 index 000000000000..2b8aa3b63ec9 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_addresses.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.communication import CommunicationServiceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-communication +# USAGE + python get_addresses.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 = CommunicationServiceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="11112222-3333-4444-5555-666677778888", + ) + + response = client.suppression_list_addresses.list( + resource_group_name="contosoResourceGroup", + email_service_name="contosoEmailService", + domain_name="contoso.com", + suppression_list_name="aaaa1111-bbbb-2222-3333-aaaa11112222", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/suppressionLists/getAddresses.json +if __name__ == "__main__": + main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_suppression_list.py b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_suppression_list.py new file mode 100644 index 000000000000..d906eebf38dd --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_suppression_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.communication import CommunicationServiceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-communication +# USAGE + python get_suppression_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 = CommunicationServiceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="11112222-3333-4444-5555-666677778888", + ) + + response = client.suppression_lists.get( + resource_group_name="contosoResourceGroup", + email_service_name="contosoEmailService", + domain_name="contoso.com", + suppression_list_name="aaaa1111-bbbb-2222-3333-aaaa11112222", + ) + print(response) + + +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/suppressionLists/getSuppressionList.json +if __name__ == "__main__": + main() diff --git a/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_suppression_lists.py b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_suppression_lists.py new file mode 100644 index 000000000000..f6e68a12e51a --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/generated_samples/suppression_lists/get_suppression_lists.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.communication import CommunicationServiceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-communication +# USAGE + python get_suppression_lists.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 = CommunicationServiceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="11112222-3333-4444-5555-666677778888", + ) + + response = client.suppression_lists.list_by_domain( + resource_group_name="contosoResourceGroup", + email_service_name="contosoEmailService", + domain_name="contoso.com", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/preview/2023-06-01-preview/examples/suppressionLists/getSuppressionLists.json +if __name__ == "__main__": + main()