From b75e5329fd96a0caa1facb08b90e401045086d09 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 24 Oct 2024 02:39:51 +0000 Subject: [PATCH] CodeGen from PR 31131 in Azure/azure-rest-api-specs Merge cb1a5b86137b2332bda241c63c052888082b08a4 into fe44d3261ff0ea816315126120672ccec78c3074 --- sdk/apicenter/azure-mgmt-apicenter/_meta.json | 10 +- .../mgmt/apicenter/_api_center_mgmt_client.py | 43 +- .../azure/mgmt/apicenter/_configuration.py | 13 +- .../azure/mgmt/apicenter/_serialization.py | 94 +- .../azure/mgmt/apicenter/_vendor.py | 16 - .../azure/mgmt/apicenter/_version.py | 2 +- .../apicenter/aio/_api_center_mgmt_client.py | 45 +- .../mgmt/apicenter/aio/_configuration.py | 13 +- .../mgmt/apicenter/aio/operations/__init__.py | 4 + .../operations/_api_definitions_operations.py | 285 ++--- .../aio/operations/_api_sources_operations.py | 501 ++++++++ .../operations/_api_versions_operations.py | 134 +-- .../aio/operations/_apis_operations.py | 135 +-- .../_deleted_services_operations.py | 334 ++++++ .../aio/operations/_deployments_operations.py | 134 +-- .../operations/_environments_operations.py | 134 +-- .../_metadata_schemas_operations.py | 136 +-- .../apicenter/aio/operations/_operations.py | 37 +- .../aio/operations/_services_operations.py | 473 +++++--- .../aio/operations/_workspaces_operations.py | 135 +-- .../azure/mgmt/apicenter/models/__init__.py | 36 +- .../models/_api_center_mgmt_client_enums.py | 14 +- .../mgmt/apicenter/models/_models_py3.py | 1023 ++++++++++------- .../mgmt/apicenter/operations/__init__.py | 4 + .../operations/_api_definitions_operations.py | 299 ++--- .../operations/_api_sources_operations.py | 730 ++++++++++++ .../operations/_api_versions_operations.py | 144 +-- .../apicenter/operations/_apis_operations.py | 145 +-- .../_deleted_services_operations.py | 469 ++++++++ .../operations/_deployments_operations.py | 144 +-- .../operations/_environments_operations.py | 144 +-- .../_metadata_schemas_operations.py | 146 +-- .../mgmt/apicenter/operations/_operations.py | 39 +- .../operations/_services_operations.py | 521 ++++++--- .../operations/_workspaces_operations.py | 145 +-- .../api_definitions_delete.py | 3 +- .../api_definitions_export_specification.py | 3 +- .../generated_samples/api_definitions_get.py | 3 +- .../generated_samples/api_definitions_head.py | 3 +- .../generated_samples/api_definitions_list.py | 3 +- .../api_sources_create_or_update.py | 53 + .../generated_samples/api_sources_delete.py | 43 + .../generated_samples/api_sources_get.py | 44 + .../generated_samples/api_sources_head.py | 44 + .../generated_samples/api_sources_list.py | 44 + .../generated_samples/api_versions_delete.py | 3 +- .../generated_samples/api_versions_get.py | 3 +- .../generated_samples/api_versions_head.py | 3 +- .../generated_samples/api_versions_list.py | 3 +- .../generated_samples/apis_delete.py | 3 +- .../generated_samples/apis_get.py | 3 +- .../generated_samples/apis_head.py | 3 +- .../generated_samples/apis_list.py | 3 +- .../deleted_services_delete.py | 41 + .../generated_samples/deleted_services_get.py | 42 + .../deleted_services_list.py | 40 + .../deleted_services_list_by_subscription.py | 42 + .../generated_samples/deployments_delete.py | 3 +- .../generated_samples/deployments_get.py | 3 +- .../generated_samples/deployments_head.py | 3 +- .../generated_samples/deployments_list.py | 3 +- .../generated_samples/environments_delete.py | 3 +- .../generated_samples/environments_get.py | 3 +- .../generated_samples/environments_head.py | 3 +- .../generated_samples/environments_list.py | 3 +- .../metadata_schemas_delete.py | 3 +- .../generated_samples/metadata_schemas_get.py | 3 +- .../metadata_schemas_head.py | 3 +- .../metadata_schemas_list.py | 3 +- .../generated_samples/operations_list.py | 3 +- .../services_create_or_update.py | 3 +- .../generated_samples/services_delete.py | 3 +- .../generated_samples/services_get.py | 3 +- .../services_import_from_apim.py | 47 + .../services_list_by_resource_group.py | 3 +- .../services_list_by_subscription.py | 3 +- .../generated_samples/workspaces_delete.py | 3 +- .../generated_samples/workspaces_get.py | 3 +- .../generated_samples/workspaces_head.py | 3 +- .../generated_samples/workspaces_list.py | 3 +- .../generated_tests/conftest.py | 35 + ..._center_mgmt_api_definitions_operations.py | 147 +++ ...r_mgmt_api_definitions_operations_async.py | 152 +++ ..._api_center_mgmt_api_sources_operations.py | 109 ++ ...enter_mgmt_api_sources_operations_async.py | 110 ++ ...api_center_mgmt_api_versions_operations.py | 108 ++ ...nter_mgmt_api_versions_operations_async.py | 109 ++ .../test_api_center_mgmt_apis_operations.py | 111 ++ ...t_api_center_mgmt_apis_operations_async.py | 112 ++ ...center_mgmt_deleted_services_operations.py | 64 ++ ..._mgmt_deleted_services_operations_async.py | 65 ++ ..._api_center_mgmt_deployments_operations.py | 113 ++ ...enter_mgmt_deployments_operations_async.py | 114 ++ ...api_center_mgmt_environments_operations.py | 107 ++ ...nter_mgmt_environments_operations_async.py | 108 ++ ...center_mgmt_metadata_schemas_operations.py | 98 ++ ..._mgmt_metadata_schemas_operations_async.py | 99 ++ .../test_api_center_mgmt_operations.py | 29 + .../test_api_center_mgmt_operations_async.py | 30 + ...est_api_center_mgmt_services_operations.py | 147 +++ ...i_center_mgmt_services_operations_async.py | 152 +++ ...t_api_center_mgmt_workspaces_operations.py | 98 ++ ...center_mgmt_workspaces_operations_async.py | 99 ++ sdk/apicenter/azure-mgmt-apicenter/setup.py | 7 +- 104 files changed, 7088 insertions(+), 2461 deletions(-) delete mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_vendor.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_sources_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deleted_services_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_sources_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deleted_services_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_create_or_update.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_head.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_list.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_list.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_list_by_subscription.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_import_from_apim.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/conftest.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_definitions_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_definitions_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_sources_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_sources_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_versions_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_versions_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_apis_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_apis_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deleted_services_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deleted_services_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deployments_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deployments_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_environments_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_environments_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_metadata_schemas_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_metadata_schemas_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_services_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_services_operations_async.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_workspaces_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_workspaces_operations_async.py diff --git a/sdk/apicenter/azure-mgmt-apicenter/_meta.json b/sdk/apicenter/azure-mgmt-apicenter/_meta.json index b91c03f64433..4e9e6ba936d1 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/_meta.json +++ b/sdk/apicenter/azure-mgmt-apicenter/_meta.json @@ -1,11 +1,11 @@ { - "commit": "a9fb3fa967eb2df4f4386358419a4f3f2f90a1ce", + "commit": "a7d12730ad85a901caf31c78316e54bbd5749483", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/apicenter/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/apicenter/resource-manager/readme.md --generate-sample=True --generate-test=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.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/apicenter/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_api_center_mgmt_client.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_api_center_mgmt_client.py index 354c2d460efb..3776ad6a75ec 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_api_center_mgmt_client.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_api_center_mgmt_client.py @@ -8,17 +8,22 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +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 as _models from ._configuration import ApiCenterMgmtClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( ApiDefinitionsOperations, + ApiSourcesOperations, ApiVersionsOperations, ApisOperations, + DeletedServicesOperations, DeploymentsOperations, EnvironmentsOperations, MetadataSchemasOperations, @@ -37,12 +42,16 @@ class ApiCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword :ivar operations: Operations operations :vartype operations: azure.mgmt.apicenter.operations.Operations + :ivar deleted_services: DeletedServicesOperations operations + :vartype deleted_services: azure.mgmt.apicenter.operations.DeletedServicesOperations :ivar services: ServicesOperations operations :vartype services: azure.mgmt.apicenter.operations.ServicesOperations :ivar metadata_schemas: MetadataSchemasOperations operations :vartype metadata_schemas: azure.mgmt.apicenter.operations.MetadataSchemasOperations :ivar workspaces: WorkspacesOperations operations :vartype workspaces: azure.mgmt.apicenter.operations.WorkspacesOperations + :ivar api_sources: ApiSourcesOperations operations + :vartype api_sources: azure.mgmt.apicenter.operations.ApiSourcesOperations :ivar apis: ApisOperations operations :vartype apis: azure.mgmt.apicenter.operations.ApisOperations :ivar deployments: DeploymentsOperations operations @@ -59,8 +68,8 @@ class ApiCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword :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 "2024-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -76,25 +85,47 @@ def __init__( self._config = ApiCenterMgmtClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _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 self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_services = DeletedServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.metadata_schemas = MetadataSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_sources = ApiSourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.apis = ApisOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.api_versions = ApiVersionsOperations(self._client, self._config, self._serialize, self._deserialize) self.api_definitions = ApiDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) self.environments = EnvironmentsOperations(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 @@ -114,12 +145,12 @@ 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) -> None: self._client.close() - def __enter__(self) -> "ApiCenterMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_configuration.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_configuration.py index 5dfce4565800..7b256fe21f6e 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_configuration.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class ApiCenterMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApiCenterMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApiCenterMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class ApiCenterMgmtClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApiCenterMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2024-03-01") + api_version: str = kwargs.pop("api_version", "2024-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ 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-apicenter/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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.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/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_serialization.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_serialization.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: 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 @@ -143,7 +143,9 @@ 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 + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + 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__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): 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: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """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)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,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): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :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( @@ -445,7 +440,7 @@ def from_dict( 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): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = 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 @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): 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) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,7 +663,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +705,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) @@ -730,6 +725,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: @@ -744,7 +740,7 @@ def query(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :keyword bool skip_quote: Whether to skip quote the serialized result. Defaults to False. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +749,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + 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) @@ -804,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +820,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) @@ -993,7 +989,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) @@ -1170,10 +1166,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): @@ -1209,7 +1205,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:]) @@ -1230,7 +1225,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:]) @@ -1371,7 +1365,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: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1391,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = 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 @@ -1444,12 +1438,12 @@ 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) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1481,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,14 +1509,14 @@ def _classify_target(self, target, data): 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__ # type: ignore @@ -1578,7 +1572,7 @@ 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"): + 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 @@ -1652,7 +1646,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) @@ -1700,7 +1694,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: @@ -1757,7 +1751,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"]: @@ -1808,7 +1802,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: @@ -1862,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + 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): @@ -1893,7 +1886,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 @@ -1910,7 +1903,7 @@ def deserialize_date(attr): 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): @@ -1945,7 +1938,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 @@ -1982,7 +1975,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 @@ -1998,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): 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/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_vendor.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_version.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_version.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/_api_center_mgmt_client.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/_api_center_mgmt_client.py index 38bf6a886caf..1538077db6a0 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/_api_center_mgmt_client.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/_api_center_mgmt_client.py @@ -8,17 +8,22 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +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 as _models from .._serialization import Deserializer, Serializer from ._configuration import ApiCenterMgmtClientConfiguration from .operations import ( ApiDefinitionsOperations, + ApiSourcesOperations, ApiVersionsOperations, ApisOperations, + DeletedServicesOperations, DeploymentsOperations, EnvironmentsOperations, MetadataSchemasOperations, @@ -37,12 +42,16 @@ class ApiCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword :ivar operations: Operations operations :vartype operations: azure.mgmt.apicenter.aio.operations.Operations + :ivar deleted_services: DeletedServicesOperations operations + :vartype deleted_services: azure.mgmt.apicenter.aio.operations.DeletedServicesOperations :ivar services: ServicesOperations operations :vartype services: azure.mgmt.apicenter.aio.operations.ServicesOperations :ivar metadata_schemas: MetadataSchemasOperations operations :vartype metadata_schemas: azure.mgmt.apicenter.aio.operations.MetadataSchemasOperations :ivar workspaces: WorkspacesOperations operations :vartype workspaces: azure.mgmt.apicenter.aio.operations.WorkspacesOperations + :ivar api_sources: ApiSourcesOperations operations + :vartype api_sources: azure.mgmt.apicenter.aio.operations.ApiSourcesOperations :ivar apis: ApisOperations operations :vartype apis: azure.mgmt.apicenter.aio.operations.ApisOperations :ivar deployments: DeploymentsOperations operations @@ -59,8 +68,8 @@ class ApiCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword :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 "2024-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -76,25 +85,49 @@ def __init__( self._config = ApiCenterMgmtClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _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 self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_services = DeletedServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.metadata_schemas = MetadataSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_sources = ApiSourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.apis = ApisOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.api_versions = ApiVersionsOperations(self._client, self._config, self._serialize, self._deserialize) self.api_definitions = ApiDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) self.environments = EnvironmentsOperations(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 @@ -114,12 +147,12 @@ 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() - async def __aenter__(self) -> "ApiCenterMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/_configuration.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/_configuration.py index c82219976e82..d4dc1c066e34 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/_configuration.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ApiCenterMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApiCenterMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ApiCenterMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class ApiCenterMgmtClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ApiCenterMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2024-03-01") + api_version: str = kwargs.pop("api_version", "2024-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,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-apicenter/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/__init__.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/__init__.py index 3ed67317ce8e..7ebe9eec46af 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/__init__.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/__init__.py @@ -7,9 +7,11 @@ # -------------------------------------------------------------------------- from ._operations import Operations +from ._deleted_services_operations import DeletedServicesOperations from ._services_operations import ServicesOperations from ._metadata_schemas_operations import MetadataSchemasOperations from ._workspaces_operations import WorkspacesOperations +from ._api_sources_operations import ApiSourcesOperations from ._apis_operations import ApisOperations from ._deployments_operations import DeploymentsOperations from ._api_versions_operations import ApiVersionsOperations @@ -22,9 +24,11 @@ __all__ = [ "Operations", + "DeletedServicesOperations", "ServicesOperations", "MetadataSchemasOperations", "WorkspacesOperations", + "ApiSourcesOperations", "ApisOperations", "DeploymentsOperations", "ApiVersionsOperations", diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_definitions_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_definitions_operations.py index e2a46d7bd4e4..fdfb05f600a1 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_definitions_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_definitions_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. @@ -7,7 +7,8 @@ # 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, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_definitions_operations import ( build_create_or_update_request, build_delete_request, @@ -41,6 +42,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -90,7 +95,6 @@ def list( :type version_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.ApiDefinition] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,7 +116,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -121,12 +125,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -138,13 +140,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApiDefinitionListResult", pipeline_response) @@ -154,11 +155,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -171,10 +172,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions" - } - @distributed_trace_async async def get( self, @@ -201,12 +198,11 @@ async def get( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiDefinition or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +216,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -229,16 +225,14 @@ async def get( definition_name=definition_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,16 +245,12 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiDefinition", pipeline_response) + deserialized = self._deserialize("ApiDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -296,7 +286,6 @@ async def 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 :return: ApiDefinition or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -311,7 +300,7 @@ async def create_or_update( api_name: str, version_name: str, definition_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +321,10 @@ async def create_or_update( :param definition_name: The name of the API definition. Required. :type definition_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: ApiDefinition or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -351,7 +339,7 @@ async def create_or_update( api_name: str, version_name: str, definition_name: str, - resource: Union[_models.ApiDefinition, IO], + resource: Union[_models.ApiDefinition, IO[bytes]], **kwargs: Any ) -> _models.ApiDefinition: """Creates new or updates existing API definition. @@ -369,18 +357,14 @@ async def create_or_update( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :param resource: Resource create parameters. Is either a ApiDefinition type or a IO type. - Required. - :type resource: ~azure.mgmt.apicenter.models.ApiDefinition 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 resource: Resource create parameters. Is either a ApiDefinition type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.apicenter.models.ApiDefinition or IO[bytes] :return: ApiDefinition or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,7 +387,7 @@ async def create_or_update( else: _json = self._serialize.body(resource, "ApiDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -415,16 +399,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -435,25 +417,15 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiDefinition", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiDefinition", pipeline_response) + deserialized = self._deserialize("ApiDefinition", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, @@ -480,12 +452,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +470,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, @@ -508,16 +479,14 @@ async def delete( # pylint: disable=inconsistent-return-statements definition_name=definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,11 +497,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def head( @@ -560,12 +525,11 @@ async def head( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -579,7 +543,7 @@ async def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -588,16 +552,14 @@ async def head( definition_name=definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,13 +570,9 @@ async def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" - } - async def _export_specification_initial( self, resource_group_name: str, @@ -624,8 +582,8 @@ async def _export_specification_initial( version_name: str, definition_name: str, **kwargs: Any - ) -> Optional[_models.ApiSpecExportResult]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -637,9 +595,9 @@ async def _export_specification_initial( _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[Optional[_models.ApiSpecExportResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_export_specification_request( + _request = build_export_specification_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -648,42 +606,39 @@ async def _export_specification_initial( definition_name=definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._export_specification_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiSpecExportResult", pipeline_response) - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _export_specification_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification" - } + return deserialized # type: ignore @distributed_trace_async async def begin_export_specification( @@ -711,14 +666,6 @@ async def begin_export_specification( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_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 ApiSpecExportResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apicenter.models.ApiSpecExportResult] @@ -746,12 +693,13 @@ async def begin_export_specification( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiSpecExportResult", pipeline_response) + deserialized = self._deserialize("ApiSpecExportResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -763,19 +711,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ApiSpecExportResult].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) # type: ignore - - begin_export_specification.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification" - } + return AsyncLROPoller[_models.ApiSpecExportResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _import_specification_initial( # pylint: disable=inconsistent-return-statements + async def _import_specification_initial( self, resource_group_name: str, service_name: str, @@ -783,10 +729,10 @@ async def _import_specification_initial( # pylint: disable=inconsistent-return- api_name: str, version_name: str, definition_name: str, - body: Union[_models.ApiSpecImportRequest, IO], + body: Union[_models.ApiSpecImportRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -799,7 +745,7 @@ async def _import_specification_initial( # pylint: disable=inconsistent-return- 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -809,7 +755,7 @@ async def _import_specification_initial( # pylint: disable=inconsistent-return- else: _json = self._serialize.body(body, "ApiSpecImportRequest") - request = build_import_specification_request( + _request = build_import_specification_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -821,36 +767,39 @@ async def _import_specification_initial( # pylint: disable=inconsistent-return- content_type=content_type, json=_json, content=_content, - template_url=self._import_specification_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _import_specification_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification" - } + return deserialized # type: ignore @overload async def begin_import_specification( @@ -886,14 +835,6 @@ async def begin_import_specification( :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -908,7 +849,7 @@ async def begin_import_specification( api_name: str, version_name: str, definition_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -929,18 +870,10 @@ async def begin_import_specification( :param definition_name: The name of the API definition. Required. :type definition_name: str :param body: The content of the action request. Required. - :type body: IO + :type body: 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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -955,7 +888,7 @@ async def begin_import_specification( api_name: str, version_name: str, definition_name: str, - body: Union[_models.ApiSpecImportRequest, IO], + body: Union[_models.ApiSpecImportRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Imports the API specification. @@ -973,20 +906,9 @@ async def begin_import_specification( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :param body: The content of the action request. Is either a ApiSpecImportRequest type or a IO - type. Required. - :type body: ~azure.mgmt.apicenter.models.ApiSpecImportRequest 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 body: The content of the action request. Is either a ApiSpecImportRequest type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.apicenter.models.ApiSpecImportRequest or IO[bytes] :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: @@ -1001,7 +923,7 @@ async def begin_import_specification( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_specification_initial( # type: ignore + raw_result = await self._import_specification_initial( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -1016,11 +938,12 @@ async def begin_import_specification( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1031,14 +954,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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) # type: ignore - - begin_import_specification.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_sources_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_sources_operations.py new file mode 100644 index 000000000000..2d2880a546cf --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_sources_operations.py @@ -0,0 +1,501 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, 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.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._api_sources_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_head_request, + build_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiSourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`api_sources` 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, + service_name: str, + workspace_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ApiSource"]: + """Returns a collection of API sources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param filter: OData filter parameter. Default value is None. + :type filter: str + :return: An iterator like instance of either ApiSource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.ApiSource] + :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.ApiSourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiSourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_name: str, api_source_name: str, **kwargs: Any + ) -> _models.ApiSource: + """Returns details of the API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :return: ApiSource or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiSource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + api_source_name=api_source_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiSource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_name: str, + api_source_name: str, + resource: _models.ApiSource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiSource: + """Creates new or updates existing API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.apicenter.models.ApiSource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiSource or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_name: str, + api_source_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiSource: + """Creates new or updates existing API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :param resource: Resource create parameters. Required. + :type resource: 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: ApiSource or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_name: str, + api_source_name: str, + resource: Union[_models.ApiSource, IO[bytes]], + **kwargs: Any + ) -> _models.ApiSource: + """Creates new or updates existing API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :param resource: Resource create parameters. Is either a ApiSource type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.apicenter.models.ApiSource or IO[bytes] + :return: ApiSource or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiSource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ApiSource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + api_source_name=api_source_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiSource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_name: str, api_source_name: str, **kwargs: Any + ) -> None: + """Deletes specified API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + api_source_name=api_source_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def head( + self, resource_group_name: str, service_name: str, workspace_name: str, api_source_name: str, **kwargs: Any + ) -> bool: + """Checks if specified API source exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_head_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + api_source_name=api_source_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_versions_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_versions_operations.py index d1a6c2cffcd5..e327f201375e 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_versions_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_versions_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_versions_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,7 +86,6 @@ def list( :type api_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiVersion or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.ApiVersion] :raises ~azure.core.exceptions.HttpResponseError: @@ -94,7 +96,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiVersionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,7 +107,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -113,12 +115,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -130,13 +130,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApiVersionListResult", pipeline_response) @@ -146,11 +145,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -163,10 +162,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions" - } - @distributed_trace_async async def get( self, @@ -190,12 +185,11 @@ async def get( :type api_name: str :param version_name: The name of the API version. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiVersion or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiVersion :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,7 +203,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiVersion] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -217,16 +211,14 @@ async def get( version_name=version_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -239,16 +231,12 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersion", pipeline_response) + deserialized = self._deserialize("ApiVersion", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -281,7 +269,6 @@ async def 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 :return: ApiVersion or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiVersion :raises ~azure.core.exceptions.HttpResponseError: @@ -295,7 +282,7 @@ async def create_or_update( workspace_name: str, api_name: str, version_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -314,11 +301,10 @@ async def create_or_update( :param version_name: The name of the API version. Required. :type version_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: ApiVersion or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiVersion :raises ~azure.core.exceptions.HttpResponseError: @@ -332,7 +318,7 @@ async def create_or_update( workspace_name: str, api_name: str, version_name: str, - resource: Union[_models.ApiVersion, IO], + resource: Union[_models.ApiVersion, IO[bytes]], **kwargs: Any ) -> _models.ApiVersion: """Creates new or updates existing API version. @@ -348,18 +334,14 @@ async def create_or_update( :type api_name: str :param version_name: The name of the API version. Required. :type version_name: str - :param resource: Resource create parameters. Is either a ApiVersion type or a IO type. + :param resource: Resource create parameters. Is either a ApiVersion type or a IO[bytes] type. Required. - :type resource: ~azure.mgmt.apicenter.models.ApiVersion 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 + :type resource: ~azure.mgmt.apicenter.models.ApiVersion or IO[bytes] :return: ApiVersion or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiVersion :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -382,7 +364,7 @@ async def create_or_update( else: _json = self._serialize.body(resource, "ApiVersion") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -393,16 +375,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -413,25 +393,15 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiVersion", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersion", pipeline_response) + deserialized = self._deserialize("ApiVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, @@ -455,12 +425,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type api_name: str :param version_name: The name of the API version. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,7 +443,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, @@ -482,16 +451,14 @@ async def delete( # pylint: disable=inconsistent-return-statements version_name=version_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -502,11 +469,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def head( @@ -531,12 +494,11 @@ async def head( :type api_name: str :param version_name: The name of the API version. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -550,7 +512,7 @@ async def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -558,16 +520,14 @@ async def head( version_name=version_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -578,9 +538,5 @@ async def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_apis_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_apis_operations.py index 20aca8cf51c4..100a0664288e 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_apis_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_apis_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._apis_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +83,6 @@ def list( :type workspace_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Api or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.Api] :raises ~azure.core.exceptions.HttpResponseError: @@ -91,7 +93,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,19 +104,17 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -126,13 +126,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ApiListResult", pipeline_response) @@ -142,11 +141,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,10 +158,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis" - } - @distributed_trace_async async def get( self, resource_group_name: str, service_name: str, workspace_name: str, api_name: str, **kwargs: Any @@ -178,12 +173,11 @@ async def get( :type workspace_name: str :param api_name: The name of the API. Required. :type api_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Api or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Api :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,23 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Api] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, api_name=api_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,16 +218,12 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Api", pipeline_response) + deserialized = self._deserialize("Api", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -265,7 +253,6 @@ async def 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 :return: Api or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Api :raises ~azure.core.exceptions.HttpResponseError: @@ -278,7 +265,7 @@ async def create_or_update( service_name: str, workspace_name: str, api_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -295,11 +282,10 @@ async def create_or_update( :param api_name: The name of the API. Required. :type api_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Api or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Api :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +298,7 @@ async def create_or_update( service_name: str, workspace_name: str, api_name: str, - resource: Union[_models.Api, IO], + resource: Union[_models.Api, IO[bytes]], **kwargs: Any ) -> _models.Api: """Creates new or updates existing API. @@ -326,17 +312,14 @@ async def create_or_update( :type workspace_name: str :param api_name: The name of the API. Required. :type api_name: str - :param resource: Resource create parameters. Is either a Api type or a IO type. Required. - :type resource: ~azure.mgmt.apicenter.models.Api 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 resource: Resource create parameters. Is either a Api type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.apicenter.models.Api or IO[bytes] :return: Api or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Api :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +342,7 @@ async def create_or_update( else: _json = self._serialize.body(resource, "Api") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -369,16 +352,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -389,25 +370,15 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("Api", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Api", pipeline_response) + deserialized = self._deserialize("Api", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, workspace_name: str, api_name: str, **kwargs: Any @@ -423,12 +394,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param api_name: The name of the API. Required. :type api_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,23 +412,21 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, api_name=api_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -469,11 +437,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def head( @@ -490,12 +454,11 @@ async def head( :type workspace_name: str :param api_name: The name of the API. Required. :type api_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -509,23 +472,21 @@ async def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, api_name=api_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -536,9 +497,5 @@ async def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deleted_services_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deleted_services_operations.py new file mode 100644 index 000000000000..4a67e873bb7b --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deleted_services_operations.py @@ -0,0 +1,334 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.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 ...operations._deleted_services_operations import ( + build_delete_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeletedServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`deleted_services` 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_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DeletedService"]: + """Lists services within an Azure subscription. + + :return: An iterator like instance of either DeletedService or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.DeletedService] + :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.DeletedServiceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedServiceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeletedService"]: + """Lists soft-deleted services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param filter: OData filter parameter. Default value is None. + :type filter: str + :return: An iterator like instance of either DeletedService or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.DeletedService] + :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.DeletedServiceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedServiceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, deleted_service_name: str, **kwargs: Any) -> _models.DeletedService: + """Returns details of the soft-deleted service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deleted_service_name: The name of the deleted service. Required. + :type deleted_service_name: str + :return: DeletedService or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.DeletedService + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DeletedService] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + deleted_service_name=deleted_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DeletedService", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, deleted_service_name: str, **kwargs: Any + ) -> None: + """Permanently deletes specified service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deleted_service_name: The name of the deleted service. Required. + :type deleted_service_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + deleted_service_name=deleted_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deployments_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deployments_operations.py index 8a50b425b349..947b98b3269f 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deployments_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deployments_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._deployments_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,7 +86,6 @@ def list( :type api_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Deployment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.Deployment] :raises ~azure.core.exceptions.HttpResponseError: @@ -94,7 +96,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeploymentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,7 +107,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -113,12 +115,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -130,13 +130,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeploymentListResult", pipeline_response) @@ -146,11 +145,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -163,10 +162,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments" - } - @distributed_trace_async async def get( self, @@ -190,12 +185,11 @@ async def get( :type api_name: str :param deployment_name: The name of the API deployment. Required. :type deployment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Deployment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,7 +203,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -217,16 +211,14 @@ async def get( deployment_name=deployment_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -239,16 +231,12 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Deployment", pipeline_response) + deserialized = self._deserialize("Deployment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -281,7 +269,6 @@ async def 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 :return: Deployment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: @@ -295,7 +282,7 @@ async def create_or_update( workspace_name: str, api_name: str, deployment_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -314,11 +301,10 @@ async def create_or_update( :param deployment_name: The name of the API deployment. Required. :type deployment_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Deployment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: @@ -332,7 +318,7 @@ async def create_or_update( workspace_name: str, api_name: str, deployment_name: str, - resource: Union[_models.Deployment, IO], + resource: Union[_models.Deployment, IO[bytes]], **kwargs: Any ) -> _models.Deployment: """Creates new or updates existing API deployment. @@ -348,18 +334,14 @@ async def create_or_update( :type api_name: str :param deployment_name: The name of the API deployment. Required. :type deployment_name: str - :param resource: Resource create parameters. Is either a Deployment type or a IO type. + :param resource: Resource create parameters. Is either a Deployment type or a IO[bytes] type. Required. - :type resource: ~azure.mgmt.apicenter.models.Deployment 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 + :type resource: ~azure.mgmt.apicenter.models.Deployment or IO[bytes] :return: Deployment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -382,7 +364,7 @@ async def create_or_update( else: _json = self._serialize.body(resource, "Deployment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -393,16 +375,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -413,25 +393,15 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("Deployment", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Deployment", pipeline_response) + deserialized = self._deserialize("Deployment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, @@ -455,12 +425,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type api_name: str :param deployment_name: The name of the API deployment. Required. :type deployment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,7 +443,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, @@ -482,16 +451,14 @@ async def delete( # pylint: disable=inconsistent-return-statements deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -502,11 +469,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def head( @@ -531,12 +494,11 @@ async def head( :type api_name: str :param deployment_name: The name of the API deployment. Required. :type deployment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -550,7 +512,7 @@ async def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -558,16 +520,14 @@ async def head( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -578,9 +538,5 @@ async def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_environments_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_environments_operations.py index b9ef45347fc3..aed5d7ceca23 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_environments_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_environments_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._environments_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +83,6 @@ def list( :type workspace_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Environment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.Environment] :raises ~azure.core.exceptions.HttpResponseError: @@ -91,7 +93,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EnvironmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,19 +104,17 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -126,13 +126,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EnvironmentListResult", pipeline_response) @@ -142,11 +141,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,10 +158,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments" - } - @distributed_trace_async async def get( self, resource_group_name: str, service_name: str, workspace_name: str, environment_name: str, **kwargs: Any @@ -178,12 +173,11 @@ async def get( :type workspace_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Environment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,23 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Environment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, environment_name=environment_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,16 +218,12 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Environment", pipeline_response) + deserialized = self._deserialize("Environment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -265,7 +253,6 @@ async def 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 :return: Environment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: @@ -278,7 +265,7 @@ async def create_or_update( service_name: str, workspace_name: str, environment_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -295,11 +282,10 @@ async def create_or_update( :param environment_name: The name of the environment. Required. :type environment_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Environment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +298,7 @@ async def create_or_update( service_name: str, workspace_name: str, environment_name: str, - resource: Union[_models.Environment, IO], + resource: Union[_models.Environment, IO[bytes]], **kwargs: Any ) -> _models.Environment: """Creates new or updates existing environment. @@ -326,18 +312,14 @@ async def create_or_update( :type workspace_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :param resource: Resource create parameters. Is either a Environment type or a IO type. + :param resource: Resource create parameters. Is either a Environment type or a IO[bytes] type. Required. - :type resource: ~azure.mgmt.apicenter.models.Environment 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 + :type resource: ~azure.mgmt.apicenter.models.Environment or IO[bytes] :return: Environment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +342,7 @@ async def create_or_update( else: _json = self._serialize.body(resource, "Environment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -370,16 +352,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,25 +370,15 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("Environment", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Environment", pipeline_response) + deserialized = self._deserialize("Environment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, workspace_name: str, environment_name: str, **kwargs: Any @@ -424,12 +394,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -443,23 +412,21 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, environment_name=environment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,11 +437,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def head( @@ -491,12 +454,11 @@ async def head( :type workspace_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -510,23 +472,21 @@ async def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, environment_name=environment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -537,9 +497,5 @@ async def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_metadata_schemas_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_metadata_schemas_operations.py index cc24fd4e1a73..e6a1bdf49faf 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_metadata_schemas_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_metadata_schemas_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._metadata_schemas_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +76,6 @@ def list( :type service_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetadataSchema or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.MetadataSchema] :raises ~azure.core.exceptions.HttpResponseError: @@ -84,7 +86,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MetadataSchemaListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,18 +97,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +118,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MetadataSchemaListResult", pipeline_response) @@ -134,11 +133,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas" - } - @distributed_trace_async async def get( self, resource_group_name: str, service_name: str, metadata_schema_name: str, **kwargs: Any @@ -168,12 +163,11 @@ async def get( :type service_name: str :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MetadataSchema or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.MetadataSchema :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,22 +181,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MetadataSchema] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, metadata_schema_name=metadata_schema_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,16 +207,12 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("MetadataSchema", pipeline_response) + deserialized = self._deserialize("MetadataSchema", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -251,7 +239,6 @@ async def 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 :return: MetadataSchema or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.MetadataSchema :raises ~azure.core.exceptions.HttpResponseError: @@ -263,7 +250,7 @@ async def create_or_update( resource_group_name: str, service_name: str, metadata_schema_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,11 +265,10 @@ async def create_or_update( :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: MetadataSchema or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.MetadataSchema :raises ~azure.core.exceptions.HttpResponseError: @@ -294,7 +280,7 @@ async def create_or_update( resource_group_name: str, service_name: str, metadata_schema_name: str, - resource: Union[_models.MetadataSchema, IO], + resource: Union[_models.MetadataSchema, IO[bytes]], **kwargs: Any ) -> _models.MetadataSchema: """Creates new or updates existing metadata schema. @@ -306,18 +292,14 @@ async def create_or_update( :type service_name: str :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str - :param resource: Resource create parameters. Is either a MetadataSchema type or a IO type. - Required. - :type resource: ~azure.mgmt.apicenter.models.MetadataSchema 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 resource: Resource create parameters. Is either a MetadataSchema type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.apicenter.models.MetadataSchema or IO[bytes] :return: MetadataSchema or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.MetadataSchema :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -340,7 +322,7 @@ async def create_or_update( else: _json = self._serialize.body(resource, "MetadataSchema") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, metadata_schema_name=metadata_schema_name, @@ -349,16 +331,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,25 +349,15 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("MetadataSchema", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("MetadataSchema", pipeline_response) + deserialized = self._deserialize("MetadataSchema", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, metadata_schema_name: str, **kwargs: Any @@ -401,12 +371,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type service_name: str :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -420,22 +389,20 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, metadata_schema_name=metadata_schema_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -446,11 +413,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def head(self, resource_group_name: str, service_name: str, metadata_schema_name: str, **kwargs: Any) -> bool: @@ -463,12 +426,11 @@ async def head(self, resource_group_name: str, service_name: str, metadata_schem :type service_name: str :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -482,22 +444,20 @@ async def head(self, resource_group_name: str, service_name: str, metadata_schem api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, metadata_schema_name=metadata_schema_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -508,9 +468,5 @@ async def head(self, resource_group_name: str, service_name: str, metadata_schem raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_operations.py index 074f06ed0be9..6a48584d5534 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/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,8 @@ # 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, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List the operations for the provider. - :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.apicenter.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -67,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,14 +80,12 @@ 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -97,13 +97,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -113,11 +112,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -129,5 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.ApiCenter/operations"} diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_services_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_services_operations.py index e23efa05ce4f..852431997edb 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_services_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_services_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. @@ -7,7 +7,8 @@ # 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, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,17 +32,21 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._services_operations import ( build_create_or_update_request, build_delete_request, build_export_metadata_schema_request, build_get_request, + build_import_from_apim_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +74,6 @@ def __init__(self, *args, **kwargs) -> None: def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Service"]: """Lists services within an Azure subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Service or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.Service] :raises ~azure.core.exceptions.HttpResponseError: @@ -79,7 +84,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Service" api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServiceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +95,13 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Service" def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,13 +113,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ServiceListResult", pipeline_response) @@ -126,11 +128,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,8 +145,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiCenter/services"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Service"]: """Returns a collection of services within the resource group. @@ -152,7 +152,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Service or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.Service] :raises ~azure.core.exceptions.HttpResponseError: @@ -163,7 +162,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServiceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -174,16 +173,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -195,13 +192,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ServiceListResult", pipeline_response) @@ -211,11 +207,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -228,10 +224,6 @@ 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.ApiCenter/services" - } - @distributed_trace_async async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Service: """Returns details of the service. @@ -241,12 +233,11 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) :type resource_group_name: str :param service_name: The name of Azure API Center service. Required. :type service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,21 +251,19 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Service] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -284,16 +273,12 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Service", pipeline_response) + deserialized = self._deserialize("Service", pipeline_response.http_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.ApiCenter/services/{serviceName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -317,7 +302,6 @@ async def 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 :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: @@ -328,7 +312,7 @@ async def create_or_update( self, resource_group_name: str, service_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -341,11 +325,10 @@ async def create_or_update( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: @@ -353,7 +336,7 @@ async def create_or_update( @distributed_trace_async async def create_or_update( - self, resource_group_name: str, service_name: str, resource: Union[_models.Service, IO], **kwargs: Any + self, resource_group_name: str, service_name: str, resource: Union[_models.Service, IO[bytes]], **kwargs: Any ) -> _models.Service: """Creates new or updates existing API. @@ -362,17 +345,14 @@ async def create_or_update( :type resource_group_name: str :param service_name: The name of Azure API Center service. Required. :type service_name: str - :param resource: Resource create parameters. Is either a Service type or a IO type. Required. - :type resource: ~azure.mgmt.apicenter.models.Service 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 resource: Resource create parameters. Is either a Service type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.apicenter.models.Service or IO[bytes] :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,7 +375,7 @@ async def create_or_update( else: _json = self._serialize.body(resource, "Service") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, @@ -403,16 +383,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -422,21 +400,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Service", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Service", pipeline_response) + deserialized = self._deserialize("Service", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - } - @overload async def update( self, @@ -459,7 +429,6 @@ async def 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 :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: @@ -470,7 +439,7 @@ async def update( self, resource_group_name: str, service_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -483,11 +452,10 @@ async def update( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param properties: The resource properties to be updated. Required. - :type properties: IO + :type properties: 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: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: @@ -495,7 +463,11 @@ async def update( @distributed_trace_async async def update( - self, resource_group_name: str, service_name: str, properties: Union[_models.ServiceUpdate, IO], **kwargs: Any + self, + resource_group_name: str, + service_name: str, + properties: Union[_models.ServiceUpdate, IO[bytes]], + **kwargs: Any ) -> _models.Service: """Updates existing service. @@ -505,17 +477,13 @@ async def update( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param properties: The resource properties to be updated. Is either a ServiceUpdate type or a - IO type. Required. - :type properties: ~azure.mgmt.apicenter.models.ServiceUpdate 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 + IO[bytes] type. Required. + :type properties: ~azure.mgmt.apicenter.models.ServiceUpdate or IO[bytes] :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -538,7 +506,7 @@ async def update( else: _json = self._serialize.body(properties, "ServiceUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, @@ -546,16 +514,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -565,16 +531,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Service", pipeline_response) + deserialized = self._deserialize("Service", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -587,12 +549,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param service_name: The name of Azure API Center service. Required. :type service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -606,21 +567,19 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -631,20 +590,16 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - } + return cls(pipeline_response, None, {}) # type: ignore async def _export_metadata_schema_initial( self, resource_group_name: str, service_name: str, - body: Union[_models.MetadataSchemaExportRequest, IO], + body: Union[_models.MetadataSchemaExportRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.MetadataSchemaExportResult]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -657,7 +612,7 @@ async def _export_metadata_schema_initial( 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[Optional[_models.MetadataSchemaExportResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -667,7 +622,7 @@ async def _export_metadata_schema_initial( else: _json = self._serialize.body(body, "MetadataSchemaExportRequest") - request = build_export_metadata_schema_request( + _request = build_export_metadata_schema_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, @@ -675,42 +630,39 @@ async def _export_metadata_schema_initial( content_type=content_type, json=_json, content=_content, - template_url=self._export_metadata_schema_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("MetadataSchemaExportResult", pipeline_response) - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _export_metadata_schema_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema" - } + return deserialized # type: ignore @overload async def begin_export_metadata_schema( @@ -734,14 +686,6 @@ async def begin_export_metadata_schema( :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 MetadataSchemaExportResult or the result of cls(response) :rtype: @@ -754,7 +698,7 @@ async def begin_export_metadata_schema( self, resource_group_name: str, service_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -767,18 +711,10 @@ async def begin_export_metadata_schema( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param body: The content of the action request. Required. - :type body: IO + :type body: 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 MetadataSchemaExportResult or the result of cls(response) :rtype: @@ -791,7 +727,7 @@ async def begin_export_metadata_schema( self, resource_group_name: str, service_name: str, - body: Union[_models.MetadataSchemaExportRequest, IO], + body: Union[_models.MetadataSchemaExportRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.MetadataSchemaExportResult]: """Exports the effective metadata schema. @@ -802,19 +738,8 @@ async def begin_export_metadata_schema( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param body: The content of the action request. Is either a MetadataSchemaExportRequest type or - a IO type. Required. - :type body: ~azure.mgmt.apicenter.models.MetadataSchemaExportRequest 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. + a IO[bytes] type. Required. + :type body: ~azure.mgmt.apicenter.models.MetadataSchemaExportRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either MetadataSchemaExportResult or the result of cls(response) :rtype: @@ -842,12 +767,13 @@ async def begin_export_metadata_schema( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MetadataSchemaExportResult", pipeline_response) + deserialized = self._deserialize("MetadataSchemaExportResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -859,14 +785,215 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.MetadataSchemaExportResult].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) # type: ignore + return AsyncLROPoller[_models.MetadataSchemaExportResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - begin_export_metadata_schema.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema" - } + async def _import_from_apim_initial( + self, + resource_group_name: str, + service_name: str, + body: Union[_models.ImportFromApimRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ImportFromApimRequest") + + _request = build_import_from_apim_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_import_from_apim( + self, + resource_group_name: str, + service_name: str, + body: _models.ImportFromApimRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportFromApimSuccessResult]: + """Imports APIs from Azure API Management. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param body: The content of the action request. Required. + :type body: ~azure.mgmt.apicenter.models.ImportFromApimRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ImportFromApimSuccessResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apicenter.models.ImportFromApimSuccessResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_import_from_apim( + self, + resource_group_name: str, + service_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportFromApimSuccessResult]: + """Imports APIs from Azure API Management. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param body: The content of the action request. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ImportFromApimSuccessResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apicenter.models.ImportFromApimSuccessResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_import_from_apim( + self, + resource_group_name: str, + service_name: str, + body: Union[_models.ImportFromApimRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportFromApimSuccessResult]: + """Imports APIs from Azure API Management. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param body: The content of the action request. Is either a ImportFromApimRequest type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.apicenter.models.ImportFromApimRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ImportFromApimSuccessResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apicenter.models.ImportFromApimSuccessResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportFromApimSuccessResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._import_from_apim_initial( + resource_group_name=resource_group_name, + service_name=service_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ImportFromApimSuccessResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ImportFromApimSuccessResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ImportFromApimSuccessResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_workspaces_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_workspaces_operations.py index ee3bfe4b8b18..341f4b704237 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_workspaces_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_workspaces_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspaces_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +76,6 @@ def list( :type service_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workspace or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apicenter.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -84,7 +86,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkspaceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,18 +97,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +118,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkspaceListResult", pipeline_response) @@ -134,11 +133,11 @@ async def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces" - } - @distributed_trace_async async def get( self, resource_group_name: str, service_name: str, workspace_name: str, **kwargs: Any @@ -168,12 +163,11 @@ async def get( :type service_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,22 +181,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,16 +207,12 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -251,7 +239,6 @@ async def 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 :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: @@ -263,7 +250,7 @@ async def create_or_update( resource_group_name: str, service_name: str, workspace_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,11 +265,10 @@ async def create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Workspace or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: @@ -294,7 +280,7 @@ async def create_or_update( resource_group_name: str, service_name: str, workspace_name: str, - resource: Union[_models.Workspace, IO], + resource: Union[_models.Workspace, IO[bytes]], **kwargs: Any ) -> _models.Workspace: """Creates new or updates existing workspace. @@ -306,17 +292,14 @@ async def create_or_update( :type service_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param resource: Resource create parameters. Is either a Workspace type or a IO type. Required. - :type resource: ~azure.mgmt.apicenter.models.Workspace 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 resource: Resource create parameters. Is either a Workspace type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.apicenter.models.Workspace or IO[bytes] :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +322,7 @@ async def create_or_update( else: _json = self._serialize.body(resource, "Workspace") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -348,16 +331,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -368,25 +349,15 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("Workspace", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, workspace_name: str, **kwargs: Any @@ -400,12 +371,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type service_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,22 +389,20 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -445,11 +413,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def head(self, resource_group_name: str, service_name: str, workspace_name: str, **kwargs: Any) -> bool: @@ -462,12 +426,11 @@ async def head(self, resource_group_name: str, service_name: str, workspace_name :type service_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -481,22 +444,20 @@ async def head(self, resource_group_name: str, service_name: str, workspace_name api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,9 +468,5 @@ async def head(self, resource_group_name: str, service_name: str, workspace_name raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/__init__.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/__init__.py index d6a0e69eeaed..022cf64952d2 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/__init__.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/__init__.py @@ -9,37 +9,39 @@ from ._models_py3 import Api from ._models_py3 import ApiDefinition from ._models_py3 import ApiDefinitionListResult -from ._models_py3 import ApiDefinitionProperties from ._models_py3 import ApiDefinitionPropertiesSpecification from ._models_py3 import ApiListResult -from ._models_py3 import ApiProperties +from ._models_py3 import ApiSource +from ._models_py3 import ApiSourceListResult from ._models_py3 import ApiSpecExportResult from ._models_py3 import ApiSpecImportRequest from ._models_py3 import ApiSpecImportRequestSpecification from ._models_py3 import ApiVersion from ._models_py3 import ApiVersionListResult -from ._models_py3 import ApiVersionProperties +from ._models_py3 import ApimSource from ._models_py3 import Contact +from ._models_py3 import DeletedService +from ._models_py3 import DeletedServiceListResult from ._models_py3 import Deployment from ._models_py3 import DeploymentListResult -from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentServer from ._models_py3 import Environment from ._models_py3 import EnvironmentListResult -from ._models_py3 import EnvironmentProperties from ._models_py3 import EnvironmentServer from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import ExternalDocumentation +from ._models_py3 import ImportFromApimRequest +from ._models_py3 import ImportFromApimSuccessResult from ._models_py3 import License +from ._models_py3 import LinkState from ._models_py3 import ManagedServiceIdentity from ._models_py3 import MetadataAssignment from ._models_py3 import MetadataSchema from ._models_py3 import MetadataSchemaExportRequest from ._models_py3 import MetadataSchemaExportResult from ._models_py3 import MetadataSchemaListResult -from ._models_py3 import MetadataSchemaProperties from ._models_py3 import Onboarding from ._models_py3 import Operation from ._models_py3 import OperationDisplay @@ -48,7 +50,6 @@ from ._models_py3 import Resource from ._models_py3 import Service from ._models_py3 import ServiceListResult -from ._models_py3 import ServiceProperties from ._models_py3 import ServiceUpdate from ._models_py3 import SystemData from ._models_py3 import TermsOfService @@ -56,7 +57,6 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import Workspace from ._models_py3 import WorkspaceListResult -from ._models_py3 import WorkspaceProperties from ._api_center_mgmt_client_enums import ActionType from ._api_center_mgmt_client_enums import ApiKind @@ -72,7 +72,7 @@ from ._api_center_mgmt_client_enums import MetadataSchemaExportFormat from ._api_center_mgmt_client_enums import Origin from ._api_center_mgmt_client_enums import ProvisioningState -from ._api_center_mgmt_client_enums import Versions +from ._api_center_mgmt_client_enums import ShouldImportSpec from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk @@ -81,37 +81,39 @@ "Api", "ApiDefinition", "ApiDefinitionListResult", - "ApiDefinitionProperties", "ApiDefinitionPropertiesSpecification", "ApiListResult", - "ApiProperties", + "ApiSource", + "ApiSourceListResult", "ApiSpecExportResult", "ApiSpecImportRequest", "ApiSpecImportRequestSpecification", "ApiVersion", "ApiVersionListResult", - "ApiVersionProperties", + "ApimSource", "Contact", + "DeletedService", + "DeletedServiceListResult", "Deployment", "DeploymentListResult", - "DeploymentProperties", "DeploymentServer", "Environment", "EnvironmentListResult", - "EnvironmentProperties", "EnvironmentServer", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "ExternalDocumentation", + "ImportFromApimRequest", + "ImportFromApimSuccessResult", "License", + "LinkState", "ManagedServiceIdentity", "MetadataAssignment", "MetadataSchema", "MetadataSchemaExportRequest", "MetadataSchemaExportResult", "MetadataSchemaListResult", - "MetadataSchemaProperties", "Onboarding", "Operation", "OperationDisplay", @@ -120,7 +122,6 @@ "Resource", "Service", "ServiceListResult", - "ServiceProperties", "ServiceUpdate", "SystemData", "TermsOfService", @@ -128,7 +129,6 @@ "UserAssignedIdentity", "Workspace", "WorkspaceListResult", - "WorkspaceProperties", "ActionType", "ApiKind", "ApiSpecExportResultFormat", @@ -143,7 +143,7 @@ "MetadataSchemaExportFormat", "Origin", "ProvisioningState", - "Versions", + "ShouldImportSpec", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/_api_center_mgmt_client_enums.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/_api_center_mgmt_client_enums.py index 44b950725510..735565c62c0f 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/_api_center_mgmt_client_enums.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/_api_center_mgmt_client_enums.py @@ -49,7 +49,7 @@ class ApiSpecImportSourceFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The inlined content of a specification document.""" LINK = "link" """The link to a specification document hosted on a publicly accessible internet - #: address.""" + address.""" class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -173,8 +173,12 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource creation was canceled.""" -class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The available API versions.""" +class ShouldImportSpec(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if the specification should be imported along with metadata.""" - V2024_03_01 = "2024-03-01" - """The initial service version""" + NEVER = "never" + """Indicates that the specification should be never be imported.""" + ON_DEMAND = "ondemand" + """Indicates that the specification should be imported only by request.""" + ALWAYS = "always" + """Indicates that the specification should always be imported along with metadata.""" diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/_models_py3.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/_models_py3.py index c239993d1ae6..75ab136ed785 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/_models_py3.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/models/_models_py3.py @@ -30,7 +30,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -72,7 +72,7 @@ class ProxyResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -84,32 +84,14 @@ class ProxyResource(Resource): :vartype system_data: ~azure.mgmt.apicenter.models.SystemData """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - -class Api(ProxyResource): +class Api(ProxyResource): # pylint: disable=too-many-instance-attributes """API entity. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -119,8 +101,28 @@ class Api(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.apicenter.models.SystemData - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.apicenter.models.ApiProperties + :ivar title: API title. + :vartype title: str + :ivar kind: Kind of API. For example, REST or GraphQL. Known values are: "rest", "graphql", + "grpc", "soap", "webhook", and "websocket". + :vartype kind: str or ~azure.mgmt.apicenter.models.ApiKind + :ivar description: Description of the API. + :vartype description: str + :ivar summary: Short description of the API. + :vartype summary: str + :ivar lifecycle_stage: Current lifecycle stage of the API. Known values are: "design", + "development", "testing", "preview", "production", "deprecated", and "retired". + :vartype lifecycle_stage: str or ~azure.mgmt.apicenter.models.LifecycleStage + :ivar terms_of_service: Terms of service for the API. + :vartype terms_of_service: ~azure.mgmt.apicenter.models.TermsOfService + :ivar external_documentation: The set of external documentation. + :vartype external_documentation: list[~azure.mgmt.apicenter.models.ExternalDocumentation] + :ivar contacts: The set of contacts. + :vartype contacts: list[~azure.mgmt.apicenter.models.Contact] + :ivar license: The license information for the API. + :vartype license: ~azure.mgmt.apicenter.models.License + :ivar custom_properties: The custom metadata defined for API catalog entities. + :vartype custom_properties: JSON """ _validation = { @@ -128,6 +130,11 @@ class Api(ProxyResource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, + "description": {"max_length": 1000}, + "summary": {"max_length": 200}, + "lifecycle_stage": {"readonly": True}, + "external_documentation": {"max_items": 20, "min_items": 0}, } _attribute_map = { @@ -135,16 +142,64 @@ class Api(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "ApiProperties"}, + "title": {"key": "properties.title", "type": "str"}, + "kind": {"key": "properties.kind", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "summary": {"key": "properties.summary", "type": "str"}, + "lifecycle_stage": {"key": "properties.lifecycleStage", "type": "str"}, + "terms_of_service": {"key": "properties.termsOfService", "type": "TermsOfService"}, + "external_documentation": {"key": "properties.externalDocumentation", "type": "[ExternalDocumentation]"}, + "contacts": {"key": "properties.contacts", "type": "[Contact]"}, + "license": {"key": "properties.license", "type": "License"}, + "custom_properties": {"key": "properties.customProperties", "type": "object"}, } - def __init__(self, *, properties: Optional["_models.ApiProperties"] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + title: Optional[str] = None, + kind: Optional[Union[str, "_models.ApiKind"]] = None, + description: Optional[str] = None, + summary: Optional[str] = None, + terms_of_service: Optional["_models.TermsOfService"] = None, + external_documentation: Optional[List["_models.ExternalDocumentation"]] = None, + contacts: Optional[List["_models.Contact"]] = None, + license: Optional["_models.License"] = None, + custom_properties: Optional[JSON] = None, + **kwargs: Any + ) -> None: """ - :keyword properties: The resource-specific properties for this resource. - :paramtype properties: ~azure.mgmt.apicenter.models.ApiProperties + :keyword title: API title. + :paramtype title: str + :keyword kind: Kind of API. For example, REST or GraphQL. Known values are: "rest", "graphql", + "grpc", "soap", "webhook", and "websocket". + :paramtype kind: str or ~azure.mgmt.apicenter.models.ApiKind + :keyword description: Description of the API. + :paramtype description: str + :keyword summary: Short description of the API. + :paramtype summary: str + :keyword terms_of_service: Terms of service for the API. + :paramtype terms_of_service: ~azure.mgmt.apicenter.models.TermsOfService + :keyword external_documentation: The set of external documentation. + :paramtype external_documentation: list[~azure.mgmt.apicenter.models.ExternalDocumentation] + :keyword contacts: The set of contacts. + :paramtype contacts: list[~azure.mgmt.apicenter.models.Contact] + :keyword license: The license information for the API. + :paramtype license: ~azure.mgmt.apicenter.models.License + :keyword custom_properties: The custom metadata defined for API catalog entities. + :paramtype custom_properties: JSON """ super().__init__(**kwargs) - self.properties = properties + self.title = title + self.kind = kind + self.description = description + self.summary = summary + self.lifecycle_stage = None + self.terms_of_service = terms_of_service + self.external_documentation = external_documentation + self.contacts = contacts + self.license = license + self.custom_properties = custom_properties class ApiDefinition(ProxyResource): @@ -153,7 +208,7 @@ class ApiDefinition(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -163,8 +218,12 @@ class ApiDefinition(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.apicenter.models.SystemData - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.apicenter.models.ApiDefinitionProperties + :ivar title: API definition title. + :vartype title: str + :ivar description: API definition description. + :vartype description: str + :ivar specification: API specification details. + :vartype specification: ~azure.mgmt.apicenter.models.ApiDefinitionPropertiesSpecification """ _validation = { @@ -172,6 +231,8 @@ class ApiDefinition(ProxyResource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, + "specification": {"readonly": True}, } _attribute_map = { @@ -179,16 +240,22 @@ class ApiDefinition(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "ApiDefinitionProperties"}, + "title": {"key": "properties.title", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "specification": {"key": "properties.specification", "type": "ApiDefinitionPropertiesSpecification"}, } - def __init__(self, *, properties: Optional["_models.ApiDefinitionProperties"] = None, **kwargs: Any) -> None: + def __init__(self, *, title: Optional[str] = None, description: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword properties: The resource-specific properties for this resource. - :paramtype properties: ~azure.mgmt.apicenter.models.ApiDefinitionProperties + :keyword title: API definition title. + :paramtype title: str + :keyword description: API definition description. + :paramtype description: str """ super().__init__(**kwargs) - self.properties = properties + self.title = title + self.description = description + self.specification = None class ApiDefinitionListResult(_serialization.Model): @@ -196,7 +263,7 @@ class ApiDefinitionListResult(_serialization.Model): 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 Azure. + All required parameters must be populated in order to send to server. :ivar value: The ApiDefinition items on this page. Required. :vartype value: list[~azure.mgmt.apicenter.models.ApiDefinition] @@ -221,45 +288,6 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ApiDefinitionProperties(_serialization.Model): - """API definition properties entity. - - 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 Azure. - - :ivar title: API definition title. Required. - :vartype title: str - :ivar description: API definition description. - :vartype description: str - :ivar specification: API specification details. - :vartype specification: ~azure.mgmt.apicenter.models.ApiDefinitionPropertiesSpecification - """ - - _validation = { - "title": {"required": True, "max_length": 50, "min_length": 1}, - "specification": {"readonly": True}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "specification": {"key": "specification", "type": "ApiDefinitionPropertiesSpecification"}, - } - - def __init__(self, *, title: str, description: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword title: API definition title. Required. - :paramtype title: str - :keyword description: API definition description. - :paramtype description: str - """ - super().__init__(**kwargs) - self.title = title - self.description = description - self.specification = None - - class ApiDefinitionPropertiesSpecification(_serialization.Model): """API specification details. @@ -291,7 +319,7 @@ class ApiListResult(_serialization.Model): 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 Azure. + All required parameters must be populated in order to send to server. :ivar value: The Api items on this page. Required. :vartype value: list[~azure.mgmt.apicenter.models.Api] @@ -316,105 +344,155 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ApiProperties(_serialization.Model): - """API properties. +class ApimSource(_serialization.Model): + """API source configuration for Azure API Management. 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 Azure. + All required parameters must be populated in order to send to server. - :ivar title: API title. Required. - :vartype title: str - :ivar kind: Kind of API. For example, REST or GraphQL. Required. Known values are: "rest", - "graphql", "grpc", "soap", "webhook", and "websocket". - :vartype kind: str or ~azure.mgmt.apicenter.models.ApiKind - :ivar description: Description of the API. - :vartype description: str - :ivar summary: Short description of the API. - :vartype summary: str - :ivar lifecycle_stage: Current lifecycle stage of the API. Known values are: "design", + :ivar resource_id: API Management service resource ID. Required. + :vartype resource_id: str + :ivar msi_resource_id: The resource ID of the managed identity that has access to the API + Management instance. + :vartype msi_resource_id: str + :ivar target_environment_id: The target environment resource ID. + :vartype target_environment_id: str + :ivar target_lifecycle_stage: The target lifecycle stage. Known values are: "design", "development", "testing", "preview", "production", "deprecated", and "retired". - :vartype lifecycle_stage: str or ~azure.mgmt.apicenter.models.LifecycleStage - :ivar terms_of_service: Terms of service for the API. - :vartype terms_of_service: ~azure.mgmt.apicenter.models.TermsOfService - :ivar external_documentation: The set of external documentation. - :vartype external_documentation: list[~azure.mgmt.apicenter.models.ExternalDocumentation] - :ivar contacts: The set of contacts. - :vartype contacts: list[~azure.mgmt.apicenter.models.Contact] - :ivar license: The license information for the API. - :vartype license: ~azure.mgmt.apicenter.models.License - :ivar custom_properties: The custom metadata defined for API catalog entities. - :vartype custom_properties: JSON + :vartype target_lifecycle_stage: str or ~azure.mgmt.apicenter.models.LifecycleStage + :ivar link_state: The state of the API source link. + :vartype link_state: ~azure.mgmt.apicenter.models.LinkState """ _validation = { - "title": {"required": True, "max_length": 50, "min_length": 1}, - "kind": {"required": True}, - "description": {"max_length": 1000}, - "summary": {"max_length": 200}, - "lifecycle_stage": {"readonly": True}, - "external_documentation": {"max_items": 20, "min_items": 0}, + "resource_id": {"required": True}, + "link_state": {"readonly": True}, } _attribute_map = { - "title": {"key": "title", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "summary": {"key": "summary", "type": "str"}, - "lifecycle_stage": {"key": "lifecycleStage", "type": "str"}, - "terms_of_service": {"key": "termsOfService", "type": "TermsOfService"}, - "external_documentation": {"key": "externalDocumentation", "type": "[ExternalDocumentation]"}, - "contacts": {"key": "contacts", "type": "[Contact]"}, - "license": {"key": "license", "type": "License"}, - "custom_properties": {"key": "customProperties", "type": "object"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "msi_resource_id": {"key": "msiResourceId", "type": "str"}, + "target_environment_id": {"key": "targetEnvironmentId", "type": "str"}, + "target_lifecycle_stage": {"key": "targetLifecycleStage", "type": "str"}, + "link_state": {"key": "linkState", "type": "LinkState"}, } def __init__( self, *, - title: str, - kind: Union[str, "_models.ApiKind"], - description: Optional[str] = None, - summary: Optional[str] = None, - terms_of_service: Optional["_models.TermsOfService"] = None, - external_documentation: Optional[List["_models.ExternalDocumentation"]] = None, - contacts: Optional[List["_models.Contact"]] = None, - license: Optional["_models.License"] = None, - custom_properties: Optional[JSON] = None, + resource_id: str, + msi_resource_id: Optional[str] = None, + target_environment_id: Optional[str] = None, + target_lifecycle_stage: Optional[Union[str, "_models.LifecycleStage"]] = None, **kwargs: Any ) -> None: """ - :keyword title: API title. Required. - :paramtype title: str - :keyword kind: Kind of API. For example, REST or GraphQL. Required. Known values are: "rest", - "graphql", "grpc", "soap", "webhook", and "websocket". - :paramtype kind: str or ~azure.mgmt.apicenter.models.ApiKind - :keyword description: Description of the API. - :paramtype description: str - :keyword summary: Short description of the API. - :paramtype summary: str - :keyword terms_of_service: Terms of service for the API. - :paramtype terms_of_service: ~azure.mgmt.apicenter.models.TermsOfService - :keyword external_documentation: The set of external documentation. - :paramtype external_documentation: list[~azure.mgmt.apicenter.models.ExternalDocumentation] - :keyword contacts: The set of contacts. - :paramtype contacts: list[~azure.mgmt.apicenter.models.Contact] - :keyword license: The license information for the API. - :paramtype license: ~azure.mgmt.apicenter.models.License - :keyword custom_properties: The custom metadata defined for API catalog entities. - :paramtype custom_properties: JSON + :keyword resource_id: API Management service resource ID. Required. + :paramtype resource_id: str + :keyword msi_resource_id: The resource ID of the managed identity that has access to the API + Management instance. + :paramtype msi_resource_id: str + :keyword target_environment_id: The target environment resource ID. + :paramtype target_environment_id: str + :keyword target_lifecycle_stage: The target lifecycle stage. Known values are: "design", + "development", "testing", "preview", "production", "deprecated", and "retired". + :paramtype target_lifecycle_stage: str or ~azure.mgmt.apicenter.models.LifecycleStage """ super().__init__(**kwargs) - self.title = title - self.kind = kind - self.description = description - self.summary = summary - self.lifecycle_stage = None - self.terms_of_service = terms_of_service - self.external_documentation = external_documentation - self.contacts = contacts - self.license = license - self.custom_properties = custom_properties + self.resource_id = resource_id + self.msi_resource_id = msi_resource_id + self.target_environment_id = target_environment_id + self.target_lifecycle_stage = target_lifecycle_stage + self.link_state = None + + +class ApiSource(ProxyResource): + """API source entity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apicenter.models.SystemData + :ivar should_import_spec: Indicates if the specification should be imported along with + metadata. Known values are: "never", "ondemand", and "always". + :vartype should_import_spec: str or ~azure.mgmt.apicenter.models.ShouldImportSpec + :ivar apim_source: API source configuration for Azure API Management. + :vartype apim_source: ~azure.mgmt.apicenter.models.ApimSource + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "should_import_spec": {"key": "properties.shouldImportSpec", "type": "str"}, + "apim_source": {"key": "properties.apimSource", "type": "ApimSource"}, + } + + def __init__( + self, + *, + should_import_spec: Optional[Union[str, "_models.ShouldImportSpec"]] = None, + apim_source: Optional["_models.ApimSource"] = None, + **kwargs: Any + ) -> None: + """ + :keyword should_import_spec: Indicates if the specification should be imported along with + metadata. Known values are: "never", "ondemand", and "always". + :paramtype should_import_spec: str or ~azure.mgmt.apicenter.models.ShouldImportSpec + :keyword apim_source: API source configuration for Azure API Management. + :paramtype apim_source: ~azure.mgmt.apicenter.models.ApimSource + """ + super().__init__(**kwargs) + self.should_import_spec = should_import_spec + self.apim_source = apim_source + + +class ApiSourceListResult(_serialization.Model): + """The response of a ApiSource list operation. + + 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 value: The ApiSource items on this page. Required. + :vartype value: list[~azure.mgmt.apicenter.models.ApiSource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True, "readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApiSource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None class ApiSpecExportResult(_serialization.Model): @@ -520,7 +598,7 @@ class ApiVersion(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -530,8 +608,11 @@ class ApiVersion(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.apicenter.models.SystemData - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.apicenter.models.ApiVersionProperties + :ivar title: API version title. + :vartype title: str + :ivar lifecycle_stage: Current lifecycle stage of the API. Known values are: "design", + "development", "testing", "preview", "production", "deprecated", and "retired". + :vartype lifecycle_stage: str or ~azure.mgmt.apicenter.models.LifecycleStage """ _validation = { @@ -539,6 +620,7 @@ class ApiVersion(ProxyResource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, } _attribute_map = { @@ -546,16 +628,27 @@ class ApiVersion(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "ApiVersionProperties"}, + "title": {"key": "properties.title", "type": "str"}, + "lifecycle_stage": {"key": "properties.lifecycleStage", "type": "str"}, } - def __init__(self, *, properties: Optional["_models.ApiVersionProperties"] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + title: Optional[str] = None, + lifecycle_stage: Optional[Union[str, "_models.LifecycleStage"]] = None, + **kwargs: Any + ) -> None: """ - :keyword properties: The resource-specific properties for this resource. - :paramtype properties: ~azure.mgmt.apicenter.models.ApiVersionProperties + :keyword title: API version title. + :paramtype title: str + :keyword lifecycle_stage: Current lifecycle stage of the API. Known values are: "design", + "development", "testing", "preview", "production", "deprecated", and "retired". + :paramtype lifecycle_stage: str or ~azure.mgmt.apicenter.models.LifecycleStage """ super().__init__(**kwargs) - self.properties = properties + self.title = title + self.lifecycle_stage = lifecycle_stage class ApiVersionListResult(_serialization.Model): @@ -563,7 +656,7 @@ class ApiVersionListResult(_serialization.Model): 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 Azure. + All required parameters must be populated in order to send to server. :ivar value: The ApiVersion items on this page. Required. :vartype value: list[~azure.mgmt.apicenter.models.ApiVersion] @@ -588,41 +681,6 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ApiVersionProperties(_serialization.Model): - """API version properties entity. - - All required parameters must be populated in order to send to Azure. - - :ivar title: API version title. Required. - :vartype title: str - :ivar lifecycle_stage: Current lifecycle stage of the API. Required. Known values are: - "design", "development", "testing", "preview", "production", "deprecated", and "retired". - :vartype lifecycle_stage: str or ~azure.mgmt.apicenter.models.LifecycleStage - """ - - _validation = { - "title": {"required": True, "max_length": 50, "min_length": 1}, - "lifecycle_stage": {"required": True}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "lifecycle_stage": {"key": "lifecycleStage", "type": "str"}, - } - - def __init__(self, *, title: str, lifecycle_stage: Union[str, "_models.LifecycleStage"], **kwargs: Any) -> None: - """ - :keyword title: API version title. Required. - :paramtype title: str - :keyword lifecycle_stage: Current lifecycle stage of the API. Required. Known values are: - "design", "development", "testing", "preview", "production", "deprecated", and "retired". - :paramtype lifecycle_stage: str or ~azure.mgmt.apicenter.models.LifecycleStage - """ - super().__init__(**kwargs) - self.title = title - self.lifecycle_stage = lifecycle_stage - - class Contact(_serialization.Model): """Contact information. @@ -663,13 +721,13 @@ def __init__( self.email = email -class Deployment(ProxyResource): - """API deployment entity. +class DeletedService(ProxyResource): + """Soft-deleted service entity. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -679,8 +737,13 @@ class Deployment(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.apicenter.models.SystemData - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.apicenter.models.DeploymentProperties + :ivar scheduled_purge_date: UTC date and time when the service will be automatically purged. + The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 + standard. + :vartype scheduled_purge_date: ~datetime.datetime + :ivar soft_deletion_date: UTC date and time when the service was soft-deleted. The date + conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype soft_deletion_date: ~datetime.datetime """ _validation = { @@ -695,27 +758,40 @@ class Deployment(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "DeploymentProperties"}, + "scheduled_purge_date": {"key": "properties.scheduledPurgeDate", "type": "iso-8601"}, + "soft_deletion_date": {"key": "properties.softDeletionDate", "type": "iso-8601"}, } - def __init__(self, *, properties: Optional["_models.DeploymentProperties"] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + scheduled_purge_date: Optional[datetime.datetime] = None, + soft_deletion_date: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: """ - :keyword properties: The resource-specific properties for this resource. - :paramtype properties: ~azure.mgmt.apicenter.models.DeploymentProperties + :keyword scheduled_purge_date: UTC date and time when the service will be automatically purged. + The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 + standard. + :paramtype scheduled_purge_date: ~datetime.datetime + :keyword soft_deletion_date: UTC date and time when the service was soft-deleted. The date + conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :paramtype soft_deletion_date: ~datetime.datetime """ super().__init__(**kwargs) - self.properties = properties + self.scheduled_purge_date = scheduled_purge_date + self.soft_deletion_date = soft_deletion_date -class DeploymentListResult(_serialization.Model): - """The response of a Deployment list operation. +class DeletedServiceListResult(_serialization.Model): + """The response of a DeletedService list operation. 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 Azure. + All required parameters must be populated in order to send to server. - :ivar value: The Deployment items on this page. Required. - :vartype value: list[~azure.mgmt.apicenter.models.Deployment] + :ivar value: The DeletedService items on this page. Required. + :vartype value: list[~azure.mgmt.apicenter.models.DeletedService] :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -726,7 +802,7 @@ class DeploymentListResult(_serialization.Model): } _attribute_map = { - "value": {"key": "value", "type": "[Deployment]"}, + "value": {"key": "value", "type": "[DeletedService]"}, "next_link": {"key": "nextLink", "type": "str"}, } @@ -737,9 +813,22 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class DeploymentProperties(_serialization.Model): - """API deployment entity properties. +class Deployment(ProxyResource): # pylint: disable=too-many-instance-attributes + """API deployment entity. + + Variables are only populated by the server, and will be ignored when sending a request. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apicenter.models.SystemData :ivar title: API deployment title. :vartype title: str :ivar description: Description of the deployment. @@ -757,18 +846,26 @@ class DeploymentProperties(_serialization.Model): """ _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, "title": {"max_length": 50, "min_length": 1}, "description": {"max_length": 500}, } _attribute_map = { - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "environment_id": {"key": "environmentId", "type": "str"}, - "definition_id": {"key": "definitionId", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "server": {"key": "server", "type": "DeploymentServer"}, - "custom_properties": {"key": "customProperties", "type": "object"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "title": {"key": "properties.title", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "environment_id": {"key": "properties.environmentId", "type": "str"}, + "definition_id": {"key": "properties.definitionId", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "server": {"key": "properties.server", "type": "DeploymentServer"}, + "custom_properties": {"key": "properties.customProperties", "type": "object"}, } def __init__( @@ -800,13 +897,43 @@ def __init__( :paramtype custom_properties: JSON """ super().__init__(**kwargs) - self.title = title - self.description = description - self.environment_id = environment_id - self.definition_id = definition_id - self.state = state - self.server = server - self.custom_properties = custom_properties + self.title = title + self.description = description + self.environment_id = environment_id + self.definition_id = definition_id + self.state = state + self.server = server + self.custom_properties = custom_properties + + +class DeploymentListResult(_serialization.Model): + """The response of a Deployment list operation. + + 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 value: The Deployment items on this page. Required. + :vartype value: list[~azure.mgmt.apicenter.models.Deployment] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True, "readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Deployment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None class DeploymentServer(_serialization.Model): @@ -835,7 +962,7 @@ class Environment(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -845,8 +972,19 @@ class Environment(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.apicenter.models.SystemData - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.apicenter.models.EnvironmentProperties + :ivar title: Environment title. + :vartype title: str + :ivar description: The environment description. + :vartype description: str + :ivar kind: Environment kind. Known values are: "development", "testing", "staging", and + "production". + :vartype kind: str or ~azure.mgmt.apicenter.models.EnvironmentKind + :ivar server: Server information of the environment. + :vartype server: ~azure.mgmt.apicenter.models.EnvironmentServer + :ivar onboarding: Environment onboarding information. + :vartype onboarding: ~azure.mgmt.apicenter.models.Onboarding + :ivar custom_properties: The custom metadata defined for API catalog entities. + :vartype custom_properties: JSON """ _validation = { @@ -854,6 +992,7 @@ class Environment(ProxyResource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, } _attribute_map = { @@ -861,16 +1000,47 @@ class Environment(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "EnvironmentProperties"}, + "title": {"key": "properties.title", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "kind": {"key": "properties.kind", "type": "str"}, + "server": {"key": "properties.server", "type": "EnvironmentServer"}, + "onboarding": {"key": "properties.onboarding", "type": "Onboarding"}, + "custom_properties": {"key": "properties.customProperties", "type": "object"}, } - def __init__(self, *, properties: Optional["_models.EnvironmentProperties"] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + kind: Optional[Union[str, "_models.EnvironmentKind"]] = None, + server: Optional["_models.EnvironmentServer"] = None, + onboarding: Optional["_models.Onboarding"] = None, + custom_properties: Optional[JSON] = None, + **kwargs: Any + ) -> None: """ - :keyword properties: The resource-specific properties for this resource. - :paramtype properties: ~azure.mgmt.apicenter.models.EnvironmentProperties + :keyword title: Environment title. + :paramtype title: str + :keyword description: The environment description. + :paramtype description: str + :keyword kind: Environment kind. Known values are: "development", "testing", "staging", and + "production". + :paramtype kind: str or ~azure.mgmt.apicenter.models.EnvironmentKind + :keyword server: Server information of the environment. + :paramtype server: ~azure.mgmt.apicenter.models.EnvironmentServer + :keyword onboarding: Environment onboarding information. + :paramtype onboarding: ~azure.mgmt.apicenter.models.Onboarding + :keyword custom_properties: The custom metadata defined for API catalog entities. + :paramtype custom_properties: JSON """ super().__init__(**kwargs) - self.properties = properties + self.title = title + self.description = description + self.kind = kind + self.server = server + self.onboarding = onboarding + self.custom_properties = custom_properties class EnvironmentListResult(_serialization.Model): @@ -878,7 +1048,7 @@ class EnvironmentListResult(_serialization.Model): 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 Azure. + All required parameters must be populated in order to send to server. :ivar value: The Environment items on this page. Required. :vartype value: list[~azure.mgmt.apicenter.models.Environment] @@ -903,75 +1073,6 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class EnvironmentProperties(_serialization.Model): - """Environment properties entity. - - All required parameters must be populated in order to send to Azure. - - :ivar title: Environment title. Required. - :vartype title: str - :ivar description: The environment description. - :vartype description: str - :ivar kind: Environment kind. Required. Known values are: "development", "testing", "staging", - and "production". - :vartype kind: str or ~azure.mgmt.apicenter.models.EnvironmentKind - :ivar server: Server information of the environment. - :vartype server: ~azure.mgmt.apicenter.models.EnvironmentServer - :ivar onboarding: Environment onboarding information. - :vartype onboarding: ~azure.mgmt.apicenter.models.Onboarding - :ivar custom_properties: The custom metadata defined for API catalog entities. - :vartype custom_properties: JSON - """ - - _validation = { - "title": {"required": True, "max_length": 50, "min_length": 1}, - "kind": {"required": True}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "server": {"key": "server", "type": "EnvironmentServer"}, - "onboarding": {"key": "onboarding", "type": "Onboarding"}, - "custom_properties": {"key": "customProperties", "type": "object"}, - } - - def __init__( - self, - *, - title: str, - kind: Union[str, "_models.EnvironmentKind"], - description: Optional[str] = None, - server: Optional["_models.EnvironmentServer"] = None, - onboarding: Optional["_models.Onboarding"] = None, - custom_properties: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword title: Environment title. Required. - :paramtype title: str - :keyword description: The environment description. - :paramtype description: str - :keyword kind: Environment kind. Required. Known values are: "development", "testing", - "staging", and "production". - :paramtype kind: str or ~azure.mgmt.apicenter.models.EnvironmentKind - :keyword server: Server information of the environment. - :paramtype server: ~azure.mgmt.apicenter.models.EnvironmentServer - :keyword onboarding: Environment onboarding information. - :paramtype onboarding: ~azure.mgmt.apicenter.models.Onboarding - :keyword custom_properties: The custom metadata defined for API catalog entities. - :paramtype custom_properties: JSON - """ - super().__init__(**kwargs) - self.title = title - self.description = description - self.kind = kind - self.server = server - self.onboarding = onboarding - self.custom_properties = custom_properties - - class EnvironmentServer(_serialization.Model): """Server information of the environment. @@ -1107,7 +1208,7 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A class ExternalDocumentation(_serialization.Model): """Additional, external documentation for the API. - 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 title: Title of the documentation. :vartype title: str @@ -1146,6 +1247,67 @@ def __init__( self.url = url +class ImportFromApimRequest(_serialization.Model): + """The import from Azure API Management request. + + :ivar source_resource_ids: An entity the metadata schema is requested for. + :vartype source_resource_ids: list[str] + """ + + _attribute_map = { + "source_resource_ids": {"key": "sourceResourceIds", "type": "[str]"}, + } + + def __init__(self, *, source_resource_ids: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword source_resource_ids: An entity the metadata schema is requested for. + :paramtype source_resource_ids: list[str] + """ + super().__init__(**kwargs) + self.source_resource_ids = source_resource_ids + + +class ImportFromApimSuccessResult(_serialization.Model): + """The import operation was successfully completed. + + All required parameters must be populated in order to send to server. + + :ivar status: Async operation status. Required. + :vartype status: str + :ivar start_time: Async operation start time. Required. + :vartype start_time: ~datetime.datetime + :ivar end_time: Async operation end time. + :vartype end_time: ~datetime.datetime + """ + + _validation = { + "status": {"required": True}, + "start_time": {"required": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + } + + def __init__( + self, *, status: str, start_time: datetime.datetime, end_time: Optional[datetime.datetime] = None, **kwargs: Any + ) -> None: + """ + :keyword status: Async operation status. Required. + :paramtype status: str + :keyword start_time: Async operation start time. Required. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Async operation end time. + :paramtype end_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.status = status + self.start_time = start_time + self.end_time = end_time + + class License(_serialization.Model): """The license information for the API. @@ -1190,12 +1352,57 @@ def __init__( self.identifier = identifier +class LinkState(_serialization.Model): + """The link state. + + All required parameters must be populated in order to send to server. + + :ivar state: The state of the link. + :vartype state: str + :ivar message: The state message. + :vartype message: str + :ivar last_updated_on: The timestamp of the last update of the link state. Required. + :vartype last_updated_on: ~datetime.datetime + """ + + _validation = { + "last_updated_on": {"required": True}, + } + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "last_updated_on": {"key": "lastUpdatedOn", "type": "iso-8601"}, + } + + def __init__( + self, + *, + last_updated_on: datetime.datetime, + state: Optional[str] = None, + message: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword state: The state of the link. + :paramtype state: str + :keyword message: The state message. + :paramtype message: str + :keyword last_updated_on: The timestamp of the last update of the link state. Required. + :paramtype last_updated_on: ~datetime.datetime + """ + super().__init__(**kwargs) + self.state = state + self.message = message + self.last_updated_on = last_updated_on + + class ManagedServiceIdentity(_serialization.Model): """Managed service identity (system assigned and/or user assigned identities). 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 Azure. + All required parameters must be populated in order to send to server. :ivar principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -1209,7 +1416,7 @@ class ManagedServiceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.apicenter.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.apicenter.models.UserAssignedIdentity] """ @@ -1241,7 +1448,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.apicenter.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.apicenter.models.UserAssignedIdentity] @@ -1300,7 +1507,7 @@ class MetadataSchema(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1310,8 +1517,10 @@ class MetadataSchema(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.apicenter.models.SystemData - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.apicenter.models.MetadataSchemaProperties + :ivar schema: The schema defining the type. + :vartype schema: str + :ivar assigned_to: The assignees. + :vartype assigned_to: list[~azure.mgmt.apicenter.models.MetadataAssignment] """ _validation = { @@ -1326,16 +1535,26 @@ class MetadataSchema(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "MetadataSchemaProperties"}, + "schema": {"key": "properties.schema", "type": "str"}, + "assigned_to": {"key": "properties.assignedTo", "type": "[MetadataAssignment]"}, } - def __init__(self, *, properties: Optional["_models.MetadataSchemaProperties"] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + schema: Optional[str] = None, + assigned_to: Optional[List["_models.MetadataAssignment"]] = None, + **kwargs: Any + ) -> None: """ - :keyword properties: The resource-specific properties for this resource. - :paramtype properties: ~azure.mgmt.apicenter.models.MetadataSchemaProperties + :keyword schema: The schema defining the type. + :paramtype schema: str + :keyword assigned_to: The assignees. + :paramtype assigned_to: list[~azure.mgmt.apicenter.models.MetadataAssignment] """ super().__init__(**kwargs) - self.properties = properties + self.schema = schema + self.assigned_to = assigned_to class MetadataSchemaExportRequest(_serialization.Model): @@ -1399,7 +1618,7 @@ class MetadataSchemaListResult(_serialization.Model): 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 Azure. + All required parameters must be populated in order to send to server. :ivar value: The MetadataSchema items on this page. Required. :vartype value: list[~azure.mgmt.apicenter.models.MetadataSchema] @@ -1424,40 +1643,6 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class MetadataSchemaProperties(_serialization.Model): - """Metadata schema properties. - - All required parameters must be populated in order to send to Azure. - - :ivar schema: The schema defining the type. Required. - :vartype schema: str - :ivar assigned_to: The assignees. - :vartype assigned_to: list[~azure.mgmt.apicenter.models.MetadataAssignment] - """ - - _validation = { - "schema": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "schema", "type": "str"}, - "assigned_to": {"key": "assignedTo", "type": "[MetadataAssignment]"}, - } - - def __init__( - self, *, schema: str, assigned_to: Optional[List["_models.MetadataAssignment"]] = None, **kwargs: Any - ) -> None: - """ - :keyword schema: The schema defining the type. Required. - :paramtype schema: str - :keyword assigned_to: The assignees. - :paramtype assigned_to: list[~azure.mgmt.apicenter.models.MetadataAssignment] - """ - super().__init__(**kwargs) - self.schema = schema - self.assigned_to = assigned_to - - class Onboarding(_serialization.Model): """Onboarding information. @@ -1617,10 +1802,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1670,10 +1855,10 @@ class Service(TrackedResource): 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 Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1687,10 +1872,14 @@ class Service(TrackedResource): :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.apicenter.models.ServiceProperties :ivar identity: The managed service identities assigned to this resource. :vartype identity: ~azure.mgmt.apicenter.models.ManagedServiceIdentity + :ivar provisioning_state: Provisioning state of the service. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.apicenter.models.ProvisioningState + :ivar restore: Flag used to restore soft-deleted API Center service. If specified and set to + 'true' all other properties will be ignored. + :vartype restore: bool """ _validation = { @@ -1699,6 +1888,7 @@ class Service(TrackedResource): "type": {"readonly": True}, "system_data": {"readonly": True}, "location": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -1708,8 +1898,9 @@ class Service(TrackedResource): "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "ServiceProperties"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "restore": {"key": "properties.restore", "type": "bool"}, } def __init__( @@ -1717,8 +1908,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - properties: Optional["_models.ServiceProperties"] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, + restore: bool = False, **kwargs: Any ) -> None: """ @@ -1726,14 +1917,16 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword properties: The resource-specific properties for this resource. - :paramtype properties: ~azure.mgmt.apicenter.models.ServiceProperties :keyword identity: The managed service identities assigned to this resource. :paramtype identity: ~azure.mgmt.apicenter.models.ManagedServiceIdentity + :keyword restore: Flag used to restore soft-deleted API Center service. If specified and set to + 'true' all other properties will be ignored. + :paramtype restore: bool """ super().__init__(tags=tags, location=location, **kwargs) - self.properties = properties self.identity = identity + self.provisioning_state = None + self.restore = restore class ServiceListResult(_serialization.Model): @@ -1741,7 +1934,7 @@ class ServiceListResult(_serialization.Model): 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 Azure. + All required parameters must be populated in order to send to server. :ivar value: The Service items on this page. Required. :vartype value: list[~azure.mgmt.apicenter.models.Service] @@ -1766,30 +1959,6 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ServiceProperties(_serialization.Model): - """The properties of the service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning state of the service. Known values are: "Succeeded", - "Failed", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.apicenter.models.ProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioning_state = None - - class ServiceUpdate(_serialization.Model): """The type used for update operations of the Service. @@ -1797,11 +1966,15 @@ class ServiceUpdate(_serialization.Model): :vartype identity: ~azure.mgmt.apicenter.models.ManagedServiceIdentity :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar restore: Flag used to restore soft-deleted API Center service. If specified and set to + 'true' all other properties will be ignored. + :vartype restore: bool """ _attribute_map = { "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "tags": {"key": "tags", "type": "{str}"}, + "restore": {"key": "properties.restore", "type": "bool"}, } def __init__( @@ -1809,6 +1982,7 @@ def __init__( *, identity: Optional["_models.ManagedServiceIdentity"] = None, tags: Optional[Dict[str, str]] = None, + restore: bool = False, **kwargs: Any ) -> None: """ @@ -1816,10 +1990,14 @@ def __init__( :paramtype identity: ~azure.mgmt.apicenter.models.ManagedServiceIdentity :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword restore: Flag used to restore soft-deleted API Center service. If specified and set to + 'true' all other properties will be ignored. + :paramtype restore: bool """ super().__init__(**kwargs) self.identity = identity self.tags = tags + self.restore = restore class SystemData(_serialization.Model): @@ -1889,7 +2067,7 @@ def __init__( class TermsOfService(_serialization.Model): """Terms of service for the API. - 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 url: URL pointing to the terms of service. Required. :vartype url: str @@ -1946,7 +2124,7 @@ class Workspace(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1956,8 +2134,10 @@ class Workspace(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.apicenter.models.SystemData - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.apicenter.models.WorkspaceProperties + :ivar title: Workspace title. + :vartype title: str + :ivar description: Workspace description. + :vartype description: str """ _validation = { @@ -1965,6 +2145,7 @@ class Workspace(ProxyResource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, } _attribute_map = { @@ -1972,16 +2153,20 @@ class Workspace(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "WorkspaceProperties"}, + "title": {"key": "properties.title", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, } - def __init__(self, *, properties: Optional["_models.WorkspaceProperties"] = None, **kwargs: Any) -> None: + def __init__(self, *, title: Optional[str] = None, description: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword properties: The resource-specific properties for this resource. - :paramtype properties: ~azure.mgmt.apicenter.models.WorkspaceProperties + :keyword title: Workspace title. + :paramtype title: str + :keyword description: Workspace description. + :paramtype description: str """ super().__init__(**kwargs) - self.properties = properties + self.title = title + self.description = description class WorkspaceListResult(_serialization.Model): @@ -1989,7 +2174,7 @@ class WorkspaceListResult(_serialization.Model): 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 Azure. + All required parameters must be populated in order to send to server. :ivar value: The Workspace items on this page. Required. :vartype value: list[~azure.mgmt.apicenter.models.Workspace] @@ -2012,35 +2197,3 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self.value = None self.next_link = None - - -class WorkspaceProperties(_serialization.Model): - """Workspace properties. - - All required parameters must be populated in order to send to Azure. - - :ivar title: Workspace title. Required. - :vartype title: str - :ivar description: Workspace description. - :vartype description: str - """ - - _validation = { - "title": {"required": True, "max_length": 50, "min_length": 1}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, *, title: str, description: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword title: Workspace title. Required. - :paramtype title: str - :keyword description: Workspace description. - :paramtype description: str - """ - super().__init__(**kwargs) - self.title = title - self.description = description diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/__init__.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/__init__.py index 3ed67317ce8e..7ebe9eec46af 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/__init__.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/__init__.py @@ -7,9 +7,11 @@ # -------------------------------------------------------------------------- from ._operations import Operations +from ._deleted_services_operations import DeletedServicesOperations from ._services_operations import ServicesOperations from ._metadata_schemas_operations import MetadataSchemasOperations from ._workspaces_operations import WorkspacesOperations +from ._api_sources_operations import ApiSourcesOperations from ._apis_operations import ApisOperations from ._deployments_operations import DeploymentsOperations from ._api_versions_operations import ApiVersionsOperations @@ -22,9 +24,11 @@ __all__ = [ "Operations", + "DeletedServicesOperations", "ServicesOperations", "MetadataSchemasOperations", "WorkspacesOperations", + "ApiSourcesOperations", "ApisOperations", "DeploymentsOperations", "ApiVersionsOperations", diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_definitions_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_definitions_operations.py index 518e2b2ed4d6..f26552102efa 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_definitions_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_definitions_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. @@ -7,7 +7,8 @@ # 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, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +58,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +111,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +165,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -217,7 +222,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -271,7 +276,7 @@ def build_head_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -325,7 +330,7 @@ def build_export_specification_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -379,7 +384,7 @@ def build_import_specification_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -468,7 +473,6 @@ def list( :type version_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.ApiDefinition] :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +483,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -490,7 +494,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -499,12 +503,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -516,13 +518,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApiDefinitionListResult", pipeline_response) @@ -532,11 +533,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -549,10 +550,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions" - } - @distributed_trace def get( self, @@ -579,12 +576,11 @@ def get( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiDefinition or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -598,7 +594,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -607,16 +603,14 @@ def get( definition_name=definition_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -629,16 +623,12 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiDefinition", pipeline_response) + deserialized = self._deserialize("ApiDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -674,7 +664,6 @@ def 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 :return: ApiDefinition or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -689,7 +678,7 @@ def create_or_update( api_name: str, version_name: str, definition_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -710,11 +699,10 @@ def create_or_update( :param definition_name: The name of the API definition. Required. :type definition_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: ApiDefinition or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiDefinition :raises ~azure.core.exceptions.HttpResponseError: @@ -729,7 +717,7 @@ def create_or_update( api_name: str, version_name: str, definition_name: str, - resource: Union[_models.ApiDefinition, IO], + resource: Union[_models.ApiDefinition, IO[bytes]], **kwargs: Any ) -> _models.ApiDefinition: """Creates new or updates existing API definition. @@ -747,18 +735,14 @@ def create_or_update( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :param resource: Resource create parameters. Is either a ApiDefinition type or a IO type. - Required. - :type resource: ~azure.mgmt.apicenter.models.ApiDefinition 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 resource: Resource create parameters. Is either a ApiDefinition type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.apicenter.models.ApiDefinition or IO[bytes] :return: ApiDefinition or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -781,7 +765,7 @@ def create_or_update( else: _json = self._serialize.body(resource, "ApiDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -793,16 +777,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -813,25 +795,15 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiDefinition", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiDefinition", pipeline_response) + deserialized = self._deserialize("ApiDefinition", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -858,12 +830,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -877,7 +848,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, @@ -886,16 +857,14 @@ def delete( # pylint: disable=inconsistent-return-statements definition_name=definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -906,11 +875,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def head( @@ -938,12 +903,11 @@ def head( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -957,7 +921,7 @@ def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -966,16 +930,14 @@ def head( definition_name=definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -986,13 +948,9 @@ def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" - } - def _export_specification_initial( self, resource_group_name: str, @@ -1002,8 +960,8 @@ def _export_specification_initial( version_name: str, definition_name: str, **kwargs: Any - ) -> Optional[_models.ApiSpecExportResult]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1015,9 +973,9 @@ def _export_specification_initial( _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[Optional[_models.ApiSpecExportResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_export_specification_request( + _request = build_export_specification_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -1026,42 +984,39 @@ def _export_specification_initial( definition_name=definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._export_specification_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiSpecExportResult", pipeline_response) - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _export_specification_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification" - } + return deserialized # type: ignore @distributed_trace def begin_export_specification( @@ -1089,14 +1044,6 @@ def begin_export_specification( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_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 ApiSpecExportResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apicenter.models.ApiSpecExportResult] @@ -1124,12 +1071,13 @@ def begin_export_specification( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiSpecExportResult", pipeline_response) + deserialized = self._deserialize("ApiSpecExportResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1141,19 +1089,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ApiSpecExportResult].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) # type: ignore - - begin_export_specification.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification" - } + return LROPoller[_models.ApiSpecExportResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _import_specification_initial( # pylint: disable=inconsistent-return-statements + def _import_specification_initial( self, resource_group_name: str, service_name: str, @@ -1161,10 +1107,10 @@ def _import_specification_initial( # pylint: disable=inconsistent-return-statem api_name: str, version_name: str, definition_name: str, - body: Union[_models.ApiSpecImportRequest, IO], + body: Union[_models.ApiSpecImportRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1177,7 +1123,7 @@ def _import_specification_initial( # pylint: disable=inconsistent-return-statem 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1187,7 +1133,7 @@ def _import_specification_initial( # pylint: disable=inconsistent-return-statem else: _json = self._serialize.body(body, "ApiSpecImportRequest") - request = build_import_specification_request( + _request = build_import_specification_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -1199,36 +1145,39 @@ def _import_specification_initial( # pylint: disable=inconsistent-return-statem content_type=content_type, json=_json, content=_content, - template_url=self._import_specification_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _import_specification_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification" - } + return deserialized # type: ignore @overload def begin_import_specification( @@ -1264,14 +1213,6 @@ def begin_import_specification( :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1286,7 +1227,7 @@ def begin_import_specification( api_name: str, version_name: str, definition_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1307,18 +1248,10 @@ def begin_import_specification( :param definition_name: The name of the API definition. Required. :type definition_name: str :param body: The content of the action request. Required. - :type body: IO + :type body: 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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1333,7 +1266,7 @@ def begin_import_specification( api_name: str, version_name: str, definition_name: str, - body: Union[_models.ApiSpecImportRequest, IO], + body: Union[_models.ApiSpecImportRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Imports the API specification. @@ -1351,20 +1284,9 @@ def begin_import_specification( :type version_name: str :param definition_name: The name of the API definition. Required. :type definition_name: str - :param body: The content of the action request. Is either a ApiSpecImportRequest type or a IO - type. Required. - :type body: ~azure.mgmt.apicenter.models.ApiSpecImportRequest 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 body: The content of the action request. Is either a ApiSpecImportRequest type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.apicenter.models.ApiSpecImportRequest or IO[bytes] :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: @@ -1379,7 +1301,7 @@ def begin_import_specification( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_specification_initial( # type: ignore + raw_result = self._import_specification_initial( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -1394,11 +1316,12 @@ def begin_import_specification( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1409,14 +1332,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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) # type: ignore - - begin_import_specification.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_sources_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_sources_operations.py new file mode 100644 index 000000000000..3901a803c2d7 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_sources_operations.py @@ -0,0 +1,730 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, 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.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + service_name: str, + workspace_name: 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apiSources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", service_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "workspaceName": _SERIALIZER.url( + "workspace_name", workspace_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + } + + _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) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_name: str, + api_source_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apiSources/{apiSourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", service_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "workspaceName": _SERIALIZER.url( + "workspace_name", workspace_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "apiSourceName": _SERIALIZER.url( + "api_source_name", api_source_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + } + + _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, + service_name: str, + workspace_name: str, + api_source_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-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apiSources/{apiSourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", service_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "workspaceName": _SERIALIZER.url( + "workspace_name", workspace_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "apiSourceName": _SERIALIZER.url( + "api_source_name", api_source_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + } + + _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, + service_name: str, + workspace_name: str, + api_source_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apiSources/{apiSourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", service_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "workspaceName": _SERIALIZER.url( + "workspace_name", workspace_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "apiSourceName": _SERIALIZER.url( + "api_source_name", api_source_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_head_request( + resource_group_name: str, + service_name: str, + workspace_name: str, + api_source_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apiSources/{apiSourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", service_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "workspaceName": _SERIALIZER.url( + "workspace_name", workspace_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + "apiSourceName": _SERIALIZER.url( + "api_source_name", api_source_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + } + + _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="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiSourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`api_sources` 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, + service_name: str, + workspace_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ApiSource"]: + """Returns a collection of API sources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param filter: OData filter parameter. Default value is None. + :type filter: str + :return: An iterator like instance of either ApiSource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.ApiSource] + :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.ApiSourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiSourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_name: str, api_source_name: str, **kwargs: Any + ) -> _models.ApiSource: + """Returns details of the API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :return: ApiSource or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiSource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + api_source_name=api_source_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiSource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_name: str, + api_source_name: str, + resource: _models.ApiSource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiSource: + """Creates new or updates existing API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.apicenter.models.ApiSource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiSource or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_name: str, + api_source_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiSource: + """Creates new or updates existing API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :param resource: Resource create parameters. Required. + :type resource: 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: ApiSource or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_name: str, + api_source_name: str, + resource: Union[_models.ApiSource, IO[bytes]], + **kwargs: Any + ) -> _models.ApiSource: + """Creates new or updates existing API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :param resource: Resource create parameters. Is either a ApiSource type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.apicenter.models.ApiSource or IO[bytes] + :return: ApiSource or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiSource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "ApiSource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + api_source_name=api_source_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiSource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_name: str, api_source_name: str, **kwargs: Any + ) -> None: + """Deletes specified API source. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + api_source_name=api_source_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def head( + self, resource_group_name: str, service_name: str, workspace_name: str, api_source_name: str, **kwargs: Any + ) -> bool: + """Checks if specified API source exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param api_source_name: The name of the API. Required. + :type api_source_name: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_head_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_name=workspace_name, + api_source_name=api_source_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_versions_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_versions_operations.py index b19477c75762..130f573fb793 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_versions_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_versions_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +102,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -149,7 +152,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -202,7 +205,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -252,7 +255,7 @@ def build_head_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -332,7 +335,6 @@ def list( :type api_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiVersion or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.ApiVersion] :raises ~azure.core.exceptions.HttpResponseError: @@ -343,7 +345,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiVersionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,7 +356,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -362,12 +364,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -379,13 +379,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApiVersionListResult", pipeline_response) @@ -395,11 +394,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -412,10 +411,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions" - } - @distributed_trace def get( self, @@ -439,12 +434,11 @@ def get( :type api_name: str :param version_name: The name of the API version. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiVersion or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiVersion :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +452,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiVersion] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -466,16 +460,14 @@ def get( version_name=version_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,16 +480,12 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersion", pipeline_response) + deserialized = self._deserialize("ApiVersion", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -530,7 +518,6 @@ def 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 :return: ApiVersion or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiVersion :raises ~azure.core.exceptions.HttpResponseError: @@ -544,7 +531,7 @@ def create_or_update( workspace_name: str, api_name: str, version_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -563,11 +550,10 @@ def create_or_update( :param version_name: The name of the API version. Required. :type version_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: ApiVersion or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiVersion :raises ~azure.core.exceptions.HttpResponseError: @@ -581,7 +567,7 @@ def create_or_update( workspace_name: str, api_name: str, version_name: str, - resource: Union[_models.ApiVersion, IO], + resource: Union[_models.ApiVersion, IO[bytes]], **kwargs: Any ) -> _models.ApiVersion: """Creates new or updates existing API version. @@ -597,18 +583,14 @@ def create_or_update( :type api_name: str :param version_name: The name of the API version. Required. :type version_name: str - :param resource: Resource create parameters. Is either a ApiVersion type or a IO type. + :param resource: Resource create parameters. Is either a ApiVersion type or a IO[bytes] type. Required. - :type resource: ~azure.mgmt.apicenter.models.ApiVersion 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 + :type resource: ~azure.mgmt.apicenter.models.ApiVersion or IO[bytes] :return: ApiVersion or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.ApiVersion :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -631,7 +613,7 @@ def create_or_update( else: _json = self._serialize.body(resource, "ApiVersion") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -642,16 +624,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -662,25 +642,15 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiVersion", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersion", pipeline_response) + deserialized = self._deserialize("ApiVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -704,12 +674,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type api_name: str :param version_name: The name of the API version. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -723,7 +692,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, @@ -731,16 +700,14 @@ def delete( # pylint: disable=inconsistent-return-statements version_name=version_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -751,11 +718,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def head( @@ -780,12 +743,11 @@ def head( :type api_name: str :param version_name: The name of the API version. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -799,7 +761,7 @@ def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -807,16 +769,14 @@ def head( version_name=version_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -827,9 +787,5 @@ def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_apis_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_apis_operations.py index 0c0cd53a41dc..bd5dbfc0ff0a 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_apis_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_apis_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +92,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +133,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -174,7 +177,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -215,7 +218,7 @@ def build_head_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -289,7 +292,6 @@ def list( :type workspace_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Api or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.Api] :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +302,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -311,19 +313,17 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -335,13 +335,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ApiListResult", pipeline_response) @@ -351,11 +350,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -368,10 +367,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis" - } - @distributed_trace def get( self, resource_group_name: str, service_name: str, workspace_name: str, api_name: str, **kwargs: Any @@ -387,12 +382,11 @@ def get( :type workspace_name: str :param api_name: The name of the API. Required. :type api_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Api or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Api :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,23 +400,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Api] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, api_name=api_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -435,16 +427,12 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Api", pipeline_response) + deserialized = self._deserialize("Api", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -474,7 +462,6 @@ def 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 :return: Api or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Api :raises ~azure.core.exceptions.HttpResponseError: @@ -487,7 +474,7 @@ def create_or_update( service_name: str, workspace_name: str, api_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -504,11 +491,10 @@ def create_or_update( :param api_name: The name of the API. Required. :type api_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Api or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Api :raises ~azure.core.exceptions.HttpResponseError: @@ -521,7 +507,7 @@ def create_or_update( service_name: str, workspace_name: str, api_name: str, - resource: Union[_models.Api, IO], + resource: Union[_models.Api, IO[bytes]], **kwargs: Any ) -> _models.Api: """Creates new or updates existing API. @@ -535,17 +521,14 @@ def create_or_update( :type workspace_name: str :param api_name: The name of the API. Required. :type api_name: str - :param resource: Resource create parameters. Is either a Api type or a IO type. Required. - :type resource: ~azure.mgmt.apicenter.models.Api 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 resource: Resource create parameters. Is either a Api type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.apicenter.models.Api or IO[bytes] :return: Api or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Api :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -568,7 +551,7 @@ def create_or_update( else: _json = self._serialize.body(resource, "Api") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -578,16 +561,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -598,25 +579,15 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("Api", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Api", pipeline_response) + deserialized = self._deserialize("Api", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, workspace_name: str, api_name: str, **kwargs: Any @@ -632,12 +603,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param api_name: The name of the API. Required. :type api_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -651,23 +621,21 @@ def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, api_name=api_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -678,11 +646,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def head( @@ -699,12 +663,11 @@ def head( :type workspace_name: str :param api_name: The name of the API. Required. :type api_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -718,23 +681,21 @@ def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, api_name=api_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -745,9 +706,5 @@ def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deleted_services_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deleted_services_operations.py new file mode 100644 index 000000000000..379828d749db --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deleted_services_operations.py @@ -0,0 +1,469 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiCenter/deletedServices") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/deletedServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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) + + +def build_get_request( + resource_group_name: str, deleted_service_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/deletedServices/{deletedServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deletedServiceName": _SERIALIZER.url( + "deleted_service_name", + deleted_service_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[a-zA-Z0-9-]{3,90}$", + ), + } + + _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_delete_request( + resource_group_name: str, deleted_service_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/deletedServices/{deletedServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deletedServiceName": _SERIALIZER.url( + "deleted_service_name", + deleted_service_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[a-zA-Z0-9-]{3,90}$", + ), + } + + _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 DeletedServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`deleted_services` 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_subscription(self, **kwargs: Any) -> Iterable["_models.DeletedService"]: + """Lists services within an Azure subscription. + + :return: An iterator like instance of either DeletedService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.DeletedService] + :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.DeletedServiceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedServiceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DeletedService"]: + """Lists soft-deleted services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param filter: OData filter parameter. Default value is None. + :type filter: str + :return: An iterator like instance of either DeletedService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.DeletedService] + :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.DeletedServiceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedServiceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, deleted_service_name: str, **kwargs: Any) -> _models.DeletedService: + """Returns details of the soft-deleted service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deleted_service_name: The name of the deleted service. Required. + :type deleted_service_name: str + :return: DeletedService or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.DeletedService + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DeletedService] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + deleted_service_name=deleted_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DeletedService", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, deleted_service_name: str, **kwargs: Any + ) -> None: + """Permanently deletes specified service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deleted_service_name: The name of the deleted service. Required. + :type deleted_service_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + deleted_service_name=deleted_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deployments_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deployments_operations.py index 79276266eda8..78ce7937eaec 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deployments_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deployments_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +102,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -149,7 +152,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -202,7 +205,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -252,7 +255,7 @@ def build_head_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -332,7 +335,6 @@ def list( :type api_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Deployment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.Deployment] :raises ~azure.core.exceptions.HttpResponseError: @@ -343,7 +345,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeploymentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,7 +356,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -362,12 +364,10 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -379,13 +379,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeploymentListResult", pipeline_response) @@ -395,11 +394,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -412,10 +411,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments" - } - @distributed_trace def get( self, @@ -439,12 +434,11 @@ def get( :type api_name: str :param deployment_name: The name of the API deployment. Required. :type deployment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Deployment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +452,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -466,16 +460,14 @@ def get( deployment_name=deployment_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,16 +480,12 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Deployment", pipeline_response) + deserialized = self._deserialize("Deployment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -530,7 +518,6 @@ def 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 :return: Deployment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: @@ -544,7 +531,7 @@ def create_or_update( workspace_name: str, api_name: str, deployment_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -563,11 +550,10 @@ def create_or_update( :param deployment_name: The name of the API deployment. Required. :type deployment_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Deployment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: @@ -581,7 +567,7 @@ def create_or_update( workspace_name: str, api_name: str, deployment_name: str, - resource: Union[_models.Deployment, IO], + resource: Union[_models.Deployment, IO[bytes]], **kwargs: Any ) -> _models.Deployment: """Creates new or updates existing API deployment. @@ -597,18 +583,14 @@ def create_or_update( :type api_name: str :param deployment_name: The name of the API deployment. Required. :type deployment_name: str - :param resource: Resource create parameters. Is either a Deployment type or a IO type. + :param resource: Resource create parameters. Is either a Deployment type or a IO[bytes] type. Required. - :type resource: ~azure.mgmt.apicenter.models.Deployment 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 + :type resource: ~azure.mgmt.apicenter.models.Deployment or IO[bytes] :return: Deployment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -631,7 +613,7 @@ def create_or_update( else: _json = self._serialize.body(resource, "Deployment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -642,16 +624,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -662,25 +642,15 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("Deployment", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Deployment", pipeline_response) + deserialized = self._deserialize("Deployment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -704,12 +674,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type api_name: str :param deployment_name: The name of the API deployment. Required. :type deployment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -723,7 +692,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, @@ -731,16 +700,14 @@ def delete( # pylint: disable=inconsistent-return-statements deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -751,11 +718,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def head( @@ -780,12 +743,11 @@ def head( :type api_name: str :param deployment_name: The name of the API deployment. Required. :type deployment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -799,7 +761,7 @@ def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -807,16 +769,14 @@ def head( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -827,9 +787,5 @@ def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_environments_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_environments_operations.py index 5da4c08a0234..05302498cd39 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_environments_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_environments_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +97,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -140,7 +143,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -189,7 +192,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -235,7 +238,7 @@ def build_head_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -309,7 +312,6 @@ def list( :type workspace_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Environment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.Environment] :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +322,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EnvironmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,19 +333,17 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -355,13 +355,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EnvironmentListResult", pipeline_response) @@ -371,11 +370,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,10 +387,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments" - } - @distributed_trace def get( self, resource_group_name: str, service_name: str, workspace_name: str, environment_name: str, **kwargs: Any @@ -407,12 +402,11 @@ def get( :type workspace_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Environment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,23 +420,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Environment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, environment_name=environment_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -455,16 +447,12 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Environment", pipeline_response) + deserialized = self._deserialize("Environment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -494,7 +482,6 @@ def 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 :return: Environment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: @@ -507,7 +494,7 @@ def create_or_update( service_name: str, workspace_name: str, environment_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -524,11 +511,10 @@ def create_or_update( :param environment_name: The name of the environment. Required. :type environment_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Environment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: @@ -541,7 +527,7 @@ def create_or_update( service_name: str, workspace_name: str, environment_name: str, - resource: Union[_models.Environment, IO], + resource: Union[_models.Environment, IO[bytes]], **kwargs: Any ) -> _models.Environment: """Creates new or updates existing environment. @@ -555,18 +541,14 @@ def create_or_update( :type workspace_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :param resource: Resource create parameters. Is either a Environment type or a IO type. + :param resource: Resource create parameters. Is either a Environment type or a IO[bytes] type. Required. - :type resource: ~azure.mgmt.apicenter.models.Environment 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 + :type resource: ~azure.mgmt.apicenter.models.Environment or IO[bytes] :return: Environment or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -589,7 +571,7 @@ def create_or_update( else: _json = self._serialize.body(resource, "Environment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -599,16 +581,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -619,25 +599,15 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("Environment", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Environment", pipeline_response) + deserialized = self._deserialize("Environment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, workspace_name: str, environment_name: str, **kwargs: Any @@ -653,12 +623,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -672,23 +641,21 @@ def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, environment_name=environment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -699,11 +666,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def head( @@ -720,12 +683,11 @@ def head( :type workspace_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -739,23 +701,21 @@ def head( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, environment_name=environment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -766,9 +726,5 @@ def head( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_metadata_schemas_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_metadata_schemas_operations.py index e4bd07d350c6..afdff8f9392f 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_metadata_schemas_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_metadata_schemas_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +46,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,7 +126,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +172,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -212,7 +215,7 @@ def build_head_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -281,7 +284,6 @@ def list( :type service_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetadataSchema or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.MetadataSchema] :raises ~azure.core.exceptions.HttpResponseError: @@ -292,7 +294,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MetadataSchemaListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,18 +305,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -326,13 +326,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MetadataSchemaListResult", pipeline_response) @@ -342,11 +341,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -359,10 +358,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas" - } - @distributed_trace def get( self, resource_group_name: str, service_name: str, metadata_schema_name: str, **kwargs: Any @@ -376,12 +371,11 @@ def get( :type service_name: str :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MetadataSchema or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.MetadataSchema :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,22 +389,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MetadataSchema] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, metadata_schema_name=metadata_schema_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -423,16 +415,12 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("MetadataSchema", pipeline_response) + deserialized = self._deserialize("MetadataSchema", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -459,7 +447,6 @@ def 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 :return: MetadataSchema or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.MetadataSchema :raises ~azure.core.exceptions.HttpResponseError: @@ -471,7 +458,7 @@ def create_or_update( resource_group_name: str, service_name: str, metadata_schema_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -486,11 +473,10 @@ def create_or_update( :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: MetadataSchema or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.MetadataSchema :raises ~azure.core.exceptions.HttpResponseError: @@ -502,7 +488,7 @@ def create_or_update( resource_group_name: str, service_name: str, metadata_schema_name: str, - resource: Union[_models.MetadataSchema, IO], + resource: Union[_models.MetadataSchema, IO[bytes]], **kwargs: Any ) -> _models.MetadataSchema: """Creates new or updates existing metadata schema. @@ -514,18 +500,14 @@ def create_or_update( :type service_name: str :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str - :param resource: Resource create parameters. Is either a MetadataSchema type or a IO type. - Required. - :type resource: ~azure.mgmt.apicenter.models.MetadataSchema 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 resource: Resource create parameters. Is either a MetadataSchema type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.apicenter.models.MetadataSchema or IO[bytes] :return: MetadataSchema or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.MetadataSchema :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -548,7 +530,7 @@ def create_or_update( else: _json = self._serialize.body(resource, "MetadataSchema") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, metadata_schema_name=metadata_schema_name, @@ -557,16 +539,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -577,25 +557,15 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("MetadataSchema", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("MetadataSchema", pipeline_response) + deserialized = self._deserialize("MetadataSchema", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, metadata_schema_name: str, **kwargs: Any @@ -609,12 +579,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type service_name: str :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -628,22 +597,20 @@ def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, metadata_schema_name=metadata_schema_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -654,11 +621,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def head(self, resource_group_name: str, service_name: str, metadata_schema_name: str, **kwargs: Any) -> bool: @@ -671,12 +634,11 @@ def head(self, resource_group_name: str, service_name: str, metadata_schema_name :type service_name: str :param metadata_schema_name: The name of the metadata schema. Required. :type metadata_schema_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -690,22 +652,20 @@ def head(self, resource_group_name: str, service_name: str, metadata_schema_name api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, metadata_schema_name=metadata_schema_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -716,9 +676,5 @@ def head(self, resource_group_name: str, service_name: str, metadata_schema_name raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_operations.py index 33f31cda0158..4cb07992a352 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/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,8 @@ # 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, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +81,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List the operations for the provider. - :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.apicenter.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -89,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,14 +102,12 @@ 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,13 +119,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -135,11 +134,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,5 +150,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.ApiCenter/operations"} diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_services_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_services_operations.py index d1946abc21cc..7893e1f0b090 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_services_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_services_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. @@ -7,7 +7,8 @@ # 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, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +72,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +102,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,7 +137,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -170,7 +175,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -208,7 +213,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -243,7 +248,7 @@ def build_export_metadata_schema_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -275,6 +280,44 @@ def build_export_metadata_schema_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_import_from_apim_request( + resource_group_name: str, service_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-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/importFromApim", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", service_name, "str", max_length=90, min_length=1, pattern=r"^[a-zA-Z0-9-]{3,90}$" + ), + } + + _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 ServicesOperations: """ .. warning:: @@ -298,7 +341,6 @@ def __init__(self, *args, **kwargs): def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Service"]: """Lists services within an Azure subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Service or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.Service] :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +351,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Service"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServiceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -320,15 +362,13 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Service"]: def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -340,13 +380,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ServiceListResult", pipeline_response) @@ -356,11 +395,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,8 +412,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ApiCenter/services"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Service"]: """Returns a collection of services within the resource group. @@ -382,7 +419,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Service or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.Service] :raises ~azure.core.exceptions.HttpResponseError: @@ -393,7 +429,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServiceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,16 +440,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -425,13 +459,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ServiceListResult", pipeline_response) @@ -441,11 +474,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,10 +491,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services" - } - @distributed_trace def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Service: """Returns details of the service. @@ -471,12 +500,11 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo :type resource_group_name: str :param service_name: The name of Azure API Center service. Required. :type service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -490,21 +518,19 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Service] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -514,16 +540,12 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Service", pipeline_response) + deserialized = self._deserialize("Service", pipeline_response.http_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.ApiCenter/services/{serviceName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -547,7 +569,6 @@ def 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 :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: @@ -558,7 +579,7 @@ def create_or_update( self, resource_group_name: str, service_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -571,11 +592,10 @@ def create_or_update( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: @@ -583,7 +603,7 @@ def create_or_update( @distributed_trace def create_or_update( - self, resource_group_name: str, service_name: str, resource: Union[_models.Service, IO], **kwargs: Any + self, resource_group_name: str, service_name: str, resource: Union[_models.Service, IO[bytes]], **kwargs: Any ) -> _models.Service: """Creates new or updates existing API. @@ -592,17 +612,14 @@ def create_or_update( :type resource_group_name: str :param service_name: The name of Azure API Center service. Required. :type service_name: str - :param resource: Resource create parameters. Is either a Service type or a IO type. Required. - :type resource: ~azure.mgmt.apicenter.models.Service 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 resource: Resource create parameters. Is either a Service type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.apicenter.models.Service or IO[bytes] :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,7 +642,7 @@ def create_or_update( else: _json = self._serialize.body(resource, "Service") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, @@ -633,16 +650,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -652,21 +667,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Service", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Service", pipeline_response) + deserialized = self._deserialize("Service", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - } - @overload def update( self, @@ -689,7 +696,6 @@ def 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 :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: @@ -700,7 +706,7 @@ def update( self, resource_group_name: str, service_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -713,11 +719,10 @@ def update( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param properties: The resource properties to be updated. Required. - :type properties: IO + :type properties: 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: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: @@ -725,7 +730,11 @@ def update( @distributed_trace def update( - self, resource_group_name: str, service_name: str, properties: Union[_models.ServiceUpdate, IO], **kwargs: Any + self, + resource_group_name: str, + service_name: str, + properties: Union[_models.ServiceUpdate, IO[bytes]], + **kwargs: Any ) -> _models.Service: """Updates existing service. @@ -735,17 +744,13 @@ def update( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param properties: The resource properties to be updated. Is either a ServiceUpdate type or a - IO type. Required. - :type properties: ~azure.mgmt.apicenter.models.ServiceUpdate 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 + IO[bytes] type. Required. + :type properties: ~azure.mgmt.apicenter.models.ServiceUpdate or IO[bytes] :return: Service or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Service :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -768,7 +773,7 @@ def update( else: _json = self._serialize.body(properties, "ServiceUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, @@ -776,16 +781,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -795,16 +798,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Service", pipeline_response) + deserialized = self._deserialize("Service", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -817,12 +816,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param service_name: The name of Azure API Center service. Required. :type service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,21 +834,19 @@ def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -861,20 +857,16 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - } + return cls(pipeline_response, None, {}) # type: ignore def _export_metadata_schema_initial( self, resource_group_name: str, service_name: str, - body: Union[_models.MetadataSchemaExportRequest, IO], + body: Union[_models.MetadataSchemaExportRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.MetadataSchemaExportResult]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -887,7 +879,7 @@ def _export_metadata_schema_initial( 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[Optional[_models.MetadataSchemaExportResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -897,7 +889,7 @@ def _export_metadata_schema_initial( else: _json = self._serialize.body(body, "MetadataSchemaExportRequest") - request = build_export_metadata_schema_request( + _request = build_export_metadata_schema_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, @@ -905,42 +897,39 @@ def _export_metadata_schema_initial( content_type=content_type, json=_json, content=_content, - template_url=self._export_metadata_schema_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("MetadataSchemaExportResult", pipeline_response) - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _export_metadata_schema_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema" - } + return deserialized # type: ignore @overload def begin_export_metadata_schema( @@ -964,14 +953,6 @@ def begin_export_metadata_schema( :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 MetadataSchemaExportResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apicenter.models.MetadataSchemaExportResult] @@ -983,7 +964,7 @@ def begin_export_metadata_schema( self, resource_group_name: str, service_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -996,18 +977,10 @@ def begin_export_metadata_schema( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param body: The content of the action request. Required. - :type body: IO + :type body: 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 MetadataSchemaExportResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apicenter.models.MetadataSchemaExportResult] @@ -1019,7 +992,7 @@ def begin_export_metadata_schema( self, resource_group_name: str, service_name: str, - body: Union[_models.MetadataSchemaExportRequest, IO], + body: Union[_models.MetadataSchemaExportRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.MetadataSchemaExportResult]: """Exports the effective metadata schema. @@ -1030,19 +1003,8 @@ def begin_export_metadata_schema( :param service_name: The name of Azure API Center service. Required. :type service_name: str :param body: The content of the action request. Is either a MetadataSchemaExportRequest type or - a IO type. Required. - :type body: ~azure.mgmt.apicenter.models.MetadataSchemaExportRequest 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. + a IO[bytes] type. Required. + :type body: ~azure.mgmt.apicenter.models.MetadataSchemaExportRequest or IO[bytes] :return: An instance of LROPoller that returns either MetadataSchemaExportResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apicenter.models.MetadataSchemaExportResult] @@ -1069,12 +1031,13 @@ def begin_export_metadata_schema( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MetadataSchemaExportResult", pipeline_response) + deserialized = self._deserialize("MetadataSchemaExportResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1086,14 +1049,212 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.MetadataSchemaExportResult].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) # type: ignore + return LROPoller[_models.MetadataSchemaExportResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - begin_export_metadata_schema.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema" - } + def _import_from_apim_initial( + self, + resource_group_name: str, + service_name: str, + body: Union[_models.ImportFromApimRequest, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ImportFromApimRequest") + + _request = build_import_from_apim_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_import_from_apim( + self, + resource_group_name: str, + service_name: str, + body: _models.ImportFromApimRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportFromApimSuccessResult]: + """Imports APIs from Azure API Management. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param body: The content of the action request. Required. + :type body: ~azure.mgmt.apicenter.models.ImportFromApimRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ImportFromApimSuccessResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apicenter.models.ImportFromApimSuccessResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_import_from_apim( + self, + resource_group_name: str, + service_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportFromApimSuccessResult]: + """Imports APIs from Azure API Management. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param body: The content of the action request. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ImportFromApimSuccessResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apicenter.models.ImportFromApimSuccessResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_import_from_apim( + self, + resource_group_name: str, + service_name: str, + body: Union[_models.ImportFromApimRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ImportFromApimSuccessResult]: + """Imports APIs from Azure API Management. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of Azure API Center service. Required. + :type service_name: str + :param body: The content of the action request. Is either a ImportFromApimRequest type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.apicenter.models.ImportFromApimRequest or IO[bytes] + :return: An instance of LROPoller that returns either ImportFromApimSuccessResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apicenter.models.ImportFromApimSuccessResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportFromApimSuccessResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._import_from_apim_initial( + resource_group_name=resource_group_name, + service_name=service_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ImportFromApimSuccessResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ImportFromApimSuccessResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ImportFromApimSuccessResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_workspaces_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_workspaces_operations.py index 60fbab68802e..81812acd5bc8 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_workspaces_operations.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_workspaces_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. @@ -7,7 +7,8 @@ # 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 sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +46,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +121,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -159,7 +162,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -197,7 +200,7 @@ def build_head_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -261,7 +264,6 @@ def list( :type service_name: str :param filter: OData filter parameter. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workspace or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apicenter.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +274,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkspaceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,18 +285,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, filter=filter, 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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -306,13 +306,12 @@ 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) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkspaceListResult", pipeline_response) @@ -322,11 +321,11 @@ def extract_data(pipeline_response): 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -339,10 +338,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces" - } - @distributed_trace def get(self, resource_group_name: str, service_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: """Returns details of the workspace. @@ -354,12 +349,11 @@ def get(self, resource_group_name: str, service_name: str, workspace_name: str, :type service_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,22 +367,20 @@ def get(self, resource_group_name: str, service_name: str, workspace_name: str, api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -401,16 +393,12 @@ def get(self, resource_group_name: str, service_name: str, workspace_name: str, response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -437,7 +425,6 @@ def 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 :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: @@ -449,7 +436,7 @@ def create_or_update( resource_group_name: str, service_name: str, workspace_name: str, - resource: IO, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -464,11 +451,10 @@ def create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param resource: Resource create parameters. Required. - :type resource: IO + :type resource: 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: Workspace or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: @@ -480,7 +466,7 @@ def create_or_update( resource_group_name: str, service_name: str, workspace_name: str, - resource: Union[_models.Workspace, IO], + resource: Union[_models.Workspace, IO[bytes]], **kwargs: Any ) -> _models.Workspace: """Creates new or updates existing workspace. @@ -492,17 +478,14 @@ def create_or_update( :type service_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param resource: Resource create parameters. Is either a Workspace type or a IO type. Required. - :type resource: ~azure.mgmt.apicenter.models.Workspace 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 resource: Resource create parameters. Is either a Workspace type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.apicenter.models.Workspace or IO[bytes] :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.apicenter.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,7 +508,7 @@ def create_or_update( else: _json = self._serialize.body(resource, "Workspace") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, @@ -534,16 +517,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -554,25 +535,15 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("Workspace", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, workspace_name: str, **kwargs: Any @@ -586,12 +557,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type service_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,22 +575,20 @@ def delete( # pylint: disable=inconsistent-return-statements 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, service_name=service_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -631,11 +599,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def head(self, resource_group_name: str, service_name: str, workspace_name: str, **kwargs: Any) -> bool: @@ -648,12 +612,11 @@ def head(self, resource_group_name: str, service_name: str, workspace_name: str, :type service_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: bool or the result of cls(response) :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -667,22 +630,20 @@ def head(self, resource_group_name: str, service_name: str, workspace_name: str, api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_head_request( + _request = build_head_request( resource_group_name=resource_group_name, service_name=service_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.head.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -693,9 +654,5 @@ def head(self, resource_group_name: str, service_name: str, workspace_name: str, raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - - head.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" - } diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_delete.py index bd37055fc631..935c1508cb0d 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -39,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiDefinitions_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_export_specification.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_export_specification.py index 8b63b7e8d4b1..273875448b74 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_export_specification.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_export_specification.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_ExportSpecification.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiDefinitions_ExportSpecification.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_get.py index 6a29726668c1..fcb243c14812 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiDefinitions_Get.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_head.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_head.py index 08e6e6d297c7..4cf52d1107d9 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_head.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_head.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_Head.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiDefinitions_Head.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_list.py index efdc9975f8e4..dbb3f8c2826f 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -40,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiDefinitions_List.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_create_or_update.py new file mode 100644 index 000000000000..3b7352c9d766 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_create_or_update.py @@ -0,0 +1,53 @@ +# 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.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_sources_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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_sources.create_or_update( + resource_group_name="contoso-resources", + service_name="contoso", + workspace_name="default", + api_source_name="contoso-api-management", + resource={ + "properties": { + "apimSource": { + "msiResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiManagement/service/contoso", + }, + "shouldImportSpec": "ondemand", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiSources_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_delete.py new file mode 100644 index 000000000000..7d9551e031e2 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_delete.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.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_sources_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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.api_sources.delete( + resource_group_name="contoso-resources", + service_name="contoso", + workspace_name="default", + api_source_name="contoso-api-management", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiSources_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_get.py new file mode 100644 index 000000000000..761cf670ad04 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_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 azure.identity import DefaultAzureCredential + +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_sources_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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_sources.get( + resource_group_name="contoso-resources", + service_name="contoso", + workspace_name="default", + api_source_name="contoso-api-management", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiSources_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_head.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_head.py new file mode 100644 index 000000000000..778ab2936bac --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_head.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_sources_head.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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_sources.head( + resource_group_name="contoso-resources", + service_name="contoso", + workspace_name="default", + api_source_name="contoso-api-management", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiSources_Head.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_list.py new file mode 100644 index 000000000000..7843992b44a9 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_sources_list.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_sources_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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_sources.list( + resource_group_name="contoso-resources", + service_name="contoso", + workspace_name="default", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiSources_List.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_delete.py index 670eaec36747..88f7a9ae0fdb 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -38,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiVersions_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiVersions_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_get.py index a97c36ea624a..52d75250c91b 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiVersions_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiVersions_Get.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_head.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_head.py index 20569f455df7..193436e4358b 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_head.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_head.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiVersions_Head.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiVersions_Head.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_list.py index f93e0588180d..17244109d001 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiVersions_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/ApiVersions_List.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_delete.py index 5f18d1ba57cc..aa7368e19844 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -37,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Apis_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Apis_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_get.py index e0693fdbbbf9..e575c4a7946f 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Apis_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Apis_Get.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_head.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_head.py index 51973f10beda..8c7cc0b5cd7f 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_head.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_head.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Apis_Head.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Apis_Head.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_list.py index 8bdd4595201f..e165d748e82e 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Apis_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Apis_List.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_delete.py new file mode 100644 index 000000000000..77cfea941a0c --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_delete.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.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python deleted_services_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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.deleted_services.delete( + resource_group_name="contoso-resources", + deleted_service_name="contoso", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/DeletedServices_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_get.py new file mode 100644 index 000000000000..66320490cf63 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_get.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.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python deleted_services_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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.deleted_services.get( + resource_group_name="contoso-resources", + deleted_service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/DeletedServices_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_list.py new file mode 100644 index 000000000000..d75f7720f9a6 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_list.py @@ -0,0 +1,40 @@ +# 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.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python deleted_services_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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.deleted_services.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/DeletedServices_List.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_list_by_subscription.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_list_by_subscription.py new file mode 100644 index 000000000000..53547b2b3398 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deleted_services_list_by_subscription.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.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python deleted_services_list_by_subscription.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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.deleted_services.list( + resource_group_name="contoso-resources", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/DeletedServices_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_delete.py index 9665982ff689..cb3da2a877b7 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -38,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Deployments_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Deployments_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_get.py index ac4df8381f61..d96444adaf1a 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Deployments_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Deployments_Get.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_head.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_head.py index ca4dbab01281..e666ce2b9fcd 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_head.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_head.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Deployments_Head.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Deployments_Head.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_list.py index 09b0d503c977..ab925067d030 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Deployments_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Deployments_List.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_delete.py index c4c4aad52cbd..2cb530968ec0 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -37,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Environments_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Environments_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_get.py index bf0ad84ed804..a60de62f032b 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Environments_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Environments_Get.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_head.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_head.py index e642a87fc3dd..d954c564ad49 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_head.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_head.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Environments_Head.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Environments_Head.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_list.py index 6a751a088689..a135befbb953 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Environments_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Environments_List.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_delete.py index 1fc38eda6930..0261afb7bea3 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/MetadataSchemas_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/MetadataSchemas_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_get.py index 7b91c9084784..b7bcb0d48db3 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/MetadataSchemas_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/MetadataSchemas_Get.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_head.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_head.py index 60c9187567dd..5e75773743fc 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_head.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_head.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/MetadataSchemas_Head.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/MetadataSchemas_Head.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_list.py index 3b091996a683..0d39dccd72e3 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/MetadataSchemas_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/MetadataSchemas_List.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/operations_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/operations_list.py index 1b27945972fd..c0f96ffe6037 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/operations_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Operations_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_create_or_update.py index ff3637ca60a0..cab1693a1c19 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_create_or_update.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_CreateOrUpdate.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Services_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_delete.py index e3f903bdc87f..fa72842d5219 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Services_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_get.py index eb47d0c57644..82e5f65b6d97 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Services_Get.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_import_from_apim.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_import_from_apim.py new file mode 100644 index 000000000000..a3b46d0cba73 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_import_from_apim.py @@ -0,0 +1,47 @@ +# 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.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python services_import_from_apim.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 = ApiCenterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.services.begin_import_from_apim( + resource_group_name="contoso-resources", + service_name="contoso", + body={ + "sourceResourceIds": [ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiManagement/service/contoso/apis/echo-api" + ] + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Services_ImportFromApim.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_list_by_resource_group.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_list_by_resource_group.py index b68b288c93d3..1a123eecb789 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_list_by_resource_group.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_ListByResourceGroup.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Services_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_list_by_subscription.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_list_by_subscription.py index 31a3f4d8dd88..b491977bee72 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_list_by_subscription.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_list_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_ListBySubscription.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Services_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_delete.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_delete.py index c07ec3b81240..74cb55341297 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Workspaces_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Workspaces_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_get.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_get.py index e5f6a2075085..c058c6a91f1b 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Workspaces_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Workspaces_Get.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_head.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_head.py index 0a7ba0e99bab..17691f1d1109 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_head.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_head.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Workspaces_Head.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Workspaces_Head.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_list.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_list.py index 024e594f6884..fe6dc24966ad 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.apicenter import ApiCenterMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Workspaces_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2024-06-01-preview/examples/Workspaces_List.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/conftest.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/conftest.py new file mode 100644 index 000000000000..06a7fdcd6c3d --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + apicentermgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + apicentermgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + apicentermgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + apicentermgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=apicentermgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=apicentermgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=apicentermgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=apicentermgmt_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_definitions_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_definitions_operations.py new file mode 100644 index 000000000000..50ff8d9a6dc0 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_definitions_operations.py @@ -0,0 +1,147 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtApiDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.api_definitions.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_definitions.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_definitions.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + resource={ + "description": "str", + "id": "str", + "name": "str", + "specification": {"name": "str", "version": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_definitions.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_head(self, resource_group): + response = self.client.api_definitions.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_export_specification(self, resource_group): + response = self.client.api_definitions.begin_export_specification( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + api_version="2024-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_import_specification(self, resource_group): + response = self.client.api_definitions.begin_import_specification( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + body={"format": "str", "specification": {"name": "str", "version": "str"}, "value": "str"}, + api_version="2024-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_definitions_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_definitions_operations_async.py new file mode 100644 index 000000000000..4e6f36d2bba4 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_definitions_operations_async.py @@ -0,0 +1,152 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtApiDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.api_definitions.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_definitions.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_definitions.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + resource={ + "description": "str", + "id": "str", + "name": "str", + "specification": {"name": "str", "version": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_definitions.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_head(self, resource_group): + response = await self.client.api_definitions.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_export_specification(self, resource_group): + response = await ( + await self.client.api_definitions.begin_export_specification( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + api_version="2024-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_import_specification(self, resource_group): + response = await ( + await self.client.api_definitions.begin_import_specification( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + definition_name="str", + body={"format": "str", "specification": {"name": "str", "version": "str"}, "value": "str"}, + api_version="2024-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_sources_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_sources_operations.py new file mode 100644 index 000000000000..471ea7af7bc5 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_sources_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtApiSourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.api_sources.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_sources.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_source_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_sources.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_source_name="str", + resource={ + "apimSource": { + "resourceId": "str", + "linkState": {"lastUpdatedOn": "2020-02-20 00:00:00", "message": "str", "state": "str"}, + "msiResourceId": "str", + "targetEnvironmentId": "str", + "targetLifecycleStage": "str", + }, + "id": "str", + "name": "str", + "shouldImportSpec": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_sources.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_source_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_head(self, resource_group): + response = self.client.api_sources.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_source_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_sources_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_sources_operations_async.py new file mode 100644 index 000000000000..4784c60313d6 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_sources_operations_async.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtApiSourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.api_sources.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_sources.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_source_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_sources.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_source_name="str", + resource={ + "apimSource": { + "resourceId": "str", + "linkState": {"lastUpdatedOn": "2020-02-20 00:00:00", "message": "str", "state": "str"}, + "msiResourceId": "str", + "targetEnvironmentId": "str", + "targetLifecycleStage": "str", + }, + "id": "str", + "name": "str", + "shouldImportSpec": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_sources.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_source_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_head(self, resource_group): + response = await self.client.api_sources.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_source_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_versions_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_versions_operations.py new file mode 100644 index 000000000000..8dbcde80a26e --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_versions_operations.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtApiVersionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.api_versions.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_versions.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_versions.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + resource={ + "id": "str", + "lifecycleStage": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_versions.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_head(self, resource_group): + response = self.client.api_versions.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_versions_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_versions_operations_async.py new file mode 100644 index 000000000000..5ea38e4bb5b0 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_api_versions_operations_async.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtApiVersionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.api_versions.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_versions.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_versions.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + resource={ + "id": "str", + "lifecycleStage": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_versions.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_head(self, resource_group): + response = await self.client.api_versions.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + version_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_apis_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_apis_operations.py new file mode 100644 index 000000000000..91018b4e0e7f --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_apis_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtApisOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.apis.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.apis.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.apis.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + resource={ + "contacts": [{"email": "str", "name": "str", "url": "str"}], + "customProperties": {}, + "description": "str", + "externalDocumentation": [{"url": "str", "description": "str", "title": "str"}], + "id": "str", + "kind": "str", + "license": {"identifier": "str", "name": "str", "url": "str"}, + "lifecycleStage": "str", + "name": "str", + "summary": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "termsOfService": {"url": "str"}, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.apis.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_head(self, resource_group): + response = self.client.apis.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_apis_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_apis_operations_async.py new file mode 100644 index 000000000000..d72da6c8675f --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_apis_operations_async.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtApisOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.apis.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.apis.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.apis.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + resource={ + "contacts": [{"email": "str", "name": "str", "url": "str"}], + "customProperties": {}, + "description": "str", + "externalDocumentation": [{"url": "str", "description": "str", "title": "str"}], + "id": "str", + "kind": "str", + "license": {"identifier": "str", "name": "str", "url": "str"}, + "lifecycleStage": "str", + "name": "str", + "summary": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "termsOfService": {"url": "str"}, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.apis.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_head(self, resource_group): + response = await self.client.apis.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deleted_services_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deleted_services_operations.py new file mode 100644 index 000000000000..92748b7e241f --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deleted_services_operations.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtDeletedServicesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.deleted_services.list_by_subscription( + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.deleted_services.list( + resource_group_name=resource_group.name, + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.deleted_services.get( + resource_group_name=resource_group.name, + deleted_service_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.deleted_services.delete( + resource_group_name=resource_group.name, + deleted_service_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deleted_services_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deleted_services_operations_async.py new file mode 100644 index 000000000000..08dbd64211da --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deleted_services_operations_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtDeletedServicesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.deleted_services.list_by_subscription( + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.deleted_services.list( + resource_group_name=resource_group.name, + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.deleted_services.get( + resource_group_name=resource_group.name, + deleted_service_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.deleted_services.delete( + resource_group_name=resource_group.name, + deleted_service_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deployments_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deployments_operations.py new file mode 100644 index 000000000000..e3b72c52ce06 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deployments_operations.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtDeploymentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.deployments.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.deployments.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + deployment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.deployments.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + deployment_name="str", + resource={ + "customProperties": {}, + "definitionId": "str", + "description": "str", + "environmentId": "str", + "id": "str", + "name": "str", + "server": {"runtimeUri": ["str"]}, + "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.deployments.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + deployment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_head(self, resource_group): + response = self.client.deployments.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + deployment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deployments_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deployments_operations_async.py new file mode 100644 index 000000000000..2ba34c6ee334 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_deployments_operations_async.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtDeploymentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.deployments.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.deployments.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + deployment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.deployments.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + deployment_name="str", + resource={ + "customProperties": {}, + "definitionId": "str", + "description": "str", + "environmentId": "str", + "id": "str", + "name": "str", + "server": {"runtimeUri": ["str"]}, + "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.deployments.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + deployment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_head(self, resource_group): + response = await self.client.deployments.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_name="str", + deployment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_environments_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_environments_operations.py new file mode 100644 index 000000000000..abf9105d7e98 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_environments_operations.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtEnvironmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.environments.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.environments.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + environment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.environments.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + environment_name="str", + resource={ + "customProperties": {}, + "description": "str", + "id": "str", + "kind": "str", + "name": "str", + "onboarding": {"developerPortalUri": ["str"], "instructions": "str"}, + "server": {"managementPortalUri": ["str"], "type": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.environments.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + environment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_head(self, resource_group): + response = self.client.environments.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + environment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_environments_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_environments_operations_async.py new file mode 100644 index 000000000000..9d31ec3a5680 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_environments_operations_async.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtEnvironmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.environments.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.environments.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + environment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.environments.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + environment_name="str", + resource={ + "customProperties": {}, + "description": "str", + "id": "str", + "kind": "str", + "name": "str", + "onboarding": {"developerPortalUri": ["str"], "instructions": "str"}, + "server": {"managementPortalUri": ["str"], "type": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.environments.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + environment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_head(self, resource_group): + response = await self.client.environments.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + environment_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_metadata_schemas_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_metadata_schemas_operations.py new file mode 100644 index 000000000000..6d1d6b122f89 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_metadata_schemas_operations.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtMetadataSchemasOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.metadata_schemas.list( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.metadata_schemas.get( + resource_group_name=resource_group.name, + service_name="str", + metadata_schema_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.metadata_schemas.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + metadata_schema_name="str", + resource={ + "assignedTo": [{"deprecated": bool, "entity": "str", "required": bool}], + "id": "str", + "name": "str", + "schema": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.metadata_schemas.delete( + resource_group_name=resource_group.name, + service_name="str", + metadata_schema_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_head(self, resource_group): + response = self.client.metadata_schemas.head( + resource_group_name=resource_group.name, + service_name="str", + metadata_schema_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_metadata_schemas_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_metadata_schemas_operations_async.py new file mode 100644 index 000000000000..39a6c63905d7 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_metadata_schemas_operations_async.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtMetadataSchemasOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.metadata_schemas.list( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.metadata_schemas.get( + resource_group_name=resource_group.name, + service_name="str", + metadata_schema_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.metadata_schemas.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + metadata_schema_name="str", + resource={ + "assignedTo": [{"deprecated": bool, "entity": "str", "required": bool}], + "id": "str", + "name": "str", + "schema": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.metadata_schemas.delete( + resource_group_name=resource_group.name, + service_name="str", + metadata_schema_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_head(self, resource_group): + response = await self.client.metadata_schemas.head( + resource_group_name=resource_group.name, + service_name="str", + metadata_schema_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_operations.py new file mode 100644 index 000000000000..da5edf5f106a --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_operations_async.py new file mode 100644 index 000000000000..b61de955010f --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_services_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_services_operations.py new file mode 100644 index 000000000000..66021c766e5b --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_services_operations.py @@ -0,0 +1,147 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtServicesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.services.list_by_subscription( + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.services.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.services.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.services.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + resource={ + "location": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "provisioningState": "str", + "restore": False, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.services.update( + resource_group_name=resource_group.name, + service_name="str", + properties={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "restore": False, + "tags": {"str": "str"}, + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.services.delete( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_export_metadata_schema(self, resource_group): + response = self.client.services.begin_export_metadata_schema( + resource_group_name=resource_group.name, + service_name="str", + body={"assignedTo": "str"}, + api_version="2024-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_import_from_apim(self, resource_group): + response = self.client.services.begin_import_from_apim( + resource_group_name=resource_group.name, + service_name="str", + body={"sourceResourceIds": ["str"]}, + api_version="2024-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_services_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_services_operations_async.py new file mode 100644 index 000000000000..abc8eeed81a0 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_services_operations_async.py @@ -0,0 +1,152 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtServicesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.services.list_by_subscription( + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.services.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.services.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.services.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + resource={ + "location": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "provisioningState": "str", + "restore": False, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.services.update( + resource_group_name=resource_group.name, + service_name="str", + properties={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "restore": False, + "tags": {"str": "str"}, + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.services.delete( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_export_metadata_schema(self, resource_group): + response = await ( + await self.client.services.begin_export_metadata_schema( + resource_group_name=resource_group.name, + service_name="str", + body={"assignedTo": "str"}, + api_version="2024-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_import_from_apim(self, resource_group): + response = await ( + await self.client.services.begin_import_from_apim( + resource_group_name=resource_group.name, + service_name="str", + body={"sourceResourceIds": ["str"]}, + api_version="2024-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_workspaces_operations.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_workspaces_operations.py new file mode 100644 index 000000000000..2d4800c09833 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_workspaces_operations.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtWorkspacesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.workspaces.list( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspaces.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspaces.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + resource={ + "description": "str", + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspaces.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_head(self, resource_group): + response = self.client.workspaces.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_workspaces_operations_async.py b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_workspaces_operations_async.py new file mode 100644 index 000000000000..9e48e3eade00 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_tests/test_api_center_mgmt_workspaces_operations_async.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apicenter.aio import ApiCenterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiCenterMgmtWorkspacesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiCenterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.workspaces.list( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspaces.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspaces.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + resource={ + "description": "str", + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "title": "str", + "type": "str", + }, + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspaces.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_head(self, resource_group): + response = await self.client.workspaces.head( + resource_group_name=resource_group.name, + service_name="str", + workspace_name="str", + api_version="2024-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apicenter/azure-mgmt-apicenter/setup.py b/sdk/apicenter/azure-mgmt-apicenter/setup.py index 67dfd68e990c..d14c33769581 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/setup.py +++ b/sdk/apicenter/azure-mgmt-apicenter/setup.py @@ -74,9 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], python_requires=">=3.8", )