From 8a230a46af529114de02c5839c586f5d156c3834 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 17 Oct 2023 01:23:17 +0000 Subject: [PATCH] CodeGen from PR 25977 in Azure/azure-rest-api-specs Merge 4480ade6f920655409fe1670b6a272007e179e75 into 0a25ea9680cf080b7d34e8c5f35f564425c6b1f7 --- sdk/apicenter/azure-mgmt-apicenter/_meta.json | 4 +- .../mgmt/apicenter/_api_center_mgmt_client.py | 81 +- .../azure/mgmt/apicenter/_configuration.py | 63 +- .../apicenter/aio/_api_center_mgmt_client.py | 81 +- .../mgmt/apicenter/aio/_configuration.py | 63 +- .../mgmt/apicenter/aio/operations/__init__.py | 14 + .../operations/_api_definitions_operations.py | 745 ++++++++++ .../operations/_api_versions_operations.py | 514 +++++++ .../aio/operations/_apis_operations.py | 509 +++++++ .../aio/operations/_deployments_operations.py | 514 +++++++ .../operations/_environments_operations.py | 509 +++++++ .../_metadata_schemas_operations.py | 506 +++++++ .../apicenter/aio/operations/_operations.py | 4 +- .../aio/operations/_services_operations.py | 222 ++- .../aio/operations/_workspaces_operations.py | 504 +++++++ .../azure/mgmt/apicenter/models/__init__.py | 74 + .../models/_api_center_mgmt_client_enums.py | 86 ++ .../mgmt/apicenter/models/_models_py3.py | 1290 ++++++++++++++++- .../mgmt/apicenter/operations/__init__.py | 14 + .../operations/_api_definitions_operations.py | 1053 ++++++++++++++ .../operations/_api_versions_operations.py | 725 +++++++++ .../apicenter/operations/_apis_operations.py | 690 +++++++++ .../operations/_deployments_operations.py | 725 +++++++++ .../operations/_environments_operations.py | 710 +++++++++ .../_metadata_schemas_operations.py | 682 +++++++++ .../mgmt/apicenter/operations/_operations.py | 6 +- .../operations/_services_operations.py | 289 +++- .../operations/_workspaces_operations.py | 674 +++++++++ .../api_definitions_create_or_update.py | 49 + .../api_definitions_delete.py | 47 + .../api_definitions_export_specification.py | 48 + .../generated_samples/api_definitions_get.py | 48 + .../generated_samples/api_definitions_head.py | 48 + .../api_definitions_import_specification.py | 48 + .../generated_samples/api_definitions_list.py | 49 + .../api_versions_create_or_update.py | 49 + .../generated_samples/api_versions_delete.py | 47 + .../generated_samples/api_versions_get.py | 48 + .../generated_samples/api_versions_head.py | 48 + .../generated_samples/api_versions_list.py | 49 + .../apis_create_or_update.py | 60 + .../generated_samples/apis_delete.py | 47 + .../generated_samples/apis_get.py | 48 + .../generated_samples/apis_head.py | 48 + .../generated_samples/apis_list.py | 49 + .../deployments_create_or_update.py | 58 + .../generated_samples/deployments_delete.py | 47 + .../generated_samples/deployments_get.py | 48 + .../generated_samples/deployments_head.py | 48 + .../generated_samples/deployments_list.py | 49 + .../environments_create_or_update.py | 65 + .../generated_samples/environments_delete.py | 47 + .../generated_samples/environments_get.py | 48 + .../generated_samples/environments_head.py | 48 + .../generated_samples/environments_list.py | 49 + .../metadata_schemas_create_or_update.py | 54 + .../metadata_schemas_delete.py | 47 + .../generated_samples/metadata_schemas_get.py | 48 + .../metadata_schemas_head.py | 48 + .../metadata_schemas_list.py | 49 + .../generated_samples/operations_list.py | 9 +- .../services_create_or_update.py | 9 +- .../generated_samples/services_delete.py | 9 +- .../services_export_metadata_schema.py | 49 + .../generated_samples/services_get.py | 9 +- .../services_list_by_resource_group.py | 9 +- .../services_list_by_subscription.py | 9 +- .../generated_samples/services_update.py | 9 +- .../workspaces_create_or_update.py | 49 + .../generated_samples/workspaces_delete.py | 47 + .../generated_samples/workspaces_get.py | 48 + .../generated_samples/workspaces_head.py | 48 + .../generated_samples/workspaces_list.py | 49 + 73 files changed, 13127 insertions(+), 160 deletions(-) create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_definitions_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_versions_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_apis_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deployments_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_environments_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_metadata_schemas_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_workspaces_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_definitions_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_versions_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_apis_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deployments_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_environments_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_metadata_schemas_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_workspaces_operations.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_create_or_update.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_export_specification.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_head.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_import_specification.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_list.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_create_or_update.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_head.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_list.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_create_or_update.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_head.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_list.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_create_or_update.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_head.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_list.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_create_or_update.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_head.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_list.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_create_or_update.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_head.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_list.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_export_metadata_schema.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_create_or_update.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_delete.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_get.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_head.py create mode 100644 sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_list.py diff --git a/sdk/apicenter/azure-mgmt-apicenter/_meta.json b/sdk/apicenter/azure-mgmt-apicenter/_meta.json index 19fbd47d2eb48..091ed38465bb5 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/_meta.json +++ b/sdk/apicenter/azure-mgmt-apicenter/_meta.json @@ -1,11 +1,11 @@ { - "commit": "1d2b8c05b55be5dd98ce94c835d7e96ee1ea7f5d", + "commit": "da78886f03e18f0f1f3733090410382781060a1f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.7", "use": [ "@autorest/python@6.7.1", "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/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 --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/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 5a987dcf0d006..d26a6f0b57a86 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 @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient @@ -15,40 +15,98 @@ from . import models as _models from ._configuration import ApiCenterMgmtClientConfiguration from ._serialization import Deserializer, Serializer -from .operations import Operations, ServicesOperations +from .operations import ( + ApiDefinitionsOperations, + ApiVersionsOperations, + ApisOperations, + DeploymentsOperations, + EnvironmentsOperations, + MetadataSchemasOperations, + Operations, + ServicesOperations, + WorkspacesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApiCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword +class ApiCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure API Center Resource Provider. :ivar operations: Operations operations :vartype operations: azure.mgmt.apicenter.operations.Operations :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 apis: ApisOperations operations + :vartype apis: azure.mgmt.apicenter.operations.ApisOperations + :ivar api_versions: ApiVersionsOperations operations + :vartype api_versions: azure.mgmt.apicenter.operations.ApiVersionsOperations + :ivar api_definitions: ApiDefinitionsOperations operations + :vartype api_definitions: azure.mgmt.apicenter.operations.ApiDefinitionsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.apicenter.operations.DeploymentsOperations + :ivar environments: EnvironmentsOperations operations + :vartype environments: azure.mgmt.apicenter.operations.EnvironmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param api_name: The name of the API. Required. + :type api_name: str + :param version_name: The name of the API version. Required. + :type version_name: str + :param definition_name: The name of the API definition. Required. + :type definition_name: str + :param deployment_name: The name of the API deployment. Required. + :type deployment_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param metadata_schema_name: The name of the metadata schema. Required. + :type metadata_schema_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param filter: OData filter parameter. Default value is None. + :type filter: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", + api_name: str, + version_name: str, + definition_name: str, + deployment_name: str, + environment_name: str, + metadata_schema_name: str, + workspace_name: str, subscription_id: str, + filter: Optional[str] = None, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = ApiCenterMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, + api_name=api_name, + version_name=version_name, + definition_name=definition_name, + deployment_name=deployment_name, + environment_name=environment_name, + metadata_schema_name=metadata_schema_name, + workspace_name=workspace_name, + subscription_id=subscription_id, + filter=filter, + **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -58,6 +116,15 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(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.apis = ApisOperations(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.deployments = DeploymentsOperations(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: """Runs the network request through the client's chained policies. 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 ea786433c1bfe..a73ece340ee6e 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_configuration.py +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -27,24 +27,75 @@ class ApiCenterMgmtClientConfiguration(Configuration): # pylint: disable=too-ma :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param api_name: The name of the API. Required. + :type api_name: str + :param version_name: The name of the API version. Required. + :type version_name: str + :param definition_name: The name of the API definition. Required. + :type definition_name: str + :param deployment_name: The name of the API deployment. Required. + :type deployment_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param metadata_schema_name: The name of the metadata schema. Required. + :type metadata_schema_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :param filter: OData filter parameter. Default value is None. + :type filter: str + :keyword api_version: Api Version. Default value is "2024-03-01". 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: + def __init__( + self, + credential: "TokenCredential", + api_name: str, + version_name: str, + definition_name: str, + deployment_name: str, + environment_name: str, + metadata_schema_name: str, + workspace_name: str, + subscription_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> None: super(ApiCenterMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-07-01-preview") + api_version: str = kwargs.pop("api_version", "2024-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") + if api_name is None: + raise ValueError("Parameter 'api_name' must not be None.") + if version_name is None: + raise ValueError("Parameter 'version_name' must not be None.") + if definition_name is None: + raise ValueError("Parameter 'definition_name' must not be None.") + if deployment_name is None: + raise ValueError("Parameter 'deployment_name' must not be None.") + if environment_name is None: + raise ValueError("Parameter 'environment_name' must not be None.") + if metadata_schema_name is None: + raise ValueError("Parameter 'metadata_schema_name' must not be None.") + if workspace_name is None: + raise ValueError("Parameter 'workspace_name' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential + self.api_name = api_name + self.version_name = version_name + self.definition_name = definition_name + self.deployment_name = deployment_name + self.environment_name = environment_name + self.metadata_schema_name = metadata_schema_name + self.workspace_name = workspace_name self.subscription_id = subscription_id + self.filter = filter 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)) 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 972c5ca379e76..c71fbc6798613 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 @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient @@ -15,40 +15,98 @@ from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import ApiCenterMgmtClientConfiguration -from .operations import Operations, ServicesOperations +from .operations import ( + ApiDefinitionsOperations, + ApiVersionsOperations, + ApisOperations, + DeploymentsOperations, + EnvironmentsOperations, + MetadataSchemasOperations, + Operations, + ServicesOperations, + WorkspacesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApiCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword +class ApiCenterMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure API Center Resource Provider. :ivar operations: Operations operations :vartype operations: azure.mgmt.apicenter.aio.operations.Operations :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 apis: ApisOperations operations + :vartype apis: azure.mgmt.apicenter.aio.operations.ApisOperations + :ivar api_versions: ApiVersionsOperations operations + :vartype api_versions: azure.mgmt.apicenter.aio.operations.ApiVersionsOperations + :ivar api_definitions: ApiDefinitionsOperations operations + :vartype api_definitions: azure.mgmt.apicenter.aio.operations.ApiDefinitionsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.apicenter.aio.operations.DeploymentsOperations + :ivar environments: EnvironmentsOperations operations + :vartype environments: azure.mgmt.apicenter.aio.operations.EnvironmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param api_name: The name of the API. Required. + :type api_name: str + :param version_name: The name of the API version. Required. + :type version_name: str + :param definition_name: The name of the API definition. Required. + :type definition_name: str + :param deployment_name: The name of the API deployment. Required. + :type deployment_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param metadata_schema_name: The name of the metadata schema. Required. + :type metadata_schema_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param filter: OData filter parameter. Default value is None. + :type filter: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", + api_name: str, + version_name: str, + definition_name: str, + deployment_name: str, + environment_name: str, + metadata_schema_name: str, + workspace_name: str, subscription_id: str, + filter: Optional[str] = None, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = ApiCenterMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, + api_name=api_name, + version_name=version_name, + definition_name=definition_name, + deployment_name=deployment_name, + environment_name=environment_name, + metadata_schema_name=metadata_schema_name, + workspace_name=workspace_name, + subscription_id=subscription_id, + filter=filter, + **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -58,6 +116,15 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(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.apis = ApisOperations(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.deployments = DeploymentsOperations(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]: """Runs the network request through the client's chained policies. 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 2364a08812369..3af9ee331957a 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 @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -27,24 +27,75 @@ class ApiCenterMgmtClientConfiguration(Configuration): # pylint: disable=too-ma :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param api_name: The name of the API. Required. + :type api_name: str + :param version_name: The name of the API version. Required. + :type version_name: str + :param definition_name: The name of the API definition. Required. + :type definition_name: str + :param deployment_name: The name of the API deployment. Required. + :type deployment_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param metadata_schema_name: The name of the metadata schema. Required. + :type metadata_schema_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :param filter: OData filter parameter. Default value is None. + :type filter: str + :keyword api_version: Api Version. Default value is "2024-03-01". 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: + def __init__( + self, + credential: "AsyncTokenCredential", + api_name: str, + version_name: str, + definition_name: str, + deployment_name: str, + environment_name: str, + metadata_schema_name: str, + workspace_name: str, + subscription_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> None: super(ApiCenterMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-07-01-preview") + api_version: str = kwargs.pop("api_version", "2024-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") + if api_name is None: + raise ValueError("Parameter 'api_name' must not be None.") + if version_name is None: + raise ValueError("Parameter 'version_name' must not be None.") + if definition_name is None: + raise ValueError("Parameter 'definition_name' must not be None.") + if deployment_name is None: + raise ValueError("Parameter 'deployment_name' must not be None.") + if environment_name is None: + raise ValueError("Parameter 'environment_name' must not be None.") + if metadata_schema_name is None: + raise ValueError("Parameter 'metadata_schema_name' must not be None.") + if workspace_name is None: + raise ValueError("Parameter 'workspace_name' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential + self.api_name = api_name + self.version_name = version_name + self.definition_name = definition_name + self.deployment_name = deployment_name + self.environment_name = environment_name + self.metadata_schema_name = metadata_schema_name + self.workspace_name = workspace_name self.subscription_id = subscription_id + self.filter = filter 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)) 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 bf7a87b593708..b2d8bc38297ec 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 @@ -8,6 +8,13 @@ from ._operations import Operations from ._services_operations import ServicesOperations +from ._metadata_schemas_operations import MetadataSchemasOperations +from ._workspaces_operations import WorkspacesOperations +from ._apis_operations import ApisOperations +from ._api_versions_operations import ApiVersionsOperations +from ._api_definitions_operations import ApiDefinitionsOperations +from ._deployments_operations import DeploymentsOperations +from ._environments_operations import EnvironmentsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -16,6 +23,13 @@ __all__ = [ "Operations", "ServicesOperations", + "MetadataSchemasOperations", + "WorkspacesOperations", + "ApisOperations", + "ApiVersionsOperations", + "ApiDefinitionsOperations", + "DeploymentsOperations", + "EnvironmentsOperations", ] __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/aio/operations/_api_definitions_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_definitions_operations.py new file mode 100644 index 0000000000000..675a649be529d --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_definitions_operations.py @@ -0,0 +1,745 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._api_definitions_operations import ( + build_create_or_update_request, + build_delete_request, + build_export_specification_request, + build_get_request, + build_head_request, + build_import_specification_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`api_definitions` 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, **kwargs: Any + ) -> AsyncIterable["_models.ApiDefinition"]: + """List API definitions. + + Returns a collection of API definitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.ApiDefinitionCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiDefinitionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ApiDefinition: + """Get API definition. + + Returns details of the API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.ApiDefinition] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.ApiDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiDefinition: + """Create or update API definition. + + Creates new or updates existing API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API definition entity. Required. + :type payload: ~azure.mgmt.apicenter.models.ApiDefinition + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiDefinition: + """Create or update API definition. + + Creates new or updates existing API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API definition entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiDefinition or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.ApiDefinition, IO], **kwargs: Any + ) -> _models.ApiDefinition: + """Create or update API definition. + + Creates new or updates existing API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API definition entity. Is either a ApiDefinition type or a IO type. Required. + :type payload: ~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 + :return: ApiDefinition or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "ApiDefinition") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("ApiDefinition", pipeline_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, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Delete API definition. + + Deletes specified API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" + } + + @distributed_trace_async + async def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if API definition exists. + + Checks if specified API definition 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + 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) + + _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, {}) + 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}" + } + + @overload + async def import_specification( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + payload: _models.ApiSpecImportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Import API specification. + + Imports the API specification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The API specification source entity. Required. + :type payload: ~azure.mgmt.apicenter.models.ApiSpecImportRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_specification( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Import API specification. + + Imports the API specification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The API specification source entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_specification( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + payload: Union[_models.ApiSpecImportRequest, IO], + **kwargs: Any + ) -> None: + """Import API specification. + + Imports the API specification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The API specification source entity. Is either a ApiSpecImportRequest type or a + IO type. Required. + :type payload: ~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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = 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[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "ApiSpecImportRequest") + + request = build_import_specification_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.import_specification.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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, {}) + + import_specification.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification" + } + + @distributed_trace_async + async def export_specification( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Optional[_models.ApiSpecExportResult]: + """Export API specification. + + Exports the API specification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiSpecExportResult or None or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSpecExportResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ApiSpecExportResult]] = kwargs.pop("cls", None) + + request = build_export_specification_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + template_url=self.export_specification.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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 + if response.status_code == 200: + deserialized = self._deserialize("ApiSpecExportResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_specification.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification" + } 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 new file mode 100644 index 0000000000000..49a77d96860d0 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_api_versions_operations.py @@ -0,0 +1,514 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._api_versions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_head_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`api_versions` 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, **kwargs: Any) -> AsyncIterable["_models.ApiVersion"]: + """List API versions. + + Returns a collection of API versions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.ApiVersionCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiVersionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ApiVersion: + """Get API version. + + Returns details of the API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.ApiVersion] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.ApiVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersion: + """Create or update API version. + + Creates new or updates existing API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API version entity. Required. + :type payload: ~azure.mgmt.apicenter.models.ApiVersion + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersion: + """Create or update API version. + + Creates new or updates existing API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API version entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiVersion or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.ApiVersion, IO], **kwargs: Any + ) -> _models.ApiVersion: + """Create or update API version. + + Creates new or updates existing API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API version entity. Is either a ApiVersion type or a IO type. Required. + :type payload: ~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 + :return: ApiVersion or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "ApiVersion") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("ApiVersion", pipeline_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, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Delete API version. + + Deletes specified API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" + } + + @distributed_trace_async + async def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if API version exists. + + Checks if specified API version 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + 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) + + _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, {}) + 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 new file mode 100644 index 0000000000000..05757edc03b6e --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_apis_operations.py @@ -0,0 +1,509 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._apis_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_head_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApisOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`apis` 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, **kwargs: Any) -> AsyncIterable["_models.Api"]: + """List APIs. + + Returns a collection of APIs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.ApiCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Api: + """Get API. + + Returns details of the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.Api] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("Api", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.Api, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Api: + """Create or update API. + + Creates new or updates existing API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API entity. Required. + :type payload: ~azure.mgmt.apicenter.models.Api + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Api: + """Create or update API. + + Creates new or updates existing API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Api or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Api + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.Api, IO], **kwargs: Any + ) -> _models.Api: + """Create or update API. + + Creates new or updates existing API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API entity. Is either a Api type or a IO type. Required. + :type payload: ~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 + :return: Api or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Api + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Api] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "Api") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("Api", pipeline_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, **kwargs: Any + ) -> None: + """Delete API. + + Deletes specified API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" + } + + @distributed_trace_async + async def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if API exists. + + Checks if specified API 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + 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) + + _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, {}) + 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/_deployments_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deployments_operations.py new file mode 100644 index 0000000000000..bffb8f8c8e686 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_deployments_operations.py @@ -0,0 +1,514 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._deployments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_head_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`deployments` 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, **kwargs: Any) -> AsyncIterable["_models.Deployment"]: + """List deployments. + + Returns a collection of API deployments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.DeploymentCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Delete API deployment. + + Deletes API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + deployment_name=self._config.deployment_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Deployment: + """Get API deployment. + + Returns details of the API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.Deployment] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + deployment_name=self._config.deployment_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("Deployment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.Deployment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Deployment: + """Create or update API deployment. + + Creates new or updates existing API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API deployment entity. Required. + :type payload: ~azure.mgmt.apicenter.models.Deployment + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Deployment: + """Create or update API deployment. + + Creates new or updates existing API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API deployment entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Deployment or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.Deployment: + """Create or update API deployment. + + Creates new or updates existing API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API deployment entity. Is either a Deployment type or a IO type. Required. + :type payload: ~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 + :return: Deployment or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "Deployment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + deployment_name=self._config.deployment_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("Deployment", pipeline_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 head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if API deployment exists. + + Checks if specified API deployment 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + deployment_name=self._config.deployment_name, + 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) + + _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, {}) + 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 new file mode 100644 index 0000000000000..8fbd6472acb11 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_environments_operations.py @@ -0,0 +1,509 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._environments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_head_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`environments` 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, **kwargs: Any) -> AsyncIterable["_models.Environment"]: + """List environments. + + Returns a collection of environments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.EnvironmentCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EnvironmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.Environment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Environment: + """Create or update environment. + + Creates new or updates existing environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Environment entity. Required. + :type payload: ~azure.mgmt.apicenter.models.Environment + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Environment: + """Create or update environment. + + Creates new or updates existing environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Environment entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Environment or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Environment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.Environment, IO], **kwargs: Any + ) -> _models.Environment: + """Create or update environment. + + Creates new or updates existing environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Environment entity. Is either a Environment type or a IO type. Required. + :type payload: ~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 + :return: Environment or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Environment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Environment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "Environment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + environment_name=self._config.environment_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("Environment", pipeline_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, **kwargs: Any + ) -> None: + """Delete environment. + + Deletes the environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + environment_name=self._config.environment_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" + } + + @distributed_trace_async + async def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if environment exists. + + Checks if specified environment 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + environment_name=self._config.environment_name, + 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) + + _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, {}) + return 200 <= response.status_code <= 299 + + head.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Environment: + """Get environment. + + Returns details of the environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.Environment] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + environment_name=self._config.environment_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("Environment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.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 new file mode 100644 index 0000000000000..77906e31a2296 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_metadata_schemas_operations.py @@ -0,0 +1,506 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._metadata_schemas_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_head_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MetadataSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`metadata_schemas` 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, **kwargs: Any + ) -> AsyncIterable["_models.MetadataSchema"]: + """List metadata schemas. + + Returns a collection of metadata schemas. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.MetadataSchemaCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MetadataSchemaCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MetadataSchema: + """Get metadata schema. + + Returns details of the metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.MetadataSchema] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + metadata_schema_name=self._config.metadata_schema_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("MetadataSchema", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.MetadataSchema, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetadataSchema: + """Create or update metadata schema. + + Creates new or updates existing metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Metadata schema entity. Required. + :type payload: ~azure.mgmt.apicenter.models.MetadataSchema + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetadataSchema: + """Create or update metadata schema. + + Creates new or updates existing metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Metadata schema entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MetadataSchema or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.MetadataSchema, IO], **kwargs: Any + ) -> _models.MetadataSchema: + """Create or update metadata schema. + + Creates new or updates existing metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Metadata schema entity. Is either a MetadataSchema type or a IO type. Required. + :type payload: ~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 + :return: MetadataSchema or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetadataSchema] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "MetadataSchema") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + metadata_schema_name=self._config.metadata_schema_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("MetadataSchema", pipeline_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, **kwargs: Any + ) -> None: + """Delete metadata schema. + + Deletes specified metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + metadata_schema_name=self._config.metadata_schema_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" + } + + @distributed_trace_async + async def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if metadata schema exists. + + Checks if specified metadata schema 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + metadata_schema_name=self._config.metadata_schema_name, + 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) + + _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, {}) + 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 074f06ed0be94..6270c14c4064d 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 @@ -54,7 +54,9 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """List the operations for the provider. + """List resource provider operations. + + Returns a collection of resource provider operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) 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 d6696e49ddc3f..b3229f95a12c3 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 @@ -32,6 +32,7 @@ from ...operations._services_operations import ( build_create_or_update_request, build_delete_request, + build_export_metadata_schema_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, @@ -144,7 +145,7 @@ async def get_next(next_link=None): @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Service"]: - """Lists services within a resource group. + """Returns a collection of services within the resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -233,6 +234,8 @@ async def get_next(next_link=None): async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Service: """Get service. + Returns details of the service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -297,20 +300,22 @@ async def create_or_update( self, resource_group_name: str, service_name: str, - resource: Optional[_models.Service] = None, + payload: Optional[_models.Service] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Create or update service. + Creates new or updates existing API. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param resource: The service entity. Default value is None. - :type resource: ~azure.mgmt.apicenter.models.Service + :param payload: The service entity. Default value is None. + :type payload: ~azure.mgmt.apicenter.models.Service :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -325,20 +330,22 @@ async def create_or_update( self, resource_group_name: str, service_name: str, - resource: Optional[IO] = None, + payload: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Create or update service. + Creates new or updates existing API. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param resource: The service entity. Default value is None. - :type resource: IO + :param payload: The service entity. Default value is None. + :type payload: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -353,19 +360,21 @@ async def create_or_update( self, resource_group_name: str, service_name: str, - resource: Optional[Union[_models.Service, IO]] = None, + payload: Optional[Union[_models.Service, IO]] = None, **kwargs: Any ) -> _models.Service: """Create or update service. + Creates new or updates existing API. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param resource: The service entity. Is either a Service type or a IO type. Default value is + :param payload: The service entity. Is either a Service type or a IO type. Default value is None. - :type resource: ~azure.mgmt.apicenter.models.Service or IO + :type payload: ~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 @@ -392,11 +401,11 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(payload, (IOBase, bytes)): + _content = payload else: - if resource is not None: - _json = self._serialize.body(resource, "Service") + if payload is not None: + _json = self._serialize.body(payload, "Service") else: _json = None @@ -447,20 +456,22 @@ async def update( self, resource_group_name: str, service_name: str, - parameters: Optional[_models.ServiceUpdate] = None, + payload: Optional[_models.ServiceUpdate] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Update service. + Updates existing service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param parameters: The service properties to be updated. Default value is None. - :type parameters: ~azure.mgmt.apicenter.models.ServiceUpdate + :param payload: The service properties to be updated. Default value is None. + :type payload: ~azure.mgmt.apicenter.models.ServiceUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -475,20 +486,22 @@ async def update( self, resource_group_name: str, service_name: str, - parameters: Optional[IO] = None, + payload: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Update service. + Updates existing service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param parameters: The service properties to be updated. Default value is None. - :type parameters: IO + :param payload: The service properties to be updated. Default value is None. + :type payload: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -503,19 +516,21 @@ async def update( self, resource_group_name: str, service_name: str, - parameters: Optional[Union[_models.ServiceUpdate, IO]] = None, + payload: Optional[Union[_models.ServiceUpdate, IO]] = None, **kwargs: Any ) -> _models.Service: """Update service. + Updates existing service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param parameters: The service properties to be updated. Is either a ServiceUpdate type or a IO + :param payload: The service properties to be updated. Is either a ServiceUpdate type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.apicenter.models.ServiceUpdate or IO + :type payload: ~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 @@ -542,11 +557,11 @@ async def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(payload, (IOBase, bytes)): + _content = payload else: - if parameters is not None: - _json = self._serialize.body(parameters, "ServiceUpdate") + if payload is not None: + _json = self._serialize.body(payload, "ServiceUpdate") else: _json = None @@ -594,6 +609,8 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete service. + Deletes specified service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -648,3 +665,154 @@ async def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" } + + @overload + async def export_metadata_schema( + self, + resource_group_name: str, + service_name: str, + payload: _models.MetadataSchemaExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.MetadataSchemaExportResult]: + """Export effective metadata schema. + + Exports the effective metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The metadata schema request details. Required. + :type payload: ~azure.mgmt.apicenter.models.MetadataSchemaExportRequest + :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: MetadataSchemaExportResult or None or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchemaExportResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_metadata_schema( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.MetadataSchemaExportResult]: + """Export effective metadata schema. + + Exports the effective metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The metadata schema request details. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MetadataSchemaExportResult or None or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchemaExportResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_metadata_schema( + self, + resource_group_name: str, + service_name: str, + payload: Union[_models.MetadataSchemaExportRequest, IO], + **kwargs: Any + ) -> Optional[_models.MetadataSchemaExportResult]: + """Export effective metadata schema. + + Exports the effective metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The metadata schema request details. Is either a MetadataSchemaExportRequest + type or a IO type. Required. + :type payload: ~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 + :return: MetadataSchemaExportResult or None or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchemaExportResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = 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[Optional[_models.MetadataSchemaExportResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "MetadataSchemaExportRequest") + + request = build_export_metadata_schema_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, + template_url=self.export_metadata_schema.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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 + if response.status_code == 200: + deserialized = self._deserialize("MetadataSchemaExportResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_metadata_schema.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema" + } 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 new file mode 100644 index 0000000000000..d0d11ea0afebc --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/aio/operations/_workspaces_operations.py @@ -0,0 +1,504 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._workspaces_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_head_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.aio.ApiCenterMgmtClient`'s + :attr:`workspaces` 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, **kwargs: Any) -> AsyncIterable["_models.Workspace"]: + """List workspaces. + + Returns a collection of workspaces. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.WorkspaceCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WorkspaceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Workspace: + """Get workspace. + + Returns details of the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.Workspace] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("Workspace", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.Workspace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Create or update workspace. + + Creates new or updates existing workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Workspace entity. Required. + :type payload: ~azure.mgmt.apicenter.models.Workspace + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Create or update workspace. + + Creates new or updates existing workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Workspace entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.Workspace, IO], **kwargs: Any + ) -> _models.Workspace: + """Create or update workspace. + + Creates new or updates existing workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Workspace entity. Is either a Workspace type or a IO type. Required. + :type payload: ~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 + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "Workspace") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("Workspace", pipeline_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, **kwargs: Any + ) -> None: + """Delete workspace. + + Deletes specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" + } + + @distributed_trace_async + async def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if workspace exists. + + Checks if specified workspace 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + 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) + + _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, {}) + 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 b66dfd23d2906..b2ca03105aec8 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 @@ -6,10 +6,35 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._models_py3 import Api +from ._models_py3 import ApiCollection +from ._models_py3 import ApiDefinition +from ._models_py3 import ApiDefinitionCollection +from ._models_py3 import ApiDefinitionPropertiesSpecification +from ._models_py3 import ApiSpecExportResult +from ._models_py3 import ApiSpecImportRequest +from ._models_py3 import ApiSpecImportRequestSpecification +from ._models_py3 import ApiVersion +from ._models_py3 import ApiVersionCollection +from ._models_py3 import Contact +from ._models_py3 import Deployment +from ._models_py3 import DeploymentCollection +from ._models_py3 import DeploymentServer +from ._models_py3 import Environment +from ._models_py3 import EnvironmentCollection +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 License from ._models_py3 import ManagedServiceIdentity +from ._models_py3 import MetadataAssignment +from ._models_py3 import MetadataSchema +from ._models_py3 import MetadataSchemaCollection +from ._models_py3 import MetadataSchemaExportRequest +from ._models_py3 import MetadataSchemaExportResult +from ._models_py3 import Onboarding from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult @@ -18,12 +43,24 @@ from ._models_py3 import ServiceCollection from ._models_py3 import ServiceUpdate from ._models_py3 import SystemData +from ._models_py3 import TermsOfService from ._models_py3 import TrackedResource from ._models_py3 import UserAssignedIdentity +from ._models_py3 import Workspace +from ._models_py3 import WorkspaceCollection from ._api_center_mgmt_client_enums import ActionType +from ._api_center_mgmt_client_enums import ApiKind +from ._api_center_mgmt_client_enums import ApiSpecExportResultFormat +from ._api_center_mgmt_client_enums import ApiSpecImportSourceFormat from ._api_center_mgmt_client_enums import CreatedByType +from ._api_center_mgmt_client_enums import DeploymentState +from ._api_center_mgmt_client_enums import EnvironmentKind +from ._api_center_mgmt_client_enums import EnvironmentServerType +from ._api_center_mgmt_client_enums import LifecycleStage from ._api_center_mgmt_client_enums import ManagedServiceIdentityType +from ._api_center_mgmt_client_enums import MetadataAssignmentEntity +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 ._patch import __all__ as _patch_all @@ -31,10 +68,35 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Api", + "ApiCollection", + "ApiDefinition", + "ApiDefinitionCollection", + "ApiDefinitionPropertiesSpecification", + "ApiSpecExportResult", + "ApiSpecImportRequest", + "ApiSpecImportRequestSpecification", + "ApiVersion", + "ApiVersionCollection", + "Contact", + "Deployment", + "DeploymentCollection", + "DeploymentServer", + "Environment", + "EnvironmentCollection", + "EnvironmentServer", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", + "ExternalDocumentation", + "License", "ManagedServiceIdentity", + "MetadataAssignment", + "MetadataSchema", + "MetadataSchemaCollection", + "MetadataSchemaExportRequest", + "MetadataSchemaExportResult", + "Onboarding", "Operation", "OperationDisplay", "OperationListResult", @@ -43,11 +105,23 @@ "ServiceCollection", "ServiceUpdate", "SystemData", + "TermsOfService", "TrackedResource", "UserAssignedIdentity", + "Workspace", + "WorkspaceCollection", "ActionType", + "ApiKind", + "ApiSpecExportResultFormat", + "ApiSpecImportSourceFormat", "CreatedByType", + "DeploymentState", + "EnvironmentKind", + "EnvironmentServerType", + "LifecycleStage", "ManagedServiceIdentityType", + "MetadataAssignmentEntity", + "MetadataSchemaExportFormat", "Origin", "ProvisioningState", ] 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 ea95477efa398..85934f97d094b 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 @@ -16,6 +16,35 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNAL = "Internal" +class ApiKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Kind of API. For example, REST or GraphQL.""" + + REST = "rest" + GRAPHQL = "graphql" + GRPC = "grpc" + SOAP = "soap" + WEBHOOK = "webhook" + WEBSOCKET = "websocket" + + +class ApiSpecExportResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ApiSpecExportResultFormat.""" + + INLINE = "inline" + """The inlined content of a specification document.""" + LINK = "link" + """The link to the result of the export operation. The URL is valid for 5 minutes.""" + + +class ApiSpecImportSourceFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Format of the API specification source.""" + + INLINE = "inline" + """The inlined content of a specification document.""" + LINK = "link" + """The link to a specification document hosted on a publicly accessible internet address.""" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" @@ -25,6 +54,46 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "Key" +class DeploymentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of API deployment.""" + + ACTIVE = "active" + INACTIVE = "inactive" + + +class EnvironmentKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Environment kind.""" + + DEVELOPMENT = "development" + TESTING = "testing" + STAGING = "staging" + PRODUCTION = "production" + + +class EnvironmentServerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the server that represents the environment.""" + + AZURE_API_MANAGEMENT = "Azure API Management" + AZURE_COMPUTE_SERVICE = "Azure compute service" + APIGEE_API_MANAGEMENT = "Apigee API Management" + AWS_API_GATEWAY = "AWS API Gateway" + KONG_API_GATEWAY = "Kong API Gateway" + KUBERNETES = "Kubernetes" + MULE_SOFT_API_MANAGEMENT = "MuleSoft API Management" + + +class LifecycleStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current lifecycle stage of the API.""" + + DESIGN = "design" + DEVELOPMENT = "development" + TESTING = "testing" + PREVIEW = "preview" + PRODUCTION = "production" + DEPRECATED = "deprecated" + RETIRED = "retired" + + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). @@ -36,6 +105,23 @@ class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" +class MetadataAssignmentEntity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An entity the metadata schema is requested for.""" + + API = "api" + ENVIRONMENT = "environment" + DEPLOYMENT = "deployment" + + +class MetadataSchemaExportFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MetadataSchemaExportFormat.""" + + INLINE = "inline" + """The inlined content of a schema document.""" + LINK = "link" + """The link to a schema document. The URL is valid for 5 minutes.""" + + class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". 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 1a852cf36f472..069d0a2ab9706 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 @@ -8,13 +8,836 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :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 + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class Api(Resource): # 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}". + :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 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: + :vartype external_documentation: list[~azure.mgmt.apicenter.models.ExternalDocumentation] + :ivar 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 = { + "id": {"readonly": True}, + "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 = { + "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"}, + "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, + *, + 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 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: + :paramtype external_documentation: list[~azure.mgmt.apicenter.models.ExternalDocumentation] + :keyword 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.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 ApiCollection(_serialization.Model): + """Paginated collection of APIs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page items. + :vartype value: list[~azure.mgmt.apicenter.models.Api] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Api]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ApiDefinition(Resource): + """API definition 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}". + :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 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 = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, + "specification": {"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"}, + "title": {"key": "properties.title", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "specification": {"key": "properties.specification", "type": "ApiDefinitionPropertiesSpecification"}, + } + + def __init__(self, *, title: Optional[str] = None, description: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword title: API definition title. + :paramtype title: str + :keyword description: API definition description. + :paramtype description: str + """ + super().__init__(**kwargs) + self.title = title + self.description = description + self.specification = None + + +class ApiDefinitionCollection(_serialization.Model): + """Paginated collection of API definitions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page items. + :vartype value: list[~azure.mgmt.apicenter.models.ApiDefinition] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApiDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ApiDefinitionPropertiesSpecification(_serialization.Model): + """API specification details. + + :ivar name: Specification name. + :vartype name: str + :ivar version: Specification version. + :vartype version: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, version: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Specification name. + :paramtype name: str + :keyword version: Specification version. + :paramtype version: str + """ + super().__init__(**kwargs) + self.name = name + self.version = version + + +class ApiSpecExportResult(_serialization.Model): + """The API specification export result. + + :ivar format: Known values are: "inline" and "link". + :vartype format: str or ~azure.mgmt.apicenter.models.ApiSpecExportResultFormat + :ivar value: The result of the export operation. + :vartype value: str + """ + + _attribute_map = { + "format": {"key": "format", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, + *, + format: Optional[Union[str, "_models.ApiSpecExportResultFormat"]] = None, + value: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword format: Known values are: "inline" and "link". + :paramtype format: str or ~azure.mgmt.apicenter.models.ApiSpecExportResultFormat + :keyword value: The result of the export operation. + :paramtype value: str + """ + super().__init__(**kwargs) + self.format = format + self.value = value + + +class ApiSpecImportRequest(_serialization.Model): + """The API specification source entity properties. + + :ivar value: Value of the API specification source. + :vartype value: str + :ivar format: Format of the API specification source. Known values are: "inline" and "link". + :vartype format: str or ~azure.mgmt.apicenter.models.ApiSpecImportSourceFormat + :ivar specification: API specification details. + :vartype specification: ~azure.mgmt.apicenter.models.ApiSpecImportRequestSpecification + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "format": {"key": "format", "type": "str"}, + "specification": {"key": "specification", "type": "ApiSpecImportRequestSpecification"}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + format: Optional[Union[str, "_models.ApiSpecImportSourceFormat"]] = None, + specification: Optional["_models.ApiSpecImportRequestSpecification"] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Value of the API specification source. + :paramtype value: str + :keyword format: Format of the API specification source. Known values are: "inline" and "link". + :paramtype format: str or ~azure.mgmt.apicenter.models.ApiSpecImportSourceFormat + :keyword specification: API specification details. + :paramtype specification: ~azure.mgmt.apicenter.models.ApiSpecImportRequestSpecification + """ + super().__init__(**kwargs) + self.value = value + self.format = format + self.specification = specification + + +class ApiSpecImportRequestSpecification(_serialization.Model): + """API specification details. + + :ivar name: Specification name. + :vartype name: str + :ivar version: Specification version. + :vartype version: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, version: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Specification name. + :paramtype name: str + :keyword version: Specification version. + :paramtype version: str + """ + super().__init__(**kwargs) + self.name = name + self.version = version + + +class ApiVersion(Resource): + """API version 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}". + :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 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 = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, + } + + _attribute_map = { + "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"}, + "lifecycle_stage": {"key": "properties.lifecycleStage", "type": "str"}, + } + + def __init__( + self, + *, + title: Optional[str] = None, + lifecycle_stage: Optional[Union[str, "_models.LifecycleStage"]] = None, + **kwargs: Any + ) -> None: + """ + :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.title = title + self.lifecycle_stage = lifecycle_stage + + +class ApiVersionCollection(_serialization.Model): + """Paginated collection of API versions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page items. + :vartype value: list[~azure.mgmt.apicenter.models.ApiVersion] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApiVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class Contact(_serialization.Model): + """Contact. + + :ivar name: Name of the contact. + :vartype name: str + :ivar url: URL for the contact. + :vartype url: str + :ivar email: Email address of the contact. + :vartype email: str + """ + + _validation = { + "name": {"max_length": 100}, + "url": {"max_length": 200}, + "email": {"max_length": 100}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "email": {"key": "email", "type": "str"}, + } + + def __init__( + self, *, name: Optional[str] = None, url: Optional[str] = None, email: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword name: Name of the contact. + :paramtype name: str + :keyword url: URL for the contact. + :paramtype url: str + :keyword email: Email address of the contact. + :paramtype email: str + """ + super().__init__(**kwargs) + self.name = name + self.url = url + self.email = email + + +class Deployment(Resource): # 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}". + :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. + :vartype description: str + :ivar environment_id: API center-scoped environment resource ID. + :vartype environment_id: str + :ivar definition_id: API center-scoped definition resource ID. + :vartype definition_id: str + :ivar state: State of API deployment. Known values are: "active" and "inactive". + :vartype state: str or ~azure.mgmt.apicenter.models.DeploymentState + :ivar server: Server. + :vartype server: ~azure.mgmt.apicenter.models.DeploymentServer + :ivar custom_properties: The custom metadata defined for API catalog entities. + :vartype custom_properties: JSON + """ + + _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 = { + "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__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + environment_id: Optional[str] = None, + definition_id: Optional[str] = None, + state: Optional[Union[str, "_models.DeploymentState"]] = None, + server: Optional["_models.DeploymentServer"] = None, + custom_properties: Optional[JSON] = None, + **kwargs: Any + ) -> None: + """ + :keyword title: API deployment title. + :paramtype title: str + :keyword description: Description of the deployment. + :paramtype description: str + :keyword environment_id: API center-scoped environment resource ID. + :paramtype environment_id: str + :keyword definition_id: API center-scoped definition resource ID. + :paramtype definition_id: str + :keyword state: State of API deployment. Known values are: "active" and "inactive". + :paramtype state: str or ~azure.mgmt.apicenter.models.DeploymentState + :keyword server: Server. + :paramtype server: ~azure.mgmt.apicenter.models.DeploymentServer + :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.environment_id = environment_id + self.definition_id = definition_id + self.state = state + self.server = server + self.custom_properties = custom_properties + + +class DeploymentCollection(_serialization.Model): + """Paginated collection of API deployments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page items. + :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": {"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): + """Server. + + :ivar runtime_uri: Base runtime URLs for this deployment. + :vartype runtime_uri: list[str] + """ + + _attribute_map = { + "runtime_uri": {"key": "runtimeUri", "type": "[str]"}, + } + + def __init__(self, *, runtime_uri: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword runtime_uri: Base runtime URLs for this deployment. + :paramtype runtime_uri: list[str] + """ + super().__init__(**kwargs) + self.runtime_uri = runtime_uri + + +class Environment(Resource): + """Environment 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}". + :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: Environment title. + :vartype title: str + :ivar description: 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: + :vartype onboarding: ~azure.mgmt.apicenter.models.Onboarding + :ivar custom_properties: The custom metadata defined for API catalog entities. + :vartype custom_properties: JSON + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, + } + + _attribute_map = { + "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"}, + "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, + *, + 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 title: Environment title. + :paramtype title: str + :keyword description: 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: + :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 EnvironmentCollection(_serialization.Model): + """Paginated collection of environments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page items. + :vartype value: list[~azure.mgmt.apicenter.models.Environment] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Environment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class EnvironmentServer(_serialization.Model): + """Server information of the environment. + + :ivar type: Type of the server that represents the environment. Known values are: "Azure API + Management", "Azure compute service", "Apigee API Management", "AWS API Gateway", "Kong API + Gateway", "Kubernetes", and "MuleSoft API Management". + :vartype type: str or ~azure.mgmt.apicenter.models.EnvironmentServerType + :ivar management_portal_uri: + :vartype management_portal_uri: list[str] + """ + + _validation = { + "management_portal_uri": {"max_items": 1, "min_items": 0}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "management_portal_uri": {"key": "managementPortalUri", "type": "[str]"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.EnvironmentServerType"]] = None, + management_portal_uri: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of the server that represents the environment. Known values are: "Azure API + Management", "Azure compute service", "Apigee API Management", "AWS API Gateway", "Kong API + Gateway", "Kubernetes", and "MuleSoft API Management". + :paramtype type: str or ~azure.mgmt.apicenter.models.EnvironmentServerType + :keyword management_portal_uri: + :paramtype management_portal_uri: list[str] + """ + super().__init__(**kwargs) + self.type = type + self.management_portal_uri = management_portal_uri class ErrorAdditionalInfo(_serialization.Model): @@ -92,21 +915,107 @@ class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :ivar error: The error object. - :vartype error: ~azure.mgmt.apicenter.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.apicenter.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.apicenter.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ExternalDocumentation(_serialization.Model): + """Additional, external documentation for the API. + + All required parameters must be populated in order to send to Azure. + + :ivar title: Title of the documentation. + :vartype title: str + :ivar description: Description of the documentation. + :vartype description: str + :ivar url: URL pointing to the documentation. Required. + :vartype url: str + """ + + _validation = { + "title": {"max_length": 50}, + "description": {"max_length": 500}, + "url": {"required": True, "max_length": 200}, + } + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "url": {"key": "url", "type": "str"}, + } + + def __init__( + self, *, url: str, title: Optional[str] = None, description: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword title: Title of the documentation. + :paramtype title: str + :keyword description: Description of the documentation. + :paramtype description: str + :keyword url: URL pointing to the documentation. Required. + :paramtype url: str + """ + super().__init__(**kwargs) + self.title = title + self.description = description + self.url = url + + +class License(_serialization.Model): + """The license information for the API. + + :ivar name: Name of the license. + :vartype name: str + :ivar url: URL pointing to the license details. The URL field is mutually exclusive of the + identifier field. + :vartype url: str + :ivar identifier: SPDX license information for the API. The identifier field is mutually + exclusive of the URL field. + :vartype identifier: str """ + _validation = { + "name": {"max_length": 100}, + "url": {"max_length": 200}, + "identifier": {"max_length": 50}, + } + _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, + "name": {"key": "name", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "identifier": {"key": "identifier", "type": "str"}, } - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + def __init__( + self, *, name: Optional[str] = None, url: Optional[str] = None, identifier: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.apicenter.models.ErrorDetail + :keyword name: Name of the license. + :paramtype name: str + :keyword url: URL pointing to the license details. The URL field is mutually exclusive of the + identifier field. + :paramtype url: str + :keyword identifier: SPDX license information for the API. The identifier field is mutually + exclusive of the URL field. + :paramtype identifier: str """ super().__init__(**kwargs) - self.error = error + self.name = name + self.url = url + self.identifier = identifier class ManagedServiceIdentity(_serialization.Model): @@ -172,6 +1081,219 @@ def __init__( self.user_assigned_identities = user_assigned_identities +class MetadataAssignment(_serialization.Model): + """MetadataAssignment. + + :ivar entity: The entities this metadata schema component gets applied to. Known values are: + "api", "environment", and "deployment". + :vartype entity: str or ~azure.mgmt.apicenter.models.MetadataAssignmentEntity + :ivar required: + :vartype required: bool + :ivar deprecated: + :vartype deprecated: bool + """ + + _attribute_map = { + "entity": {"key": "entity", "type": "str"}, + "required": {"key": "required", "type": "bool"}, + "deprecated": {"key": "deprecated", "type": "bool"}, + } + + def __init__( + self, + *, + entity: Optional[Union[str, "_models.MetadataAssignmentEntity"]] = None, + required: Optional[bool] = None, + deprecated: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword entity: The entities this metadata schema component gets applied to. Known values are: + "api", "environment", and "deployment". + :paramtype entity: str or ~azure.mgmt.apicenter.models.MetadataAssignmentEntity + :keyword required: + :paramtype required: bool + :keyword deprecated: + :paramtype deprecated: bool + """ + super().__init__(**kwargs) + self.entity = entity + self.required = required + self.deprecated = deprecated + + +class MetadataSchema(Resource): + """Metadata schema entity. Used to define metadata for the entities in API catalog. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apicenter.models.SystemData + :ivar schema: The schema defining the type. + :vartype schema: str + :ivar assigned_to: + :vartype assigned_to: list[~azure.mgmt.apicenter.models.MetadataAssignment] + """ + + _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"}, + "schema": {"key": "properties.schema", "type": "str"}, + "assigned_to": {"key": "properties.assignedTo", "type": "[MetadataAssignment]"}, + } + + def __init__( + self, + *, + schema: Optional[str] = None, + assigned_to: Optional[List["_models.MetadataAssignment"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword schema: The schema defining the type. + :paramtype schema: str + :keyword assigned_to: + :paramtype assigned_to: list[~azure.mgmt.apicenter.models.MetadataAssignment] + """ + super().__init__(**kwargs) + self.schema = schema + self.assigned_to = assigned_to + + +class MetadataSchemaCollection(_serialization.Model): + """Paginated collection of metadata schemas. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page items. + :vartype value: list[~azure.mgmt.apicenter.models.MetadataSchema] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[MetadataSchema]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class MetadataSchemaExportRequest(_serialization.Model): + """The metadata schema export request. + + :ivar assigned_to: An entity the metadata schema is requested for. Known values are: "api", + "environment", and "deployment". + :vartype assigned_to: str or ~azure.mgmt.apicenter.models.MetadataAssignmentEntity + """ + + _attribute_map = { + "assigned_to": {"key": "assignedTo", "type": "str"}, + } + + def __init__( + self, *, assigned_to: Optional[Union[str, "_models.MetadataAssignmentEntity"]] = None, **kwargs: Any + ) -> None: + """ + :keyword assigned_to: An entity the metadata schema is requested for. Known values are: "api", + "environment", and "deployment". + :paramtype assigned_to: str or ~azure.mgmt.apicenter.models.MetadataAssignmentEntity + """ + super().__init__(**kwargs) + self.assigned_to = assigned_to + + +class MetadataSchemaExportResult(_serialization.Model): + """The metadata schema export result. + + :ivar format: Known values are: "inline" and "link". + :vartype format: str or ~azure.mgmt.apicenter.models.MetadataSchemaExportFormat + :ivar value: The result of the export operation. + :vartype value: str + """ + + _attribute_map = { + "format": {"key": "format", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, + *, + format: Optional[Union[str, "_models.MetadataSchemaExportFormat"]] = None, + value: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword format: Known values are: "inline" and "link". + :paramtype format: str or ~azure.mgmt.apicenter.models.MetadataSchemaExportFormat + :keyword value: The result of the export operation. + :paramtype value: str + """ + super().__init__(**kwargs) + self.format = format + self.value = value + + +class Onboarding(_serialization.Model): + """Onboarding. + + :ivar instructions: Onboarding guide. + :vartype instructions: str + :ivar developer_portal_uri: + :vartype developer_portal_uri: list[str] + """ + + _validation = { + "developer_portal_uri": {"max_items": 1, "min_items": 0}, + } + + _attribute_map = { + "instructions": {"key": "instructions", "type": "str"}, + "developer_portal_uri": {"key": "developerPortalUri", "type": "[str]"}, + } + + def __init__( + self, *, instructions: Optional[str] = None, developer_portal_uri: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """ + :keyword instructions: Onboarding guide. + :paramtype instructions: str + :keyword developer_portal_uri: + :paramtype developer_portal_uri: list[str] + """ + super().__init__(**kwargs) + self.instructions = instructions + self.developer_portal_uri = developer_portal_uri + + class Operation(_serialization.Model): """Details of a REST API operation, returned from the Resource Provider Operations API. @@ -293,47 +1415,6 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :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 - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - class TrackedResource(Resource): """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. @@ -410,9 +1491,9 @@ class Service(TrackedResource): :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar identity: The identity of the service. + :ivar identity: Managed service identity (system assigned and/or user assigned identities). :vartype identity: ~azure.mgmt.apicenter.models.ManagedServiceIdentity - :ivar provisioning_state: The status of the last operation. Known values are: "Succeeded", + :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 """ @@ -450,7 +1531,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword identity: The identity of the service. + :keyword identity: Managed service identity (system assigned and/or user assigned identities). :paramtype identity: ~azure.mgmt.apicenter.models.ManagedServiceIdentity """ super().__init__(tags=tags, location=location, **kwargs) @@ -495,7 +1576,7 @@ class ServiceUpdate(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The status of the last operation. Known values are: "Succeeded", + :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 """ @@ -578,6 +1659,32 @@ def __init__( self.last_modified_at = last_modified_at +class TermsOfService(_serialization.Model): + """Terms of service for the API. + + All required parameters must be populated in order to send to Azure. + + :ivar url: URL pointing to the terms of service. Required. + :vartype url: str + """ + + _validation = { + "url": {"required": True, "max_length": 200}, + } + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + } + + def __init__(self, *, url: str, **kwargs: Any) -> None: + """ + :keyword url: URL pointing to the terms of service. Required. + :paramtype url: str + """ + super().__init__(**kwargs) + self.url = url + + class UserAssignedIdentity(_serialization.Model): """User assigned identity properties. @@ -604,3 +1711,82 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self.principal_id = None self.client_id = None + + +class Workspace(Resource): + """Workspace 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}". + :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: Workspace title. + :vartype title: str + :ivar description: Workspace description. + :vartype description: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"max_length": 50, "min_length": 1}, + } + + _attribute_map = { + "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"}, + } + + def __init__(self, *, title: Optional[str] = None, description: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword title: Workspace title. + :paramtype title: str + :keyword description: Workspace description. + :paramtype description: str + """ + super().__init__(**kwargs) + self.title = title + self.description = description + + +class WorkspaceCollection(_serialization.Model): + """Paginated collection of workspaces. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page items. + :vartype value: list[~azure.mgmt.apicenter.models.Workspace] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Workspace]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None 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 bf7a87b593708..b2d8bc38297ec 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 @@ -8,6 +8,13 @@ from ._operations import Operations from ._services_operations import ServicesOperations +from ._metadata_schemas_operations import MetadataSchemasOperations +from ._workspaces_operations import WorkspacesOperations +from ._apis_operations import ApisOperations +from ._api_versions_operations import ApiVersionsOperations +from ._api_definitions_operations import ApiDefinitionsOperations +from ._deployments_operations import DeploymentsOperations +from ._environments_operations import EnvironmentsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -16,6 +23,13 @@ __all__ = [ "Operations", "ServicesOperations", + "MetadataSchemasOperations", + "WorkspacesOperations", + "ApisOperations", + "ApiVersionsOperations", + "ApiDefinitionsOperations", + "DeploymentsOperations", + "EnvironmentsOperations", ] __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/operations/_api_definitions_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_definitions_operations.py new file mode 100644 index 0000000000000..d4e032977de20 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_definitions_operations.py @@ -0,0 +1,1053 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: 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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_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, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + "definitionName": _SERIALIZER.url("definition_name", definition_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + "definitionName": _SERIALIZER.url("definition_name", definition_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + "definitionName": _SERIALIZER.url("definition_name", definition_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_head_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + "definitionName": _SERIALIZER.url("definition_name", definition_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_import_specification_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + "definitionName": _SERIALIZER.url("definition_name", definition_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_export_specification_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + definition_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + "definitionName": _SERIALIZER.url("definition_name", definition_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`api_definitions` 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, **kwargs: Any) -> Iterable["_models.ApiDefinition"]: + """List API definitions. + + Returns a collection of API definitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.ApiDefinitionCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiDefinitionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions" + } + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ApiDefinition: + """Get API definition. + + Returns details of the API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.ApiDefinition] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.ApiDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiDefinition: + """Create or update API definition. + + Creates new or updates existing API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API definition entity. Required. + :type payload: ~azure.mgmt.apicenter.models.ApiDefinition + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiDefinition: + """Create or update API definition. + + Creates new or updates existing API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API definition entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiDefinition or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.ApiDefinition, IO], **kwargs: Any + ) -> _models.ApiDefinition: + """Create or update API definition. + + Creates new or updates existing API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API definition entity. Is either a ApiDefinition type or a IO type. Required. + :type payload: ~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 + :return: ApiDefinition or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "ApiDefinition") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("ApiDefinition", pipeline_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, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Delete API definition. + + Deletes specified API definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" + } + + @distributed_trace + def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if API definition exists. + + Checks if specified API definition 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + 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) + + _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, {}) + 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}" + } + + @overload + def import_specification( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + payload: _models.ApiSpecImportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Import API specification. + + Imports the API specification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The API specification source entity. Required. + :type payload: ~azure.mgmt.apicenter.models.ApiSpecImportRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_specification( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Import API specification. + + Imports the API specification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The API specification source entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_specification( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + payload: Union[_models.ApiSpecImportRequest, IO], + **kwargs: Any + ) -> None: + """Import API specification. + + Imports the API specification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The API specification source entity. Is either a ApiSpecImportRequest type or a + IO type. Required. + :type payload: ~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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = 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[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "ApiSpecImportRequest") + + request = build_import_specification_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.import_specification.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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, {}) + + import_specification.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification" + } + + @distributed_trace + def export_specification( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Optional[_models.ApiSpecExportResult]: + """Export API specification. + + Exports the API specification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiSpecExportResult or None or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiSpecExportResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ApiSpecExportResult]] = kwargs.pop("cls", None) + + request = build_export_specification_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + definition_name=self._config.definition_name, + api_version=api_version, + template_url=self.export_specification.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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 + if response.status_code == 200: + deserialized = self._deserialize("ApiSpecExportResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_specification.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification" + } 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 new file mode 100644 index 0000000000000..c95c5ec79b121 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_api_versions_operations.py @@ -0,0 +1,725 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: 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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_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, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_head_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + version_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "versionName": _SERIALIZER.url("version_name", version_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`api_versions` 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, **kwargs: Any) -> Iterable["_models.ApiVersion"]: + """List API versions. + + Returns a collection of API versions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.ApiVersionCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiVersionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions" + } + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ApiVersion: + """Get API version. + + Returns details of the API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.ApiVersion] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.ApiVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersion: + """Create or update API version. + + Creates new or updates existing API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API version entity. Required. + :type payload: ~azure.mgmt.apicenter.models.ApiVersion + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersion: + """Create or update API version. + + Creates new or updates existing API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API version entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiVersion or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.ApiVersion, IO], **kwargs: Any + ) -> _models.ApiVersion: + """Create or update API version. + + Creates new or updates existing API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API version entity. Is either a ApiVersion type or a IO type. Required. + :type payload: ~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 + :return: ApiVersion or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.ApiVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "ApiVersion") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("ApiVersion", pipeline_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, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Delete API version. + + Deletes specified API version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" + } + + @distributed_trace + def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if API version exists. + + Checks if specified API version 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + version_name=self._config.version_name, + 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) + + _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, {}) + 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 new file mode 100644 index 0000000000000..772a3c895688c --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_apis_operations.py @@ -0,0 +1,690 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: 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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_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, service_name: str, subscription_id: str, workspace_name: str, api_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, service_name: str, subscription_id: str, workspace_name: str, api_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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, subscription_id: str, workspace_name: str, api_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_head_request( + resource_group_name: str, service_name: str, subscription_id: str, workspace_name: str, api_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApisOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`apis` 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, **kwargs: Any) -> Iterable["_models.Api"]: + """List APIs. + + Returns a collection of APIs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.ApiCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis" + } + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Api: + """Get API. + + Returns details of the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.Api] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("Api", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.Api, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Api: + """Create or update API. + + Creates new or updates existing API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API entity. Required. + :type payload: ~azure.mgmt.apicenter.models.Api + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Api: + """Create or update API. + + Creates new or updates existing API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Api or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Api + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.Api, IO], **kwargs: Any + ) -> _models.Api: + """Create or update API. + + Creates new or updates existing API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API entity. Is either a Api type or a IO type. Required. + :type payload: ~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 + :return: Api or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Api + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Api] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "Api") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("Api", pipeline_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, **kwargs: Any + ) -> None: + """Delete API. + + Deletes specified API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" + } + + @distributed_trace + def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if API exists. + + Checks if specified API 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + 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) + + _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, {}) + 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/_deployments_operations.py b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deployments_operations.py new file mode 100644 index 0000000000000..cf1f4c7f685d1 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_deployments_operations.py @@ -0,0 +1,725 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: 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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_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_delete_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_head_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + api_name: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "apiName": _SERIALIZER.url("api_name", api_name, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`deployments` 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, **kwargs: Any) -> Iterable["_models.Deployment"]: + """List deployments. + + Returns a collection of API deployments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.DeploymentCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> None: + """Delete API deployment. + + Deletes API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + deployment_name=self._config.deployment_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" + } + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Deployment: + """Get API deployment. + + Returns details of the API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.Deployment] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + deployment_name=self._config.deployment_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("Deployment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.Deployment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Deployment: + """Create or update API deployment. + + Creates new or updates existing API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API deployment entity. Required. + :type payload: ~azure.mgmt.apicenter.models.Deployment + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Deployment: + """Create or update API deployment. + + Creates new or updates existing API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API deployment entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Deployment or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.Deployment: + """Create or update API deployment. + + Creates new or updates existing API deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: API deployment entity. Is either a Deployment type or a IO type. Required. + :type payload: ~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 + :return: Deployment or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "Deployment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + deployment_name=self._config.deployment_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("Deployment", pipeline_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 head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if API deployment exists. + + Checks if specified API deployment 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_name=self._config.api_name, + deployment_name=self._config.deployment_name, + 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) + + _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, {}) + 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 new file mode 100644 index 0000000000000..a9075a402bf68 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_environments_operations.py @@ -0,0 +1,710 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: 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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_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_create_or_update_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + environment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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, + subscription_id: str, + workspace_name: str, + environment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_head_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + environment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + workspace_name: str, + environment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class EnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`environments` 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, **kwargs: Any) -> Iterable["_models.Environment"]: + """List environments. + + Returns a collection of environments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.EnvironmentCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EnvironmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.Environment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Environment: + """Create or update environment. + + Creates new or updates existing environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Environment entity. Required. + :type payload: ~azure.mgmt.apicenter.models.Environment + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Environment: + """Create or update environment. + + Creates new or updates existing environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Environment entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Environment or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Environment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.Environment, IO], **kwargs: Any + ) -> _models.Environment: + """Create or update environment. + + Creates new or updates existing environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Environment entity. Is either a Environment type or a IO type. Required. + :type payload: ~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 + :return: Environment or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Environment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Environment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "Environment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + environment_name=self._config.environment_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("Environment", pipeline_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, **kwargs: Any + ) -> None: + """Delete environment. + + Deletes the environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + environment_name=self._config.environment_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" + } + + @distributed_trace + def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if environment exists. + + Checks if specified environment 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + environment_name=self._config.environment_name, + 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) + + _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, {}) + return 200 <= response.status_code <= 299 + + head.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" + } + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Environment: + """Get environment. + + Returns details of the environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.Environment] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + environment_name=self._config.environment_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("Environment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.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 new file mode 100644 index 0000000000000..334b00640c0f1 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_metadata_schemas_operations.py @@ -0,0 +1,682 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, service_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas", + ) # 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), + } + + _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, subscription_id: str, metadata_schema_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + ) # 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), + "metadataSchemaName": _SERIALIZER.url( + "metadata_schema_name", metadata_schema_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, service_name: str, subscription_id: str, metadata_schema_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + ) # 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), + "metadataSchemaName": _SERIALIZER.url( + "metadata_schema_name", metadata_schema_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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, subscription_id: str, metadata_schema_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + ) # 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), + "metadataSchemaName": _SERIALIZER.url( + "metadata_schema_name", metadata_schema_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_head_request( + resource_group_name: str, service_name: str, subscription_id: str, metadata_schema_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + ) # 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), + "metadataSchemaName": _SERIALIZER.url( + "metadata_schema_name", metadata_schema_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +class MetadataSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`metadata_schemas` 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, **kwargs: Any) -> Iterable["_models.MetadataSchema"]: + """List metadata schemas. + + Returns a collection of metadata schemas. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.MetadataSchemaCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MetadataSchemaCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas" + } + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.MetadataSchema: + """Get metadata schema. + + Returns details of the metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.MetadataSchema] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + metadata_schema_name=self._config.metadata_schema_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("MetadataSchema", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.MetadataSchema, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetadataSchema: + """Create or update metadata schema. + + Creates new or updates existing metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Metadata schema entity. Required. + :type payload: ~azure.mgmt.apicenter.models.MetadataSchema + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetadataSchema: + """Create or update metadata schema. + + Creates new or updates existing metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Metadata schema entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MetadataSchema or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.MetadataSchema, IO], **kwargs: Any + ) -> _models.MetadataSchema: + """Create or update metadata schema. + + Creates new or updates existing metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Metadata schema entity. Is either a MetadataSchema type or a IO type. Required. + :type payload: ~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 + :return: MetadataSchema or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetadataSchema] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "MetadataSchema") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + metadata_schema_name=self._config.metadata_schema_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("MetadataSchema", pipeline_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, **kwargs: Any + ) -> None: + """Delete metadata schema. + + Deletes specified metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + metadata_schema_name=self._config.metadata_schema_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" + } + + @distributed_trace + def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if metadata schema exists. + + Checks if specified metadata schema 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + metadata_schema_name=self._config.metadata_schema_name, + 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) + + _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, {}) + 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 bc96927521381..ff51f532d0795 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 @@ -40,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +76,9 @@ def __init__(self, *args, **kwargs): @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """List the operations for the provider. + """List resource provider operations. + + Returns a collection of resource provider operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) 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 d1b42fa70e924..b29cfcd749bfe 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 @@ -41,13 +41,13 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiCenter/services") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -65,7 +65,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +74,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -95,7 +95,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", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,11 +104,11 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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", pattern=r"^[a-zA-Z0-9\-]{1,64}$"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str", max_length=90, min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -128,7 +128,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -138,11 +138,11 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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", pattern=r"^[a-zA-Z0-9\-]{1,64}$"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str", max_length=90, min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -164,7 +164,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -174,11 +174,11 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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", pattern=r"^[a-zA-Z0-9\-]{1,64}$"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str", max_length=90, min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -200,7 +200,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -209,11 +209,11 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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", pattern=r"^[a-zA-Z0-9\-]{1,64}$"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str", max_length=90, min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -227,6 +227,42 @@ def build_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) +def build_export_metadata_schema_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-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema", + ) # 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), + } + + _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:: @@ -329,7 +365,7 @@ def get_next(next_link=None): @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Service"]: - """Lists services within a resource group. + """Returns a collection of services within the resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -418,6 +454,8 @@ def get_next(next_link=None): def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Service: """Get service. + Returns details of the service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -482,20 +520,22 @@ def create_or_update( self, resource_group_name: str, service_name: str, - resource: Optional[_models.Service] = None, + payload: Optional[_models.Service] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Create or update service. + Creates new or updates existing API. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param resource: The service entity. Default value is None. - :type resource: ~azure.mgmt.apicenter.models.Service + :param payload: The service entity. Default value is None. + :type payload: ~azure.mgmt.apicenter.models.Service :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -510,20 +550,22 @@ def create_or_update( self, resource_group_name: str, service_name: str, - resource: Optional[IO] = None, + payload: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Create or update service. + Creates new or updates existing API. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param resource: The service entity. Default value is None. - :type resource: IO + :param payload: The service entity. Default value is None. + :type payload: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -538,19 +580,21 @@ def create_or_update( self, resource_group_name: str, service_name: str, - resource: Optional[Union[_models.Service, IO]] = None, + payload: Optional[Union[_models.Service, IO]] = None, **kwargs: Any ) -> _models.Service: """Create or update service. + Creates new or updates existing API. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param resource: The service entity. Is either a Service type or a IO type. Default value is + :param payload: The service entity. Is either a Service type or a IO type. Default value is None. - :type resource: ~azure.mgmt.apicenter.models.Service or IO + :type payload: ~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 @@ -577,11 +621,11 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(payload, (IOBase, bytes)): + _content = payload else: - if resource is not None: - _json = self._serialize.body(resource, "Service") + if payload is not None: + _json = self._serialize.body(payload, "Service") else: _json = None @@ -632,20 +676,22 @@ def update( self, resource_group_name: str, service_name: str, - parameters: Optional[_models.ServiceUpdate] = None, + payload: Optional[_models.ServiceUpdate] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Update service. + Updates existing service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param parameters: The service properties to be updated. Default value is None. - :type parameters: ~azure.mgmt.apicenter.models.ServiceUpdate + :param payload: The service properties to be updated. Default value is None. + :type payload: ~azure.mgmt.apicenter.models.ServiceUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -660,20 +706,22 @@ def update( self, resource_group_name: str, service_name: str, - parameters: Optional[IO] = None, + payload: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Service: """Update service. + Updates existing service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param parameters: The service properties to be updated. Default value is None. - :type parameters: IO + :param payload: The service properties to be updated. Default value is None. + :type payload: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -688,19 +736,21 @@ def update( self, resource_group_name: str, service_name: str, - parameters: Optional[Union[_models.ServiceUpdate, IO]] = None, + payload: Optional[Union[_models.ServiceUpdate, IO]] = None, **kwargs: Any ) -> _models.Service: """Update service. + Updates existing service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param service_name: Service name. Required. :type service_name: str - :param parameters: The service properties to be updated. Is either a ServiceUpdate type or a IO + :param payload: The service properties to be updated. Is either a ServiceUpdate type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.apicenter.models.ServiceUpdate or IO + :type payload: ~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 @@ -727,11 +777,11 @@ def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(payload, (IOBase, bytes)): + _content = payload else: - if parameters is not None: - _json = self._serialize.body(parameters, "ServiceUpdate") + if payload is not None: + _json = self._serialize.body(payload, "ServiceUpdate") else: _json = None @@ -779,6 +829,8 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete service. + Deletes specified service. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -833,3 +885,154 @@ def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" } + + @overload + def export_metadata_schema( + self, + resource_group_name: str, + service_name: str, + payload: _models.MetadataSchemaExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.MetadataSchemaExportResult]: + """Export effective metadata schema. + + Exports the effective metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The metadata schema request details. Required. + :type payload: ~azure.mgmt.apicenter.models.MetadataSchemaExportRequest + :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: MetadataSchemaExportResult or None or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchemaExportResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_metadata_schema( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.MetadataSchemaExportResult]: + """Export effective metadata schema. + + Exports the effective metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The metadata schema request details. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MetadataSchemaExportResult or None or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchemaExportResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_metadata_schema( + self, + resource_group_name: str, + service_name: str, + payload: Union[_models.MetadataSchemaExportRequest, IO], + **kwargs: Any + ) -> Optional[_models.MetadataSchemaExportResult]: + """Export effective metadata schema. + + Exports the effective metadata schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: The metadata schema request details. Is either a MetadataSchemaExportRequest + type or a IO type. Required. + :type payload: ~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 + :return: MetadataSchemaExportResult or None or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.MetadataSchemaExportResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = 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[Optional[_models.MetadataSchemaExportResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "MetadataSchemaExportRequest") + + request = build_export_metadata_schema_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, + template_url=self.export_metadata_schema.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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 + if response.status_code == 200: + deserialized = self._deserialize("MetadataSchemaExportResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_metadata_schema.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema" + } 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 new file mode 100644 index 0000000000000..f2703a01773f9 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/azure/mgmt/apicenter/operations/_workspaces_operations.py @@ -0,0 +1,674 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, service_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-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces", + ) # 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), + } + + _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, subscription_id: str, workspace_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, service_name: str, subscription_id: str, workspace_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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, subscription_id: str, workspace_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_head_request( + resource_group_name: str, service_name: str, subscription_id: str, workspace_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + ) # 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), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apicenter.ApiCenterMgmtClient`'s + :attr:`workspaces` 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, **kwargs: Any) -> Iterable["_models.Workspace"]: + """List workspaces. + + Returns a collection of workspaces. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: 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: + """ + _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.WorkspaceCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=self._config.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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WorkspaceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces" + } + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.Workspace: + """Get workspace. + + Returns details of the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_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 = { + 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.Workspace] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("Workspace", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: _models.Workspace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Create or update workspace. + + Creates new or updates existing workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Workspace entity. Required. + :type payload: ~azure.mgmt.apicenter.models.Workspace + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Create or update workspace. + + Creates new or updates existing workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Workspace entity. Required. + :type payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, service_name: str, payload: Union[_models.Workspace, IO], **kwargs: Any + ) -> _models.Workspace: + """Create or update workspace. + + Creates new or updates existing workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. Required. + :type service_name: str + :param payload: Workspace entity. Is either a Workspace type or a IO type. Required. + :type payload: ~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 + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.apicenter.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(payload, (IOBase, bytes)): + _content = payload + else: + _json = self._serialize.body(payload, "Workspace") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + deserialized = self._deserialize("Workspace", pipeline_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, **kwargs: Any + ) -> None: + """Delete workspace. + + Deletes specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: Service name. 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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" + } + + @distributed_trace + def head(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Check if workspace exists. + + Checks if specified workspace 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: Service name. Required. + :type service_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 = { + 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, + subscription_id=self._config.subscription_id, + workspace_name=self._config.workspace_name, + 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) + + _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, {}) + 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_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_create_or_update.py new file mode 100644 index 0000000000000..ba172a92bb822 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_create_or_update.py @@ -0,0 +1,49 @@ +# 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_definitions_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(), + api_name="openapi", + version_name="2023-01-01", + definition_name="openapi", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_definitions.create_or_update( + resource_group_name="contoso-resources", + service_name="contoso", + payload={"properties": {"description": "Default spec", "title": "OpenAPI"}}, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_CreateOrUpdate.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 0000000000000..d79dfa1f39c4f --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_delete.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 api_definitions_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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="openapi", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.api_definitions.delete( + resource_group_name="contoso-resources", + service_name="contoso", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..ddb0bbba94f40 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_export_specification.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_definitions_export_specification.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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="openapi", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_definitions.export_specification( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..b49ec62b4ec31 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_get.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_definitions_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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="openapi", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_definitions.get( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..c7bd35a50564f --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_head.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_definitions_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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="openapi", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_definitions.head( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_Head.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_import_specification.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_import_specification.py new file mode 100644 index 0000000000000..82faea6eca18d --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_import_specification.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_definitions_import_specification.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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="openapi", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.api_definitions.import_specification( + resource_group_name="contoso-resources", + service_name="contoso", + payload={"format": "link", "specification": {"name": "openapi", "version": "3.0.1"}, "value": "https://..."}, + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_ImportSpecification.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 new file mode 100644 index 0000000000000..59f979440eda7 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_definitions_list.py @@ -0,0 +1,49 @@ +# 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_definitions_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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_definitions.list( + resource_group_name="contoso-resources", + service_name="contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiDefinitions_List.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_create_or_update.py new file mode 100644 index 0000000000000..774afb0f99beb --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_create_or_update.py @@ -0,0 +1,49 @@ +# 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_versions_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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_versions.create_or_update( + resource_group_name="contoso-resources", + service_name="contoso", + payload={"properties": {"lifecycleStage": "production", "title": "2023-01-01"}}, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiVersions_CreateOrUpdate.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 new file mode 100644 index 0000000000000..3ad8f2a688418 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_delete.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 api_versions_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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.api_versions.delete( + resource_group_name="contoso-resources", + service_name="contoso", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..2289146d2420f --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_get.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_versions_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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_versions.get( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..a5d7458229121 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_head.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python api_versions_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(), + api_name="echo-api", + version_name="2023-01-01", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_versions.head( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..f69ce7c26d975 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/api_versions_list.py @@ -0,0 +1,49 @@ +# 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_versions_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_versions.list( + resource_group_name="contoso-resources", + service_name="contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/ApiVersions_List.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_create_or_update.py new file mode 100644 index 0000000000000..ce9001b37507c --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_create_or_update.py @@ -0,0 +1,60 @@ +# 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 apis_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.apis.create_or_update( + resource_group_name="contoso-resources", + service_name="contoso", + payload={ + "properties": { + "customProperties": {"author": "John Doe"}, + "description": "A simple HTTP request/response service.", + "externalDocumentation": [{"title": "Onboarding docs", "url": "https://docs.contoso.com"}], + "kind": "rest", + "license": {"url": "https://contoso.com/license"}, + "lifecycleStage": "design", + "termsOfService": {"url": "https://contoso.com/terms-of-service"}, + "title": "Echo API", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Apis_CreateOrUpdate.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 new file mode 100644 index 0000000000000..f3f36f4e63eb3 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_delete.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 apis_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.apis.delete( + resource_group_name="contoso-resources", + service_name="contoso", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..629c6fef164bf --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_get.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python apis_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.apis.get( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..521863ef895dc --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_head.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python apis_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.apis.head( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..4f182ae3185f7 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/apis_list.py @@ -0,0 +1,49 @@ +# 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 apis_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.apis.list( + resource_group_name="contoso-resources", + service_name="contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Apis_List.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_create_or_update.py new file mode 100644 index 0000000000000..8d5cae2c6e3f2 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_create_or_update.py @@ -0,0 +1,58 @@ +# 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 deployments_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="production", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.deployments.create_or_update( + resource_group_name="contoso-resources", + service_name="contoso", + payload={ + "properties": { + "definitionId": "/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi", + "description": "Public cloud production deployment.", + "environmentId": "/workspaces/default/environments/production", + "server": {"runtimeUri": ["https://api.contoso.com"]}, + "state": "active", + "title": "Production deployment", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Deployments_CreateOrUpdate.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 new file mode 100644 index 0000000000000..90d40fbcf00a0 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_delete.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 deployments_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="production", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.deployments.delete( + resource_group_name="contoso-resources", + service_name="contoso", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..b22bb2d66413a --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_get.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python deployments_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="production", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.deployments.get( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..69c2732b26da4 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_head.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python deployments_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="production", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.deployments.head( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..9b7dd3317194d --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/deployments_list.py @@ -0,0 +1,49 @@ +# 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 deployments_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(), + api_name="echo-api", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.deployments.list( + resource_group_name="contoso-resources", + service_name="contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Deployments_List.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_create_or_update.py new file mode 100644 index 0000000000000..b8b382881a62e --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_create_or_update.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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python environments_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="public", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.environments.create_or_update( + resource_group_name="contoso-resources", + service_name="contoso", + payload={ + "properties": { + "description": "The primary Azure API Management service for the European division of Contoso.", + "kind": "production", + "onboarding": { + "developerPortalUri": ["https://developer.contoso.com"], + "instructions": "Sign in or sign up in the specified developer portal to request API access. You must complete the internal privacy training for your account to be approved.", + }, + "server": { + "managementPortalUri": [ + "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiManagement/service/contoso" + ], + "type": "Azure API Management", + }, + "title": "Contoso Europe Azure API Management", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Environments_CreateOrUpdate.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 new file mode 100644 index 0000000000000..54512332e0285 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_delete.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 environments_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="public", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.environments.delete( + resource_group_name="contoso-resources", + service_name="contoso", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..34a3a0b475852 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_get.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python environments_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="public", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.environments.get( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..9d252c73d2e76 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_head.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python environments_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="public", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.environments.head( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..edf6c53b7c10d --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/environments_list.py @@ -0,0 +1,49 @@ +# 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 environments_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.environments.list( + resource_group_name="contoso-resources", + service_name="contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Environments_List.json +if __name__ == "__main__": + main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_create_or_update.py new file mode 100644 index 0000000000000..00eaee2dae728 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_create_or_update.py @@ -0,0 +1,54 @@ +# 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 metadata_schemas_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="author", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.metadata_schemas.create_or_update( + resource_group_name="contoso-resources", + service_name="contoso", + payload={ + "properties": { + "assignedTo": [{"deprecated": True, "entity": "api"}], + "schema": '{"type":"string", "title":"Author", pattern: "^[a-zA-Z]+$"}', + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/MetadataSchemas_CreateOrUpdate.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 new file mode 100644 index 0000000000000..f02537d73d741 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_delete.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 metadata_schemas_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="author", + workspace_name="WORKSPACE_NAME", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.metadata_schemas.delete( + resource_group_name="contoso-resources", + service_name="contoso", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..9b0d83cc4ff5c --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_get.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python metadata_schemas_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="lastName", + workspace_name="WORKSPACE_NAME", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.metadata_schemas.get( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..3d2309aa2d40c --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_head.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python metadata_schemas_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="author", + workspace_name="WORKSPACE_NAME", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.metadata_schemas.head( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..30fc8149a751e --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/metadata_schemas_list.py @@ -0,0 +1,49 @@ +# 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 metadata_schemas_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.metadata_schemas.list( + resource_group_name="contoso-resources", + service_name="contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 469f571e85d61..ed818c0f1cf64 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/operations_list.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/operations_list.py @@ -26,6 +26,13 @@ def main(): client = ApiCenterMgmtClient( credential=DefaultAzureCredential(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", subscription_id="SUBSCRIPTION_ID", ) @@ -34,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Operations_List.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 e339cbf569141..fb0ad6c8ead2e 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 @@ -26,6 +26,13 @@ def main(): client = ApiCenterMgmtClient( credential=DefaultAzureCredential(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", subscription_id="00000000-0000-0000-0000-000000000000", ) @@ -36,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_CreateOrUpdate.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 9f75fd6c7b3c0..7d8ae2084ecdd 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_delete.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_delete.py @@ -26,6 +26,13 @@ def main(): client = ApiCenterMgmtClient( credential=DefaultAzureCredential(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", subscription_id="00000000-0000-0000-0000-000000000000", ) @@ -35,6 +42,6 @@ def main(): ) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Delete.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_Delete.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_export_metadata_schema.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_export_metadata_schema.py new file mode 100644 index 0000000000000..5ee8ae8e54aa3 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_export_metadata_schema.py @@ -0,0 +1,49 @@ +# 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_export_metadata_schema.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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.services.export_metadata_schema( + resource_group_name="contoso-resources", + service_name="contoso", + payload={"assignedTo": "api"}, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_ExportMetadataSchema.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 627cd7be91d50..d2f7cec8bf82f 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_get.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_get.py @@ -26,6 +26,13 @@ def main(): client = ApiCenterMgmtClient( credential=DefaultAzureCredential(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", subscription_id="00000000-0000-0000-0000-000000000000", ) @@ -36,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Get.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_Get.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 cd60fac064d32..893498f878c42 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 @@ -26,6 +26,13 @@ def main(): client = ApiCenterMgmtClient( credential=DefaultAzureCredential(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", subscription_id="00000000-0000-0000-0000-000000000000", ) @@ -36,6 +43,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_ListByResourceGroup.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 9f175d1cc5733..af617d11f12ac 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 @@ -26,6 +26,13 @@ def main(): client = ApiCenterMgmtClient( credential=DefaultAzureCredential(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", subscription_id="00000000-0000-0000-0000-000000000000", ) @@ -34,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_ListBySubscription.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_update.py index d0577769ed27c..a5a7d2b002323 100644 --- a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_update.py +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/services_update.py @@ -26,6 +26,13 @@ def main(): client = ApiCenterMgmtClient( credential=DefaultAzureCredential(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", subscription_id="00000000-0000-0000-0000-000000000000", ) @@ -36,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Update.json +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Services_Update.json if __name__ == "__main__": main() diff --git a/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_create_or_update.py b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_create_or_update.py new file mode 100644 index 0000000000000..25fe22b95fe55 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_create_or_update.py @@ -0,0 +1,49 @@ +# 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 workspaces_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspaces.create_or_update( + resource_group_name="contoso-resources", + service_name="contoso", + payload={"properties": {"title": "default"}}, + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Workspaces_CreateOrUpdate.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 new file mode 100644 index 0000000000000..105928d2bdb6e --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_delete.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 workspaces_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspaces.delete( + resource_group_name="contoso-resources", + service_name="contoso", + ) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..b2e1fd5fa8261 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_get.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python workspaces_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspaces.get( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..a4e242616dfe2 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_head.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.apicenter import ApiCenterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apicenter +# USAGE + python workspaces_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="default", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspaces.head( + resource_group_name="contoso-resources", + service_name="contoso", + ) + print(response) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/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 new file mode 100644 index 0000000000000..6b49f080a9d41 --- /dev/null +++ b/sdk/apicenter/azure-mgmt-apicenter/generated_samples/workspaces_list.py @@ -0,0 +1,49 @@ +# 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 workspaces_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(), + api_name="API_NAME", + version_name="VERSION_NAME", + definition_name="DEFINITION_NAME", + deployment_name="DEPLOYMENT_NAME", + environment_name="ENVIRONMENT_NAME", + metadata_schema_name="METADATA_SCHEMA_NAME", + workspace_name="WORKSPACE_NAME", + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspaces.list( + resource_group_name="contoso-resources", + service_name="contoso", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apicenter/resource-manager/Microsoft.ApiCenter/stable/2024-03-01/examples/Workspaces_List.json +if __name__ == "__main__": + main()