diff --git a/sdk/purview/azure-mgmt-purview/README.md b/sdk/purview/azure-mgmt-purview/README.md index 0bad6866f4f0..47776121143c 100644 --- a/sdk/purview/azure-mgmt-purview/README.md +++ b/sdk/purview/azure-mgmt-purview/README.md @@ -1,28 +1,61 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Purview Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ -# Usage +## Getting started +### Prerequisites -To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) - -For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) -Code samples for this package can be found at [Purview Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. -Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) +- Python 3.8+ is required to use this package. +- [Azure subscription](https://azure.microsoft.com/free/) +### Install the package -# Provide Feedback +```bash +pip install azure-mgmt-purview +pip install azure-identity +``` + +### Authentication + +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` for Azure client secret. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, client can be authenticated by following code: + +```python +from azure.identity import DefaultAzureCredential +from azure.mgmt.purview import PurviewManagementClient +import os + +sub_id = os.getenv("AZURE_SUBSCRIPTION_ID") +client = PurviewManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id) +``` + +## Examples + +Code samples for this package can be found at: +- [Search Purview Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +## Troubleshooting + +## Next steps + +## Provide Feedback If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-purview%2FREADME.png) diff --git a/sdk/purview/azure-mgmt-purview/_meta.json b/sdk/purview/azure-mgmt-purview/_meta.json index 0dbe1c13970c..99ec6f650c71 100644 --- a/sdk/purview/azure-mgmt-purview/_meta.json +++ b/sdk/purview/azure-mgmt-purview/_meta.json @@ -1,11 +1,11 @@ { - "commit": "65467c71b96b9fae47ed74d9866a3494030336d4", + "commit": "42f86979ad0554ccf60fc09c53d744493b3865f4", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.2.1", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.13.7", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/purview/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.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/purview/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.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", "readme": "specification/purview/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/__init__.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/__init__.py index e6e70ae3b0f3..49b8f4f94d3a 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/__init__.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/__init__.py @@ -13,7 +13,7 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_configuration.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_configuration.py index a863a4840bc2..d8f011b3834b 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_configuration.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_configuration.py @@ -6,26 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PurviewManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class PurviewManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for PurviewManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,14 +28,13 @@ class PurviewManagementClientConfiguration(Configuration): # pylint: disable=to :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-04-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(PurviewManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-07-01") # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", "2024-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,20 +46,18 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-purview/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_purview_management_client.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_purview_management_client.py index 588c20c2698b..c80216ac5306 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_purview_management_client.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_purview_management_client.py @@ -9,18 +9,24 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from . import models +from . import models as _models from ._configuration import PurviewManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( AccountsOperations, DefaultAccountsOperations, + FeaturesOperations, + IngestionPrivateEndpointConnectionsOperations, + KafkaConfigurationsOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, + UsagesOperations, ) if TYPE_CHECKING: @@ -28,13 +34,21 @@ from azure.core.credentials import TokenCredential -class PurviewManagementClient: # pylint: disable=client-accepts-api-version-keyword +class PurviewManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Creates a Microsoft.Purview management client. :ivar accounts: AccountsOperations operations :vartype accounts: azure.mgmt.purview.operations.AccountsOperations :ivar default_accounts: DefaultAccountsOperations operations :vartype default_accounts: azure.mgmt.purview.operations.DefaultAccountsOperations + :ivar features: FeaturesOperations operations + :vartype features: azure.mgmt.purview.operations.FeaturesOperations + :ivar ingestion_private_endpoint_connections: IngestionPrivateEndpointConnectionsOperations + operations + :vartype ingestion_private_endpoint_connections: + azure.mgmt.purview.operations.IngestionPrivateEndpointConnectionsOperations + :ivar kafka_configurations: KafkaConfigurationsOperations operations + :vartype kafka_configurations: azure.mgmt.purview.operations.KafkaConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.purview.operations.Operations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations @@ -42,14 +56,16 @@ class PurviewManagementClient: # pylint: disable=client-accepts-api-version-key azure.mgmt.purview.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.purview.operations.PrivateLinkResourcesOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.purview.operations.UsagesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. 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 "2021-07-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-04-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 Retry-After header is present. @@ -65,9 +81,27 @@ def __init__( self._config = PurviewManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -75,6 +109,13 @@ def __init__( self.default_accounts = DefaultAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ingestion_private_endpoint_connections = IngestionPrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kafka_configurations = KafkaConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize @@ -82,8 +123,9 @@ def __init__( self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -103,17 +145,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> PurviewManagementClient + def __enter__(self) -> "PurviewManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_serialization.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_serialization.py index 7c1dedb5133d..2f781d740827 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_serialization.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_serialization.py @@ -25,6 +25,7 @@ # -------------------------------------------------------------------------- # pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode import calendar @@ -37,23 +38,38 @@ import re import sys import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore except ImportError: - from urllib.parse import quote # type: ignore + from urllib.parse import quote import xml.etree.ElementTree as ET -import isodate +import isodate # type: ignore -from typing import Dict, Any, cast, TYPE_CHECKING - -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -if TYPE_CHECKING: - from typing import Optional, Union, AnyStr, IO, Mapping +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] class RawDeserializer: @@ -65,8 +81,7 @@ class RawDeserializer: CONTEXT_NAME = "deserialized_data" @classmethod - def deserialize_from_text(cls, data, content_type=None): - # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: """Decode data according to content-type. Accept a stream of data as well, but will be load at once in memory for now. @@ -109,7 +124,7 @@ def deserialize_from_text(cls, data, content_type=None): pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -128,12 +143,11 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod - def deserialize_from_http_generics(cls, body_bytes, headers): - # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: """Deserialize from HTTP response. Use bytes and headers to NOT use any requests/aiohttp or whatever @@ -156,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes, headers): return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str # type: ignore - unicode_str = str # type: ignore - _LOGGER = logging.getLogger(__name__) try: @@ -188,7 +195,7 @@ def dst(self, dt): try: - from datetime import timezone as _FixedOffset + from datetime import timezone as _FixedOffset # type: ignore except ImportError: # Python 2.7 class _FixedOffset(datetime.tzinfo): # type: ignore @@ -219,7 +226,7 @@ def __getinitargs__(self): try: from datetime import timezone - TZ_UTC = timezone.utc # type: ignore + TZ_UTC = timezone.utc except ImportError: TZ_UTC = UTC() # type: ignore @@ -276,12 +283,12 @@ class Model(object): serialization and deserialization. """ - _subtype_map = {} # type: Dict[str, Dict[str, Any]] - _attribute_map = {} # type: Dict[str, Dict[str, Any]] - _validation = {} # type: Dict[str, Dict[str, Any]] + _subtype_map: Dict[str, Dict[str, Any]] = {} + _attribute_map: Dict[str, Dict[str, Any]] = {} + _validation: Dict[str, Dict[str, Any]] = {} - def __init__(self, **kwargs): - self.additional_properties = {} + def __init__(self, **kwargs: Any) -> None: + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -290,27 +297,27 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): + def enable_additional_properties_sending(cls) -> None: cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: - cls._xml_map + cls._xml_map # type: ignore except AttributeError: return False return True @@ -319,14 +326,14 @@ def is_xml_model(cls): def _create_xml_node(cls): """Create XML node.""" try: - xml_map = cls._xml_map + xml_map = cls._xml_map # type: ignore except AttributeError: xml_map = {} return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - def serialize(self, keep_readonly=False, **kwargs): - """Return the JSON that would be sent to azure from this model. + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -337,10 +344,15 @@ def serialize(self, keep_readonly=False, **kwargs): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore - def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -371,7 +383,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -387,7 +399,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -396,10 +408,15 @@ def deserialize(cls, data, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod - def from_dict(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -412,8 +429,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( - [ + deserializer.key_extractors = ( # type: ignore + [ # type: ignore attribute_key_case_insensitive_extractor, rest_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, @@ -421,7 +438,7 @@ def from_dict(cls, data, key_extractors=None, content_type=None): if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -453,7 +470,7 @@ def _classify(cls, response, objects): return cls flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) try: - return objects[flatten_mapping_type[subtype_value]] + return objects[flatten_mapping_type[subtype_value]] # type: ignore except KeyError: _LOGGER.warning( "Subtype value %s has no mapping, use base class %s.", @@ -521,7 +538,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -537,7 +554,7 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -605,14 +622,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): - serialized.text = new_attr + serialized.text = new_attr # type: ignore continue if isinstance(new_attr, list): - serialized.extend(new_attr) + serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): @@ -621,30 +638,30 @@ def _serialize(self, target_obj, data_type=None, **kwargs): new_attr.tag = "}".join([splitted_tag[0], xml_name]) else: new_attr.tag = xml_name - serialized.append(new_attr) + serialized.append(new_attr) # type: ignore else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) - serialized.append(local_node) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore else: # JSON - for k in reversed(keys): - unflattened = {k: new_attr} - new_attr = unflattened + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized - for k in keys: + for k in keys: # type: ignore if k not in _serialized: - _serialized.update(_new_attr) - _new_attr = _new_attr[k] + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -659,8 +676,8 @@ def body(self, data, data_type, **kwargs): """ # Just in case this is a dict - internal_data_type = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -675,7 +692,7 @@ def body(self, data, data_type, **kwargs): # We're not able to deal with additional properties for now. deserializer.additional_properties_detection = False if is_xml_model_serialization: - deserializer.key_extractors = [ + deserializer.key_extractors = [ # type: ignore attribute_key_case_insensitive_extractor, ] else: @@ -686,7 +703,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -706,6 +723,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -718,7 +736,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -726,10 +746,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -780,6 +798,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is CoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -798,7 +818,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -843,7 +863,7 @@ def serialize_unicode(cls, data): pass try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore # Don't change it, JSON and XML ElementTree are totally able # to serialize correctly u'' strings return data @@ -866,6 +886,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -878,9 +900,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -925,7 +952,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -958,7 +987,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1001,10 +1030,10 @@ def serialize_enum(attr, enum_obj=None): except AttributeError: result = attr try: - enum_obj(result) + enum_obj(result) # type: ignore return result except ValueError: - for enum_value in enum_obj: + for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" @@ -1135,10 +1164,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1164,7 +1193,8 @@ def rest_key_extractor(attr, attr_desc, data): working_data = data while "." in key: - dict_keys = _FLATTEN.split(key) + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1173,7 +1203,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1194,7 +1223,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1245,7 +1273,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1269,7 +1297,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1335,7 +1363,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1355,7 +1383,7 @@ def __init__(self, classes=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1408,7 +1436,7 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) @@ -1416,7 +1444,7 @@ def _deserialize(self, target_obj, data): if data is None: return data try: - attributes = response._attribute_map + attributes = response._attribute_map # type: ignore d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1444,8 +1472,8 @@ def _deserialize(self, target_obj, data): value = self.deserialize_data(raw_value, attr_desc["type"]) d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name - raise_with_traceback(DeserializationError, msg, err) + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1474,22 +1502,22 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. """ if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify - return target, target.__class__.__name__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1499,7 +1527,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. """ try: @@ -1542,8 +1570,8 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): @@ -1565,7 +1593,7 @@ def _instantiate_model(self, response, attrs, additional_properties=None): response_obj.additional_properties = additional_properties return response_obj except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore raise DeserializationError(msg + str(err)) else: try: @@ -1616,7 +1644,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1664,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1721,7 +1749,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1747,7 +1775,7 @@ def deserialize_unicode(data): # Consider this is real string try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore return data except NameError: return str(data) @@ -1772,7 +1800,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1798,7 +1825,7 @@ def deserialize_bytearray(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return bytearray(b64decode(attr)) + return bytearray(b64decode(attr)) # type: ignore @staticmethod def deserialize_base64(attr): @@ -1810,8 +1837,8 @@ def deserialize_base64(attr): """ if isinstance(attr, ET.Element): attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) - attr = attr + padding + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore encoded = attr.replace("-", "+").replace("_", "/") return b64decode(encoded) @@ -1826,10 +1853,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1841,7 +1868,7 @@ def deserialize_long(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return _long_type(attr) + return _long_type(attr) # type: ignore @staticmethod def deserialize_duration(attr): @@ -1857,7 +1884,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1871,10 +1898,10 @@ def deserialize_date(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1886,7 +1913,7 @@ def deserialize_time(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) return isodate.parse_time(attr) @@ -1901,7 +1928,7 @@ def deserialize_rfc(attr): if isinstance(attr, ET.Element): attr = attr.text try: - parsed_date = email.utils.parsedate_tz(attr) + parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) @@ -1909,7 +1936,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1924,7 +1951,7 @@ def deserialize_iso(attr): if isinstance(attr, ET.Element): attr = attr.text try: - attr = attr.upper() + attr = attr.upper() # type: ignore match = Deserializer.valid_date.match(attr) if not match: raise ValueError("Invalid datetime string: " + attr) @@ -1946,7 +1973,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1960,11 +1987,12 @@ def deserialize_unix(attr): :raises: DeserializationError if format invalid """ if isinstance(attr, ET.Element): - attr = int(attr.text) + attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_vendor.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_vendor.py index 9aad73fc743e..0dafe0e287ff 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_vendor.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_vendor.py @@ -14,14 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - formatted_components = template.split("/") - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_version.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_version.py index 653b73a4a199..961c76eb77c1 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_version.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b1" +VERSION = "1.0.1" diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/__init__.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/__init__.py index d93e00513fd7..791346049107 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/__init__.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/__init__.py @@ -10,7 +10,7 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/_configuration.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/_configuration.py index 11becda7a786..3b24ce7d803e 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/_configuration.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/_configuration.py @@ -6,26 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PurviewManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class PurviewManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for PurviewManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,14 +28,13 @@ class PurviewManagementClientConfiguration(Configuration): # pylint: disable=to :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-04-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(PurviewManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-07-01") # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", "2024-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-purview/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/_purview_management_client.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/_purview_management_client.py index f6a2b248f7c0..2b69302f0501 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/_purview_management_client.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/_purview_management_client.py @@ -9,18 +9,24 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from .. import models +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import PurviewManagementClientConfiguration from .operations import ( AccountsOperations, DefaultAccountsOperations, + FeaturesOperations, + IngestionPrivateEndpointConnectionsOperations, + KafkaConfigurationsOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, + UsagesOperations, ) if TYPE_CHECKING: @@ -28,13 +34,21 @@ from azure.core.credentials_async import AsyncTokenCredential -class PurviewManagementClient: # pylint: disable=client-accepts-api-version-keyword +class PurviewManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Creates a Microsoft.Purview management client. :ivar accounts: AccountsOperations operations :vartype accounts: azure.mgmt.purview.aio.operations.AccountsOperations :ivar default_accounts: DefaultAccountsOperations operations :vartype default_accounts: azure.mgmt.purview.aio.operations.DefaultAccountsOperations + :ivar features: FeaturesOperations operations + :vartype features: azure.mgmt.purview.aio.operations.FeaturesOperations + :ivar ingestion_private_endpoint_connections: IngestionPrivateEndpointConnectionsOperations + operations + :vartype ingestion_private_endpoint_connections: + azure.mgmt.purview.aio.operations.IngestionPrivateEndpointConnectionsOperations + :ivar kafka_configurations: KafkaConfigurationsOperations operations + :vartype kafka_configurations: azure.mgmt.purview.aio.operations.KafkaConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.purview.aio.operations.Operations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations @@ -43,14 +57,16 @@ class PurviewManagementClient: # pylint: disable=client-accepts-api-version-key :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.purview.aio.operations.PrivateLinkResourcesOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.purview.aio.operations.UsagesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. 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 "2021-07-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-04-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 Retry-After header is present. @@ -66,9 +82,27 @@ def __init__( self._config = PurviewManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -76,6 +110,13 @@ def __init__( self.default_accounts = DefaultAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ingestion_private_endpoint_connections = IngestionPrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kafka_configurations = KafkaConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize @@ -83,8 +124,11 @@ def __init__( self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -104,7 +148,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() @@ -113,5 +157,5 @@ async def __aenter__(self) -> "PurviewManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/__init__.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/__init__.py index 50cffb0c9a59..3496c9ce1a35 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/__init__.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/__init__.py @@ -8,20 +8,28 @@ from ._accounts_operations import AccountsOperations from ._default_accounts_operations import DefaultAccountsOperations +from ._features_operations import FeaturesOperations +from ._ingestion_private_endpoint_connections_operations import IngestionPrivateEndpointConnectionsOperations +from ._kafka_configurations_operations import KafkaConfigurationsOperations from ._operations import Operations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._usages_operations import UsagesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "AccountsOperations", "DefaultAccountsOperations", + "FeaturesOperations", + "IngestionPrivateEndpointConnectionsOperations", + "KafkaConfigurationsOperations", "Operations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", + "UsagesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_accounts_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_accounts_operations.py index 37e8dcc9c060..b7d9291d194a 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_accounts_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_accounts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -43,10 +43,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,18 +67,13 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.Account"]: - """Gets the accounts resources by resource group. + def list_by_subscription(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.Account"]: + """Gets the accounts resources by subscription. - List accounts in ResourceGroup. + List accounts in Subscription. - :param resource_group_name: The resource group name. Required. - :type resource_group_name: str :param skip_token: The skip token. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Account or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,10 +81,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AccountList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -106,17 +95,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -128,26 +115,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("AccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,17 +148,18 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts"} # type: ignore - @distributed_trace - def list_by_subscription(self, skip_token: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.Account"]: - """Gets the accounts resources by subscription. + def list_by_resource_group( + self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Account"]: + """Gets the accounts resources by resource group. - List accounts in Subscription. + List accounts in ResourceGroup. + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str :param skip_token: The skip token. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Account or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -178,10 +167,8 @@ def list_by_subscription(self, skip_token: Optional[str] = None, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AccountList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -194,16 +181,16 @@ def list_by_subscription(self, skip_token: Optional[str] = None, **kwargs: Any) def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -215,26 +202,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("AccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -247,8 +235,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Purview/accounts"} # type: ignore - @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.Account: """Gets the account resource. @@ -259,7 +245,6 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Account or the result of cls(response) :rtype: ~azure.mgmt.purview.models.Account :raises ~azure.core.exceptions.HttpResponseError: @@ -275,25 +260,23 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_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) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -306,14 +289,12 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return deserialized # type: ignore async def _create_or_update_initial( - self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO], **kwargs: Any + self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO[bytes]], **kwargs: Any ) -> _models.Account: error_map = { 401: ClientAuthenticationError, @@ -326,21 +307,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + 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.Account] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(account, (IO, bytes)): + if isinstance(account, (IOBase, bytes)): _content = account else: _json = self._serialize.body(account, "Account") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -348,15 +327,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,11 +352,9 @@ async def _create_or_update_initial( deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -402,14 +379,6 @@ async def begin_create_or_update( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.purview.models.Account] @@ -421,7 +390,7 @@ async def begin_create_or_update( self, resource_group_name: str, account_name: str, - account: IO, + account: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,18 +404,10 @@ async def begin_create_or_update( :param account_name: The name of the account. Required. :type account_name: str :param account: The account. Required. - :type account: IO + :type account: IO[bytes] :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.purview.models.Account] @@ -455,7 +416,7 @@ async def begin_create_or_update( @distributed_trace_async async def begin_create_or_update( - self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO], **kwargs: Any + self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Account]: """Create or update an account resource. @@ -465,19 +426,8 @@ async def begin_create_or_update( :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :param account: The account. Is either a model type or a IO type. Required. - :type account: ~azure.mgmt.purview.models.Account 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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param account: The account. Is either a Account type or a IO[bytes] type. Required. + :type account: ~azure.mgmt.purview.models.Account or IO[bytes] :return: An instance of AsyncLROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.purview.models.Account] @@ -486,16 +436,14 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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.Account] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, account=account, @@ -511,25 +459,25 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Account].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return AsyncLROPoller[_models.Account]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any @@ -545,25 +493,23 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + 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( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -574,9 +520,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -588,14 +532,6 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -603,13 +539,11 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -624,30 +558,28 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, account_name: str, - account_update_parameters: Union[_models.AccountUpdateParameters, IO], + account_update_parameters: Union[_models.AccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Account: error_map = { @@ -661,21 +593,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + 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.Account] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(account_update_parameters, (IO, bytes)): + if isinstance(account_update_parameters, (IOBase, bytes)): _content = account_update_parameters else: _json = self._serialize.body(account_update_parameters, "AccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -683,15 +613,15 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -708,11 +638,9 @@ async def _update_initial( deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return deserialized # type: ignore @overload async def begin_update( @@ -737,14 +665,6 @@ async def begin_update( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.purview.models.Account] @@ -756,7 +676,7 @@ async def begin_update( self, resource_group_name: str, account_name: str, - account_update_parameters: IO, + account_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -770,18 +690,10 @@ async def begin_update( :param account_name: The name of the account. Required. :type account_name: str :param account_update_parameters: The account update parameters. Required. - :type account_update_parameters: IO + :type account_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.purview.models.Account] @@ -793,7 +705,7 @@ async def begin_update( self, resource_group_name: str, account_name: str, - account_update_parameters: Union[_models.AccountUpdateParameters, IO], + account_update_parameters: Union[_models.AccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Account]: """Patches the account resource. @@ -804,20 +716,10 @@ async def begin_update( :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :param account_update_parameters: The account update parameters. Is either a model type or a IO - type. Required. - :type account_update_parameters: ~azure.mgmt.purview.models.AccountUpdateParameters 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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param account_update_parameters: The account update parameters. Is either a + AccountUpdateParameters type or a IO[bytes] type. Required. + :type account_update_parameters: ~azure.mgmt.purview.models.AccountUpdateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.purview.models.Account] @@ -826,16 +728,14 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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.Account] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( # type: ignore + raw_result = await self._update_initial( resource_group_name=resource_group_name, account_name=account_name, account_update_parameters=account_update_parameters, @@ -851,89 +751,26 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Account].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore - - @distributed_trace_async - async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.AccessKeys: - """Lists the keys asynchronous. - - List the authorization keys associated with this account. - - :param resource_group_name: The resource group name. Required. - :type resource_group_name: str - :param account_name: The name of the account. Required. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys or the result of cls(response) - :rtype: ~azure.mgmt.purview.models.AccessKeys - :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 = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - - request = build_list_keys_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_keys.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + return AsyncLROPoller[_models.Account]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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.ErrorResponseModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessKeys", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/listkeys"} # type: ignore - @overload async def add_root_collection_admin( # pylint: disable=inconsistent-return-statements self, @@ -957,7 +794,6 @@ async def add_root_collection_admin( # pylint: disable=inconsistent-return-stat :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -968,7 +804,7 @@ async def add_root_collection_admin( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, account_name: str, - collection_admin_update: IO, + collection_admin_update: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -982,11 +818,10 @@ async def add_root_collection_admin( # pylint: disable=inconsistent-return-stat :param account_name: The name of the account. Required. :type account_name: str :param collection_admin_update: The collection admin update payload. Required. - :type collection_admin_update: IO + :type collection_admin_update: IO[bytes] :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -997,7 +832,7 @@ async def add_root_collection_admin( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, account_name: str, - collection_admin_update: Union[_models.CollectionAdminUpdate, IO], + collection_admin_update: Union[_models.CollectionAdminUpdate, IO[bytes]], **kwargs: Any ) -> None: """Add the administrator for root collection. @@ -1008,13 +843,9 @@ async def add_root_collection_admin( # pylint: disable=inconsistent-return-stat :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :param collection_admin_update: The collection admin update payload. Is either a model type or - a IO type. Required. - :type collection_admin_update: ~azure.mgmt.purview.models.CollectionAdminUpdate 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 + :param collection_admin_update: The collection admin update payload. Is either a + CollectionAdminUpdate type or a IO[bytes] type. Required. + :type collection_admin_update: ~azure.mgmt.purview.models.CollectionAdminUpdate or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1030,21 +861,19 @@ async def add_root_collection_admin( # pylint: disable=inconsistent-return-stat _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + 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[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(collection_admin_update, (IO, bytes)): + if isinstance(collection_admin_update, (IOBase, bytes)): _content = collection_admin_update else: _json = self._serialize.body(collection_admin_update, "CollectionAdminUpdate") - request = build_add_root_collection_admin_request( + _request = build_add_root_collection_admin_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1052,15 +881,69 @@ async def add_root_collection_admin( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, content=_content, - template_url=self.add_root_collection_admin.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.AccessKeys: + """Lists the keys asynchronous. + + List the authorization keys associated with this account. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.AccessKeys + :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.AccessKeys] = kwargs.pop("cls", None) + + _request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1070,10 +953,12 @@ async def add_root_collection_admin( # pylint: disable=inconsistent-return-stat error = self._deserialize.failsafe_deserialize(_models.ErrorResponseModel, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = self._deserialize("AccessKeys", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - add_root_collection_admin.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/addRootCollectionAdmin"} # type: ignore + return deserialized # type: ignore @overload async def check_name_availability( @@ -1092,7 +977,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.purview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1100,18 +984,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, check_name_availability_request: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks the account name availability. Checks if account name is available. :param check_name_availability_request: The check name availability request. Required. - :type check_name_availability_request: IO + :type check_name_availability_request: IO[bytes] :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.purview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1119,20 +1002,16 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, check_name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], **kwargs: Any + self, check_name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks the account name availability. Checks if account name is available. - :param check_name_availability_request: The check name availability request. Is either a model - type or a IO type. Required. + :param check_name_availability_request: The check name availability request. Is either a + CheckNameAvailabilityRequest type or a IO[bytes] type. Required. :type check_name_availability_request: ~azure.mgmt.purview.models.CheckNameAvailabilityRequest - 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 + or IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.purview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1148,35 +1027,33 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] + 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.CheckNameAvailabilityResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_request, (IO, bytes)): + if isinstance(check_name_availability_request, (IOBase, bytes)): _content = check_name_availability_request else: _json = self._serialize.body(check_name_availability_request, "CheckNameAvailabilityRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1189,8 +1066,6 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Purview/checkNameAvailability"} # type: ignore + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_default_accounts_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_default_accounts_operations.py index d688af49927b..329e5bf31605 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_default_accounts_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_default_accounts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._default_accounts_operations import build_get_request, build_remove_request, build_set_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,7 +71,6 @@ async def get( :param scope: The Id of the scope object, for example if the scope is "Subscription" then it is the ID of that subscription. Default value is None. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DefaultAccountPayload or the result of cls(response) :rtype: ~azure.mgmt.purview.models.DefaultAccountPayload :raises ~azure.core.exceptions.HttpResponseError: @@ -91,25 +86,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DefaultAccountPayload] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DefaultAccountPayload] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope_tenant_id=scope_tenant_id, scope_type=scope_type, scope=scope, 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) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -122,11 +115,73 @@ async def get( deserialized = self._deserialize("DefaultAccountPayload", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - get.metadata = {"url": "/providers/Microsoft.Purview/getDefaultAccount"} # type: ignore + @distributed_trace_async + async def remove( # pylint: disable=inconsistent-return-statements + self, + scope_tenant_id: str, + scope_type: Union[str, _models.ScopeType], + scope: Optional[str] = None, + **kwargs: Any + ) -> None: + """Removes the default account from the scope. + + Removes the default account from the scope. + + :param scope_tenant_id: The tenant ID. Required. + :type scope_tenant_id: str + :param scope_type: The scope for the default account. Known values are: "Tenant" and + "Subscription". Required. + :type scope_type: str or ~azure.mgmt.purview.models.ScopeType + :param scope: The Id of the scope object, for example if the scope is "Subscription" then it is + the ID of that subscription. Default value is None. + :type scope: str + :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_remove_request( + scope_tenant_id=scope_tenant_id, + scope_type=scope_type, + scope=scope, + api_version=api_version, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @overload async def set( @@ -146,7 +201,6 @@ async def set( :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: DefaultAccountPayload or the result of cls(response) :rtype: ~azure.mgmt.purview.models.DefaultAccountPayload :raises ~azure.core.exceptions.HttpResponseError: @@ -154,7 +208,7 @@ async def set( @overload async def set( - self, default_account_payload: IO, *, content_type: str = "application/json", **kwargs: Any + self, default_account_payload: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DefaultAccountPayload: """Sets the default account for the scope. @@ -162,11 +216,10 @@ async def set( :param default_account_payload: The payload containing the default account information and the scope. Required. - :type default_account_payload: IO + :type default_account_payload: IO[bytes] :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: DefaultAccountPayload or the result of cls(response) :rtype: ~azure.mgmt.purview.models.DefaultAccountPayload :raises ~azure.core.exceptions.HttpResponseError: @@ -174,19 +227,15 @@ async def set( @distributed_trace_async async def set( - self, default_account_payload: Union[_models.DefaultAccountPayload, IO], **kwargs: Any + self, default_account_payload: Union[_models.DefaultAccountPayload, IO[bytes]], **kwargs: Any ) -> _models.DefaultAccountPayload: """Sets the default account for the scope. Sets the default account for the scope. :param default_account_payload: The payload containing the default account information and the - scope. Is either a model type or a IO type. Required. - :type default_account_payload: ~azure.mgmt.purview.models.DefaultAccountPayload 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 + scope. Is either a DefaultAccountPayload type or a IO[bytes] type. Required. + :type default_account_payload: ~azure.mgmt.purview.models.DefaultAccountPayload or IO[bytes] :return: DefaultAccountPayload or the result of cls(response) :rtype: ~azure.mgmt.purview.models.DefaultAccountPayload :raises ~azure.core.exceptions.HttpResponseError: @@ -202,34 +251,32 @@ async def set( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DefaultAccountPayload] + 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.DefaultAccountPayload] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(default_account_payload, (IO, bytes)): + if isinstance(default_account_payload, (IOBase, bytes)): _content = default_account_payload else: _json = self._serialize.body(default_account_payload, "DefaultAccountPayload") - request = build_set_request( + _request = build_set_request( api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.set.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -242,77 +289,6 @@ async def set( deserialized = self._deserialize("DefaultAccountPayload", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - set.metadata = {"url": "/providers/Microsoft.Purview/setDefaultAccount"} # type: ignore - - @distributed_trace_async - async def remove( # pylint: disable=inconsistent-return-statements - self, - scope_tenant_id: str, - scope_type: Union[str, _models.ScopeType], - scope: Optional[str] = None, - **kwargs: Any - ) -> None: - """Removes the default account from the scope. - - Removes the default account from the scope. - - :param scope_tenant_id: The tenant ID. Required. - :type scope_tenant_id: str - :param scope_type: The scope for the default account. Known values are: "Tenant" and - "Subscription". Required. - :type scope_type: str or ~azure.mgmt.purview.models.ScopeType - :param scope: The Id of the scope object, for example if the scope is "Subscription" then it is - the ID of that subscription. Default value is None. - :type scope: 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 = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_remove_request( - scope_tenant_id=scope_tenant_id, - scope_type=scope_type, - scope=scope, - api_version=api_version, - template_url=self.remove.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **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.ErrorResponseModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - remove.metadata = {"url": "/providers/Microsoft.Purview/removeDefaultAccount"} # type: ignore + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_features_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_features_operations.py new file mode 100644 index 000000000000..30f39383ffce --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_features_operations.py @@ -0,0 +1,316 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +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_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._features_operations import build_account_get_request, build_subscription_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FeaturesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.purview.aio.PurviewManagementClient`'s + :attr:`features` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def subscription_get( + self, + locations: str, + feature_request: _models.BatchFeatureRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the location and subscription. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param locations: Location of feature. Required. + :type locations: str + :param feature_request: Request body with feature names. Required. + :type feature_request: ~azure.mgmt.purview.models.BatchFeatureRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def subscription_get( + self, locations: str, feature_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the location and subscription. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param locations: Location of feature. Required. + :type locations: str + :param feature_request: Request body with feature names. Required. + :type feature_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def subscription_get( + self, locations: str, feature_request: Union[_models.BatchFeatureRequest, IO[bytes]], **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the location and subscription. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param locations: Location of feature. Required. + :type locations: str + :param feature_request: Request body with feature names. Is either a BatchFeatureRequest type + or a IO[bytes] type. Required. + :type feature_request: ~azure.mgmt.purview.models.BatchFeatureRequest or IO[bytes] + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :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.BatchFeatureStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(feature_request, (IOBase, bytes)): + _content = feature_request + else: + _json = self._serialize.body(feature_request, "BatchFeatureRequest") + + _request = build_subscription_get_request( + locations=locations, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BatchFeatureStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def account_get( + self, + resource_group_name: str, + account_name: str, + feature_request: _models.BatchFeatureRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the account. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param feature_request: Request body with feature names. Required. + :type feature_request: ~azure.mgmt.purview.models.BatchFeatureRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def account_get( + self, + resource_group_name: str, + account_name: str, + feature_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the account. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param feature_request: Request body with feature names. Required. + :type feature_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def account_get( + self, + resource_group_name: str, + account_name: str, + feature_request: Union[_models.BatchFeatureRequest, IO[bytes]], + **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the account. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param feature_request: Request body with feature names. Is either a BatchFeatureRequest type + or a IO[bytes] type. Required. + :type feature_request: ~azure.mgmt.purview.models.BatchFeatureRequest or IO[bytes] + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :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.BatchFeatureStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(feature_request, (IOBase, bytes)): + _content = feature_request + else: + _json = self._serialize.body(feature_request, "BatchFeatureRequest") + + _request = build_account_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BatchFeatureStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_ingestion_private_endpoint_connections_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_ingestion_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..adda1b1c46c8 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_ingestion_private_endpoint_connections_operations.py @@ -0,0 +1,283 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +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._ingestion_private_endpoint_connections_operations import ( + build_list_request, + build_update_status_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IngestionPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.purview.aio.PurviewManagementClient`'s + :attr:`ingestion_private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """Lists all ingestion private endpoint connections. + + Lists all ingestion private endpoint connections. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.purview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) + + error_map = { + 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("PrivateEndpointConnectionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def update_status( + self, + resource_group_name: str, + account_name: str, + request: _models.PrivateEndpointConnectionStatusUpdateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionStatusUpdateResponse: + """Updates ingestion private endpoint connection status. + + Update ingestion private endpoint connection status. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param request: The ingestion private endpoint connection status update request. Required. + :type request: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionStatusUpdateResponse or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_status( + self, + resource_group_name: str, + account_name: str, + request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionStatusUpdateResponse: + """Updates ingestion private endpoint connection status. + + Update ingestion private endpoint connection status. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param request: The ingestion private endpoint connection status update request. Required. + :type request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionStatusUpdateResponse or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_status( + self, + resource_group_name: str, + account_name: str, + request: Union[_models.PrivateEndpointConnectionStatusUpdateRequest, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnectionStatusUpdateResponse: + """Updates ingestion private endpoint connection status. + + Update ingestion private endpoint connection status. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param request: The ingestion private endpoint connection status update request. Is either a + PrivateEndpointConnectionStatusUpdateRequest type or a IO[bytes] type. Required. + :type request: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateRequest or + IO[bytes] + :return: PrivateEndpointConnectionStatusUpdateResponse or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateResponse + :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.PrivateEndpointConnectionStatusUpdateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IOBase, bytes)): + _content = request + else: + _json = self._serialize.body(request, "PrivateEndpointConnectionStatusUpdateRequest") + + _request = build_update_status_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionStatusUpdateResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_kafka_configurations_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_kafka_configurations_operations.py new file mode 100644 index 000000000000..29eb266004f8 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_kafka_configurations_operations.py @@ -0,0 +1,421 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +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._kafka_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_account_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class KafkaConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.purview.aio.PurviewManagementClient`'s + :attr:`kafka_configurations` 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_account( + self, resource_group_name: str, account_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.KafkaConfiguration"]: + """Gets the list of Kafka configurations for the account. + + Lists the Kafka configurations in the Account. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param skip_token: The skip token. Default value is None. + :type skip_token: str + :return: An iterator like instance of either KafkaConfiguration or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.purview.models.KafkaConfiguration] + :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.KafkaConfigurationList] = 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_account_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + 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("KafkaConfigurationList", 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, kafka_configuration_name: str, **kwargs: Any + ) -> _models.KafkaConfiguration: + """Gets the kafka configuration. + + Gets the kafka configuration for the account. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: Name of kafka configuration. Required. + :type kafka_configuration_name: str + :return: KafkaConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.KafkaConfiguration + :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.KafkaConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + kafka_configuration_name=kafka_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KafkaConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + kafka_configuration_name: str, + kafka_configuration: _models.KafkaConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KafkaConfiguration: + """Create or update the kafka configuration. + + Create or update Kafka Configuration. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: The kafka configuration name. Required. + :type kafka_configuration_name: str + :param kafka_configuration: The kafka configuration of the account. Required. + :type kafka_configuration: ~azure.mgmt.purview.models.KafkaConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: KafkaConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.KafkaConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + kafka_configuration_name: str, + kafka_configuration: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KafkaConfiguration: + """Create or update the kafka configuration. + + Create or update Kafka Configuration. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: The kafka configuration name. Required. + :type kafka_configuration_name: str + :param kafka_configuration: The kafka configuration of the account. Required. + :type kafka_configuration: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: KafkaConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.KafkaConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + kafka_configuration_name: str, + kafka_configuration: Union[_models.KafkaConfiguration, IO[bytes]], + **kwargs: Any + ) -> _models.KafkaConfiguration: + """Create or update the kafka configuration. + + Create or update Kafka Configuration. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: The kafka configuration name. Required. + :type kafka_configuration_name: str + :param kafka_configuration: The kafka configuration of the account. Is either a + KafkaConfiguration type or a IO[bytes] type. Required. + :type kafka_configuration: ~azure.mgmt.purview.models.KafkaConfiguration or IO[bytes] + :return: KafkaConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.KafkaConfiguration + :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.KafkaConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(kafka_configuration, (IOBase, bytes)): + _content = kafka_configuration + else: + _json = self._serialize.body(kafka_configuration, "KafkaConfiguration") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + kafka_configuration_name=kafka_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("KafkaConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("KafkaConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, kafka_configuration_name: str, **kwargs: Any + ) -> None: + """Deletes the kafka configuration on the account. + + Deletes a KafkaConfiguration resource. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: Name of kafka configuration. Required. + :type kafka_configuration_name: str + :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, + account_name=account_name, + kafka_configuration_name=kafka_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_operations.py index 987fe4480441..ad5f053d24b8 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,7 +58,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: List of available operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.purview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,10 +65,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -87,14 +79,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -106,26 +97,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,5 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Purview/operations"} # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_private_endpoint_connections_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_private_endpoint_connections_operations.py index 8b4203930931..cceecaed3ed8 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -38,10 +38,6 @@ build_list_by_account_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +75,6 @@ def list_by_account( :type account_name: str :param skip_token: The skip token. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -89,10 +84,8 @@ def list_by_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -105,18 +98,17 @@ def list_by_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_account_request( + _request = build_list_by_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -128,26 +120,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("PrivateEndpointConnectionList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,8 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections"} # type: ignore - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -176,7 +167,6 @@ async def get( :type account_name: str :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.purview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -192,26 +182,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_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) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -224,18 +212,16 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - request: Union[_models.PrivateEndpointConnection, IO], + request: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: error_map = { @@ -249,21 +235,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(request, (IO, bytes)): + if isinstance(request, (IOBase, bytes)): _content = request else: _json = self._serialize.body(request, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -272,15 +256,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -297,11 +281,9 @@ async def _create_or_update_initial( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -329,14 +311,6 @@ async def begin_create_or_update( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -350,7 +324,7 @@ async def begin_create_or_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - request: IO, + request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -366,18 +340,10 @@ async def begin_create_or_update( :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param request: The request. Required. - :type request: IO + :type request: IO[bytes] :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -391,7 +357,7 @@ async def begin_create_or_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - request: Union[_models.PrivateEndpointConnection, IO], + request: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approves/Rejects private endpoint connection request. @@ -404,19 +370,9 @@ async def begin_create_or_update( :type account_name: str :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param request: The request. Is either a model type or a IO type. Required. - :type request: ~azure.mgmt.purview.models.PrivateEndpointConnection 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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param request: The request. Is either a PrivateEndpointConnection type or a IO[bytes] type. + Required. + :type request: ~azure.mgmt.purview.models.PrivateEndpointConnection or IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -426,16 +382,14 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -452,25 +406,25 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -486,26 +440,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + 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( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -516,9 +468,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -534,14 +484,6 @@ async def begin_delete( :type account_name: str :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -549,13 +491,11 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -571,21 +511,19 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_private_link_resources_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_private_link_resources_operations.py index 7783c418dd0c..a464c569f5aa 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_private_link_resources_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -34,10 +33,6 @@ build_list_by_account_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +68,6 @@ def list_by_account( :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.purview.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -81,10 +75,8 @@ def list_by_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResourceList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -97,17 +89,16 @@ def list_by_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_account_request( + _request = build_list_by_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,26 +110,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("PrivateLinkResourceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,8 +143,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateLinkResources"} # type: ignore - @distributed_trace_async async def get_by_group_id( self, resource_group_name: str, account_name: str, group_id: str, **kwargs: Any @@ -167,7 +157,6 @@ async def get_by_group_id( :type account_name: str :param group_id: The group identifier. Required. :type group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.purview.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: @@ -183,26 +172,24 @@ async def get_by_group_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_by_group_id_request( + _request = build_get_by_group_id_request( resource_group_name=resource_group_name, account_name=account_name, group_id=group_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_group_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,8 +202,6 @@ async def get_by_group_id( deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_group_id.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateLinkResources/{groupId}"} # type: ignore + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_usages_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_usages_operations.py new file mode 100644 index 000000000000..17ba037e199a --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/aio/operations/_usages_operations.py @@ -0,0 +1,109 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +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_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._usages_operations import build_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.purview.aio.PurviewManagementClient`'s + :attr:`usages` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, filter: Optional[str] = None, **kwargs: Any) -> _models.UsageList: + """Gets the Usage quota configuration. + + Get the usage quota configuration. + + :param location: The region. Required. + :type location: str + :param filter: The filter, currently unused. Default value is None. + :type filter: str + :return: UsageList or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.UsageList + :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.UsageList] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UsageList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/__init__.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/__init__.py index 670410743ed6..603324862af4 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/__init__.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/__init__.py @@ -10,22 +10,32 @@ from ._models_py3 import Account from ._models_py3 import AccountEndpoints from ._models_py3 import AccountList -from ._models_py3 import AccountProperties +from ._models_py3 import AccountMergeInfo +from ._models_py3 import AccountPropertiesAccountStatus from ._models_py3 import AccountPropertiesEndpoints from ._models_py3 import AccountPropertiesManagedResources from ._models_py3 import AccountSku from ._models_py3 import AccountSkuAutoGenerated +from ._models_py3 import AccountStatus +from ._models_py3 import AccountStatusErrorDetails from ._models_py3 import AccountUpdateParameters +from ._models_py3 import BatchFeatureRequest +from ._models_py3 import BatchFeatureStatus from ._models_py3 import CheckNameAvailabilityRequest from ._models_py3 import CheckNameAvailabilityResult from ._models_py3 import CloudConnectors from ._models_py3 import CollectionAdminUpdate +from ._models_py3 import Consent +from ._models_py3 import Credentials from ._models_py3 import DefaultAccountPayload from ._models_py3 import DimensionProperties from ._models_py3 import ErrorModel from ._models_py3 import ErrorResponseModel from ._models_py3 import ErrorResponseModelError from ._models_py3 import Identity +from ._models_py3 import IngestionStorage +from ._models_py3 import KafkaConfiguration +from ._models_py3 import KafkaConfigurationList from ._models_py3 import ManagedResources from ._models_py3 import Operation from ._models_py3 import OperationDisplay @@ -36,27 +46,45 @@ from ._models_py3 import PrivateEndpoint from ._models_py3 import PrivateEndpointConnection from ._models_py3 import PrivateEndpointConnectionList +from ._models_py3 import PrivateEndpointConnectionStatusUpdateRequest +from ._models_py3 import PrivateEndpointConnectionStatusUpdateResponse from ._models_py3 import PrivateLinkResource from ._models_py3 import PrivateLinkResourceList -from ._models_py3 import PrivateLinkResourceProperties from ._models_py3 import PrivateLinkServiceConnectionState from ._models_py3 import ProxyResource +from ._models_py3 import ProxyResourceSystemData +from ._models_py3 import QuotaName from ._models_py3 import SystemData from ._models_py3 import TrackedResource from ._models_py3 import TrackedResourceSystemData +from ._models_py3 import Usage +from ._models_py3 import UsageList +from ._models_py3 import UsageName from ._models_py3 import UserAssignedIdentity +from ._purview_management_client_enums import AccountProvisioningState +from ._purview_management_client_enums import AccountSkuName +from ._purview_management_client_enums import ConsentKind +from ._purview_management_client_enums import ConsentScopeType +from ._purview_management_client_enums import ConsentStatus from ._purview_management_client_enums import CreatedByType +from ._purview_management_client_enums import EventHubType +from ._purview_management_client_enums import EventStreamingState +from ._purview_management_client_enums import EventStreamingType +from ._purview_management_client_enums import KafkaConfigurationIdentityType from ._purview_management_client_enums import LastModifiedByType -from ._purview_management_client_enums import Name +from ._purview_management_client_enums import ManagedEventHubState +from ._purview_management_client_enums import ManagedIdentityType +from ._purview_management_client_enums import MergeAccountType +from ._purview_management_client_enums import MergeStatus +from ._purview_management_client_enums import PrivateEndpointConnectionStatus from ._purview_management_client_enums import ProvisioningState from ._purview_management_client_enums import PublicNetworkAccess from ._purview_management_client_enums import Reason from ._purview_management_client_enums import ScopeType -from ._purview_management_client_enums import Status -from ._purview_management_client_enums import Type +from ._purview_management_client_enums import TenantEndpointState from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -64,22 +92,32 @@ "Account", "AccountEndpoints", "AccountList", - "AccountProperties", + "AccountMergeInfo", + "AccountPropertiesAccountStatus", "AccountPropertiesEndpoints", "AccountPropertiesManagedResources", "AccountSku", "AccountSkuAutoGenerated", + "AccountStatus", + "AccountStatusErrorDetails", "AccountUpdateParameters", + "BatchFeatureRequest", + "BatchFeatureStatus", "CheckNameAvailabilityRequest", "CheckNameAvailabilityResult", "CloudConnectors", "CollectionAdminUpdate", + "Consent", + "Credentials", "DefaultAccountPayload", "DimensionProperties", "ErrorModel", "ErrorResponseModel", "ErrorResponseModelError", "Identity", + "IngestionStorage", + "KafkaConfiguration", + "KafkaConfigurationList", "ManagedResources", "Operation", "OperationDisplay", @@ -90,24 +128,42 @@ "PrivateEndpoint", "PrivateEndpointConnection", "PrivateEndpointConnectionList", + "PrivateEndpointConnectionStatusUpdateRequest", + "PrivateEndpointConnectionStatusUpdateResponse", "PrivateLinkResource", "PrivateLinkResourceList", - "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", "ProxyResource", + "ProxyResourceSystemData", + "QuotaName", "SystemData", "TrackedResource", "TrackedResourceSystemData", + "Usage", + "UsageList", + "UsageName", "UserAssignedIdentity", + "AccountProvisioningState", + "AccountSkuName", + "ConsentKind", + "ConsentScopeType", + "ConsentStatus", "CreatedByType", + "EventHubType", + "EventStreamingState", + "EventStreamingType", + "KafkaConfigurationIdentityType", "LastModifiedByType", - "Name", + "ManagedEventHubState", + "ManagedIdentityType", + "MergeAccountType", + "MergeStatus", + "PrivateEndpointConnectionStatus", "ProvisioningState", "PublicNetworkAccess", "Reason", "ScopeType", - "Status", - "Type", + "TenantEndpointState", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/_models_py3.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/_models_py3.py index 9abcb93c4ecf..9cec0977360e 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/_models_py3.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization @@ -17,7 +17,7 @@ class AccessKeys(_serialization.Model): - """The Account access keys. + """The Purview Account access keys. :ivar atlas_kafka_primary_endpoint: Gets or sets the primary connection string. :vartype atlas_kafka_primary_endpoint: str @@ -35,8 +35,8 @@ def __init__( *, atlas_kafka_primary_endpoint: Optional[str] = None, atlas_kafka_secondary_endpoint: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword atlas_kafka_primary_endpoint: Gets or sets the primary connection string. :paramtype atlas_kafka_primary_endpoint: str @@ -55,7 +55,7 @@ class TrackedResource(_serialization.Model): :ivar id: Gets or sets the identifier. :vartype id: str - :ivar identity: Identity Info on the tracked resource. + :ivar identity: The Managed Identity of the resource. :vartype identity: ~azure.mgmt.purview.models.Identity :ivar location: Gets or sets the location. :vartype location: str @@ -92,10 +92,10 @@ def __init__( identity: Optional["_models.Identity"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword identity: Identity Info on the tracked resource. + :keyword identity: The Managed Identity of the resource. :paramtype identity: ~azure.mgmt.purview.models.Identity :keyword location: Gets or sets the location. :paramtype location: str @@ -119,7 +119,7 @@ class Account(TrackedResource): # pylint: disable=too-many-instance-attributes :ivar id: Gets or sets the identifier. :vartype id: str - :ivar identity: Identity Info on the tracked resource. + :ivar identity: The Managed Identity of the resource. :vartype identity: ~azure.mgmt.purview.models.Identity :ivar location: Gets or sets the location. :vartype location: str @@ -133,8 +133,9 @@ class Account(TrackedResource): # pylint: disable=too-many-instance-attributes :vartype type: str :ivar sku: Gets or sets the Sku. :vartype sku: ~azure.mgmt.purview.models.AccountSku - :ivar cloud_connectors: Cloud connectors. - External cloud identifier used as part of scanning configuration. + :ivar account_status: Gets or sets the status of the account. + :vartype account_status: ~azure.mgmt.purview.models.AccountPropertiesAccountStatus + :ivar cloud_connectors: External Cloud Service connectors. :vartype cloud_connectors: ~azure.mgmt.purview.models.CloudConnectors :ivar created_at: Gets the time at which the entity was created. :vartype created_at: ~datetime.datetime @@ -142,14 +143,28 @@ class Account(TrackedResource): # pylint: disable=too-many-instance-attributes :vartype created_by: str :ivar created_by_object_id: Gets the creators of the entity's object id. :vartype created_by_object_id: str + :ivar default_domain: Gets the default domain in the account. + :vartype default_domain: str :ivar endpoints: The URIs that are the public endpoints of the account. :vartype endpoints: ~azure.mgmt.purview.models.AccountPropertiesEndpoints :ivar friendly_name: Gets or sets the friendly name. :vartype friendly_name: str + :ivar ingestion_storage: Ingestion Storage Account Info. + :vartype ingestion_storage: ~azure.mgmt.purview.models.IngestionStorage + :ivar managed_event_hub_state: Gets or sets the state of managed eventhub. If enabled managed + eventhub will be created, if disabled the managed eventhub will be removed. Known values are: + "NotSpecified", "Disabled", and "Enabled". + :vartype managed_event_hub_state: str or ~azure.mgmt.purview.models.ManagedEventHubState :ivar managed_resource_group_name: Gets or sets the managed resource group name. :vartype managed_resource_group_name: str :ivar managed_resources: Gets the resource identifiers of the managed resources. :vartype managed_resources: ~azure.mgmt.purview.models.AccountPropertiesManagedResources + :ivar managed_resources_public_network_access: Gets or sets the public network access for + managed resources. Known values are: "NotSpecified", "Enabled", and "Disabled". + :vartype managed_resources_public_network_access: str or + ~azure.mgmt.purview.models.PublicNetworkAccess + :ivar merge_info: Gets or sets the Merge Info. + :vartype merge_info: ~azure.mgmt.purview.models.AccountMergeInfo :ivar private_endpoint_connections: Gets the private endpoint connections information. :vartype private_endpoint_connections: list[~azure.mgmt.purview.models.PrivateEndpointConnection] @@ -160,6 +175,9 @@ class Account(TrackedResource): # pylint: disable=too-many-instance-attributes :ivar public_network_access: Gets or sets the public network access. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype public_network_access: str or ~azure.mgmt.purview.models.PublicNetworkAccess + :ivar tenant_endpoint_state: Gets or sets the state of tenant endpoint. Known values are: + "NotSpecified", "Disabled", and "Enabled". + :vartype tenant_endpoint_state: str or ~azure.mgmt.purview.models.TenantEndpointState """ _validation = { @@ -167,10 +185,11 @@ class Account(TrackedResource): # pylint: disable=too-many-instance-attributes "name": {"readonly": True}, "system_data": {"readonly": True}, "type": {"readonly": True}, - "sku": {"readonly": True}, + "account_status": {"readonly": True}, "created_at": {"readonly": True}, "created_by": {"readonly": True}, "created_by_object_id": {"readonly": True}, + "default_domain": {"readonly": True}, "endpoints": {"readonly": True}, "friendly_name": {"readonly": True}, "managed_resources": {"readonly": True}, @@ -187,62 +206,101 @@ class Account(TrackedResource): # pylint: disable=too-many-instance-attributes "tags": {"key": "tags", "type": "{str}"}, "type": {"key": "type", "type": "str"}, "sku": {"key": "sku", "type": "AccountSku"}, + "account_status": {"key": "properties.accountStatus", "type": "AccountPropertiesAccountStatus"}, "cloud_connectors": {"key": "properties.cloudConnectors", "type": "CloudConnectors"}, "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "created_by_object_id": {"key": "properties.createdByObjectId", "type": "str"}, + "default_domain": {"key": "properties.defaultDomain", "type": "str"}, "endpoints": {"key": "properties.endpoints", "type": "AccountPropertiesEndpoints"}, "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "ingestion_storage": {"key": "properties.ingestionStorage", "type": "IngestionStorage"}, + "managed_event_hub_state": {"key": "properties.managedEventHubState", "type": "str"}, "managed_resource_group_name": {"key": "properties.managedResourceGroupName", "type": "str"}, "managed_resources": {"key": "properties.managedResources", "type": "AccountPropertiesManagedResources"}, + "managed_resources_public_network_access": { + "key": "properties.managedResourcesPublicNetworkAccess", + "type": "str", + }, + "merge_info": {"key": "properties.mergeInfo", "type": "AccountMergeInfo"}, "private_endpoint_connections": { "key": "properties.privateEndpointConnections", "type": "[PrivateEndpointConnection]", }, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "tenant_endpoint_state": {"key": "properties.tenantEndpointState", "type": "str"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, identity: Optional["_models.Identity"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.AccountSku"] = None, cloud_connectors: Optional["_models.CloudConnectors"] = None, + ingestion_storage: Optional["_models.IngestionStorage"] = None, + managed_event_hub_state: Union[str, "_models.ManagedEventHubState"] = "NotSpecified", managed_resource_group_name: Optional[str] = None, - public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", - **kwargs - ): + managed_resources_public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + merge_info: Optional["_models.AccountMergeInfo"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + tenant_endpoint_state: Optional[Union[str, "_models.TenantEndpointState"]] = None, + **kwargs: Any + ) -> None: """ - :keyword identity: Identity Info on the tracked resource. + :keyword identity: The Managed Identity of the resource. :paramtype identity: ~azure.mgmt.purview.models.Identity :keyword location: Gets or sets the location. :paramtype location: str :keyword tags: Tags on the azure resource. :paramtype tags: dict[str, str] - :keyword cloud_connectors: Cloud connectors. - External cloud identifier used as part of scanning configuration. + :keyword sku: Gets or sets the Sku. + :paramtype sku: ~azure.mgmt.purview.models.AccountSku + :keyword cloud_connectors: External Cloud Service connectors. :paramtype cloud_connectors: ~azure.mgmt.purview.models.CloudConnectors + :keyword ingestion_storage: Ingestion Storage Account Info. + :paramtype ingestion_storage: ~azure.mgmt.purview.models.IngestionStorage + :keyword managed_event_hub_state: Gets or sets the state of managed eventhub. If enabled + managed eventhub will be created, if disabled the managed eventhub will be removed. Known + values are: "NotSpecified", "Disabled", and "Enabled". + :paramtype managed_event_hub_state: str or ~azure.mgmt.purview.models.ManagedEventHubState :keyword managed_resource_group_name: Gets or sets the managed resource group name. :paramtype managed_resource_group_name: str + :keyword managed_resources_public_network_access: Gets or sets the public network access for + managed resources. Known values are: "NotSpecified", "Enabled", and "Disabled". + :paramtype managed_resources_public_network_access: str or + ~azure.mgmt.purview.models.PublicNetworkAccess + :keyword merge_info: Gets or sets the Merge Info. + :paramtype merge_info: ~azure.mgmt.purview.models.AccountMergeInfo :keyword public_network_access: Gets or sets the public network access. Known values are: "NotSpecified", "Enabled", and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.purview.models.PublicNetworkAccess + :keyword tenant_endpoint_state: Gets or sets the state of tenant endpoint. Known values are: + "NotSpecified", "Disabled", and "Enabled". + :paramtype tenant_endpoint_state: str or ~azure.mgmt.purview.models.TenantEndpointState """ super().__init__(identity=identity, location=location, tags=tags, **kwargs) - self.sku = None + self.sku = sku + self.account_status = None self.cloud_connectors = cloud_connectors self.created_at = None self.created_by = None self.created_by_object_id = None + self.default_domain = None self.endpoints = None self.friendly_name = None + self.ingestion_storage = ingestion_storage + self.managed_event_hub_state = managed_event_hub_state self.managed_resource_group_name = managed_resource_group_name self.managed_resources = None + self.managed_resources_public_network_access = managed_resources_public_network_access + self.merge_info = merge_info self.private_endpoint_connections = None self.provisioning_state = None self.public_network_access = public_network_access + self.tenant_endpoint_state = tenant_endpoint_state class AccountEndpoints(_serialization.Model): @@ -252,39 +310,32 @@ class AccountEndpoints(_serialization.Model): :ivar catalog: Gets the catalog endpoint. :vartype catalog: str - :ivar guardian: Gets the guardian endpoint. - :vartype guardian: str :ivar scan: Gets the scan endpoint. :vartype scan: str """ _validation = { "catalog": {"readonly": True}, - "guardian": {"readonly": True}, "scan": {"readonly": True}, } _attribute_map = { "catalog": {"key": "catalog", "type": "str"}, - "guardian": {"key": "guardian", "type": "str"}, "scan": {"key": "scan", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.catalog = None - self.guardian = None self.scan = None class AccountList(_serialization.Model): - """Paged list of account resources. + """Paged list of Account resources. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar count: Total item count. - :vartype count: int :ivar next_link: The Url of next result page. :vartype next_link: str :ivar value: Collection of items of type results. Required. @@ -296,147 +347,134 @@ class AccountList(_serialization.Model): } _attribute_map = { - "count": {"key": "count", "type": "int"}, "next_link": {"key": "nextLink", "type": "str"}, "value": {"key": "value", "type": "[Account]"}, } - def __init__( - self, *, value: List["_models.Account"], count: Optional[int] = None, next_link: Optional[str] = None, **kwargs - ): + def __init__(self, *, value: List["_models.Account"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword count: Total item count. - :paramtype count: int :keyword next_link: The Url of next result page. :paramtype next_link: str :keyword value: Collection of items of type results. Required. :paramtype value: list[~azure.mgmt.purview.models.Account] """ super().__init__(**kwargs) - self.count = count self.next_link = next_link self.value = value -class AccountProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The account properties. +class AccountMergeInfo(_serialization.Model): + """The public Account Merge Info model. Variables are only populated by the server, and will be ignored when sending a request. - :ivar cloud_connectors: Cloud connectors. - External cloud identifier used as part of scanning configuration. - :vartype cloud_connectors: ~azure.mgmt.purview.models.CloudConnectors - :ivar created_at: Gets the time at which the entity was created. - :vartype created_at: ~datetime.datetime - :ivar created_by: Gets the creator of the entity. - :vartype created_by: str - :ivar created_by_object_id: Gets the creators of the entity's object id. - :vartype created_by_object_id: str - :ivar endpoints: The URIs that are the public endpoints of the account. - :vartype endpoints: ~azure.mgmt.purview.models.AccountPropertiesEndpoints - :ivar friendly_name: Gets or sets the friendly name. - :vartype friendly_name: str - :ivar managed_resource_group_name: Gets or sets the managed resource group name. - :vartype managed_resource_group_name: str - :ivar managed_resources: Gets the resource identifiers of the managed resources. - :vartype managed_resources: ~azure.mgmt.purview.models.AccountPropertiesManagedResources - :ivar private_endpoint_connections: Gets the private endpoint connections information. - :vartype private_endpoint_connections: - list[~azure.mgmt.purview.models.PrivateEndpointConnection] - :ivar provisioning_state: Gets or sets the state of the provisioning. Known values are: - "Unknown", "Creating", "Moving", "Deleting", "SoftDeleting", "SoftDeleted", "Failed", - "Succeeded", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.purview.models.ProvisioningState - :ivar public_network_access: Gets or sets the public network access. Known values are: - "NotSpecified", "Enabled", and "Disabled". - :vartype public_network_access: str or ~azure.mgmt.purview.models.PublicNetworkAccess + :ivar account_location: The account location of the *other* account in the merge operation. + :vartype account_location: str + :ivar account_name: The account name of the *other* account in the merge operation. + :vartype account_name: str + :ivar account_resource_group_name: The resource group name of the *other* account in the merge + operation. + :vartype account_resource_group_name: str + :ivar account_subscription_id: The subscription id of the *other* account in the merge + operation. + :vartype account_subscription_id: str + :ivar deprovisioned: The deprovisioned status of the account. + Only applicable for the secondary account. + :vartype deprovisioned: bool + :ivar merge_status: The status of the merge operation. Known values are: "Succeeded", "Failed", + and "InProgress". + :vartype merge_status: str or ~azure.mgmt.purview.models.MergeStatus + :ivar type_of_account: The account's type for the merge operation. Known values are: "Primary" + and "Secondary". + :vartype type_of_account: str or ~azure.mgmt.purview.models.MergeAccountType """ _validation = { - "created_at": {"readonly": True}, - "created_by": {"readonly": True}, - "created_by_object_id": {"readonly": True}, - "endpoints": {"readonly": True}, - "friendly_name": {"readonly": True}, - "managed_resources": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - "provisioning_state": {"readonly": True}, + "account_location": {"readonly": True}, + "account_name": {"readonly": True}, + "account_resource_group_name": {"readonly": True}, + "account_subscription_id": {"readonly": True}, + "deprovisioned": {"readonly": True}, + "merge_status": {"readonly": True}, + "type_of_account": {"readonly": True}, } _attribute_map = { - "cloud_connectors": {"key": "cloudConnectors", "type": "CloudConnectors"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_object_id": {"key": "createdByObjectId", "type": "str"}, - "endpoints": {"key": "endpoints", "type": "AccountPropertiesEndpoints"}, - "friendly_name": {"key": "friendlyName", "type": "str"}, - "managed_resource_group_name": {"key": "managedResourceGroupName", "type": "str"}, - "managed_resources": {"key": "managedResources", "type": "AccountPropertiesManagedResources"}, - "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "account_location": {"key": "accountLocation", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + "account_resource_group_name": {"key": "accountResourceGroupName", "type": "str"}, + "account_subscription_id": {"key": "accountSubscriptionId", "type": "str"}, + "deprovisioned": {"key": "deprovisioned", "type": "bool"}, + "merge_status": {"key": "mergeStatus", "type": "str"}, + "type_of_account": {"key": "typeOfAccount", "type": "str"}, } - def __init__( - self, - *, - cloud_connectors: Optional["_models.CloudConnectors"] = None, - managed_resource_group_name: Optional[str] = None, - public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", - **kwargs - ): - """ - :keyword cloud_connectors: Cloud connectors. - External cloud identifier used as part of scanning configuration. - :paramtype cloud_connectors: ~azure.mgmt.purview.models.CloudConnectors - :keyword managed_resource_group_name: Gets or sets the managed resource group name. - :paramtype managed_resource_group_name: str - :keyword public_network_access: Gets or sets the public network access. Known values are: - "NotSpecified", "Enabled", and "Disabled". - :paramtype public_network_access: str or ~azure.mgmt.purview.models.PublicNetworkAccess - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.cloud_connectors = cloud_connectors - self.created_at = None - self.created_by = None - self.created_by_object_id = None - self.endpoints = None - self.friendly_name = None - self.managed_resource_group_name = managed_resource_group_name - self.managed_resources = None - self.private_endpoint_connections = None - self.provisioning_state = None - self.public_network_access = public_network_access + self.account_location = None + self.account_name = None + self.account_resource_group_name = None + self.account_subscription_id = None + self.deprovisioned = None + self.merge_status = None + self.type_of_account = None -class AccountPropertiesEndpoints(AccountEndpoints): - """The URIs that are the public endpoints of the account. +class AccountStatus(_serialization.Model): + """The account status. Variables are only populated by the server, and will be ignored when sending a request. - :ivar catalog: Gets the catalog endpoint. - :vartype catalog: str - :ivar guardian: Gets the guardian endpoint. - :vartype guardian: str - :ivar scan: Gets the scan endpoint. - :vartype scan: str + :ivar account_provisioning_state: Gets the account status code. Known values are: "Unknown", + "Creating", "Updating", "Moving", "Deleting", "SoftDeleting", "SoftDeleted", "Failed", + "Succeeded", and "Canceled". + :vartype account_provisioning_state: str or ~azure.mgmt.purview.models.AccountProvisioningState + :ivar error_details: Gets the account error details. + :vartype error_details: ~azure.mgmt.purview.models.AccountStatusErrorDetails """ _validation = { - "catalog": {"readonly": True}, - "guardian": {"readonly": True}, - "scan": {"readonly": True}, + "account_provisioning_state": {"readonly": True}, + "error_details": {"readonly": True}, } _attribute_map = { - "catalog": {"key": "catalog", "type": "str"}, - "guardian": {"key": "guardian", "type": "str"}, - "scan": {"key": "scan", "type": "str"}, + "account_provisioning_state": {"key": "accountProvisioningState", "type": "str"}, + "error_details": {"key": "errorDetails", "type": "AccountStatusErrorDetails"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) + self.account_provisioning_state = None + self.error_details = None + + +class AccountPropertiesAccountStatus(AccountStatus): + """Gets or sets the status of the account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar account_provisioning_state: Gets the account status code. Known values are: "Unknown", + "Creating", "Updating", "Moving", "Deleting", "SoftDeleting", "SoftDeleted", "Failed", + "Succeeded", and "Canceled". + :vartype account_provisioning_state: str or ~azure.mgmt.purview.models.AccountProvisioningState + :ivar error_details: Gets the account error details. + :vartype error_details: ~azure.mgmt.purview.models.AccountStatusErrorDetails + """ + + +class AccountPropertiesEndpoints(AccountEndpoints): + """The URIs that are the public endpoints of the account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar catalog: Gets the catalog endpoint. + :vartype catalog: str + :ivar scan: Gets the scan endpoint. + :vartype scan: str + """ class ManagedResources(_serialization.Model): @@ -465,7 +503,7 @@ class ManagedResources(_serialization.Model): "storage_account": {"key": "storageAccount", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.event_hub_namespace = None @@ -487,30 +525,14 @@ class AccountPropertiesManagedResources(ManagedResources): :vartype storage_account: str """ - _validation = { - "event_hub_namespace": {"readonly": True}, - "resource_group": {"readonly": True}, - "storage_account": {"readonly": True}, - } - - _attribute_map = { - "event_hub_namespace": {"key": "eventHubNamespace", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - "storage_account": {"key": "storageAccount", "type": "str"}, - } - - def __init__(self, **kwargs): - """ """ - super().__init__(**kwargs) - class AccountSkuAutoGenerated(_serialization.Model): """The Sku. :ivar capacity: Gets or sets the sku capacity. :vartype capacity: int - :ivar name: Gets or sets the sku name. "Standard" - :vartype name: str or ~azure.mgmt.purview.models.Name + :ivar name: Gets or sets the sku name. Known values are: "Standard" and "Free". + :vartype name: str or ~azure.mgmt.purview.models.AccountSkuName """ _attribute_map = { @@ -518,12 +540,18 @@ class AccountSkuAutoGenerated(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, capacity: Optional[int] = None, name: Optional[Union[str, "_models.Name"]] = None, **kwargs): + def __init__( + self, + *, + capacity: Optional[int] = None, + name: Optional[Union[str, "_models.AccountSkuName"]] = None, + **kwargs: Any + ) -> None: """ :keyword capacity: Gets or sets the sku capacity. :paramtype capacity: int - :keyword name: Gets or sets the sku name. "Standard" - :paramtype name: str or ~azure.mgmt.purview.models.Name + :keyword name: Gets or sets the sku name. Known values are: "Standard" and "Free". + :paramtype name: str or ~azure.mgmt.purview.models.AccountSkuName """ super().__init__(**kwargs) self.capacity = capacity @@ -535,62 +563,274 @@ class AccountSku(AccountSkuAutoGenerated): :ivar capacity: Gets or sets the sku capacity. :vartype capacity: int - :ivar name: Gets or sets the sku name. "Standard" - :vartype name: str or ~azure.mgmt.purview.models.Name + :ivar name: Gets or sets the sku name. Known values are: "Standard" and "Free". + :vartype name: str or ~azure.mgmt.purview.models.AccountSkuName + """ + + +class ErrorModel(_serialization.Model): + """Default error model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Gets or sets the code. + :vartype code: str + :ivar details: Gets or sets the details. + :vartype details: list[~azure.mgmt.purview.models.ErrorModel] + :ivar message: Gets or sets the messages. + :vartype message: str + :ivar target: Gets or sets the target. + :vartype target: str """ + _validation = { + "code": {"readonly": True}, + "details": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + } + _attribute_map = { - "capacity": {"key": "capacity", "type": "int"}, - "name": {"key": "name", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "details": {"key": "details", "type": "[ErrorModel]"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__(self, *, capacity: Optional[int] = None, name: Optional[Union[str, "_models.Name"]] = None, **kwargs): - """ - :keyword capacity: Gets or sets the sku capacity. - :paramtype capacity: int - :keyword name: Gets or sets the sku name. "Standard" - :paramtype name: str or ~azure.mgmt.purview.models.Name - """ - super().__init__(capacity=capacity, name=name, **kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.details = None + self.message = None + self.target = None + + +class AccountStatusErrorDetails(ErrorModel): + """Gets the account error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Gets or sets the code. + :vartype code: str + :ivar details: Gets or sets the details. + :vartype details: list[~azure.mgmt.purview.models.ErrorModel] + :ivar message: Gets or sets the messages. + :vartype message: str + :ivar target: Gets or sets the target. + :vartype target: str + """ -class AccountUpdateParameters(_serialization.Model): +class AccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The account update properties. - :ivar identity: Identity related info to add/remove userAssignedIdentities. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar identity: The Managed Identity of the resource. :vartype identity: ~azure.mgmt.purview.models.Identity - :ivar properties: The account properties. - :vartype properties: ~azure.mgmt.purview.models.AccountProperties :ivar tags: Tags on the azure resource. :vartype tags: dict[str, str] + :ivar account_status: Gets or sets the status of the account. + :vartype account_status: ~azure.mgmt.purview.models.AccountPropertiesAccountStatus + :ivar cloud_connectors: External Cloud Service connectors. + :vartype cloud_connectors: ~azure.mgmt.purview.models.CloudConnectors + :ivar created_at: Gets the time at which the entity was created. + :vartype created_at: ~datetime.datetime + :ivar created_by: Gets the creator of the entity. + :vartype created_by: str + :ivar created_by_object_id: Gets the creators of the entity's object id. + :vartype created_by_object_id: str + :ivar default_domain: Gets the default domain in the account. + :vartype default_domain: str + :ivar endpoints: The URIs that are the public endpoints of the account. + :vartype endpoints: ~azure.mgmt.purview.models.AccountPropertiesEndpoints + :ivar friendly_name: Gets or sets the friendly name. + :vartype friendly_name: str + :ivar ingestion_storage: Ingestion Storage Account Info. + :vartype ingestion_storage: ~azure.mgmt.purview.models.IngestionStorage + :ivar managed_event_hub_state: Gets or sets the state of managed eventhub. If enabled managed + eventhub will be created, if disabled the managed eventhub will be removed. Known values are: + "NotSpecified", "Disabled", and "Enabled". + :vartype managed_event_hub_state: str or ~azure.mgmt.purview.models.ManagedEventHubState + :ivar managed_resource_group_name: Gets or sets the managed resource group name. + :vartype managed_resource_group_name: str + :ivar managed_resources: Gets the resource identifiers of the managed resources. + :vartype managed_resources: ~azure.mgmt.purview.models.AccountPropertiesManagedResources + :ivar managed_resources_public_network_access: Gets or sets the public network access for + managed resources. Known values are: "NotSpecified", "Enabled", and "Disabled". + :vartype managed_resources_public_network_access: str or + ~azure.mgmt.purview.models.PublicNetworkAccess + :ivar merge_info: Gets or sets the Merge Info. + :vartype merge_info: ~azure.mgmt.purview.models.AccountMergeInfo + :ivar private_endpoint_connections: Gets the private endpoint connections information. + :vartype private_endpoint_connections: + list[~azure.mgmt.purview.models.PrivateEndpointConnection] + :ivar provisioning_state: Gets or sets the state of the provisioning. Known values are: + "Unknown", "Creating", "Moving", "Deleting", "SoftDeleting", "SoftDeleted", "Failed", + "Succeeded", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.purview.models.ProvisioningState + :ivar public_network_access: Gets or sets the public network access. Known values are: + "NotSpecified", "Enabled", and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.purview.models.PublicNetworkAccess + :ivar tenant_endpoint_state: Gets or sets the state of tenant endpoint. Known values are: + "NotSpecified", "Disabled", and "Enabled". + :vartype tenant_endpoint_state: str or ~azure.mgmt.purview.models.TenantEndpointState """ + _validation = { + "account_status": {"readonly": True}, + "created_at": {"readonly": True}, + "created_by": {"readonly": True}, + "created_by_object_id": {"readonly": True}, + "default_domain": {"readonly": True}, + "endpoints": {"readonly": True}, + "friendly_name": {"readonly": True}, + "managed_resources": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + _attribute_map = { "identity": {"key": "identity", "type": "Identity"}, - "properties": {"key": "properties", "type": "AccountProperties"}, "tags": {"key": "tags", "type": "{str}"}, + "account_status": {"key": "properties.accountStatus", "type": "AccountPropertiesAccountStatus"}, + "cloud_connectors": {"key": "properties.cloudConnectors", "type": "CloudConnectors"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "created_by": {"key": "properties.createdBy", "type": "str"}, + "created_by_object_id": {"key": "properties.createdByObjectId", "type": "str"}, + "default_domain": {"key": "properties.defaultDomain", "type": "str"}, + "endpoints": {"key": "properties.endpoints", "type": "AccountPropertiesEndpoints"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "ingestion_storage": {"key": "properties.ingestionStorage", "type": "IngestionStorage"}, + "managed_event_hub_state": {"key": "properties.managedEventHubState", "type": "str"}, + "managed_resource_group_name": {"key": "properties.managedResourceGroupName", "type": "str"}, + "managed_resources": {"key": "properties.managedResources", "type": "AccountPropertiesManagedResources"}, + "managed_resources_public_network_access": { + "key": "properties.managedResourcesPublicNetworkAccess", + "type": "str", + }, + "merge_info": {"key": "properties.mergeInfo", "type": "AccountMergeInfo"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "tenant_endpoint_state": {"key": "properties.tenantEndpointState", "type": "str"}, } def __init__( self, *, identity: Optional["_models.Identity"] = None, - properties: Optional["_models.AccountProperties"] = None, tags: Optional[Dict[str, str]] = None, - **kwargs - ): + cloud_connectors: Optional["_models.CloudConnectors"] = None, + ingestion_storage: Optional["_models.IngestionStorage"] = None, + managed_event_hub_state: Union[str, "_models.ManagedEventHubState"] = "NotSpecified", + managed_resource_group_name: Optional[str] = None, + managed_resources_public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + merge_info: Optional["_models.AccountMergeInfo"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + tenant_endpoint_state: Optional[Union[str, "_models.TenantEndpointState"]] = None, + **kwargs: Any + ) -> None: """ - :keyword identity: Identity related info to add/remove userAssignedIdentities. + :keyword identity: The Managed Identity of the resource. :paramtype identity: ~azure.mgmt.purview.models.Identity - :keyword properties: The account properties. - :paramtype properties: ~azure.mgmt.purview.models.AccountProperties :keyword tags: Tags on the azure resource. :paramtype tags: dict[str, str] + :keyword cloud_connectors: External Cloud Service connectors. + :paramtype cloud_connectors: ~azure.mgmt.purview.models.CloudConnectors + :keyword ingestion_storage: Ingestion Storage Account Info. + :paramtype ingestion_storage: ~azure.mgmt.purview.models.IngestionStorage + :keyword managed_event_hub_state: Gets or sets the state of managed eventhub. If enabled + managed eventhub will be created, if disabled the managed eventhub will be removed. Known + values are: "NotSpecified", "Disabled", and "Enabled". + :paramtype managed_event_hub_state: str or ~azure.mgmt.purview.models.ManagedEventHubState + :keyword managed_resource_group_name: Gets or sets the managed resource group name. + :paramtype managed_resource_group_name: str + :keyword managed_resources_public_network_access: Gets or sets the public network access for + managed resources. Known values are: "NotSpecified", "Enabled", and "Disabled". + :paramtype managed_resources_public_network_access: str or + ~azure.mgmt.purview.models.PublicNetworkAccess + :keyword merge_info: Gets or sets the Merge Info. + :paramtype merge_info: ~azure.mgmt.purview.models.AccountMergeInfo + :keyword public_network_access: Gets or sets the public network access. Known values are: + "NotSpecified", "Enabled", and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.purview.models.PublicNetworkAccess + :keyword tenant_endpoint_state: Gets or sets the state of tenant endpoint. Known values are: + "NotSpecified", "Disabled", and "Enabled". + :paramtype tenant_endpoint_state: str or ~azure.mgmt.purview.models.TenantEndpointState """ super().__init__(**kwargs) self.identity = identity - self.properties = properties self.tags = tags + self.account_status = None + self.cloud_connectors = cloud_connectors + self.created_at = None + self.created_by = None + self.created_by_object_id = None + self.default_domain = None + self.endpoints = None + self.friendly_name = None + self.ingestion_storage = ingestion_storage + self.managed_event_hub_state = managed_event_hub_state + self.managed_resource_group_name = managed_resource_group_name + self.managed_resources = None + self.managed_resources_public_network_access = managed_resources_public_network_access + self.merge_info = merge_info + self.private_endpoint_connections = None + self.provisioning_state = None + self.public_network_access = public_network_access + self.tenant_endpoint_state = tenant_endpoint_state + + +class BatchFeatureRequest(_serialization.Model): + """Feature request model. + + :ivar features: Set of features. + :vartype features: list[str] + """ + + _validation = { + "features": {"unique": True}, + } + + _attribute_map = { + "features": {"key": "features", "type": "[str]"}, + } + + def __init__(self, *, features: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword features: Set of features. + :paramtype features: list[str] + """ + super().__init__(**kwargs) + self.features = features + + +class BatchFeatureStatus(_serialization.Model): + """List of features with enabled status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar features: Features with enabled status. + :vartype features: dict[str, bool] + """ + + _validation = { + "features": {"readonly": True}, + } + + _attribute_map = { + "features": {"key": "features", "type": "{bool}"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.features = None class CheckNameAvailabilityRequest(_serialization.Model): @@ -607,7 +847,7 @@ class CheckNameAvailabilityRequest(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Resource name to verify for availability. :paramtype name: str @@ -643,8 +883,8 @@ def __init__( message: Optional[str] = None, name_available: Optional[bool] = None, reason: Optional[Union[str, "_models.Reason"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword message: Error message. :paramtype message: str @@ -678,7 +918,7 @@ class CloudConnectors(_serialization.Model): "aws_external_id": {"key": "awsExternalId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.aws_external_id = None @@ -695,7 +935,7 @@ class CollectionAdminUpdate(_serialization.Model): "object_id": {"key": "objectId", "type": "str"}, } - def __init__(self, *, object_id: Optional[str] = None, **kwargs): + def __init__(self, *, object_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword object_id: Gets or sets the object identifier of the admin. :paramtype object_id: str @@ -704,6 +944,134 @@ def __init__(self, *, object_id: Optional[str] = None, **kwargs): self.object_id = object_id +class ProxyResource(_serialization.Model): + """Proxy Azure Resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Gets or sets the identifier. + :vartype id: str + :ivar name: Gets or sets the name. + :vartype name: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.purview.models.ProxyResourceSystemData + :ivar type: Gets or sets the type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "system_data": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "system_data": {"key": "systemData", "type": "ProxyResourceSystemData"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.system_data = None + self.type = None + + +class Consent(ProxyResource): + """Consent extension resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Gets or sets the identifier. + :vartype id: str + :ivar name: Gets or sets the name. + :vartype name: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.purview.models.ProxyResourceSystemData + :ivar type: Gets or sets the type. + :vartype type: str + :ivar kind: Gets or sets the consent kind. Known values are: "Metadata" and "Governance". + :vartype kind: str or ~azure.mgmt.purview.models.ConsentKind + :ivar scope: + :vartype scope: str + :ivar scope_type: Defines consent scope type. Known values are: "Azure", "Fabric", + "Databricks", "Snowflake", and "S3". + :vartype scope_type: str or ~azure.mgmt.purview.models.ConsentScopeType + :ivar status: Defines consent status. Known values are: "NotSpecified", "Enabled", and + "Disabled". + :vartype status: str or ~azure.mgmt.purview.models.ConsentStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "system_data": {"readonly": True}, + "type": {"readonly": True}, + "scope": {"readonly": True}, + "scope_type": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "system_data": {"key": "systemData", "type": "ProxyResourceSystemData"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "scope_type": {"key": "properties.scopeType", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + } + + def __init__(self, *, kind: Optional[Union[str, "_models.ConsentKind"]] = None, **kwargs: Any) -> None: + """ + :keyword kind: Gets or sets the consent kind. Known values are: "Metadata" and "Governance". + :paramtype kind: str or ~azure.mgmt.purview.models.ConsentKind + """ + super().__init__(**kwargs) + self.kind = kind + self.scope = None + self.scope_type = None + self.status = None + + +class Credentials(_serialization.Model): + """Credentials to access the event streaming service attached to the purview account. + + :ivar identity_id: Identity identifier for UserAssign type. + :vartype identity_id: str + :ivar type: Identity Type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.purview.models.KafkaConfigurationIdentityType + """ + + _attribute_map = { + "identity_id": {"key": "identityId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + identity_id: Optional[str] = None, + type: Optional[Union[str, "_models.KafkaConfigurationIdentityType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity_id: Identity identifier for UserAssign type. + :paramtype identity_id: str + :keyword type: Identity Type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :paramtype type: str or ~azure.mgmt.purview.models.KafkaConfigurationIdentityType + """ + super().__init__(**kwargs) + self.identity_id = identity_id + self.type = type + + class DefaultAccountPayload(_serialization.Model): """Payload to get and set the default account in the given scope. @@ -740,8 +1108,8 @@ def __init__( scope_tenant_id: Optional[str] = None, scope_type: Optional[Union[str, "_models.ScopeType"]] = None, subscription_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword account_name: The name of the account that is set as the default. :paramtype account_name: str @@ -791,8 +1159,8 @@ def __init__( display_name: Optional[str] = None, name: Optional[str] = None, to_be_exported_for_customer: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword display_name: localized display name of the dimension to customer. :paramtype display_name: str @@ -808,8 +1176,31 @@ def __init__( self.to_be_exported_for_customer = to_be_exported_for_customer -class ErrorModel(_serialization.Model): - """Default error model. +class ErrorResponseModel(_serialization.Model): + """Default error response model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar error: Gets or sets the error. + :vartype error: ~azure.mgmt.purview.models.ErrorResponseModelError + """ + + _validation = { + "error": {"readonly": True}, + } + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseModelError"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.error = None + + +class ErrorResponseModelError(ErrorModel): + """Gets or sets the error. Variables are only populated by the server, and will be ignored when sending a request. @@ -823,137 +1214,228 @@ class ErrorModel(_serialization.Model): :vartype target: str """ + +class Identity(_serialization.Model): + """The Managed Identity of the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: Service principal object Id. + :vartype principal_id: str + :ivar tenant_id: Tenant Id. + :vartype tenant_id: str + :ivar type: Identity Type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.purview.models.ManagedIdentityType + :ivar user_assigned_identities: User Assigned Identities. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.purview.models.UserAssignedIdentity] + """ + _validation = { - "code": {"readonly": True}, - "details": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - "code": {"key": "code", "type": "str"}, - "details": {"key": "details", "type": "[ErrorModel]"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } - def __init__(self, **kwargs): - """ """ + def __init__( + self, + *, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Identity Type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :paramtype type: str or ~azure.mgmt.purview.models.ManagedIdentityType + :keyword user_assigned_identities: User Assigned Identities. + :paramtype user_assigned_identities: dict[str, ~azure.mgmt.purview.models.UserAssignedIdentity] + """ super().__init__(**kwargs) - self.code = None - self.details = None - self.message = None - self.target = None + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities -class ErrorResponseModel(_serialization.Model): - """Default error response model. +class IngestionStorage(_serialization.Model): + """Ingestion Storage Account Info. Variables are only populated by the server, and will be ignored when sending a request. - :ivar error: Gets or sets the error. - :vartype error: ~azure.mgmt.purview.models.ErrorResponseModelError + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar primary_endpoint: Gets or sets the primary endpoint. + :vartype primary_endpoint: str + :ivar public_network_access: Gets or sets the public network access setting. Known values are: + "NotSpecified", "Enabled", and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.purview.models.PublicNetworkAccess """ _validation = { - "error": {"readonly": True}, + "id": {"readonly": True}, + "primary_endpoint": {"readonly": True}, } _attribute_map = { - "error": {"key": "error", "type": "ErrorResponseModelError"}, + "id": {"key": "id", "type": "str"}, + "primary_endpoint": {"key": "primaryEndpoint", "type": "str"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, } - def __init__(self, **kwargs): - """ """ + def __init__( + self, *, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs: Any + ) -> None: + """ + :keyword public_network_access: Gets or sets the public network access setting. Known values + are: "NotSpecified", "Enabled", and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.purview.models.PublicNetworkAccess + """ super().__init__(**kwargs) - self.error = None + self.id = None + self.primary_endpoint = None + self.public_network_access = public_network_access -class ErrorResponseModelError(ErrorModel): - """Gets or sets the error. +class KafkaConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes + """The configuration of the event streaming service resource attached to the Purview account for + kafka notifications. Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Gets or sets the code. - :vartype code: str - :ivar details: Gets or sets the details. - :vartype details: list[~azure.mgmt.purview.models.ErrorModel] - :ivar message: Gets or sets the messages. - :vartype message: str - :ivar target: Gets or sets the target. - :vartype target: str + :ivar id: Gets or sets the identifier. + :vartype id: str + :ivar name: Gets or sets the name. + :vartype name: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.purview.models.ProxyResourceSystemData + :ivar type: Gets or sets the type. + :vartype type: str + :ivar consumer_group: Consumer group for hook event hub. + :vartype consumer_group: str + :ivar credentials: Credentials to access the event streaming service attached to the purview + account. + :vartype credentials: ~azure.mgmt.purview.models.Credentials + :ivar event_hub_partition_id: Optional partition Id for notification event hub. If not set, all + partitions will be leveraged. + :vartype event_hub_partition_id: str + :ivar event_hub_resource_id: + :vartype event_hub_resource_id: str + :ivar event_hub_type: The event hub type. Known values are: "Notification" and "Hook". + :vartype event_hub_type: str or ~azure.mgmt.purview.models.EventHubType + :ivar event_streaming_state: The state of the event streaming service. Known values are: + "Disabled" and "Enabled". + :vartype event_streaming_state: str or ~azure.mgmt.purview.models.EventStreamingState + :ivar event_streaming_type: The event streaming service type. Known values are: "None", + "Managed", and "Azure". + :vartype event_streaming_type: str or ~azure.mgmt.purview.models.EventStreamingType """ _validation = { - "code": {"readonly": True}, - "details": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "system_data": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - "code": {"key": "code", "type": "str"}, - "details": {"key": "details", "type": "[ErrorModel]"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "system_data": {"key": "systemData", "type": "ProxyResourceSystemData"}, + "type": {"key": "type", "type": "str"}, + "consumer_group": {"key": "properties.consumerGroup", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "Credentials"}, + "event_hub_partition_id": {"key": "properties.eventHubPartitionId", "type": "str"}, + "event_hub_resource_id": {"key": "properties.eventHubResourceId", "type": "str"}, + "event_hub_type": {"key": "properties.eventHubType", "type": "str"}, + "event_streaming_state": {"key": "properties.eventStreamingState", "type": "str"}, + "event_streaming_type": {"key": "properties.eventStreamingType", "type": "str"}, } - def __init__(self, **kwargs): - """ """ + def __init__( + self, + *, + consumer_group: Optional[str] = None, + credentials: Optional["_models.Credentials"] = None, + event_hub_partition_id: Optional[str] = None, + event_hub_resource_id: Optional[str] = None, + event_hub_type: Optional[Union[str, "_models.EventHubType"]] = None, + event_streaming_state: Union[str, "_models.EventStreamingState"] = "Enabled", + event_streaming_type: Union[str, "_models.EventStreamingType"] = "None", + **kwargs: Any + ) -> None: + """ + :keyword consumer_group: Consumer group for hook event hub. + :paramtype consumer_group: str + :keyword credentials: Credentials to access the event streaming service attached to the purview + account. + :paramtype credentials: ~azure.mgmt.purview.models.Credentials + :keyword event_hub_partition_id: Optional partition Id for notification event hub. If not set, + all partitions will be leveraged. + :paramtype event_hub_partition_id: str + :keyword event_hub_resource_id: + :paramtype event_hub_resource_id: str + :keyword event_hub_type: The event hub type. Known values are: "Notification" and "Hook". + :paramtype event_hub_type: str or ~azure.mgmt.purview.models.EventHubType + :keyword event_streaming_state: The state of the event streaming service. Known values are: + "Disabled" and "Enabled". + :paramtype event_streaming_state: str or ~azure.mgmt.purview.models.EventStreamingState + :keyword event_streaming_type: The event streaming service type. Known values are: "None", + "Managed", and "Azure". + :paramtype event_streaming_type: str or ~azure.mgmt.purview.models.EventStreamingType + """ super().__init__(**kwargs) + self.consumer_group = consumer_group + self.credentials = credentials + self.event_hub_partition_id = event_hub_partition_id + self.event_hub_resource_id = event_hub_resource_id + self.event_hub_type = event_hub_type + self.event_streaming_state = event_streaming_state + self.event_streaming_type = event_streaming_type -class Identity(_serialization.Model): - """The Managed Identity of the resource. +class KafkaConfigurationList(_serialization.Model): + """Paged list of kafka configuration resources. - Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to server. - :ivar principal_id: Service principal object Id. - :vartype principal_id: str - :ivar tenant_id: Tenant Id. - :vartype tenant_id: str - :ivar type: Identity Type. Known values are: "None", "SystemAssigned", and "UserAssigned". - :vartype type: str or ~azure.mgmt.purview.models.Type - :ivar user_assigned_identities: User Assigned Identities. - :vartype user_assigned_identities: dict[str, ~azure.mgmt.purview.models.UserAssignedIdentity] + :ivar next_link: The Url of next result page. + :vartype next_link: str + :ivar value: Collection of items of type results. Required. + :vartype value: list[~azure.mgmt.purview.models.KafkaConfiguration] """ _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[KafkaConfiguration]"}, } def __init__( - self, - *, - type: Optional[Union[str, "_models.Type"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs - ): + self, *, value: List["_models.KafkaConfiguration"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword type: Identity Type. Known values are: "None", "SystemAssigned", and "UserAssigned". - :paramtype type: str or ~azure.mgmt.purview.models.Type - :keyword user_assigned_identities: User Assigned Identities. - :paramtype user_assigned_identities: dict[str, ~azure.mgmt.purview.models.UserAssignedIdentity] + :keyword next_link: The Url of next result page. + :paramtype next_link: str + :keyword value: Collection of items of type results. Required. + :paramtype value: list[~azure.mgmt.purview.models.KafkaConfiguration] """ super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = type - self.user_assigned_identities = user_assigned_identities + self.next_link = next_link + self.value = value class Operation(_serialization.Model): """Operation resource. - :ivar display: Properties on the operation. + :ivar display: The response model for get operation properties. :vartype display: ~azure.mgmt.purview.models.OperationDisplay :ivar is_data_action: Whether operation is a data action. :vartype is_data_action: bool @@ -961,7 +1443,7 @@ class Operation(_serialization.Model): :vartype name: str :ivar origin: origin of the operation. :vartype origin: str - :ivar service_specification: meta service specification. + :ivar service_specification: The operation meta service specification. :vartype service_specification: ~azure.mgmt.purview.models.OperationMetaServiceSpecification """ @@ -984,10 +1466,10 @@ def __init__( name: Optional[str] = None, origin: Optional[str] = None, service_specification: Optional["_models.OperationMetaServiceSpecification"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword display: Properties on the operation. + :keyword display: The response model for get operation properties. :paramtype display: ~azure.mgmt.purview.models.OperationDisplay :keyword is_data_action: Whether operation is a data action. :paramtype is_data_action: bool @@ -995,7 +1477,7 @@ def __init__( :paramtype name: str :keyword origin: origin of the operation. :paramtype origin: str - :keyword service_specification: meta service specification. + :keyword service_specification: The operation meta service specification. :paramtype service_specification: ~azure.mgmt.purview.models.OperationMetaServiceSpecification """ super().__init__(**kwargs) @@ -1033,8 +1515,8 @@ def __init__( operation: Optional[str] = None, provider: Optional[str] = None, resource: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the operation for display purposes. :paramtype description: str @@ -1055,7 +1537,7 @@ def __init__( class OperationList(_serialization.Model): """Paged list of operation resources. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar count: Total item count. :vartype count: int @@ -1081,8 +1563,8 @@ def __init__( value: List["_models.Operation"], count: Optional[int] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword count: Total item count. :paramtype count: int @@ -1120,8 +1602,8 @@ def __init__( blob_duration: Optional[str] = None, display_name: Optional[str] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword blob_duration: blob duration of the log. :paramtype blob_duration: str @@ -1198,8 +1680,8 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, unit: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword aggregation_type: aggregation type of metric. :paramtype aggregation_type: str @@ -1264,8 +1746,8 @@ def __init__( *, log_specifications: Optional[List["_models.OperationMetaLogSpecification"]] = None, metric_specifications: Optional[List["_models.OperationMetaMetricSpecification"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_specifications: log specifications for the operation. :paramtype log_specifications: list[~azure.mgmt.purview.models.OperationMetaLogSpecification] @@ -1289,7 +1771,7 @@ class PrivateEndpoint(_serialization.Model): "id": {"key": "id", "type": "str"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ :keyword id: The private endpoint identifier. :paramtype id: str @@ -1298,39 +1780,6 @@ def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=re self.id = id -class ProxyResource(_serialization.Model): - """Proxy Azure Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Gets or sets the identifier. - :vartype id: str - :ivar name: Gets or sets the name. - :vartype name: str - :ivar type: Gets or sets the type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs): - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - class PrivateEndpointConnection(ProxyResource): """A private endpoint connection class. @@ -1340,6 +1789,8 @@ class PrivateEndpointConnection(ProxyResource): :vartype id: str :ivar name: Gets or sets the name. :vartype name: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.purview.models.ProxyResourceSystemData :ivar type: Gets or sets the type. :vartype type: str :ivar private_endpoint: The private endpoint information. @@ -1354,6 +1805,7 @@ class PrivateEndpointConnection(ProxyResource): _validation = { "id": {"readonly": True}, "name": {"readonly": True}, + "system_data": {"readonly": True}, "type": {"readonly": True}, "provisioning_state": {"readonly": True}, } @@ -1361,6 +1813,7 @@ class PrivateEndpointConnection(ProxyResource): _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, + "system_data": {"key": "systemData", "type": "ProxyResourceSystemData"}, "type": {"key": "type", "type": "str"}, "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, "private_link_service_connection_state": { @@ -1375,8 +1828,8 @@ def __init__( *, private_endpoint: Optional["_models.PrivateEndpoint"] = None, private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword private_endpoint: The private endpoint information. :paramtype private_endpoint: ~azure.mgmt.purview.models.PrivateEndpoint @@ -1393,10 +1846,8 @@ def __init__( class PrivateEndpointConnectionList(_serialization.Model): """Paged list of private endpoint connections. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar count: Total item count. - :vartype count: int :ivar next_link: The Url of next result page. :vartype next_link: str :ivar value: Collection of items of type results. Required. @@ -1408,33 +1859,80 @@ class PrivateEndpointConnectionList(_serialization.Model): } _attribute_map = { - "count": {"key": "count", "type": "int"}, "next_link": {"key": "nextLink", "type": "str"}, "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } def __init__( - self, - *, - value: List["_models.PrivateEndpointConnection"], - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs - ): + self, *, value: List["_models.PrivateEndpointConnection"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword count: Total item count. - :paramtype count: int :keyword next_link: The Url of next result page. :paramtype next_link: str :keyword value: Collection of items of type results. Required. :paramtype value: list[~azure.mgmt.purview.models.PrivateEndpointConnection] """ super().__init__(**kwargs) - self.count = count self.next_link = next_link self.value = value +class PrivateEndpointConnectionStatusUpdateRequest(_serialization.Model): # pylint: disable=name-too-long + """A private endpoint connection status update request class. + + :ivar private_endpoint_id: The private endpoint resource identifier. + :vartype private_endpoint_id: str + :ivar status: The private endpoint connection status. + :vartype status: str + """ + + _attribute_map = { + "private_endpoint_id": {"key": "privateEndpointId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, *, private_endpoint_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword private_endpoint_id: The private endpoint resource identifier. + :paramtype private_endpoint_id: str + :keyword status: The private endpoint connection status. + :paramtype status: str + """ + super().__init__(**kwargs) + self.private_endpoint_id = private_endpoint_id + self.status = status + + +class PrivateEndpointConnectionStatusUpdateResponse(_serialization.Model): # pylint: disable=name-too-long + """A private endpoint connection status update response class. + + :ivar private_endpoint_id: The private endpoint resource identifier. + :vartype private_endpoint_id: str + :ivar status: The private endpoint connection status. + :vartype status: str + """ + + _attribute_map = { + "private_endpoint_id": {"key": "privateEndpointId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, *, private_endpoint_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword private_endpoint_id: The private endpoint resource identifier. + :paramtype private_endpoint_id: str + :keyword status: The private endpoint connection status. + :paramtype status: str + """ + super().__init__(**kwargs) + self.private_endpoint_id = private_endpoint_id + self.status = status + + class PrivateLinkResource(_serialization.Model): """A privately linkable resource. @@ -1444,42 +1942,51 @@ class PrivateLinkResource(_serialization.Model): :vartype id: str :ivar name: The private link resource name. :vartype name: str - :ivar properties: The private link resource properties. - :vartype properties: ~azure.mgmt.purview.models.PrivateLinkResourceProperties :ivar type: The private link resource type. :vartype type: str + :ivar group_id: The private link resource group identifier. + :vartype group_id: str + :ivar required_members: This translates to how many Private IPs should be created for each + privately linkable resource. + :vartype required_members: list[str] + :ivar required_zone_names: The required zone names for private link resource. + :vartype required_zone_names: list[str] """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, - "properties": {"readonly": True}, "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + "required_zone_names": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "PrivateLinkResourceProperties"}, "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None - self.properties = None self.type = None + self.group_id = None + self.required_members = None + self.required_zone_names = None class PrivateLinkResourceList(_serialization.Model): """Paged list of private link resources. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar count: Total item count. - :vartype count: int :ivar next_link: The Url of next result page. :vartype next_link: str :ivar value: Collection of items of type results. Required. @@ -1491,67 +1998,24 @@ class PrivateLinkResourceList(_serialization.Model): } _attribute_map = { - "count": {"key": "count", "type": "int"}, "next_link": {"key": "nextLink", "type": "str"}, "value": {"key": "value", "type": "[PrivateLinkResource]"}, } def __init__( - self, - *, - value: List["_models.PrivateLinkResource"], - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs - ): + self, *, value: List["_models.PrivateLinkResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword count: Total item count. - :paramtype count: int :keyword next_link: The Url of next result page. :paramtype next_link: str :keyword value: Collection of items of type results. Required. :paramtype value: list[~azure.mgmt.purview.models.PrivateLinkResource] """ super().__init__(**kwargs) - self.count = count self.next_link = next_link self.value = value -class PrivateLinkResourceProperties(_serialization.Model): - """A privately linkable resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_id: The private link resource group identifier. - :vartype group_id: str - :ivar required_members: This translates to how many Private IPs should be created for each - privately linkable resource. - :vartype required_members: list[str] - :ivar required_zone_names: The required zone names for private link resource. - :vartype required_zone_names: list[str] - """ - - _validation = { - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - "required_zone_names": {"readonly": True}, - } - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, **kwargs): - """ """ - super().__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = None - - class PrivateLinkServiceConnectionState(_serialization.Model): """The private link service connection state. @@ -1561,7 +2025,7 @@ class PrivateLinkServiceConnectionState(_serialization.Model): :vartype description: str :ivar status: The status. Known values are: "Unknown", "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or ~azure.mgmt.purview.models.Status + :vartype status: str or ~azure.mgmt.purview.models.PrivateEndpointConnectionStatus """ _attribute_map = { @@ -1575,9 +2039,9 @@ def __init__( *, actions_required: Optional[str] = None, description: Optional[str] = None, - status: Optional[Union[str, "_models.Status"]] = None, - **kwargs - ): + status: Optional[Union[str, "_models.PrivateEndpointConnectionStatus"]] = None, + **kwargs: Any + ) -> None: """ :keyword actions_required: The required actions. :paramtype actions_required: str @@ -1585,7 +2049,7 @@ def __init__( :paramtype description: str :keyword status: The status. Known values are: "Unknown", "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or ~azure.mgmt.purview.models.Status + :paramtype status: str or ~azure.mgmt.purview.models.PrivateEndpointConnectionStatus """ super().__init__(**kwargs) self.actions_required = actions_required @@ -1632,7 +2096,7 @@ class SystemData(_serialization.Model): "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.created_at = None @@ -1643,6 +2107,54 @@ def __init__(self, **kwargs): self.last_modified_by_type = None +class ProxyResourceSystemData(SystemData): + """Metadata pertaining to creation and last modification of the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.purview.models.CreatedByType + :ivar last_modified_at: The timestamp of the last modification the resource (UTC). + :vartype last_modified_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.purview.models.LastModifiedByType + """ + + +class QuotaName(_serialization.Model): + """Quota name. + + :ivar localized_value: Gets or sets the localized name value. + :vartype localized_value: str + :ivar value: Gets or sets the name value. + :vartype value: str + """ + + _attribute_map = { + "localized_value": {"key": "localizedValue", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, localized_value: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword localized_value: Gets or sets the localized name value. + :paramtype localized_value: str + :keyword value: Gets or sets the name value. + :paramtype value: str + """ + super().__init__(**kwargs) + self.localized_value = localized_value + self.value = value + + class TrackedResourceSystemData(SystemData): """Metadata pertaining to creation and last modification of the resource. @@ -1664,27 +2176,88 @@ class TrackedResourceSystemData(SystemData): :vartype last_modified_by_type: str or ~azure.mgmt.purview.models.LastModifiedByType """ + +class Usage(_serialization.Model): + """Response for usage information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar current_value: Current usage quota value. + :vartype current_value: int + :ivar id: Fully qualified resource Id. + :vartype id: str + :ivar limit: Usage quota limit. + :vartype limit: int + :ivar name: Quota name. + :vartype name: ~azure.mgmt.purview.models.UsageName + :ivar unit: Quota usage unit. + :vartype unit: str + """ + _validation = { - "created_at": {"readonly": True}, - "created_by": {"readonly": True}, - "created_by_type": {"readonly": True}, - "last_modified_at": {"readonly": True}, - "last_modified_by": {"readonly": True}, - "last_modified_by_type": {"readonly": True}, + "current_value": {"readonly": True}, + "id": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, + "unit": {"readonly": True}, } _attribute_map = { - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "id": {"key": "id", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, + "unit": {"key": "unit", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) + self.current_value = None + self.id = None + self.limit = None + self.name = None + self.unit = None + + +class UsageList(_serialization.Model): + """List of usage information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar next_link: The Url of next link. + :vartype next_link: str + :ivar value: Collection of usage values. + :vartype value: list[~azure.mgmt.purview.models.Usage] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Usage]"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The Url of next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.next_link = next_link + self.value = None + + +class UsageName(QuotaName): + """Quota name. + + :ivar localized_value: Gets or sets the localized name value. + :vartype localized_value: str + :ivar value: Gets or sets the name value. + :vartype value: str + """ class UserAssignedIdentity(_serialization.Model): @@ -1708,7 +2281,7 @@ class UserAssignedIdentity(_serialization.Model): "principal_id": {"key": "principalId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.client_id = None diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/_purview_management_client_enums.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/_purview_management_client_enums.py index 6dc253d18f11..9b1a38d7afa6 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/_purview_management_client_enums.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/models/_purview_management_client_enums.py @@ -10,6 +10,53 @@ from azure.core import CaseInsensitiveEnumMeta +class AccountProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the account status code.""" + + UNKNOWN = "Unknown" + CREATING = "Creating" + UPDATING = "Updating" + MOVING = "Moving" + DELETING = "Deleting" + SOFT_DELETING = "SoftDeleting" + SOFT_DELETED = "SoftDeleted" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + CANCELED = "Canceled" + + +class AccountSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the sku name.""" + + STANDARD = "Standard" + FREE = "Free" + + +class ConsentKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the consent kind.""" + + METADATA = "Metadata" + GOVERNANCE = "Governance" + + +class ConsentScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines consent scope type.""" + + AZURE = "Azure" + FABRIC = "Fabric" + DATABRICKS = "Databricks" + SNOWFLAKE = "Snowflake" + S3 = "S3" + + +class ConsentStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines consent status.""" + + NOT_SPECIFIED = "NotSpecified" + ENABLED = "Enabled" + DISABLED = "Disabled" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" @@ -19,6 +66,36 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "Key" +class EventHubType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The event hub type.""" + + NOTIFICATION = "Notification" + HOOK = "Hook" + + +class EventStreamingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the event streaming service.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class EventStreamingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The event streaming service type.""" + + NONE = "None" + MANAGED = "Managed" + AZURE = "Azure" + + +class KafkaConfigurationIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identity Type.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + + class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that last modified the resource.""" @@ -28,10 +105,47 @@ class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "Key" -class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets or sets the sku name.""" +class ManagedEventHubState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the state of managed eventhub. If enabled managed eventhub will be created, if + disabled the managed eventhub will be removed. + """ - STANDARD = "Standard" + NOT_SPECIFIED = "NotSpecified" + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identity Type.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + + +class MergeAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The account's type for the merge operation.""" + + PRIMARY = "Primary" + SECONDARY = "Secondary" + + +class MergeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the merge operation.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + IN_PROGRESS = "InProgress" + + +class PrivateEndpointConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status.""" + + UNKNOWN = "Unknown" + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -49,7 +163,7 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets or sets the public network access.""" + """Gets or sets the public network access for managed resources.""" NOT_SPECIFIED = "NotSpecified" ENABLED = "Enabled" @@ -70,19 +184,9 @@ class ScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SUBSCRIPTION = "Subscription" -class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status.""" +class TenantEndpointState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the state of tenant endpoint.""" - UNKNOWN = "Unknown" - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - DISCONNECTED = "Disconnected" - - -class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Identity Type.""" - - NONE = "None" - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" + NOT_SPECIFIED = "NotSpecified" + DISABLED = "Disabled" + ENABLED = "Enabled" diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/__init__.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/__init__.py index 50cffb0c9a59..3496c9ce1a35 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/__init__.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/__init__.py @@ -8,20 +8,28 @@ from ._accounts_operations import AccountsOperations from ._default_accounts_operations import DefaultAccountsOperations +from ._features_operations import FeaturesOperations +from ._ingestion_private_endpoint_connections_operations import IngestionPrivateEndpointConnectionsOperations +from ._kafka_configurations_operations import KafkaConfigurationsOperations from ._operations import Operations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._usages_operations import UsagesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "AccountsOperations", "DefaultAccountsOperations", + "FeaturesOperations", + "IngestionPrivateEndpointConnectionsOperations", + "KafkaConfigurationsOperations", "Operations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", + "UsagesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_accounts_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_accounts_operations.py index 2d8986b8c994..65379119e2b2 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_accounts_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_accounts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,26 +39,22 @@ _SERIALIZER.client_side_validation = False -def build_list_by_resource_group_request( - resource_group_name: str, subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any +def build_list_by_subscription_request( + subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Purview/accounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,22 +67,26 @@ def build_list_by_resource_group_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any +def build_list_by_resource_group_request( + resource_group_name: str, subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Purview/accounts") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts", + ) # 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"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +103,7 @@ def build_get_request(resource_group_name: str, account_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,10 +114,17 @@ def build_get_request(resource_group_name: str, account_name: str, subscription_ path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -138,8 +141,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,10 +153,17 @@ def build_create_or_update_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +182,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -183,10 +193,17 @@ def build_delete_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,8 +220,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -215,10 +232,17 @@ def build_update_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,66 +255,80 @@ def build_update_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_keys_request( +def build_add_root_collection_admin_request( resource_group_name: str, account_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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-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.Purview/accounts/{accountName}/listkeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/addRootCollectionAdmin", ) # 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"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_add_root_collection_admin_request( +def build_list_keys_request( resource_group_name: str, account_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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/addRootCollectionAdmin", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/listkeys", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) @@ -300,8 +338,8 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -312,7 +350,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -345,18 +383,13 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.Account"]: - """Gets the accounts resources by resource group. + def list_by_subscription(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.Account"]: + """Gets the accounts resources by subscription. - List accounts in ResourceGroup. + List accounts in Subscription. - :param resource_group_name: The resource group name. Required. - :type resource_group_name: str :param skip_token: The skip token. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Account or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -364,10 +397,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AccountList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -380,17 +411,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -402,26 +431,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("AccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -434,17 +464,18 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts"} # type: ignore - @distributed_trace - def list_by_subscription(self, skip_token: Optional[str] = None, **kwargs: Any) -> Iterable["_models.Account"]: - """Gets the accounts resources by subscription. + def list_by_resource_group( + self, resource_group_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Account"]: + """Gets the accounts resources by resource group. - List accounts in Subscription. + List accounts in ResourceGroup. + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str :param skip_token: The skip token. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Account or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -452,10 +483,8 @@ def list_by_subscription(self, skip_token: Optional[str] = None, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccountList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AccountList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -468,16 +497,16 @@ def list_by_subscription(self, skip_token: Optional[str] = None, **kwargs: Any) def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -489,26 +518,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("AccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,8 +551,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Purview/accounts"} # type: ignore - @distributed_trace def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.Account: """Gets the account resource. @@ -533,7 +561,6 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Account or the result of cls(response) :rtype: ~azure.mgmt.purview.models.Account :raises ~azure.core.exceptions.HttpResponseError: @@ -549,25 +576,23 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_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) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -580,14 +605,12 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return deserialized # type: ignore def _create_or_update_initial( - self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO], **kwargs: Any + self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO[bytes]], **kwargs: Any ) -> _models.Account: error_map = { 401: ClientAuthenticationError, @@ -600,21 +623,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + 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.Account] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(account, (IO, bytes)): + if isinstance(account, (IOBase, bytes)): _content = account else: _json = self._serialize.body(account, "Account") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -622,15 +643,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -647,11 +668,9 @@ def _create_or_update_initial( deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return deserialized # type: ignore @overload def begin_create_or_update( @@ -676,14 +695,6 @@ def begin_create_or_update( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -694,7 +705,7 @@ def begin_create_or_update( self, resource_group_name: str, account_name: str, - account: IO, + account: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -708,18 +719,10 @@ def begin_create_or_update( :param account_name: The name of the account. Required. :type account_name: str :param account: The account. Required. - :type account: IO + :type account: IO[bytes] :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -727,7 +730,7 @@ def begin_create_or_update( @distributed_trace def begin_create_or_update( - self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO], **kwargs: Any + self, resource_group_name: str, account_name: str, account: Union[_models.Account, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Account]: """Create or update an account resource. @@ -737,19 +740,8 @@ def begin_create_or_update( :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :param account: The account. Is either a model type or a IO type. Required. - :type account: ~azure.mgmt.purview.models.Account 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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param account: The account. Is either a Account type or a IO[bytes] type. Required. + :type account: ~azure.mgmt.purview.models.Account or IO[bytes] :return: An instance of LROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -757,16 +749,14 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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.Account] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, account=account, @@ -782,25 +772,25 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Account].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return LROPoller[_models.Account]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any @@ -816,25 +806,23 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + 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( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -845,9 +833,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -859,14 +845,6 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -874,13 +852,11 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -895,30 +871,28 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, account_name: str, - account_update_parameters: Union[_models.AccountUpdateParameters, IO], + account_update_parameters: Union[_models.AccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Account: error_map = { @@ -932,21 +906,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] + 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.Account] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(account_update_parameters, (IO, bytes)): + if isinstance(account_update_parameters, (IOBase, bytes)): _content = account_update_parameters else: _json = self._serialize.body(account_update_parameters, "AccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -954,15 +926,15 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -979,11 +951,9 @@ def _update_initial( deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore + return deserialized # type: ignore @overload def begin_update( @@ -1008,14 +978,6 @@ def begin_update( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -1026,7 +988,7 @@ def begin_update( self, resource_group_name: str, account_name: str, - account_update_parameters: IO, + account_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1040,18 +1002,10 @@ def begin_update( :param account_name: The name of the account. Required. :type account_name: str :param account_update_parameters: The account update parameters. Required. - :type account_update_parameters: IO + :type account_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -1062,7 +1016,7 @@ def begin_update( self, resource_group_name: str, account_name: str, - account_update_parameters: Union[_models.AccountUpdateParameters, IO], + account_update_parameters: Union[_models.AccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Account]: """Patches the account resource. @@ -1073,20 +1027,10 @@ def begin_update( :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :param account_update_parameters: The account update parameters. Is either a model type or a IO - type. Required. - :type account_update_parameters: ~azure.mgmt.purview.models.AccountUpdateParameters 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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param account_update_parameters: The account update parameters. Is either a + AccountUpdateParameters type or a IO[bytes] type. Required. + :type account_update_parameters: ~azure.mgmt.purview.models.AccountUpdateParameters or + IO[bytes] :return: An instance of LROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.Account] :raises ~azure.core.exceptions.HttpResponseError: @@ -1094,16 +1038,14 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Account] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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.Account] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( # type: ignore + raw_result = self._update_initial( resource_group_name=resource_group_name, account_name=account_name, account_update_parameters=account_update_parameters, @@ -1119,89 +1061,26 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Account", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Account].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}"} # type: ignore - - @distributed_trace - def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.AccessKeys: - """Lists the keys asynchronous. - - List the authorization keys associated with this account. - - :param resource_group_name: The resource group name. Required. - :type resource_group_name: str - :param account_name: The name of the account. Required. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys or the result of cls(response) - :rtype: ~azure.mgmt.purview.models.AccessKeys - :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 = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - - request = build_list_keys_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_keys.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + return LROPoller[_models.Account]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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.ErrorResponseModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessKeys", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/listkeys"} # type: ignore - @overload def add_root_collection_admin( # pylint: disable=inconsistent-return-statements self, @@ -1225,7 +1104,6 @@ def add_root_collection_admin( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1236,7 +1114,7 @@ def add_root_collection_admin( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - collection_admin_update: IO, + collection_admin_update: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1250,11 +1128,10 @@ def add_root_collection_admin( # pylint: disable=inconsistent-return-statements :param account_name: The name of the account. Required. :type account_name: str :param collection_admin_update: The collection admin update payload. Required. - :type collection_admin_update: IO + :type collection_admin_update: IO[bytes] :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1265,7 +1142,7 @@ def add_root_collection_admin( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - collection_admin_update: Union[_models.CollectionAdminUpdate, IO], + collection_admin_update: Union[_models.CollectionAdminUpdate, IO[bytes]], **kwargs: Any ) -> None: """Add the administrator for root collection. @@ -1276,13 +1153,9 @@ def add_root_collection_admin( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :param collection_admin_update: The collection admin update payload. Is either a model type or - a IO type. Required. - :type collection_admin_update: ~azure.mgmt.purview.models.CollectionAdminUpdate 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 + :param collection_admin_update: The collection admin update payload. Is either a + CollectionAdminUpdate type or a IO[bytes] type. Required. + :type collection_admin_update: ~azure.mgmt.purview.models.CollectionAdminUpdate or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1298,21 +1171,19 @@ def add_root_collection_admin( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + 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[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(collection_admin_update, (IO, bytes)): + if isinstance(collection_admin_update, (IOBase, bytes)): _content = collection_admin_update else: _json = self._serialize.body(collection_admin_update, "CollectionAdminUpdate") - request = build_add_root_collection_admin_request( + _request = build_add_root_collection_admin_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1320,15 +1191,69 @@ def add_root_collection_admin( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.add_root_collection_admin.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.AccessKeys: + """Lists the keys asynchronous. + + List the authorization keys associated with this account. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.AccessKeys + :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.AccessKeys] = kwargs.pop("cls", None) + + _request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1338,10 +1263,12 @@ def add_root_collection_admin( # pylint: disable=inconsistent-return-statements error = self._deserialize.failsafe_deserialize(_models.ErrorResponseModel, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = self._deserialize("AccessKeys", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - add_root_collection_admin.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/addRootCollectionAdmin"} # type: ignore + return deserialized # type: ignore @overload def check_name_availability( @@ -1360,7 +1287,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.purview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1368,18 +1294,17 @@ def check_name_availability( @overload def check_name_availability( - self, check_name_availability_request: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks the account name availability. Checks if account name is available. :param check_name_availability_request: The check name availability request. Required. - :type check_name_availability_request: IO + :type check_name_availability_request: IO[bytes] :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.purview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1387,20 +1312,16 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, check_name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], **kwargs: Any + self, check_name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks the account name availability. Checks if account name is available. - :param check_name_availability_request: The check name availability request. Is either a model - type or a IO type. Required. + :param check_name_availability_request: The check name availability request. Is either a + CheckNameAvailabilityRequest type or a IO[bytes] type. Required. :type check_name_availability_request: ~azure.mgmt.purview.models.CheckNameAvailabilityRequest - 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 + or IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.purview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1416,35 +1337,33 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] + 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.CheckNameAvailabilityResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_name_availability_request, (IO, bytes)): + if isinstance(check_name_availability_request, (IOBase, bytes)): _content = check_name_availability_request else: _json = self._serialize.body(check_name_availability_request, "CheckNameAvailabilityRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1457,8 +1376,6 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Purview/checkNameAvailability"} # type: ignore + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_default_accounts_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_default_accounts_operations.py index b949dbdf74a2..6516f4e8a914 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_default_accounts_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_default_accounts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,48 +60,48 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_set_request(**kwargs: Any) -> HttpRequest: +def build_remove_request( + *, scope_tenant_id: str, scope_type: Union[str, _models.ScopeType], scope: Optional[str] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Purview/setDefaultAccount") + _url = kwargs.pop("template_url", "/providers/Microsoft.Purview/removeDefaultAccount") # Construct parameters + _params["scopeTenantId"] = _SERIALIZER.query("scope_tenant_id", scope_tenant_id, "str") + _params["scopeType"] = _SERIALIZER.query("scope_type", scope_type, "str") + if scope is not None: + _params["scope"] = _SERIALIZER.query("scope", scope, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_remove_request( - *, scope_tenant_id: str, scope_type: Union[str, _models.ScopeType], scope: Optional[str] = None, **kwargs: Any -) -> HttpRequest: +def build_set_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-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", "/providers/Microsoft.Purview/removeDefaultAccount") + _url = kwargs.pop("template_url", "/providers/Microsoft.Purview/setDefaultAccount") # Construct parameters - _params["scopeTenantId"] = _SERIALIZER.query("scope_tenant_id", scope_tenant_id, "str") - _params["scopeType"] = _SERIALIZER.query("scope_type", scope_type, "str") - if scope is not None: - _params["scope"] = _SERIALIZER.query("scope", scope, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) @@ -150,7 +146,6 @@ def get( :param scope: The Id of the scope object, for example if the scope is "Subscription" then it is the ID of that subscription. Default value is None. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DefaultAccountPayload or the result of cls(response) :rtype: ~azure.mgmt.purview.models.DefaultAccountPayload :raises ~azure.core.exceptions.HttpResponseError: @@ -166,25 +161,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DefaultAccountPayload] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DefaultAccountPayload] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope_tenant_id=scope_tenant_id, scope_type=scope_type, scope=scope, 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) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,11 +190,73 @@ def get( deserialized = self._deserialize("DefaultAccountPayload", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def remove( # pylint: disable=inconsistent-return-statements + self, + scope_tenant_id: str, + scope_type: Union[str, _models.ScopeType], + scope: Optional[str] = None, + **kwargs: Any + ) -> None: + """Removes the default account from the scope. + + Removes the default account from the scope. + + :param scope_tenant_id: The tenant ID. Required. + :type scope_tenant_id: str + :param scope_type: The scope for the default account. Known values are: "Tenant" and + "Subscription". Required. + :type scope_type: str or ~azure.mgmt.purview.models.ScopeType + :param scope: The Id of the scope object, for example if the scope is "Subscription" then it is + the ID of that subscription. Default value is None. + :type scope: str + :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_remove_request( + scope_tenant_id=scope_tenant_id, + scope_type=scope_type, + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - return deserialized + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - get.metadata = {"url": "/providers/Microsoft.Purview/getDefaultAccount"} # type: ignore + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @overload def set( @@ -221,7 +276,6 @@ def set( :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: DefaultAccountPayload or the result of cls(response) :rtype: ~azure.mgmt.purview.models.DefaultAccountPayload :raises ~azure.core.exceptions.HttpResponseError: @@ -229,7 +283,7 @@ def set( @overload def set( - self, default_account_payload: IO, *, content_type: str = "application/json", **kwargs: Any + self, default_account_payload: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DefaultAccountPayload: """Sets the default account for the scope. @@ -237,11 +291,10 @@ def set( :param default_account_payload: The payload containing the default account information and the scope. Required. - :type default_account_payload: IO + :type default_account_payload: IO[bytes] :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: DefaultAccountPayload or the result of cls(response) :rtype: ~azure.mgmt.purview.models.DefaultAccountPayload :raises ~azure.core.exceptions.HttpResponseError: @@ -249,19 +302,15 @@ def set( @distributed_trace def set( - self, default_account_payload: Union[_models.DefaultAccountPayload, IO], **kwargs: Any + self, default_account_payload: Union[_models.DefaultAccountPayload, IO[bytes]], **kwargs: Any ) -> _models.DefaultAccountPayload: """Sets the default account for the scope. Sets the default account for the scope. :param default_account_payload: The payload containing the default account information and the - scope. Is either a model type or a IO type. Required. - :type default_account_payload: ~azure.mgmt.purview.models.DefaultAccountPayload 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 + scope. Is either a DefaultAccountPayload type or a IO[bytes] type. Required. + :type default_account_payload: ~azure.mgmt.purview.models.DefaultAccountPayload or IO[bytes] :return: DefaultAccountPayload or the result of cls(response) :rtype: ~azure.mgmt.purview.models.DefaultAccountPayload :raises ~azure.core.exceptions.HttpResponseError: @@ -277,34 +326,32 @@ def set( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DefaultAccountPayload] + 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.DefaultAccountPayload] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(default_account_payload, (IO, bytes)): + if isinstance(default_account_payload, (IOBase, bytes)): _content = default_account_payload else: _json = self._serialize.body(default_account_payload, "DefaultAccountPayload") - request = build_set_request( + _request = build_set_request( api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.set.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -317,77 +364,6 @@ def set( deserialized = self._deserialize("DefaultAccountPayload", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - set.metadata = {"url": "/providers/Microsoft.Purview/setDefaultAccount"} # type: ignore - - @distributed_trace - def remove( # pylint: disable=inconsistent-return-statements - self, - scope_tenant_id: str, - scope_type: Union[str, _models.ScopeType], - scope: Optional[str] = None, - **kwargs: Any - ) -> None: - """Removes the default account from the scope. - - Removes the default account from the scope. - - :param scope_tenant_id: The tenant ID. Required. - :type scope_tenant_id: str - :param scope_type: The scope for the default account. Known values are: "Tenant" and - "Subscription". Required. - :type scope_type: str or ~azure.mgmt.purview.models.ScopeType - :param scope: The Id of the scope object, for example if the scope is "Subscription" then it is - the ID of that subscription. Default value is None. - :type scope: 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 = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_remove_request( - scope_tenant_id=scope_tenant_id, - scope_type=scope_type, - scope=scope, - api_version=api_version, - template_url=self.remove.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **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.ErrorResponseModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - remove.metadata = {"url": "/providers/Microsoft.Purview/removeDefaultAccount"} # type: ignore + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_features_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_features_operations.py new file mode 100644 index 000000000000..94418105b1de --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_features_operations.py @@ -0,0 +1,390 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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_subscription_get_request(locations: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-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}/providers/Microsoft.Purview/locations/{locations}/listFeatures" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locations": _SERIALIZER.url("locations", locations, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_account_get_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-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.Purview/accounts/{accountName}/listFeatures", + ) # 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"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class FeaturesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.purview.PurviewManagementClient`'s + :attr:`features` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def subscription_get( + self, + locations: str, + feature_request: _models.BatchFeatureRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the location and subscription. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param locations: Location of feature. Required. + :type locations: str + :param feature_request: Request body with feature names. Required. + :type feature_request: ~azure.mgmt.purview.models.BatchFeatureRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def subscription_get( + self, locations: str, feature_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the location and subscription. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param locations: Location of feature. Required. + :type locations: str + :param feature_request: Request body with feature names. Required. + :type feature_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def subscription_get( + self, locations: str, feature_request: Union[_models.BatchFeatureRequest, IO[bytes]], **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the location and subscription. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param locations: Location of feature. Required. + :type locations: str + :param feature_request: Request body with feature names. Is either a BatchFeatureRequest type + or a IO[bytes] type. Required. + :type feature_request: ~azure.mgmt.purview.models.BatchFeatureRequest or IO[bytes] + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :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.BatchFeatureStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(feature_request, (IOBase, bytes)): + _content = feature_request + else: + _json = self._serialize.body(feature_request, "BatchFeatureRequest") + + _request = build_subscription_get_request( + locations=locations, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BatchFeatureStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def account_get( + self, + resource_group_name: str, + account_name: str, + feature_request: _models.BatchFeatureRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the account. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param feature_request: Request body with feature names. Required. + :type feature_request: ~azure.mgmt.purview.models.BatchFeatureRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def account_get( + self, + resource_group_name: str, + account_name: str, + feature_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the account. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param feature_request: Request body with feature names. Required. + :type feature_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def account_get( + self, + resource_group_name: str, + account_name: str, + feature_request: Union[_models.BatchFeatureRequest, IO[bytes]], + **kwargs: Any + ) -> _models.BatchFeatureStatus: + """Gets a list of features and their status for the account. + Status of enabled features will be true. Status of disabled features will be false. + Features that don't exist will be excluded from the results. + + Gets details from a list of feature names. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param feature_request: Request body with feature names. Is either a BatchFeatureRequest type + or a IO[bytes] type. Required. + :type feature_request: ~azure.mgmt.purview.models.BatchFeatureRequest or IO[bytes] + :return: BatchFeatureStatus or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.BatchFeatureStatus + :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.BatchFeatureStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(feature_request, (IOBase, bytes)): + _content = feature_request + else: + _json = self._serialize.body(feature_request, "BatchFeatureRequest") + + _request = build_account_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BatchFeatureStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_ingestion_private_endpoint_connections_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_ingestion_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..f307d204a8e9 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_ingestion_private_endpoint_connections_operations.py @@ -0,0 +1,358 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +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, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/ingestionPrivateEndpointConnections", + ) # 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"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_status_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-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.Purview/accounts/{accountName}/ingestionPrivateEndpointConnectionStatus", + ) # 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"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IngestionPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.purview.PurviewManagementClient`'s + :attr:`ingestion_private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """Lists all ingestion private endpoint connections. + + Lists all ingestion private endpoint connections. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.purview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) + + error_map = { + 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("PrivateEndpointConnectionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def update_status( + self, + resource_group_name: str, + account_name: str, + request: _models.PrivateEndpointConnectionStatusUpdateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionStatusUpdateResponse: + """Updates ingestion private endpoint connection status. + + Update ingestion private endpoint connection status. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param request: The ingestion private endpoint connection status update request. Required. + :type request: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionStatusUpdateResponse or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_status( + self, + resource_group_name: str, + account_name: str, + request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionStatusUpdateResponse: + """Updates ingestion private endpoint connection status. + + Update ingestion private endpoint connection status. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param request: The ingestion private endpoint connection status update request. Required. + :type request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionStatusUpdateResponse or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_status( + self, + resource_group_name: str, + account_name: str, + request: Union[_models.PrivateEndpointConnectionStatusUpdateRequest, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnectionStatusUpdateResponse: + """Updates ingestion private endpoint connection status. + + Update ingestion private endpoint connection status. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param request: The ingestion private endpoint connection status update request. Is either a + PrivateEndpointConnectionStatusUpdateRequest type or a IO[bytes] type. Required. + :type request: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateRequest or + IO[bytes] + :return: PrivateEndpointConnectionStatusUpdateResponse or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.PrivateEndpointConnectionStatusUpdateResponse + :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.PrivateEndpointConnectionStatusUpdateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IOBase, bytes)): + _content = request + else: + _json = self._serialize.body(request, "PrivateEndpointConnectionStatusUpdateRequest") + + _request = build_update_status_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionStatusUpdateResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_kafka_configurations_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_kafka_configurations_operations.py new file mode 100644 index 000000000000..32f7b89940d0 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_kafka_configurations_operations.py @@ -0,0 +1,604 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +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_account_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/kafkaConfigurations", + ) # 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"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "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, account_name: str, kafka_configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/kafkaConfigurations/{kafkaConfigurationName}", + ) # 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"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + "kafkaConfigurationName": _SERIALIZER.url( + "kafka_configuration_name", + kafka_configuration_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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, account_name: str, kafka_configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-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.Purview/accounts/{accountName}/kafkaConfigurations/{kafkaConfigurationName}", + ) # 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"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + "kafkaConfigurationName": _SERIALIZER.url( + "kafka_configuration_name", + kafka_configuration_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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, account_name: str, kafka_configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/kafkaConfigurations/{kafkaConfigurationName}", + ) # 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"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), + "kafkaConfigurationName": _SERIALIZER.url( + "kafka_configuration_name", + kafka_configuration_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[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 KafkaConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.purview.PurviewManagementClient`'s + :attr:`kafka_configurations` 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_account( + self, resource_group_name: str, account_name: str, skip_token: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.KafkaConfiguration"]: + """Gets the list of Kafka configurations for the account. + + Lists the Kafka configurations in the Account. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param skip_token: The skip token. Default value is None. + :type skip_token: str + :return: An iterator like instance of either KafkaConfiguration or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.purview.models.KafkaConfiguration] + :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.KafkaConfigurationList] = 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_account_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + api_version=api_version, + 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("KafkaConfigurationList", 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, kafka_configuration_name: str, **kwargs: Any + ) -> _models.KafkaConfiguration: + """Gets the kafka configuration. + + Gets the kafka configuration for the account. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: Name of kafka configuration. Required. + :type kafka_configuration_name: str + :return: KafkaConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.KafkaConfiguration + :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.KafkaConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + kafka_configuration_name=kafka_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KafkaConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + kafka_configuration_name: str, + kafka_configuration: _models.KafkaConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KafkaConfiguration: + """Create or update the kafka configuration. + + Create or update Kafka Configuration. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: The kafka configuration name. Required. + :type kafka_configuration_name: str + :param kafka_configuration: The kafka configuration of the account. Required. + :type kafka_configuration: ~azure.mgmt.purview.models.KafkaConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: KafkaConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.KafkaConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + kafka_configuration_name: str, + kafka_configuration: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KafkaConfiguration: + """Create or update the kafka configuration. + + Create or update Kafka Configuration. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: The kafka configuration name. Required. + :type kafka_configuration_name: str + :param kafka_configuration: The kafka configuration of the account. Required. + :type kafka_configuration: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: KafkaConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.KafkaConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + kafka_configuration_name: str, + kafka_configuration: Union[_models.KafkaConfiguration, IO[bytes]], + **kwargs: Any + ) -> _models.KafkaConfiguration: + """Create or update the kafka configuration. + + Create or update Kafka Configuration. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: The kafka configuration name. Required. + :type kafka_configuration_name: str + :param kafka_configuration: The kafka configuration of the account. Is either a + KafkaConfiguration type or a IO[bytes] type. Required. + :type kafka_configuration: ~azure.mgmt.purview.models.KafkaConfiguration or IO[bytes] + :return: KafkaConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.KafkaConfiguration + :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.KafkaConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(kafka_configuration, (IOBase, bytes)): + _content = kafka_configuration + else: + _json = self._serialize.body(kafka_configuration, "KafkaConfiguration") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + kafka_configuration_name=kafka_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("KafkaConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("KafkaConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, kafka_configuration_name: str, **kwargs: Any + ) -> None: + """Deletes the kafka configuration on the account. + + Deletes a KafkaConfiguration resource. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param account_name: The name of the account. Required. + :type account_name: str + :param kafka_configuration_name: Name of kafka configuration. Required. + :type kafka_configuration_name: str + :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, + account_name=account_name, + kafka_configuration_name=kafka_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_operations.py index 85af34e4dd62..e2fb4a8fc914 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +80,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: List of available operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.purview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -93,10 +87,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -109,14 +101,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -128,26 +119,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,5 +151,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Purview/operations"} # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_private_endpoint_connections_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_private_endpoint_connections_operations.py index 028ac5a2900a..c1e875210358 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_private_endpoint_connections_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +50,7 @@ def build_list_by_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,10 +61,17 @@ def build_list_by_account_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,7 +94,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -102,13 +105,20 @@ def build_get_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -129,8 +139,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -141,13 +151,20 @@ def build_create_or_update_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -170,7 +187,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -181,13 +198,20 @@ def build_delete_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +255,6 @@ def list_by_account( :type account_name: str :param skip_token: The skip token. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.purview.models.PrivateEndpointConnection] @@ -240,10 +263,8 @@ def list_by_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -256,18 +277,17 @@ def list_by_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_account_request( + _request = build_list_by_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_by_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -279,26 +299,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("PrivateEndpointConnectionList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -311,8 +332,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections"} # type: ignore - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -327,7 +346,6 @@ def get( :type account_name: str :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.purview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -343,26 +361,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_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) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -375,18 +391,16 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - request: Union[_models.PrivateEndpointConnection, IO], + request: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: error_map = { @@ -400,21 +414,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(request, (IO, bytes)): + if isinstance(request, (IOBase, bytes)): _content = request else: _json = self._serialize.body(request, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -423,15 +435,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -448,11 +460,9 @@ def _create_or_update_initial( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore @overload def begin_create_or_update( @@ -480,14 +490,6 @@ def begin_create_or_update( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.PrivateEndpointConnection] @@ -500,7 +502,7 @@ def begin_create_or_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - request: IO, + request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -516,18 +518,10 @@ def begin_create_or_update( :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param request: The request. Required. - :type request: IO + :type request: IO[bytes] :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.PrivateEndpointConnection] @@ -540,7 +534,7 @@ def begin_create_or_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - request: Union[_models.PrivateEndpointConnection, IO], + request: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Approves/Rejects private endpoint connection request. @@ -553,19 +547,9 @@ def begin_create_or_update( :type account_name: str :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param request: The request. Is either a model type or a IO type. Required. - :type request: ~azure.mgmt.purview.models.PrivateEndpointConnection 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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param request: The request. Is either a PrivateEndpointConnection type or a IO[bytes] type. + Required. + :type request: ~azure.mgmt.purview.models.PrivateEndpointConnection or IO[bytes] :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.purview.models.PrivateEndpointConnection] @@ -574,16 +558,14 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -600,25 +582,25 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -634,26 +616,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + 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( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -664,9 +644,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -682,14 +660,6 @@ def begin_delete( :type account_name: str :param private_endpoint_connection_name: Name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -697,13 +667,11 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -719,21 +687,19 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_private_link_resources_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_private_link_resources_operations.py index 40c15c245f97..fb4f5eeaa7f7 100644 --- a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_private_link_resources_operations.py +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -28,12 +27,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +42,7 @@ def build_list_by_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,10 +53,17 @@ def build_list_by_account_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +80,7 @@ def build_get_by_group_id_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,11 +91,18 @@ def build_get_by_group_id_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", + account_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$", + ), "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -135,7 +144,6 @@ def list_by_account( :type resource_group_name: str :param account_name: The name of the account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.purview.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -143,10 +151,8 @@ def list_by_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResourceList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -159,17 +165,16 @@ def list_by_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_account_request( + _request = build_list_by_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -181,26 +186,27 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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) # type: ignore - request.method = "GET" - return request + _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("PrivateLinkResourceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + 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) + _request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,8 +219,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateLinkResources"} # type: ignore - @distributed_trace def get_by_group_id( self, resource_group_name: str, account_name: str, group_id: str, **kwargs: Any @@ -229,7 +233,6 @@ def get_by_group_id( :type account_name: str :param group_id: The group identifier. Required. :type group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.purview.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: @@ -245,26 +248,24 @@ def get_by_group_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-07-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_by_group_id_request( + _request = build_get_by_group_id_request( resource_group_name=resource_group_name, account_name=account_name, group_id=group_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_group_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -277,8 +278,6 @@ def get_by_group_id( deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_group_id.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateLinkResources/{groupId}"} # type: ignore + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_usages_operations.py b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_usages_operations.py new file mode 100644 index 000000000000..fb7d5222274e --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/azure/mgmt/purview/operations/_usages_operations.py @@ -0,0 +1,143 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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_get_request( + location: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Purview/locations/{location}/usages" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.purview.PurviewManagementClient`'s + :attr:`usages` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, filter: Optional[str] = None, **kwargs: Any) -> _models.UsageList: + """Gets the Usage quota configuration. + + Get the usage quota configuration. + + :param location: The region. Required. + :type location: str + :param filter: The filter, currently unused. Default value is None. + :type filter: str + :return: UsageList or the result of cls(response) + :rtype: ~azure.mgmt.purview.models.UsageList + :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.UsageList] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + 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.ErrorResponseModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UsageList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_add_root_collection_admin.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_add_root_collection_admin.py index 260d9e681ee1..ec345d36fa1f 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_add_root_collection_admin.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_add_root_collection_admin.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -29,14 +32,13 @@ def main(): subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", ) - response = client.accounts.add_root_collection_admin( + client.accounts.add_root_collection_admin( resource_group_name="SampleResourceGroup", account_name="account1", collection_admin_update={"objectId": "7e8de0e7-2bfc-4e1f-9659-2a5785e4356f"}, ) - print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_AddRootCollectionAdmin.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_AddRootCollectionAdmin.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_check_name_availability.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_check_name_availability.py index c0ec83c9b30b..91976abac726 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_check_name_availability.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_check_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -35,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_CheckNameAvailability.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_create_or_update.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_create_or_update.py index a0f1768845b8..3b99dac98b19 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_create_or_update.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_create_or_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -32,11 +35,11 @@ def main(): response = client.accounts.begin_create_or_update( resource_group_name="SampleResourceGroup", account_name="account1", - account={"location": "West US 2", "properties": {"managedResourceGroupName": "custom-rgname"}}, + account={"location": "West US 2"}, ).result() print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_CreateOrUpdate.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_delete.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_delete.py index 83d57df76f6a..9763c5d14b6b 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_delete.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", ) - response = client.accounts.begin_delete( + client.accounts.begin_delete( resource_group_name="SampleResourceGroup", account_name="account1", ).result() - print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_Delete.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_Delete.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_get.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_get.py index 977170852871..92e31bdabd2d 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_get.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_Get.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_Get.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_by_resource_group.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_by_resource_group.py index b8ffb87223d7..ff5e3e12939a 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_by_resource_group.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_ListByResourceGroup.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_by_subscription.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_by_subscription.py index 3033c5e2ed4d..4ce11817c302 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_by_subscription.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_ListBySubscription.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_keys.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_keys.py index 6e5c90c550f2..9841c6892c27 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_keys.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_list_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_ListKeys.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_ListKeys.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_update.py b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_update.py index 60f93f83a45d..4c354c09258e 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/accounts_update.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/accounts_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -32,11 +35,19 @@ def main(): response = client.accounts.begin_update( resource_group_name="SampleResourceGroup", account_name="account1", - account_update_parameters={"tags": {"newTag": "New tag value."}}, + account_update_parameters={ + "properties": { + "cloudConnectors": {}, + "ingestionStorage": {"publicNetworkAccess": "Disabled"}, + "managedResourcesPublicNetworkAccess": "Disabled", + "publicNetworkAccess": "Disabled", + }, + "tags": {"newTag": "New tag value."}, + }, ).result() print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Accounts_Update.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Accounts_Update.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_get.py b/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_get.py index 98025a52e2f6..a4ba768b9f5e 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_get.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_get.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -30,12 +36,12 @@ def main(): ) response = client.default_accounts.get( - scope_tenant_id="11733A4E-BA84-46FF-91D1-AFF1A3215A90", + scope_tenant_id="ee85a74c-405e-4adc-bb47-ffa8ca0c9f31", scope_type="Tenant", ) print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/DefaultAccounts_Get.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/DefaultAccounts_Get.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_remove.py b/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_remove.py index 15ca29ea5e81..4dec94fbac98 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_remove.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_remove.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -29,13 +35,12 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.default_accounts.remove( - scope_tenant_id="11733A4E-BA84-46FF-91D1-AFF1A3215A90", + client.default_accounts.remove( + scope_tenant_id="ee85a74c-405e-4adc-bb47-ffa8ca0c9f31", scope_type="Tenant", ) - print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/DefaultAccounts_Remove.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/DefaultAccounts_Remove.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_set.py b/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_set.py index c66b404e7b39..7b15309eda00 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_set.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/default_accounts_set.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -33,15 +36,15 @@ def main(): default_account_payload={ "accountName": "myDefaultAccount", "resourceGroupName": "rg-1", - "scope": "11733A4E-BA84-46FF-91D1-AFF1A3215A90", - "scopeTenantId": "11733A4E-BA84-46FF-91D1-AFF1A3215A90", + "scope": "12345678-1234-1234-1234-12345678abcd", + "scopeTenantId": "12345678-1234-1234-1234-12345678abcd", "scopeType": "Tenant", - "subscriptionId": "12345678-1234-1234-12345678aaa", + "subscriptionId": "12345678-1234-1234-1234-12345678aaaa", }, ) print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/DefaultAccounts_Set.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/DefaultAccounts_Set.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/features_account_get.py b/sdk/purview/azure-mgmt-purview/generated_samples/features_account_get.py new file mode 100644 index 000000000000..09ded0de9f1e --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/features_account_get.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 typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python features_account_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-12345678abc", + ) + + response = client.features.account_get( + resource_group_name="SampleResourceGroup", + account_name="account1", + feature_request={"features": ["Feature1", "Feature2", "FeatureThatDoesntExist"]}, + ) + print(response) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Features_AccountGet.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/features_subscription_get.py b/sdk/purview/azure-mgmt-purview/generated_samples/features_subscription_get.py new file mode 100644 index 000000000000..a1d993319590 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/features_subscription_get.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 typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python features_subscription_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-12345678abc", + ) + + response = client.features.subscription_get( + locations="eastus", + feature_request={"features": ["Feature1", "Feature2", "FeatureThatDoesntExist"]}, + ) + print(response) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Features_SubscriptionGet.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/ingestion_private_endpoint_connections_list.py b/sdk/purview/azure-mgmt-purview/generated_samples/ingestion_private_endpoint_connections_list.py new file mode 100644 index 000000000000..02837c9fc09c --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/ingestion_private_endpoint_connections_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.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python ingestion_private_endpoint_connections_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 = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", + ) + + response = client.ingestion_private_endpoint_connections.list( + resource_group_name="SampleResourceGroup", + account_name="account1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/IngestionPrivateEndpointConnections_List.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/ingestion_private_endpoint_connections_update_status.py b/sdk/purview/azure-mgmt-purview/generated_samples/ingestion_private_endpoint_connections_update_status.py new file mode 100644 index 000000000000..9f61fd848ef2 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/ingestion_private_endpoint_connections_update_status.py @@ -0,0 +1,48 @@ +# 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 typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python ingestion_private_endpoint_connections_update_status.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 = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", + ) + + response = client.ingestion_private_endpoint_connections.update_status( + resource_group_name="SampleResourceGroup", + account_name="account1", + request={ + "privateEndpointId": "/subscriptions/12345678-1234-1234-12345678abc/resourceGroups/SampleResourceGroup/providers/Microsoft.Purview/accounts/account1/privateEndpointConnections/privateEndpointConnection1", + "status": "Approved", + }, + ) + print(response) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/IngestionPrivateEndpointConnections_UpdateStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_create_or_update.py b/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_create_or_update.py new file mode 100644 index 000000000000..cadf6ca6ef98 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_create_or_update.py @@ -0,0 +1,59 @@ +# 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 typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python kafka_configurations_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", + ) + + response = client.kafka_configurations.create_or_update( + resource_group_name="rgpurview", + account_name="account1", + kafka_configuration_name="kafkaConfigName", + kafka_configuration={ + "properties": { + "consumerGroup": "consumerGroup", + "credentials": { + "identityId": "/subscriptions/47e8596d-ee73-4eb2-b6b4-cc13c2b87ssd/resourceGroups/testRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testId", + "type": "UserAssigned", + }, + "eventHubPartitionId": "partitionId", + "eventHubResourceId": "/subscriptions/225be6fe-ec1c-4d51-a368-f69348d2e6c5/resourceGroups/testRG/providers/Microsoft.EventHub/namespaces/eventHubNameSpaceName", + "eventHubType": "Notification", + "eventStreamingState": "Enabled", + "eventStreamingType": "Azure", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/KafkaConfigurations_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_delete.py b/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_delete.py new file mode 100644 index 000000000000..14f5f4845ea2 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) 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.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python kafka_configurations_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", + ) + + client.kafka_configurations.delete( + resource_group_name="rgpurview", + account_name="account1", + kafka_configuration_name="kafkaConfigName", + ) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/KafkaConfigurations_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_get.py b/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_get.py new file mode 100644 index 000000000000..2d902cd0a5da --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) 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.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python kafka_configurations_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", + ) + + response = client.kafka_configurations.get( + resource_group_name="rgpurview", + account_name="account1", + kafka_configuration_name="kafkaConfigName", + ) + print(response) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/KafkaConfigurations_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_list_by_account.py b/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_list_by_account.py new file mode 100644 index 000000000000..8adcc8fd56a4 --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/kafka_configurations_list_by_account.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.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python kafka_configurations_list_by_account.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 = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", + ) + + response = client.kafka_configurations.list_by_account( + resource_group_name="rgpurview", + account_name="account1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/KafkaConfigurations_ListByAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/operations_list.py b/sdk/purview/azure-mgmt-purview/generated_samples/operations_list.py index a453265010d4..3d1595887034 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/operations_list.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/Operations_List.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_create_or_update.py b/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_create_or_update.py index a6eff59a4d5f..3b255ae96737 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_create_or_update.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_create_or_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/PrivateEndpointConnections_CreateOrUpdate.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/PrivateEndpointConnections_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_delete.py b/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_delete.py index 4241cd35d0ac..0cb8c1d0898a 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_delete.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="34adfa4f-cedf-4dc0-ba29-b6d1a69ab345", ) - response = client.private_endpoint_connections.begin_delete( + client.private_endpoint_connections.begin_delete( resource_group_name="SampleResourceGroup", account_name="account1", private_endpoint_connection_name="privateEndpointConnection1", ).result() - print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/PrivateEndpointConnections_Delete.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/PrivateEndpointConnections_Delete.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_get.py b/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_get.py index 1c77647fe95b..dad177b9c6d8 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_get.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/PrivateEndpointConnections_Get.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/PrivateEndpointConnections_Get.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_list_by_account.py b/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_list_by_account.py index 5ea6c3af05ed..23c088cf2c9e 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_list_by_account.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/private_endpoint_connections_list_by_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/PrivateEndpointConnections_ListByAccount.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/PrivateEndpointConnections_ListByAccount.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/private_link_resources_get_by_group_id.py b/sdk/purview/azure-mgmt-purview/generated_samples/private_link_resources_get_by_group_id.py index 9e6074e08c84..9d2b809a8910 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/private_link_resources_get_by_group_id.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/private_link_resources_get_by_group_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/PrivateLinkResources_GetByGroupId.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/PrivateLinkResources_GetByGroupId.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/private_link_resources_list_by_account.py b/sdk/purview/azure-mgmt-purview/generated_samples/private_link_resources_list_by_account.py index 6a66e89142af..4740fbee9e75 100644 --- a/sdk/purview/azure-mgmt-purview/generated_samples/private_link_resources_list_by_account.py +++ b/sdk/purview/azure-mgmt-purview/generated_samples/private_link_resources_list_by_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.purview import PurviewManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/stable/2021-07-01/examples/PrivateLinkResources_ListByAccount.json +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/PrivateLinkResources_ListByAccount.json if __name__ == "__main__": main() diff --git a/sdk/purview/azure-mgmt-purview/generated_samples/usages_get.py b/sdk/purview/azure-mgmt-purview/generated_samples/usages_get.py new file mode 100644 index 000000000000..4328b47ae73e --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/generated_samples/usages_get.py @@ -0,0 +1,41 @@ +# 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.purview import PurviewManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-purview +# USAGE + python usages_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PurviewManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-12345678abc", + ) + + response = client.usages.get( + location="West US 2", + ) + print(response) + + +# x-ms-original-file: specification/purview/resource-manager/Microsoft.Purview/preview/2024-04-01-preview/examples/Usages_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/purview/azure-mgmt-purview/setup.py b/sdk/purview/azure-mgmt-purview/setup.py index 52e6fa48b4ca..5b0a8108245c 100644 --- a/sdk/purview/azure-mgmt-purview/setup.py +++ b/sdk/purview/azure-mgmt-purview/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,63 +16,67 @@ PACKAGE_PPRINT_NAME = "Purview Management" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'License :: OSI Approved :: MIT License', + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", ], zip_safe=False, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "msrest>=0.7.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", )