diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/CHANGELOG.md b/sdk/managedapplications/azure-mgmt-managedapplications/CHANGELOG.md index c680ce9a7847..e24be282afd5 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/CHANGELOG.md +++ b/sdk/managedapplications/azure-mgmt-managedapplications/CHANGELOG.md @@ -1,5 +1,31 @@ # Release History +## 1.0.0b2 (2026-07-08) + +### Features Added + + - Client `ManagedApplicationsMgmtClient` added parameter `cloud_setting` in method `__init__` + - Client `ManagedApplicationsMgmtClient` added method `portal_registry_package` + - Client `ManagedApplicationsMgmtClient` added method `send_request` + - Added model `RegistryPackage` + - Added model `RegistryPackageLinks` + - Added model `RegistryPackagePlan` + +### Breaking Changes + + - This version introduces new hybrid models which have dual dictionary and model nature. Please follow https://aka.ms/azsdk/python/migrate/hybrid-models for migration. + - Model `Application` moved instance variable `managed_resource_group_id`, `application_definition_id`, `parameters`, `outputs`, `provisioning_state`, `billing_details`, `jit_access_policy`, `publisher_tenant_id`, `authorizations`, `management_mode`, `customer_support`, `support_urls`, `artifacts`, `created_by` and `updated_by` under property `properties` whose type is `ApplicationProperties` + - Model `ApplicationDefinition` moved instance variable `lock_level`, `display_name`, `is_enabled`, `authorizations`, `artifacts`, `description`, `package_file_uri`, `storage_account_id`, `main_template`, `create_ui_definition`, `notification_policy`, `locking_policy`, `deployment_policy`, `management_policy` and `policies` under property `properties` whose type is `ApplicationDefinitionProperties` + - Model `ApplicationPatchable` moved instance variable `managed_resource_group_id`, `application_definition_id`, `parameters`, `outputs`, `provisioning_state`, `billing_details`, `jit_access_policy`, `publisher_tenant_id`, `authorizations`, `management_mode`, `customer_support`, `support_urls`, `artifacts`, `created_by` and `updated_by` under property `properties` whose type is `ApplicationProperties` + - Model `JitRequestDefinition` moved instance variable `application_resource_id`, `publisher_tenant_id`, `jit_authorization_policies`, `jit_scheduling_policy`, `provisioning_state`, `jit_request_state`, `created_by` and `updated_by` under property `properties` whose type is `JitRequestProperties` + - Deleted or renamed operation group `ManagedApplicationsMgmtClientOperationsMixin` + - Method `ApplicationsOperations.begin_update` changed return type from `LROPoller[ApplicationPatchable]` to `LROPoller[Application]` + - Method `ApplicationsOperations.begin_update_by_id` changed return type from `LROPoller[ApplicationPatchable]` to `LROPoller[Application]` + +### Other Changes + + - Deleted model `ApplicationDefinitionListResult`/`ApplicationListResult`/`OperationListResult` which actually were not used by SDK users + ## 1.0.0b1 (2023-09-20) * Initial Release diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/MANIFEST.in b/sdk/managedapplications/azure-mgmt-managedapplications/MANIFEST.in index 5adcbff4582e..6a3ef325cce8 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/MANIFEST.in +++ b/sdk/managedapplications/azure-mgmt-managedapplications/MANIFEST.in @@ -1,8 +1,7 @@ -include _meta.json -recursive-include tests *.py *.json -recursive-include samples *.py *.md include *.md -include azure/__init__.py -include azure/mgmt/__init__.py include LICENSE include azure/mgmt/managedapplications/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/README.md b/sdk/managedapplications/azure-mgmt-managedapplications/README.md index bc9c1667c21e..faf505989093 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/README.md +++ b/sdk/managedapplications/azure-mgmt-managedapplications/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Managedapplications Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.10+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.10+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Microsoft Entra](https://learn.microsoft.com/entra/fundamentals/what-is-entra) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - - diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/_meta.json b/sdk/managedapplications/azure-mgmt-managedapplications/_meta.json deleted file mode 100644 index e45ae288d3de..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "baa82396a21dcc1c79a6aeea185589749515012d", - "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/solutions/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", - "readme": "specification/solutions/resource-manager/readme.md" -} \ No newline at end of file diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/_metadata.json b/sdk/managedapplications/azure-mgmt-managedapplications/_metadata.json new file mode 100644 index 000000000000..58f806bb8a69 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/_metadata.json @@ -0,0 +1,11 @@ +{ + "apiVersion": "2023-12-01-preview", + "apiVersions": { + "Microsoft.Solutions": "2023-12-01-preview" + }, + "commit": "ea850a065dc8679f82dc3fdbba9ceff53eeba116", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/solutions/Solutions.Management", + "emitterVersion": "0.63.2", + "httpClientPythonVersion": "^0.34.1" +} \ No newline at end of file diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/api.md b/sdk/managedapplications/azure-mgmt-managedapplications/api.md new file mode 100644 index 000000000000..450d773a2f0b --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/api.md @@ -0,0 +1,2721 @@ +```py +namespace azure.mgmt.managedapplications + + class azure.mgmt.managedapplications.ManagedApplicationsMgmtClient(_ManagedApplicationsMgmtClientOperationsMixin): implements ContextManager + application_definitions: ApplicationDefinitionsOperations + applications: ApplicationsOperations + jit_requests: JitRequestsOperations + + def __init__( + self, + credential: TokenCredential, + subscription_id: str, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + polling_interval: Optional[int] = ..., + **kwargs: Any + ) -> None: ... + + def close(self) -> None: ... + + @distributed_trace + def list_operations(self, **kwargs: Any) -> ItemPaged[Operation]: ... + + @overload + def portal_registry_package( + self, + parameters: RegistryPackagePlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> RegistryPackage: ... + + @overload + def portal_registry_package( + self, + parameters: RegistryPackagePlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> RegistryPackage: ... + + @overload + def portal_registry_package( + self, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> RegistryPackage: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> HttpResponse: ... + + +namespace azure.mgmt.managedapplications.aio + + class azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient(_ManagedApplicationsMgmtClientOperationsMixin): implements AsyncContextManager + application_definitions: ApplicationDefinitionsOperations + applications: ApplicationsOperations + jit_requests: JitRequestsOperations + + def __init__( + self, + credential: AsyncTokenCredential, + subscription_id: str, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + polling_interval: Optional[int] = ..., + **kwargs: Any + ) -> None: ... + + async def close(self) -> None: ... + + @distributed_trace + def list_operations(self, **kwargs: Any) -> AsyncItemPaged[Operation]: ... + + @overload + async def portal_registry_package( + self, + parameters: RegistryPackagePlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> RegistryPackage: ... + + @overload + async def portal_registry_package( + self, + parameters: RegistryPackagePlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> RegistryPackage: ... + + @overload + async def portal_registry_package( + self, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> RegistryPackage: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: ... + + +namespace azure.mgmt.managedapplications.aio.operations + + class azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace_async + async def delete_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[ApplicationDefinition]: ... + + @distributed_trace_async + async def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[ApplicationDefinition]: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncItemPaged[ApplicationDefinition]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged[ApplicationDefinition]: ... + + @overload + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + + class azure.mgmt.managedapplications.aio.operations.ApplicationsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def begin_delete_by_id( + self, + application_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def begin_refresh_permissions( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: UpdateAccessDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[UpdateAccessDefinition]: ... + + @overload + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: UpdateAccessDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[UpdateAccessDefinition]: ... + + @overload + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[UpdateAccessDefinition]: ... + + @overload + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @overload + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Application]: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[Application]: ... + + @distributed_trace_async + async def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[Application]: ... + + @distributed_trace_async + async def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AllowedUpgradePlansResult: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncItemPaged[Application]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged[Application]: ... + + @overload + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: ListTokenRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ManagedIdentityTokenResult: ... + + @overload + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: ListTokenRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ManagedIdentityTokenResult: ... + + @overload + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ManagedIdentityTokenResult: ... + + + class azure.mgmt.managedapplications.aio.operations.JitRequestsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: JitRequestDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[JitRequestDefinition]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: JitRequestDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[JitRequestDefinition]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[JitRequestDefinition]: ... + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[JitRequestDefinition]: ... + + @distributed_trace_async + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> JitRequestDefinitionListResult: ... + + @distributed_trace_async + async def list_by_subscription(self, **kwargs: Any) -> JitRequestDefinitionListResult: ... + + @overload + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: JitRequestPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JitRequestDefinition: ... + + @overload + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: JitRequestPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JitRequestDefinition: ... + + @overload + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JitRequestDefinition: ... + + +namespace azure.mgmt.managedapplications.models + + class azure.mgmt.managedapplications.models.ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + INTERNAL = "Internal" + + + class azure.mgmt.managedapplications.models.AllowedUpgradePlansResult(_Model): + value: Optional[list[Plan]] + + @overload + def __init__( + self, + *, + value: Optional[list[Plan]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.Application(GenericResource): + id: str + identity: Optional[Identity] + kind: str + location: str + managed_by: str + name: str + plan: Optional[Plan] + properties: ApplicationProperties + sku: Sku + system_data: SystemData + tags: dict[str, str] + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + identity: Optional[Identity] = ..., + kind: str, + location: Optional[str] = ..., + managed_by: Optional[str] = ..., + plan: Optional[Plan] = ..., + properties: ApplicationProperties, + sku: Optional[Sku] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationArtifact(_Model): + name: Union[str, ApplicationArtifactName] + type: Union[str, ApplicationArtifactType] + uri: str + + @overload + def __init__( + self, + *, + name: Union[str, ApplicationArtifactName], + type: Union[str, ApplicationArtifactType], + uri: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + AUTHORIZATIONS = "Authorizations" + CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + NOT_SPECIFIED = "NotSpecified" + VIEW_DEFINITION = "ViewDefinition" + + + class azure.mgmt.managedapplications.models.ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + CUSTOM = "Custom" + NOT_SPECIFIED = "NotSpecified" + TEMPLATE = "Template" + + + class azure.mgmt.managedapplications.models.ApplicationAuthorization(_Model): + principal_id: str + role_definition_id: str + + @overload + def __init__( + self, + *, + principal_id: str, + role_definition_id: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationBillingDetailsDefinition(_Model): + resource_usage_id: Optional[str] + + @overload + def __init__( + self, + *, + resource_usage_id: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationClientDetails(_Model): + application_id: Optional[str] + oid: Optional[str] + puid: Optional[str] + + @overload + def __init__( + self, + *, + application_id: Optional[str] = ..., + oid: Optional[str] = ..., + puid: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationDefinition(GenericResource): + id: str + location: str + managed_by: str + name: str + properties: ApplicationDefinitionProperties + sku: Sku + system_data: SystemData + tags: dict[str, str] + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + location: Optional[str] = ..., + managed_by: Optional[str] = ..., + properties: ApplicationDefinitionProperties, + sku: Optional[Sku] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationDefinitionArtifact(_Model): + name: Union[str, ApplicationDefinitionArtifactName] + type: Union[str, ApplicationArtifactType] + uri: str + + @overload + def __init__( + self, + *, + name: Union[str, ApplicationDefinitionArtifactName], + type: Union[str, ApplicationArtifactType], + uri: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + CREATE_UI_DEFINITION = "CreateUiDefinition" + MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + NOT_SPECIFIED = "NotSpecified" + + + class azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable(_Model): + tags: Optional[dict[str, str]] + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationDefinitionProperties(_Model): + artifacts: Optional[list[ApplicationDefinitionArtifact]] + authorizations: Optional[list[ApplicationAuthorization]] + create_ui_definition: Optional[Any] + deployment_policy: Optional[ApplicationDeploymentPolicy] + description: Optional[str] + display_name: Optional[str] + is_enabled: Optional[bool] + lock_level: Union[str, ApplicationLockLevel] + locking_policy: Optional[ApplicationPackageLockingPolicyDefinition] + main_template: Optional[Any] + management_policy: Optional[ApplicationManagementPolicy] + notification_policy: Optional[ApplicationNotificationPolicy] + package_file_uri: Optional[str] + policies: Optional[list[ApplicationPolicy]] + storage_account_id: Optional[str] + + @overload + def __init__( + self, + *, + artifacts: Optional[list[ApplicationDefinitionArtifact]] = ..., + authorizations: Optional[list[ApplicationAuthorization]] = ..., + create_ui_definition: Optional[Any] = ..., + deployment_policy: Optional[ApplicationDeploymentPolicy] = ..., + description: Optional[str] = ..., + display_name: Optional[str] = ..., + is_enabled: Optional[bool] = ..., + lock_level: Union[str, ApplicationLockLevel], + locking_policy: Optional[ApplicationPackageLockingPolicyDefinition] = ..., + main_template: Optional[Any] = ..., + management_policy: Optional[ApplicationManagementPolicy] = ..., + notification_policy: Optional[ApplicationNotificationPolicy] = ..., + package_file_uri: Optional[str] = ..., + policies: Optional[list[ApplicationPolicy]] = ..., + storage_account_id: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationDeploymentPolicy(_Model): + deployment_mode: Union[str, DeploymentMode] + + @overload + def __init__( + self, + *, + deployment_mode: Union[str, DeploymentMode] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationJitAccessPolicy(_Model): + jit_access_enabled: bool + jit_approval_mode: Optional[Union[str, JitApprovalMode]] + jit_approvers: Optional[list[JitApproverDefinition]] + maximum_jit_access_duration: Optional[str] + + @overload + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, JitApprovalMode]] = ..., + jit_approvers: Optional[list[JitApproverDefinition]] = ..., + maximum_jit_access_duration: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + CAN_NOT_DELETE = "CanNotDelete" + NONE = "None" + READ_ONLY = "ReadOnly" + + + class azure.mgmt.managedapplications.models.ApplicationManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + MANAGED = "Managed" + NOT_SPECIFIED = "NotSpecified" + UNMANAGED = "Unmanaged" + + + class azure.mgmt.managedapplications.models.ApplicationManagementPolicy(_Model): + mode: Optional[Union[str, ApplicationManagementMode]] + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, ApplicationManagementMode]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationNotificationEndpoint(_Model): + uri: str + + @overload + def __init__( + self, + *, + uri: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationNotificationPolicy(_Model): + notification_endpoints: list[ApplicationNotificationEndpoint] + + @overload + def __init__( + self, + *, + notification_endpoints: list[ApplicationNotificationEndpoint] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationPackageContact(_Model): + contact_name: Optional[str] + email: str + phone: str + + @overload + def __init__( + self, + *, + contact_name: Optional[str] = ..., + email: str, + phone: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationPackageLockingPolicyDefinition(_Model): + allowed_actions: Optional[list[str]] + allowed_data_actions: Optional[list[str]] + + @overload + def __init__( + self, + *, + allowed_actions: Optional[list[str]] = ..., + allowed_data_actions: Optional[list[str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationPackageSupportUrls(_Model): + government_cloud: Optional[str] + public_azure: Optional[str] + + @overload + def __init__( + self, + *, + government_cloud: Optional[str] = ..., + public_azure: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationPatchable(GenericResource): + id: str + identity: Optional[Identity] + kind: Optional[str] + location: str + managed_by: str + name: str + plan: Optional[PlanPatchable] + properties: Optional[ApplicationProperties] + sku: Sku + system_data: SystemData + tags: dict[str, str] + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + identity: Optional[Identity] = ..., + kind: Optional[str] = ..., + location: Optional[str] = ..., + managed_by: Optional[str] = ..., + plan: Optional[PlanPatchable] = ..., + properties: Optional[ApplicationProperties] = ..., + sku: Optional[Sku] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationPolicy(_Model): + name: Optional[str] + parameters: Optional[str] + policy_definition_id: Optional[str] + + @overload + def __init__( + self, + *, + name: Optional[str] = ..., + parameters: Optional[str] = ..., + policy_definition_id: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ApplicationProperties(_Model): + application_definition_id: Optional[str] + artifacts: Optional[list[ApplicationArtifact]] + authorizations: Optional[list[ApplicationAuthorization]] + billing_details: Optional[ApplicationBillingDetailsDefinition] + created_by: Optional[ApplicationClientDetails] + customer_support: Optional[ApplicationPackageContact] + jit_access_policy: Optional[ApplicationJitAccessPolicy] + managed_resource_group_id: Optional[str] + management_mode: Optional[Union[str, ApplicationManagementMode]] + outputs: Optional[Any] + parameters: Optional[Any] + provisioning_state: Optional[Union[str, ProvisioningState]] + publisher_tenant_id: Optional[str] + support_urls: Optional[ApplicationPackageSupportUrls] + updated_by: Optional[ApplicationClientDetails] + + @overload + def __init__( + self, + *, + application_definition_id: Optional[str] = ..., + jit_access_policy: Optional[ApplicationJitAccessPolicy] = ..., + managed_resource_group_id: Optional[str] = ..., + parameters: Optional[Any] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPLICATION = "Application" + KEY = "Key" + MANAGED_IDENTITY = "ManagedIdentity" + USER = "User" + + + class azure.mgmt.managedapplications.models.DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + COMPLETE = "Complete" + INCREMENTAL = "Incremental" + NOT_SPECIFIED = "NotSpecified" + + + class azure.mgmt.managedapplications.models.ErrorAdditionalInfo(_Model): + info: Optional[Any] + type: Optional[str] + + + class azure.mgmt.managedapplications.models.ErrorDetail(_Model): + additional_info: Optional[list[ErrorAdditionalInfo]] + code: Optional[str] + details: Optional[list[ErrorDetail]] + message: Optional[str] + target: Optional[str] + + + class azure.mgmt.managedapplications.models.ErrorResponse(_Model): + error: Optional[ErrorDetail] + + @overload + def __init__( + self, + *, + error: Optional[ErrorDetail] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.GenericResource(Resource): + id: str + location: str + managed_by: Optional[str] + name: str + sku: Optional[Sku] + system_data: SystemData + tags: dict[str, str] + type: str + + @overload + def __init__( + self, + *, + location: Optional[str] = ..., + managed_by: Optional[str] = ..., + sku: Optional[Sku] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.Identity(_Model): + principal_id: Optional[str] + tenant_id: Optional[str] + type: Optional[Union[str, ResourceIdentityType]] + user_assigned_identities: Optional[dict[str, UserAssignedResourceIdentity]] + + @overload + def __init__( + self, + *, + type: Optional[Union[str, ResourceIdentityType]] = ..., + user_assigned_identities: Optional[dict[str, UserAssignedResourceIdentity]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + AUTO_APPROVE = "AutoApprove" + MANUAL_APPROVE = "ManualApprove" + NOT_SPECIFIED = "NotSpecified" + + + class azure.mgmt.managedapplications.models.JitApproverDefinition(_Model): + display_name: Optional[str] + id: str + type: Optional[Union[str, JitApproverType]] + + @overload + def __init__( + self, + *, + display_name: Optional[str] = ..., + id: str, + type: Optional[Union[str, JitApproverType]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + GROUP = "group" + USER = "user" + + + class azure.mgmt.managedapplications.models.JitAuthorizationPolicies(_Model): + principal_id: str + role_definition_id: str + + @overload + def __init__( + self, + *, + principal_id: str, + role_definition_id: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.JitRequestDefinition(Resource): + id: str + location: str + name: str + properties: Optional[JitRequestProperties] + system_data: SystemData + tags: dict[str, str] + type: str + + def __getattr__(self, name: str) -> Any: ... + + @overload + def __init__( + self, + *, + location: Optional[str] = ..., + properties: Optional[JitRequestProperties] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + def __setattr__( + self, + key: str, + value: Any + ) -> None: ... + + + class azure.mgmt.managedapplications.models.JitRequestDefinitionListResult(_Model): + next_link: Optional[str] + value: list[JitRequestDefinition] + + @overload + def __init__( + self, + *, + next_link: Optional[str] = ..., + value: list[JitRequestDefinition] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.JitRequestMetadata(_Model): + origin_request_id: Optional[str] + requestor_id: Optional[str] + subject_display_name: Optional[str] + tenant_display_name: Optional[str] + + @overload + def __init__( + self, + *, + origin_request_id: Optional[str] = ..., + requestor_id: Optional[str] = ..., + subject_display_name: Optional[str] = ..., + tenant_display_name: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.JitRequestPatchable(_Model): + tags: Optional[dict[str, str]] + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.JitRequestProperties(_Model): + application_resource_id: str + created_by: Optional[ApplicationClientDetails] + jit_authorization_policies: list[JitAuthorizationPolicies] + jit_request_state: Optional[Union[str, JitRequestState]] + jit_scheduling_policy: JitSchedulingPolicy + provisioning_state: Optional[Union[str, ProvisioningState]] + publisher_tenant_id: Optional[str] + updated_by: Optional[ApplicationClientDetails] + + @overload + def __init__( + self, + *, + application_resource_id: str, + jit_authorization_policies: list[JitAuthorizationPolicies], + jit_scheduling_policy: JitSchedulingPolicy + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPROVED = "Approved" + CANCELED = "Canceled" + DENIED = "Denied" + EXPIRED = "Expired" + FAILED = "Failed" + NOT_SPECIFIED = "NotSpecified" + PENDING = "Pending" + TIMEOUT = "Timeout" + + + class azure.mgmt.managedapplications.models.JitSchedulingPolicy(_Model): + duration: timedelta + start_time: datetime + type: Union[str, JitSchedulingType] + + @overload + def __init__( + self, + *, + duration: timedelta, + start_time: datetime, + type: Union[str, JitSchedulingType] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + NOT_SPECIFIED = "NotSpecified" + ONCE = "Once" + RECURRING = "Recurring" + + + class azure.mgmt.managedapplications.models.ListTokenRequest(_Model): + authorization_audience: Optional[str] + user_assigned_identities: Optional[list[str]] + + @overload + def __init__( + self, + *, + authorization_audience: Optional[str] = ..., + user_assigned_identities: Optional[list[str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ManagedIdentityToken(_Model): + access_token: Optional[str] + authorization_audience: Optional[str] + expires_in: Optional[str] + expires_on: Optional[str] + not_before: Optional[str] + resource_id: Optional[str] + token_type: Optional[str] + + @overload + def __init__( + self, + *, + access_token: Optional[str] = ..., + authorization_audience: Optional[str] = ..., + expires_in: Optional[str] = ..., + expires_on: Optional[str] = ..., + not_before: Optional[str] = ..., + resource_id: Optional[str] = ..., + token_type: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ManagedIdentityTokenResult(_Model): + value: Optional[list[ManagedIdentityToken]] + + @overload + def __init__( + self, + *, + value: Optional[list[ManagedIdentityToken]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.Operation(_Model): + action_type: Optional[Union[str, ActionType]] + display: Optional[OperationDisplay] + is_data_action: Optional[bool] + name: Optional[str] + origin: Optional[Union[str, Origin]] + + @overload + def __init__( + self, + *, + display: Optional[OperationDisplay] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.OperationDisplay(_Model): + description: Optional[str] + operation: Optional[str] + provider: Optional[str] + resource: Optional[str] + + + class azure.mgmt.managedapplications.models.Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + SYSTEM = "system" + USER = "user" + USER_SYSTEM = "user,system" + + + class azure.mgmt.managedapplications.models.Plan(_Model): + name: str + product: str + promotion_code: Optional[str] + publisher: str + version: str + + @overload + def __init__( + self, + *, + name: str, + product: str, + promotion_code: Optional[str] = ..., + publisher: str, + version: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.PlanPatchable(_Model): + name: Optional[str] + product: Optional[str] + promotion_code: Optional[str] + publisher: Optional[str] + version: Optional[str] + + @overload + def __init__( + self, + *, + name: Optional[str] = ..., + product: Optional[str] = ..., + promotion_code: Optional[str] = ..., + publisher: Optional[str] = ..., + version: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ACCEPTED = "Accepted" + CANCELED = "Canceled" + DELETED = "Deleted" + DELETING = "Deleting" + FAILED = "Failed" + NOT_SPECIFIED = "NotSpecified" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + + + class azure.mgmt.managedapplications.models.RegistryPackage(_Model): + offer: str + package_links: RegistryPackageLinks + plan: str + publisher: str + version: str + + @overload + def __init__( + self, + *, + offer: str, + package_links: RegistryPackageLinks, + plan: str, + publisher: str, + version: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.RegistryPackageLinks(_Model): + create_ui_definition_link: Optional[str] + deployment_template_link: Optional[str] + + @overload + def __init__( + self, + *, + create_ui_definition_link: Optional[str] = ..., + deployment_template_link: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.RegistryPackagePlan(_Model): + offer: str + plan: str + publisher: str + version: Optional[str] + + @overload + def __init__( + self, + *, + offer: str, + plan: str, + publisher: str, + version: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.Resource(_Model): + id: Optional[str] + location: Optional[str] + name: Optional[str] + system_data: Optional[SystemData] + tags: Optional[dict[str, str]] + type: Optional[str] + + @overload + def __init__( + self, + *, + location: Optional[str] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + USER_ASSIGNED = "UserAssigned" + + + class azure.mgmt.managedapplications.models.Sku(_Model): + capacity: Optional[int] + family: Optional[str] + model: Optional[str] + name: str + size: Optional[str] + tier: Optional[str] + + @overload + def __init__( + self, + *, + capacity: Optional[int] = ..., + family: Optional[str] = ..., + model: Optional[str] = ..., + name: str, + size: Optional[str] = ..., + tier: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ELEVATE = "Elevate" + NOT_SPECIFIED = "NotSpecified" + REMOVE = "Remove" + + + class azure.mgmt.managedapplications.models.Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPROVED = "Approved" + DENIED = "Denied" + EXPIRED = "Expired" + FAILED = "Failed" + NOT_SPECIFIED = "NotSpecified" + TIMEOUT = "Timeout" + + + class azure.mgmt.managedapplications.models.SystemData(_Model): + created_at: Optional[datetime] + created_by: Optional[str] + created_by_type: Optional[Union[str, CreatedByType]] + last_modified_at: Optional[datetime] + last_modified_by: Optional[str] + last_modified_by_type: Optional[Union[str, CreatedByType]] + + @overload + def __init__( + self, + *, + created_at: Optional[datetime] = ..., + created_by: Optional[str] = ..., + created_by_type: Optional[Union[str, CreatedByType]] = ..., + last_modified_at: Optional[datetime] = ..., + last_modified_by: Optional[str] = ..., + last_modified_by_type: Optional[Union[str, CreatedByType]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.UpdateAccessDefinition(_Model): + approver: Optional[str] + metadata: JitRequestMetadata + status: Union[str, Status] + sub_status: Union[str, Substatus] + + @overload + def __init__( + self, + *, + approver: Optional[str] = ..., + metadata: JitRequestMetadata, + status: Union[str, Status], + sub_status: Union[str, Substatus] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.managedapplications.models.UserAssignedResourceIdentity(_Model): + principal_id: Optional[str] + tenant_id: Optional[str] + + +namespace azure.mgmt.managedapplications.operations + + class azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @distributed_trace + def delete( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace + def delete_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[ApplicationDefinition]: ... + + @distributed_trace + def get_by_id( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs: Any + ) -> Optional[ApplicationDefinition]: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> ItemPaged[ApplicationDefinition]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged[ApplicationDefinition]: ... + + @overload + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + @overload + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ApplicationDefinition: ... + + + class azure.mgmt.managedapplications.operations.ApplicationsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def begin_delete_by_id( + self, + application_id: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def begin_refresh_permissions( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: UpdateAccessDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[UpdateAccessDefinition]: ... + + @overload + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: UpdateAccessDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[UpdateAccessDefinition]: ... + + @overload + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[UpdateAccessDefinition]: ... + + @overload + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @overload + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Application]: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> Optional[Application]: ... + + @distributed_trace + def get_by_id( + self, + application_id: str, + **kwargs: Any + ) -> Optional[Application]: ... + + @distributed_trace + def list_allowed_upgrade_plans( + self, + resource_group_name: str, + application_name: str, + **kwargs: Any + ) -> AllowedUpgradePlansResult: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> ItemPaged[Application]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged[Application]: ... + + @overload + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: ListTokenRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ManagedIdentityTokenResult: ... + + @overload + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: ListTokenRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ManagedIdentityTokenResult: ... + + @overload + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> ManagedIdentityTokenResult: ... + + + class azure.mgmt.managedapplications.operations.JitRequestsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: JitRequestDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[JitRequestDefinition]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: JitRequestDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[JitRequestDefinition]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[JitRequestDefinition]: ... + + @distributed_trace + def delete( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + jit_request_name: str, + **kwargs: Any + ) -> Optional[JitRequestDefinition]: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> JitRequestDefinitionListResult: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> JitRequestDefinitionListResult: ... + + @overload + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: JitRequestPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JitRequestDefinition: ... + + @overload + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: JitRequestPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JitRequestDefinition: ... + + @overload + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JitRequestDefinition: ... + + +namespace azure.mgmt.managedapplications.types + + class azure.mgmt.managedapplications.types.Application(GenericResource): + key "id": str + key "identity": ForwardRef('Identity', module='types') + key "kind": Required[str] + key "location": str + key "managedBy": str + key "name": str + key "plan": ForwardRef('Plan', module='types') + key "properties": Required[ApplicationProperties] + key "sku": ForwardRef('Sku', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + identity: Identity + kind: str + location: str + managed_by: str + name: str + plan: Plan + properties: ApplicationProperties + sku: Sku + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.managedapplications.types.ApplicationArtifact(TypedDict, total=False): + key "name": Required[Union[str, ApplicationArtifactName]] + key "type": Required[Union[str, ApplicationArtifactType]] + key "uri": Required[str] + name: Union[str, ApplicationArtifactName] + type: Union[str, ApplicationArtifactType] + uri: str + + + class azure.mgmt.managedapplications.types.ApplicationAuthorization(TypedDict, total=False): + key "principalId": Required[str] + key "roleDefinitionId": Required[str] + principal_id: str + role_definition_id: str + + + class azure.mgmt.managedapplications.types.ApplicationBillingDetailsDefinition(TypedDict, total=False): + key "resourceUsageId": str + resource_usage_id: str + + + class azure.mgmt.managedapplications.types.ApplicationClientDetails(TypedDict, total=False): + key "applicationId": str + key "oid": str + key "puid": str + application_id: str + oid: str + puid: str + + + class azure.mgmt.managedapplications.types.ApplicationDefinition(GenericResource): + key "id": str + key "location": str + key "managedBy": str + key "name": str + key "properties": Required[ApplicationDefinitionProperties] + key "sku": ForwardRef('Sku', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + location: str + managed_by: str + name: str + properties: ApplicationDefinitionProperties + sku: Sku + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.managedapplications.types.ApplicationDefinitionArtifact(TypedDict, total=False): + key "name": Required[Union[str, ApplicationDefinitionArtifactName]] + key "type": Required[Union[str, ApplicationArtifactType]] + key "uri": Required[str] + name: Union[str, ApplicationDefinitionArtifactName] + type: Union[str, ApplicationArtifactType] + uri: str + + + class azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable(TypedDict, total=False): + tags: dict[str, str] + + + class azure.mgmt.managedapplications.types.ApplicationDefinitionProperties(TypedDict, total=False): + key "createUiDefinition": Any + key "deploymentPolicy": ForwardRef('ApplicationDeploymentPolicy', module='types') + key "description": str + key "displayName": str + key "isEnabled": bool + key "lockLevel": Required[Union[str, ApplicationLockLevel]] + key "lockingPolicy": ForwardRef('ApplicationPackageLockingPolicyDefinition', module='types') + key "mainTemplate": Any + key "managementPolicy": ForwardRef('ApplicationManagementPolicy', module='types') + key "notificationPolicy": ForwardRef('ApplicationNotificationPolicy', module='types') + key "packageFileUri": str + key "storageAccountId": str + artifacts: list[ApplicationDefinitionArtifact] + authorizations: list[ApplicationAuthorization] + create_ui_definition: Any + deployment_policy: ApplicationDeploymentPolicy + description: str + display_name: str + is_enabled: bool + lock_level: Union[str, ApplicationLockLevel] + locking_policy: ApplicationPackageLockingPolicyDefinition + main_template: Any + management_policy: ApplicationManagementPolicy + notification_policy: ApplicationNotificationPolicy + package_file_uri: str + policies: list[ApplicationPolicy] + storage_account_id: str + + + class azure.mgmt.managedapplications.types.ApplicationDeploymentPolicy(TypedDict, total=False): + key "deploymentMode": Required[Union[str, DeploymentMode]] + deployment_mode: Union[str, DeploymentMode] + + + class azure.mgmt.managedapplications.types.ApplicationJitAccessPolicy(TypedDict, total=False): + key "jitAccessEnabled": Required[bool] + key "jitApprovalMode": Union[str, JitApprovalMode] + key "maximumJitAccessDuration": str + jitApprovers: list[JitApproverDefinition] + jit_access_enabled: bool + jit_approval_mode: Union[str, JitApprovalMode] + jit_approvers: list[JitApproverDefinition] + maximum_jit_access_duration: str + + + class azure.mgmt.managedapplications.types.ApplicationManagementPolicy(TypedDict, total=False): + key "mode": Union[str, ApplicationManagementMode] + mode: Union[str, ApplicationManagementMode] + + + class azure.mgmt.managedapplications.types.ApplicationNotificationEndpoint(TypedDict, total=False): + key "uri": Required[str] + uri: str + + + class azure.mgmt.managedapplications.types.ApplicationNotificationPolicy(TypedDict, total=False): + key "notificationEndpoints": Required[list[ApplicationNotificationEndpoint]] + notification_endpoints: list[ApplicationNotificationEndpoint] + + + class azure.mgmt.managedapplications.types.ApplicationPackageContact(TypedDict, total=False): + key "contactName": str + key "email": Required[str] + key "phone": Required[str] + contact_name: str + email: str + phone: str + + + class azure.mgmt.managedapplications.types.ApplicationPackageLockingPolicyDefinition(TypedDict, total=False): + allowedActions: list[str] + allowedDataActions: list[str] + allowed_actions: list[str] + allowed_data_actions: list[str] + + + class azure.mgmt.managedapplications.types.ApplicationPackageSupportUrls(TypedDict, total=False): + key "governmentCloud": str + key "publicAzure": str + government_cloud: str + public_azure: str + + + class azure.mgmt.managedapplications.types.ApplicationPatchable(GenericResource): + key "id": str + key "identity": ForwardRef('Identity', module='types') + key "kind": str + key "location": str + key "managedBy": str + key "name": str + key "plan": ForwardRef('PlanPatchable', module='types') + key "properties": ForwardRef('ApplicationProperties', module='types') + key "sku": ForwardRef('Sku', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + identity: Identity + kind: str + location: str + managed_by: str + name: str + plan: PlanPatchable + properties: ApplicationProperties + sku: Sku + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.managedapplications.types.ApplicationPolicy(TypedDict, total=False): + key "name": str + key "parameters": str + key "policyDefinitionId": str + name: str + parameters: str + policy_definition_id: str + + + class azure.mgmt.managedapplications.types.ApplicationProperties(TypedDict, total=False): + key "applicationDefinitionId": str + key "billingDetails": ForwardRef('ApplicationBillingDetailsDefinition', module='types') + key "createdBy": ForwardRef('ApplicationClientDetails', module='types') + key "customerSupport": ForwardRef('ApplicationPackageContact', module='types') + key "jitAccessPolicy": ForwardRef('ApplicationJitAccessPolicy', module='types') + key "managedResourceGroupId": str + key "managementMode": Union[str, ApplicationManagementMode] + key "outputs": Any + key "parameters": Any + key "provisioningState": Union[str, ProvisioningState] + key "publisherTenantId": str + key "supportUrls": ForwardRef('ApplicationPackageSupportUrls', module='types') + key "updatedBy": ForwardRef('ApplicationClientDetails', module='types') + application_definition_id: str + artifacts: list[ApplicationArtifact] + authorizations: list[ApplicationAuthorization] + billing_details: ApplicationBillingDetailsDefinition + created_by: ApplicationClientDetails + customer_support: ApplicationPackageContact + jit_access_policy: ApplicationJitAccessPolicy + managed_resource_group_id: str + management_mode: Union[str, ApplicationManagementMode] + outputs: Any + parameters: Any + provisioning_state: Union[str, ProvisioningState] + publisher_tenant_id: str + support_urls: ApplicationPackageSupportUrls + updated_by: ApplicationClientDetails + + + class azure.mgmt.managedapplications.types.GenericResource(Resource): + key "id": str + key "location": str + key "managedBy": str + key "name": str + key "sku": ForwardRef('Sku', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + location: str + managed_by: str + name: str + sku: Sku + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.managedapplications.types.Identity(TypedDict, total=False): + key "principalId": str + key "tenantId": str + key "type": Union[str, ResourceIdentityType] + principal_id: str + tenant_id: str + type: Union[str, ResourceIdentityType] + userAssignedIdentities: dict[str, UserAssignedResourceIdentity] + user_assigned_identities: dict[str, UserAssignedResourceIdentity] + + + class azure.mgmt.managedapplications.types.JitApproverDefinition(TypedDict, total=False): + key "displayName": str + key "id": Required[str] + key "type": Union[str, JitApproverType] + display_name: str + id: str + type: Union[str, JitApproverType] + + + class azure.mgmt.managedapplications.types.JitAuthorizationPolicies(TypedDict, total=False): + key "principalId": Required[str] + key "roleDefinitionId": Required[str] + principal_id: str + role_definition_id: str + + + class azure.mgmt.managedapplications.types.JitRequestDefinition(Resource): + key "id": str + key "location": str + key "name": str + key "properties": ForwardRef('JitRequestProperties', module='types') + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + location: str + name: str + properties: JitRequestProperties + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.managedapplications.types.JitRequestMetadata(TypedDict, total=False): + key "originRequestId": str + key "requestorId": str + key "subjectDisplayName": str + key "tenantDisplayName": str + origin_request_id: str + requestor_id: str + subject_display_name: str + tenant_display_name: str + + + class azure.mgmt.managedapplications.types.JitRequestPatchable(TypedDict, total=False): + tags: dict[str, str] + + + class azure.mgmt.managedapplications.types.JitRequestProperties(TypedDict, total=False): + key "applicationResourceId": Required[str] + key "createdBy": ForwardRef('ApplicationClientDetails', module='types') + key "jitAuthorizationPolicies": Required[list[JitAuthorizationPolicies]] + key "jitRequestState": Union[str, JitRequestState] + key "jitSchedulingPolicy": Required[JitSchedulingPolicy] + key "provisioningState": Union[str, ProvisioningState] + key "publisherTenantId": str + key "updatedBy": ForwardRef('ApplicationClientDetails', module='types') + application_resource_id: str + created_by: ApplicationClientDetails + jit_authorization_policies: list[JitAuthorizationPolicies] + jit_request_state: Union[str, JitRequestState] + jit_scheduling_policy: JitSchedulingPolicy + provisioning_state: Union[str, ProvisioningState] + publisher_tenant_id: str + updated_by: ApplicationClientDetails + + + class azure.mgmt.managedapplications.types.JitSchedulingPolicy(TypedDict, total=False): + key "duration": Required[str] + key "startTime": Required[str] + key "type": Required[Union[str, JitSchedulingType]] + duration: str + start_time: str + type: Union[str, JitSchedulingType] + + + class azure.mgmt.managedapplications.types.ListTokenRequest(TypedDict, total=False): + key "authorizationAudience": str + authorization_audience: str + userAssignedIdentities: list[str] + user_assigned_identities: list[str] + + + class azure.mgmt.managedapplications.types.Plan(TypedDict, total=False): + key "name": Required[str] + key "product": Required[str] + key "promotionCode": str + key "publisher": Required[str] + key "version": Required[str] + name: str + product: str + promotion_code: str + publisher: str + version: str + + + class azure.mgmt.managedapplications.types.PlanPatchable(TypedDict, total=False): + key "name": str + key "product": str + key "promotionCode": str + key "publisher": str + key "version": str + name: str + product: str + promotion_code: str + publisher: str + version: str + + + class azure.mgmt.managedapplications.types.RegistryPackagePlan(TypedDict, total=False): + key "offer": Required[str] + key "plan": Required[str] + key "publisher": Required[str] + key "version": str + offer: str + plan: str + publisher: str + version: str + + + class azure.mgmt.managedapplications.types.Resource(TypedDict, total=False): + key "id": str + key "location": str + key "name": str + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + location: str + name: str + system_data: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.managedapplications.types.Sku(TypedDict, total=False): + key "capacity": int + key "family": str + key "model": str + key "name": Required[str] + key "size": str + key "tier": str + capacity: int + family: str + model: str + name: str + size: str + tier: str + + + class azure.mgmt.managedapplications.types.SystemData(TypedDict, total=False): + key "createdAt": str + key "createdBy": str + key "createdByType": Union[str, CreatedByType] + key "lastModifiedAt": str + key "lastModifiedBy": str + key "lastModifiedByType": Union[str, CreatedByType] + created_at: str + created_by: str + created_by_type: Union[str, CreatedByType] + last_modified_at: str + last_modified_by: str + last_modified_by_type: Union[str, CreatedByType] + + + class azure.mgmt.managedapplications.types.UpdateAccessDefinition(TypedDict, total=False): + key "Approver": str + key "Metadata": Required[JitRequestMetadata] + key "Status": Required[Union[str, Status]] + key "SubStatus": Required[Union[str, Substatus]] + approver: str + metadata: JitRequestMetadata + status: Union[str, Status] + sub_status: Union[str, Substatus] + + + class azure.mgmt.managedapplications.types.UserAssignedResourceIdentity(TypedDict, total=False): + key "principalId": str + key "tenantId": str + principal_id: str + tenant_id: str + + +``` \ No newline at end of file diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/api.metadata.yml b/sdk/managedapplications/azure-mgmt-managedapplications/api.metadata.yml new file mode 100644 index 000000000000..6ba188017881 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/api.metadata.yml @@ -0,0 +1,3 @@ +apiMdSha256: ec3d009884dca8cd52dca42fd8efea402604be3b1ec69eafd6b910ac240638a2 +parserVersion: 0.3.28 +pythonVersion: 3.13.14 diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/apiview-properties.json b/sdk/managedapplications/azure-mgmt-managedapplications/apiview-properties.json new file mode 100644 index 000000000000..fd8118176036 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/apiview-properties.json @@ -0,0 +1,136 @@ +{ + "CrossLanguagePackageId": "Microsoft.Solutions", + "CrossLanguageDefinitionId": { + "azure.mgmt.managedapplications.models.AllowedUpgradePlansResult": "Microsoft.Solutions.AllowedUpgradePlansResult", + "azure.mgmt.managedapplications.models.Resource": "Microsoft.Solutions.Resource", + "azure.mgmt.managedapplications.models.GenericResource": "Microsoft.Solutions.GenericResource", + "azure.mgmt.managedapplications.models.Application": "Microsoft.Solutions.Application", + "azure.mgmt.managedapplications.models.ApplicationArtifact": "Microsoft.Solutions.ApplicationArtifact", + "azure.mgmt.managedapplications.models.ApplicationAuthorization": "Microsoft.Solutions.ApplicationAuthorization", + "azure.mgmt.managedapplications.models.ApplicationBillingDetailsDefinition": "Microsoft.Solutions.ApplicationBillingDetailsDefinition", + "azure.mgmt.managedapplications.models.ApplicationClientDetails": "Microsoft.Solutions.ApplicationClientDetails", + "azure.mgmt.managedapplications.models.ApplicationDefinition": "Microsoft.Solutions.ApplicationDefinition", + "azure.mgmt.managedapplications.models.ApplicationDefinitionArtifact": "Microsoft.Solutions.ApplicationDefinitionArtifact", + "azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable": "Microsoft.Solutions.ApplicationDefinitionPatchable", + "azure.mgmt.managedapplications.models.ApplicationDefinitionProperties": "Microsoft.Solutions.ApplicationDefinitionProperties", + "azure.mgmt.managedapplications.models.ApplicationDeploymentPolicy": "Microsoft.Solutions.ApplicationDeploymentPolicy", + "azure.mgmt.managedapplications.models.ApplicationJitAccessPolicy": "Microsoft.Solutions.ApplicationJitAccessPolicy", + "azure.mgmt.managedapplications.models.ApplicationManagementPolicy": "Microsoft.Solutions.ApplicationManagementPolicy", + "azure.mgmt.managedapplications.models.ApplicationNotificationEndpoint": "Microsoft.Solutions.ApplicationNotificationEndpoint", + "azure.mgmt.managedapplications.models.ApplicationNotificationPolicy": "Microsoft.Solutions.ApplicationNotificationPolicy", + "azure.mgmt.managedapplications.models.ApplicationPackageContact": "Microsoft.Solutions.ApplicationPackageContact", + "azure.mgmt.managedapplications.models.ApplicationPackageLockingPolicyDefinition": "Microsoft.Solutions.ApplicationPackageLockingPolicyDefinition", + "azure.mgmt.managedapplications.models.ApplicationPackageSupportUrls": "Microsoft.Solutions.ApplicationPackageSupportUrls", + "azure.mgmt.managedapplications.models.ApplicationPatchable": "Microsoft.Solutions.ApplicationPatchable", + "azure.mgmt.managedapplications.models.ApplicationPolicy": "Microsoft.Solutions.ApplicationPolicy", + "azure.mgmt.managedapplications.models.ApplicationProperties": "Microsoft.Solutions.ApplicationProperties", + "azure.mgmt.managedapplications.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.managedapplications.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.managedapplications.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.managedapplications.models.Identity": "Microsoft.Solutions.Identity", + "azure.mgmt.managedapplications.models.JitApproverDefinition": "Microsoft.Solutions.JitApproverDefinition", + "azure.mgmt.managedapplications.models.JitAuthorizationPolicies": "Microsoft.Solutions.JitAuthorizationPolicies", + "azure.mgmt.managedapplications.models.JitRequestDefinition": "Microsoft.Solutions.JitRequestDefinition", + "azure.mgmt.managedapplications.models.JitRequestDefinitionListResult": "Azure.ResourceManager.ResourceListResult", + "azure.mgmt.managedapplications.models.JitRequestMetadata": "Microsoft.Solutions.JitRequestMetadata", + "azure.mgmt.managedapplications.models.JitRequestPatchable": "Microsoft.Solutions.JitRequestPatchable", + "azure.mgmt.managedapplications.models.JitRequestProperties": "Microsoft.Solutions.JitRequestProperties", + "azure.mgmt.managedapplications.models.JitSchedulingPolicy": "Microsoft.Solutions.JitSchedulingPolicy", + "azure.mgmt.managedapplications.models.ListTokenRequest": "Microsoft.Solutions.ListTokenRequest", + "azure.mgmt.managedapplications.models.ManagedIdentityToken": "Microsoft.Solutions.ManagedIdentityToken", + "azure.mgmt.managedapplications.models.ManagedIdentityTokenResult": "Microsoft.Solutions.ManagedIdentityTokenResult", + "azure.mgmt.managedapplications.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", + "azure.mgmt.managedapplications.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "azure.mgmt.managedapplications.models.Plan": "Microsoft.Solutions.Plan", + "azure.mgmt.managedapplications.models.PlanPatchable": "Microsoft.Solutions.PlanPatchable", + "azure.mgmt.managedapplications.models.RegistryPackage": "Microsoft.Solutions.RegistryPackage", + "azure.mgmt.managedapplications.models.RegistryPackageLinks": "Microsoft.Solutions.RegistryPackageLinks", + "azure.mgmt.managedapplications.models.RegistryPackagePlan": "Microsoft.Solutions.RegistryPackagePlan", + "azure.mgmt.managedapplications.models.Sku": "Microsoft.Solutions.Sku", + "azure.mgmt.managedapplications.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.managedapplications.models.UpdateAccessDefinition": "Microsoft.Solutions.UpdateAccessDefinition", + "azure.mgmt.managedapplications.models.UserAssignedResourceIdentity": "Microsoft.Solutions.userAssignedResourceIdentity", + "azure.mgmt.managedapplications.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.managedapplications.models.ProvisioningState": "Microsoft.Solutions.ProvisioningState", + "azure.mgmt.managedapplications.models.JitApprovalMode": "Microsoft.Solutions.JitApprovalMode", + "azure.mgmt.managedapplications.models.JitApproverType": "Microsoft.Solutions.JitApproverType", + "azure.mgmt.managedapplications.models.ApplicationManagementMode": "Microsoft.Solutions.ApplicationManagementMode", + "azure.mgmt.managedapplications.models.ApplicationArtifactName": "Microsoft.Solutions.ApplicationArtifactName", + "azure.mgmt.managedapplications.models.ApplicationArtifactType": "Microsoft.Solutions.ApplicationArtifactType", + "azure.mgmt.managedapplications.models.ResourceIdentityType": "Microsoft.Solutions.ResourceIdentityType", + "azure.mgmt.managedapplications.models.Status": "Microsoft.Solutions.Status", + "azure.mgmt.managedapplications.models.Substatus": "Microsoft.Solutions.Substatus", + "azure.mgmt.managedapplications.models.ApplicationLockLevel": "Microsoft.Solutions.ApplicationLockLevel", + "azure.mgmt.managedapplications.models.ApplicationDefinitionArtifactName": "Microsoft.Solutions.ApplicationDefinitionArtifactName", + "azure.mgmt.managedapplications.models.DeploymentMode": "Microsoft.Solutions.DeploymentMode", + "azure.mgmt.managedapplications.models.JitSchedulingType": "Microsoft.Solutions.JitSchedulingType", + "azure.mgmt.managedapplications.models.JitRequestState": "Microsoft.Solutions.JitRequestState", + "azure.mgmt.managedapplications.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.managedapplications.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.get": "Microsoft.Solutions.Applications.get", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.get": "Microsoft.Solutions.Applications.get", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.begin_create_or_update": "Microsoft.Solutions.Applications.createOrUpdate", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.begin_create_or_update": "Microsoft.Solutions.Applications.createOrUpdate", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.begin_update": "Microsoft.Solutions.Applications.update", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.begin_update": "Microsoft.Solutions.Applications.update", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.begin_delete": "Microsoft.Solutions.Applications.delete", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.begin_delete": "Microsoft.Solutions.Applications.delete", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.list_by_resource_group": "Microsoft.Solutions.Applications.listByResourceGroup", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.list_by_resource_group": "Microsoft.Solutions.Applications.listByResourceGroup", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.list_by_subscription": "Microsoft.Solutions.Applications.listBySubscription", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.list_by_subscription": "Microsoft.Solutions.Applications.listBySubscription", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.begin_refresh_permissions": "Microsoft.Solutions.Applications.refreshPermissions", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.begin_refresh_permissions": "Microsoft.Solutions.Applications.refreshPermissions", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.list_allowed_upgrade_plans": "Microsoft.Solutions.Applications.listAllowedUpgradePlans", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.list_allowed_upgrade_plans": "Microsoft.Solutions.Applications.listAllowedUpgradePlans", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.begin_update_access": "Microsoft.Solutions.Applications.updateAccess", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.begin_update_access": "Microsoft.Solutions.Applications.updateAccess", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.list_tokens": "Microsoft.Solutions.Applications.listTokens", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.list_tokens": "Microsoft.Solutions.Applications.listTokens", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.get_by_id": "Microsoft.Solutions.ApplicationsOperationGroup.getById", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.get_by_id": "Microsoft.Solutions.ApplicationsOperationGroup.getById", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.begin_create_or_update_by_id": "Microsoft.Solutions.ApplicationsOperationGroup.createOrUpdateById", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.begin_create_or_update_by_id": "Microsoft.Solutions.ApplicationsOperationGroup.createOrUpdateById", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.begin_update_by_id": "Microsoft.Solutions.ApplicationsOperationGroup.updateById", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.begin_update_by_id": "Microsoft.Solutions.ApplicationsOperationGroup.updateById", + "azure.mgmt.managedapplications.operations.ApplicationsOperations.begin_delete_by_id": "Microsoft.Solutions.ApplicationsOperationGroup.deleteById", + "azure.mgmt.managedapplications.aio.operations.ApplicationsOperations.begin_delete_by_id": "Microsoft.Solutions.ApplicationsOperationGroup.deleteById", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.get": "Microsoft.Solutions.ApplicationDefinitions.get", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.get": "Microsoft.Solutions.ApplicationDefinitions.get", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.create_or_update": "Microsoft.Solutions.ApplicationDefinitions.createOrUpdate", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.create_or_update": "Microsoft.Solutions.ApplicationDefinitions.createOrUpdate", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.update": "Microsoft.Solutions.ApplicationDefinitions.update", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.update": "Microsoft.Solutions.ApplicationDefinitions.update", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.delete": "Microsoft.Solutions.ApplicationDefinitions.delete", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.delete": "Microsoft.Solutions.ApplicationDefinitions.delete", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.get_by_id": "Microsoft.Solutions.ApplicationDefinitionOpsById.getById", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.get_by_id": "Microsoft.Solutions.ApplicationDefinitionOpsById.getById", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.create_or_update_by_id": "Microsoft.Solutions.ApplicationDefinitionOpsById.createOrUpdateById", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.create_or_update_by_id": "Microsoft.Solutions.ApplicationDefinitionOpsById.createOrUpdateById", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.update_by_id": "Microsoft.Solutions.ApplicationDefinitionOpsById.updateById", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.update_by_id": "Microsoft.Solutions.ApplicationDefinitionOpsById.updateById", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.delete_by_id": "Microsoft.Solutions.ApplicationDefinitionOpsById.deleteById", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.delete_by_id": "Microsoft.Solutions.ApplicationDefinitionOpsById.deleteById", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.list_by_resource_group": "Microsoft.Solutions.ApplicationDefinitionListOperationGroup.listByResourceGroup", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.list_by_resource_group": "Microsoft.Solutions.ApplicationDefinitionListOperationGroup.listByResourceGroup", + "azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations.list_by_subscription": "Microsoft.Solutions.ApplicationDefinitionListOperationGroup.listBySubscription", + "azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations.list_by_subscription": "Microsoft.Solutions.ApplicationDefinitionListOperationGroup.listBySubscription", + "azure.mgmt.managedapplications.operations.JitRequestsOperations.get": "Microsoft.Solutions.JitRequestDefinitions.get", + "azure.mgmt.managedapplications.aio.operations.JitRequestsOperations.get": "Microsoft.Solutions.JitRequestDefinitions.get", + "azure.mgmt.managedapplications.operations.JitRequestsOperations.begin_create_or_update": "Microsoft.Solutions.JitRequestDefinitions.createOrUpdate", + "azure.mgmt.managedapplications.aio.operations.JitRequestsOperations.begin_create_or_update": "Microsoft.Solutions.JitRequestDefinitions.createOrUpdate", + "azure.mgmt.managedapplications.operations.JitRequestsOperations.update": "Microsoft.Solutions.JitRequestDefinitions.update", + "azure.mgmt.managedapplications.aio.operations.JitRequestsOperations.update": "Microsoft.Solutions.JitRequestDefinitions.update", + "azure.mgmt.managedapplications.operations.JitRequestsOperations.delete": "Microsoft.Solutions.JitRequestDefinitions.delete", + "azure.mgmt.managedapplications.aio.operations.JitRequestsOperations.delete": "Microsoft.Solutions.JitRequestDefinitions.delete", + "azure.mgmt.managedapplications.operations.JitRequestsOperations.list_by_resource_group": "Microsoft.Solutions.JitRequestDefinitions.listByResourceGroup", + "azure.mgmt.managedapplications.aio.operations.JitRequestsOperations.list_by_resource_group": "Microsoft.Solutions.JitRequestDefinitions.listByResourceGroup", + "azure.mgmt.managedapplications.operations.JitRequestsOperations.list_by_subscription": "Microsoft.Solutions.JitRequestDefinitions.listBySubscription", + "azure.mgmt.managedapplications.aio.operations.JitRequestsOperations.list_by_subscription": "Microsoft.Solutions.JitRequestDefinitions.listBySubscription", + "azure.mgmt.managedapplications.ManagedApplicationsMgmtClient.portal_registry_package": "Microsoft.Solutions.portalRegistryPackage", + "azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient.portal_registry_package": "Microsoft.Solutions.portalRegistryPackage", + "azure.mgmt.managedapplications.ManagedApplicationsMgmtClient.list_operations": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient.list_operations": "Azure.ResourceManager.Legacy.Operations.list" + }, + "CrossLanguageVersion": "b6a0bd578472" +} \ No newline at end of file diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/__init__.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/__init__.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/__init__.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/__init__.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/__init__.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/__init__.py index b23ee650907b..6d8758ad62f7 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/__init__.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/__init__.py @@ -2,18 +2,24 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._managed_applications_mgmt_client import ManagedApplicationsMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import ManagedApplicationsMgmtClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ManagedApplicationsMgmtClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_client.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_client.py new file mode 100644 index 000000000000..70e3ff5f17ce --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_client.py @@ -0,0 +1,154 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +import sys +from typing import Any, Optional, TYPE_CHECKING, cast + +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings +from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints + +from ._configuration import ManagedApplicationsMgmtClientConfiguration +from ._utils.serialization import Deserializer, Serializer +from .operations import ( + ApplicationDefinitionsOperations, + ApplicationsOperations, + JitRequestsOperations, + _ManagedApplicationsMgmtClientOperationsMixin, +) + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + +if TYPE_CHECKING: + from azure.core import AzureClouds + from azure.core.credentials import TokenCredential + + +class ManagedApplicationsMgmtClient(_ManagedApplicationsMgmtClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: azure.mgmt.managedapplications.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: azure.mgmt.managedapplications.operations.JitRequestsOperations + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param base_url: Service host. Default value is None. + :type base_url: str + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2023-12-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = ManagedApplicationsMgmtClientConfiguration( + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs + ) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_configuration.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_configuration.py index f7f8769b3f0b..bd3e22fa6b63 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_configuration.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_configuration.py @@ -2,41 +2,53 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class ManagedApplicationsMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ManagedApplicationsMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ManagedApplicationsMgmtClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :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 "2021-07-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2023-12-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ManagedApplicationsMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-07-01") + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2023-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,9 +57,12 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-managedapplications/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +71,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_managed_applications_mgmt_client.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_managed_applications_mgmt_client.py deleted file mode 100644 index d1516830358d..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_managed_applications_mgmt_client.py +++ /dev/null @@ -1,107 +0,0 @@ -# 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 copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from ._configuration import ManagedApplicationsMgmtClientConfiguration -from ._serialization import Deserializer, Serializer -from .operations import ( - ApplicationDefinitionsOperations, - ApplicationsOperations, - JitRequestsOperations, - ManagedApplicationsMgmtClientOperationsMixin, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class ManagedApplicationsMgmtClient( - ManagedApplicationsMgmtClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword - """ARM applications. - - :ivar applications: ApplicationsOperations operations - :vartype applications: azure.mgmt.managedapplications.operations.ApplicationsOperations - :ivar application_definitions: ApplicationDefinitionsOperations operations - :vartype application_definitions: - azure.mgmt.managedapplications.operations.ApplicationDefinitionsOperations - :ivar jit_requests: JitRequestsOperations operations - :vartype jit_requests: azure.mgmt.managedapplications.operations.JitRequestsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = ManagedApplicationsMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.application_definitions = ApplicationDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.jit_requests = JitRequestsOperations(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. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "ManagedApplicationsMgmtClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_patch.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_patch.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/__init__.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/model_base.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/model_base.py new file mode 100644 index 000000000000..b93f5120d517 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/model_base.py @@ -0,0 +1,1770 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +from azure.core.rest import HttpResponse + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_duration(td: timedelta, format: typing.Optional[str] = None): + """Serialize a timedelta to its wire representation. + + For the ``seconds``/``milliseconds`` encodings the value is converted to a + numeric value, otherwise it falls back to an ISO 8601 duration string. + + :param timedelta td: The timedelta to serialize. + :param str format: The duration encoding format. + :rtype: int or float or str + :return: serialized duration + """ + seconds = td.total_seconds() + if format == "duration-seconds-int": + return int(seconds) + if format == "duration-seconds-float": + return seconds + if format == "duration-milliseconds-int": + return int(seconds * 1000) + if format == "duration-milliseconds-float": + return seconds * 1000 + return _timedelta_as_isostr(td) + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_duration_numeric(attr, unit): + if isinstance(attr, timedelta): + return attr + return timedelta(**{unit: float(attr)}) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, + "duration-seconds-int": functools.partial(_deserialize_duration_numeric, unit="seconds"), + "duration-seconds-float": functools.partial(_deserialize_duration_numeric, unit="seconds"), + "duration-milliseconds-int": functools.partial(_deserialize_duration_numeric, unit="milliseconds"), + "duration-milliseconds-float": functools.partial(_deserialize_duration_numeric, unit="milliseconds"), +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _serialize_duration(o, format) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +# ============================================================================ +# Fast-path scalar deserializer functions for rest_field(deserializer=...) +# These are referenced from rest_field declarations to bypass the generic +# _deserialize -> _deserialize_with_callable chain. +# Only simple/primitive types — no models or container types. +# ============================================================================ + + +def _xml_deser_str(value): + if isinstance(value, ET.Element): + return value.text or "" + return str(value) if value is not None else None + + +def _xml_deser_int(value): + if isinstance(value, ET.Element): + return int(value.text) if value.text else None + return int(value) if value is not None else None + + +def _xml_deser_float(value): + if isinstance(value, ET.Element): + return float(value.text) if value.text else None + return float(value) if value is not None else None + + +def _xml_deser_bool(value): + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + if text in (True, False): + return text + return text.lower() == "true" + + +# pylint: disable=docstring-missing-param +def _xml_deser_bytes(value): + """Deserialize bytes from XML (base64).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes(text) + + +def _xml_deser_bytes_base64url(value): + """Deserialize bytes from XML (base64url).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes_base64(text) + + +def _xml_deser_datetime(value): + """Deserialize a datetime from XML (ISO 8601 / rfc3339).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime(text) + + +def _xml_deser_datetime_rfc7231(value): + """Deserialize a datetime from XML (RFC7231 format).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_rfc7231(text) + + +def _xml_deser_datetime_unix_timestamp(value): + """Deserialize a datetime from XML (Unix timestamp).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_unix_timestamp(float(text)) + + +def _xml_deser_date(value): + """Deserialize a date from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_date(text) + + +def _xml_deser_time(value): + """Deserialize a time from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_time(text) + + +def _xml_deser_duration(value): + """Deserialize a timedelta from XML (ISO 8601 duration).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_duration(text) + + +def _xml_deser_decimal(value): + """Deserialize a Decimal from XML.""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_decimal(text) + + +def _xml_deser_enum_or_str(enum_cls, value): + """Deserialize a Union[EnumType, str] from XML.""" + text = value.text if isinstance(value, ET.Element) else value + if text is None: + return None + try: + return enum_cls(text) + except ValueError: + return text + + +def _extract_xml_model_type(rf_type): + """Extract the concrete Model class from a resolved rf._type partial chain. + + Unwraps ``Optional[Model]`` and ``_deserialize_model(Model, ...)`` + wrappers. Only handles Model and Optional[Model] — other composite + types (List, Dict, Union, etc.) return None and fall through to the + generic ``_deserialize`` path at runtime. + """ + if rf_type is None: + return None + if isinstance(rf_type, type) and _is_model(rf_type): + return rf_type + if not isinstance(rf_type, functools.partial): + return None + func = rf_type.func + args = rf_type.args + if func is _deserialize_with_optional and args: + return _extract_xml_model_type(args[0]) + if func is _deserialize_model and args: + cls = args[0] + return cls if isinstance(cls, type) and _is_model(cls) else None + return None + + +def _build_xml_field_plan( # pylint: disable=docstring-missing-return, docstring-missing-rtype, unused-variable + cls, attr_to_rest_field: dict +) -> list: + """Build a precomputed XML field plan for fast _init_from_xml iteration. + + Called once per model class in __new__. Returns a list of tuples: + (rest_name, xml_name, kind, deser, rf_type, is_optional, items_name) + + kind: 0=wrapped, 1=attribute, 2=unwrapped, 3=text + + For Model and Optional[Model] fields that lack a scalar + ``_deserializer``, this function precomputes the Model class as the + deserializer so ``_init_from_xml`` can call ``ModelClass(element)`` + directly instead of going through the expensive + ``_get_deserialize_callable_from_annotation`` chain at runtime. + """ + model_meta = getattr(cls, "_xml", {}) + model_ns = model_meta.get("ns") or model_meta.get("namespace") + plan = [] + + for rf in attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + deser = rf._deserializer + + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + is_optional = rf._is_optional + + # For Model / Optional[Model] fields without a scalar deserializer, + # precompute the Model class as the deserializer. + if deser is None and rf._type is not None: + model_cls = _extract_xml_model_type(rf._type) + if model_cls is not None: + deser = model_cls + + if prop_meta.get("attribute", False): + plan.append((rf._rest_name, xml_name, 1, deser, rf._type, is_optional, None)) + elif prop_meta.get("unwrapped", False): + items_name = prop_meta.get("itemsName") + if items_name: + items_ns = prop_meta.get("itemsNs") + if items_ns is not None: + xml_ns = items_ns + if xml_ns: + items_name = "{" + xml_ns + "}" + items_name + else: + items_name = xml_name + plan.append((rf._rest_name, xml_name, 2, deser, rf._type, is_optional, items_name)) + elif prop_meta.get("text", False): + plan.append((rf._rest_name, xml_name, 3, deser, rf._type, is_optional, None)) + else: + plan.append((rf._rest_name, xml_name, 0, deser, rf._type, is_optional, None)) + + return plan + + +# pylint: enable=docstring-missing-param +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass: dict[str, typing.Any] = {} + if args: + if isinstance(args[0], ET.Element): + dict_to_pass.update(self._init_from_xml(args[0])) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + # Apply client default values for fields the caller didn't set so that + # defaults are part of `_data` and therefore included during serialization. + for rf in self._attr_to_rest_field.values(): + if rf._default is _UNSET: + continue + if rf._rest_name in dict_to_pass: + continue + dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) + super().__init__(dict_to_pass) + + def _init_from_xml( # pylint: disable=too-many-branches, too-many-statements + self, element: ET.Element + ) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + existed_attr_keys: list[str] = [] + + field_plan = getattr(self, "_xml_field_plan", None) + if field_plan: + for rest_name, xml_name, kind, deser, rf_type, is_optional, items_name in field_plan: + if kind == 0: # wrapped element (most common) + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(item) + else: + result[rest_name] = _deserialize(rf_type, item) + elif kind == 1: # attribute + attr_val = element.get(xml_name) + if attr_val is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(attr_val) + else: + result[rest_name] = attr_val + elif kind == 2: # unwrapped array + items = element.findall(items_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(items_name) + if deser: + result[rest_name] = deser(items) + else: + result[rest_name] = _deserialize(rf_type, items) + elif not is_optional: + existed_attr_keys.append(items_name) + result[rest_name] = [] + elif kind == 3: # text + if element.text is not None: + if deser: + result[rest_name] = deser(element.text) + else: + result[rest_name] = element.text + else: + model_meta = getattr(self, "_xml", {}) + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + # Build XML field plan for fast _init_from_xml (only for XML models) + if getattr(cls, "_xml", None): + cls._xml_field_plan = _build_xml_field_plan(cls, attr_to_rest_field) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._is_optional = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + self._deserializer = deserializer + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name, _UNSET) + if item is _UNSET: + # Field not set by user; return the client default if one exists, otherwise None + return self._default if self._default is not _UNSET else None + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + # Fast path: use _deserializer directly (avoids _serialize/_deserialize chain) + if self._deserializer: + deserialized = self._deserializer(item) + else: + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + deserializer=deserializer, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) + wrapped_element = _create_xml_element( + element_name, + model_meta.get("prefix"), + _model_ns, + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + _set_xml_attribute(wrapped_element, k, v, prop_meta) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": _dict_ns, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": _items_ns, + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: + ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + if _is_model(deserializer): + return deserializer._deserialize(element, []) + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_serialization.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/serialization.py similarity index 73% rename from sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_serialization.py rename to sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/serialization.py index 4bae2292227b..75906e2eb77f 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_serialization.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/serialization.py @@ -1,30 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -39,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -48,11 +29,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, - List, - Mapping, ) try: @@ -63,12 +40,16 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -91,6 +72,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +95,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -124,7 +107,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +126,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -153,6 +138,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -170,13 +160,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -184,80 +167,31 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: - self.additional_properties: Dict[str, Any] = {} - for k in kwargs: + self.additional_properties: Optional[dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -305,13 +246,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -331,7 +282,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -340,7 +295,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,12 +306,14 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -385,12 +342,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -400,30 +360,31 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -431,9 +392,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -445,7 +408,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -453,21 +416,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -506,11 +473,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -545,12 +514,16 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, "unix-time": Serializer.serialize_unix, "duration": Serializer.serialize_duration, + "duration-seconds-int": Serializer.serialize_duration_seconds_int, + "duration-seconds-float": Serializer.serialize_duration_seconds_float, + "duration-milliseconds-int": Serializer.serialize_duration_milliseconds_int, + "duration-milliseconds-float": Serializer.serialize_duration_milliseconds_float, "date": Serializer.serialize_date, "time": Serializer.serialize_time, "decimal": Serializer.serialize_decimal, @@ -561,17 +534,20 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -597,17 +573,19 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -638,7 +616,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -649,7 +628,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,18 +647,18 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) - else: - return serialized + raise SerializationError(msg) from err + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -708,20 +687,22 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -730,30 +711,30 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -763,19 +744,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -784,37 +766,36 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -824,12 +805,11 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) - else: - return self._serialize(data, **kwargs) + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -845,23 +825,33 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -875,8 +865,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -886,15 +875,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -949,9 +936,8 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} @@ -975,7 +961,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -983,6 +969,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -993,7 +980,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1007,7 +994,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1038,56 +1025,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1095,11 +1087,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1109,30 +1102,87 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def _serialize_duration_numeric(attr, scale, as_int): + """Serialize a TimeDelta into a numeric value scaled to the wire unit. + + :param TimeDelta attr: Object to be serialized. + :param int scale: Multiplier applied to total seconds (1 for seconds, 1000 for milliseconds). + :param bool as_int: Whether to truncate the result to an int. + :rtype: int or float + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + value = attr.total_seconds() * scale if isinstance(attr, datetime.timedelta) else attr + return int(value) if as_int else float(value) + + @staticmethod + def serialize_duration_seconds_int(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into an integer number of seconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: int + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1, True) + + @staticmethod + def serialize_duration_seconds_float(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into a floating point number of seconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: float + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1, False) + + @staticmethod + def serialize_duration_milliseconds_int(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into an integer number of milliseconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: int + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1000, True) + + @staticmethod + def serialize_duration_milliseconds_float(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into a floating point number of milliseconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: float + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1000, False) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1145,12 +1195,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1170,19 +1221,20 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1190,17 +1242,17 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1209,14 +1261,15 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1230,7 +1283,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1238,17 +1290,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1285,7 +1349,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1337,22 +1401,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1360,7 +1423,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1369,14 +1432,18 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, "unix-time": Deserializer.deserialize_unix, "duration": Deserializer.deserialize_duration, + "duration-seconds-int": Deserializer.deserialize_duration_seconds, + "duration-seconds-float": Deserializer.deserialize_duration_seconds, + "duration-milliseconds-int": Deserializer.deserialize_duration_milliseconds, + "duration-milliseconds-float": Deserializer.deserialize_duration_milliseconds, "date": Deserializer.deserialize_date, "time": Deserializer.deserialize_time, "decimal": Deserializer.deserialize_decimal, @@ -1389,9 +1456,13 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): } self.deserialize_expected_types = { "duration": (isodate.Duration, datetime.timedelta), + "duration-seconds-int": (isodate.Duration, datetime.timedelta), + "duration-seconds-float": (isodate.Duration, datetime.timedelta), + "duration-milliseconds-int": (isodate.Duration, datetime.timedelta), + "duration-milliseconds-float": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1401,33 +1472,56 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): # Otherwise, result are unexpected self.additional_properties_detection = True - def __call__(self, target_obj, response_data, content_type=None): + def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements """Call the deserializer to process a REST response. :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ + # Fast path for header deserialization: response_data is a plain str or None + # and target_obj is a simple scalar type. This avoids the expensive + # _unpack_content → _deserialize → _classify_target → deserialize_data chain. + if response_data is None: + return None + if target_obj == "str" and isinstance(response_data, str): + return response_data + if isinstance(response_data, str): + if target_obj == "int": + return int(response_data) + if target_obj == "bool": + if response_data in ("true", "1", "True"): + return True + if response_data in ("false", "0", "False"): + return False + return bool(response_data) + if target_obj == "rfc-1123": + return Deserializer.deserialize_rfc(response_data) + if target_obj == "bytearray": + return Deserializer.deserialize_bytearray(response_data) + data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1444,15 +1538,15 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1481,10 +1575,9 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1511,18 +1604,20 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1537,10 +1632,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1558,10 +1655,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1578,31 +1677,42 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1611,15 +1721,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1633,7 +1744,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1652,15 +1767,15 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) - else: - return self._deserialize(obj_type, data) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1677,6 +1792,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1687,20 +1803,21 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1726,11 +1843,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1738,8 +1854,9 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1749,24 +1866,27 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): @@ -1774,6 +1894,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1787,8 +1908,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1800,6 +1920,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1808,12 +1929,11 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1829,8 +1949,9 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1841,8 +1962,9 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1856,24 +1978,26 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1884,8 +2008,9 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1893,32 +2018,75 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) - else: - return duration + raise DeserializationError(msg) from err + return duration + + @staticmethod + def _deserialize_duration_numeric(attr, unit): + """Deserialize a numeric duration value into a TimeDelta object. + + :param float attr: response value to be deserialized. + :param str unit: The wire unit, used as the ``timedelta`` keyword + (``"seconds"`` or ``"milliseconds"``). + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = datetime.timedelta(**{unit: float(attr)}) # type: ignore + except (ValueError, OverflowError, TypeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_duration_seconds(attr): + """Deserialize a numeric number of seconds into a TimeDelta object. + + :param float attr: response value to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + return Deserializer._deserialize_duration_numeric(attr, "seconds") + + @staticmethod + def deserialize_duration_milliseconds(attr): + """Deserialize a numeric number of milliseconds into a TimeDelta object. + + :param float attr: response value to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + return Deserializer._deserialize_duration_numeric(attr, "milliseconds") @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1931,31 +2099,32 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1982,9 +2151,8 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_unix(attr): @@ -1992,15 +2160,16 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_vendor.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/utils.py similarity index 52% rename from sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_vendor.py rename to sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/utils.py index 976841e0d9b4..35c9c836f85f 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_vendor.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_utils/utils.py @@ -1,28 +1,25 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from abc import ABC -from typing import TYPE_CHECKING - -from azure.core.pipeline.transport import HttpRequest - -from ._configuration import ManagedApplicationsMgmtClientConfiguration +from typing import Generic, TYPE_CHECKING, TypeVar if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core import AsyncPipelineClient + from .serialization import Deserializer, Serializer + - from .._serialization import Deserializer, Serializer +TClient = TypeVar("TClient") +TConfig = TypeVar("TConfig") -class ManagedApplicationsMgmtClientMixinABC(ABC): +class ClientMixinABC(ABC, Generic[TClient, TConfig]): """DO NOT use this class. It is for internal typing use only.""" - _client: "AsyncPipelineClient" - _config: ManagedApplicationsMgmtClientConfiguration + _client: TClient + _config: TConfig _serialize: "Serializer" _deserialize: "Deserializer" diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_vendor.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_vendor.py deleted file mode 100644 index a02fa4cc6712..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_vendor.py +++ /dev/null @@ -1,36 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from azure.core.pipeline.transport import HttpRequest - -from ._configuration import ManagedApplicationsMgmtClientConfiguration - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -class ManagedApplicationsMgmtClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: ManagedApplicationsMgmtClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_version.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_version.py index e5754a47ce68..bbcd28b4aa67 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_version.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/_version.py @@ -2,8 +2,8 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "1.0.0b2" diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/__init__.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/__init__.py index aeeeb63c5d65..fa37d86729f1 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/__init__.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/__init__.py @@ -2,15 +2,21 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._managed_applications_mgmt_client import ManagedApplicationsMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import ManagedApplicationsMgmtClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ManagedApplicationsMgmtClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_client.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_client.py new file mode 100644 index 000000000000..f86ef8c15464 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_client.py @@ -0,0 +1,158 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +import sys +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast + +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings +from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints + +from .._utils.serialization import Deserializer, Serializer +from ._configuration import ManagedApplicationsMgmtClientConfiguration +from .operations import ( + ApplicationDefinitionsOperations, + ApplicationsOperations, + JitRequestsOperations, + _ManagedApplicationsMgmtClientOperationsMixin, +) + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + +if TYPE_CHECKING: + from azure.core import AzureClouds + from azure.core.credentials_async import AsyncTokenCredential + + +class ManagedApplicationsMgmtClient(_ManagedApplicationsMgmtClientOperationsMixin): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: azure.mgmt.managedapplications.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations + :ivar jit_requests: JitRequestsOperations operations + :vartype jit_requests: azure.mgmt.managedapplications.aio.operations.JitRequestsOperations + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param base_url: Service host. Default value is None. + :type base_url: str + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2023-12-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = ManagedApplicationsMgmtClientConfiguration( + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs + ) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, _endpoint), policies=_policies, **kwargs + ) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_requests = JitRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_configuration.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_configuration.py index e269b072c2e2..676d443cec92 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_configuration.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_configuration.py @@ -2,41 +2,53 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class ManagedApplicationsMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ManagedApplicationsMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ManagedApplicationsMgmtClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :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 "2021-07-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2023-12-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ManagedApplicationsMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-07-01") + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2023-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,9 +57,12 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-managedapplications/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +71,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_managed_applications_mgmt_client.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_managed_applications_mgmt_client.py deleted file mode 100644 index d867dcf72f07..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_managed_applications_mgmt_client.py +++ /dev/null @@ -1,107 +0,0 @@ -# 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 copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ManagedApplicationsMgmtClientConfiguration -from .operations import ( - ApplicationDefinitionsOperations, - ApplicationsOperations, - JitRequestsOperations, - ManagedApplicationsMgmtClientOperationsMixin, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class ManagedApplicationsMgmtClient( - ManagedApplicationsMgmtClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword - """ARM applications. - - :ivar applications: ApplicationsOperations operations - :vartype applications: azure.mgmt.managedapplications.aio.operations.ApplicationsOperations - :ivar application_definitions: ApplicationDefinitionsOperations operations - :vartype application_definitions: - azure.mgmt.managedapplications.aio.operations.ApplicationDefinitionsOperations - :ivar jit_requests: JitRequestsOperations operations - :vartype jit_requests: azure.mgmt.managedapplications.aio.operations.JitRequestsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = ManagedApplicationsMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.application_definitions = ApplicationDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.jit_requests = JitRequestsOperations(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. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "ManagedApplicationsMgmtClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_patch.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_patch.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/__init__.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/__init__.py index 0597df909301..c2139abdd693 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/__init__.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/__init__.py @@ -2,24 +2,29 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._managed_applications_mgmt_client_operations import ManagedApplicationsMgmtClientOperationsMixin -from ._applications_operations import ApplicationsOperations -from ._application_definitions_operations import ApplicationDefinitionsOperations -from ._jit_requests_operations import JitRequestsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import ApplicationsOperations # type: ignore +from ._operations import ApplicationDefinitionsOperations # type: ignore +from ._operations import JitRequestsOperations # type: ignore +from ._operations import _ManagedApplicationsMgmtClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ManagedApplicationsMgmtClientOperationsMixin", "ApplicationsOperations", "ApplicationDefinitionsOperations", "JitRequestsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_application_definitions_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_application_definitions_operations.py deleted file mode 100644 index 96e6c3545515..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_application_definitions_operations.py +++ /dev/null @@ -1,1087 +0,0 @@ -# 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._application_definitions_operations import ( - build_create_or_update_by_id_request, - build_create_or_update_request, - build_delete_by_id_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_by_id_request, - build_update_request, -) -from .._vendor import ManagedApplicationsMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApplicationDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient`'s - :attr:`application_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_async - async def get( - self, resource_group_name: str, application_definition_name: str, **kwargs: Any - ) -> Optional[_models.ApplicationDefinition]: - """Gets the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition 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.ApplicationDefinition]] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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, 404]: - 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("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, application_definition_name: str, **kwargs: Any - ) -> None: - """Deletes the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 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, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: _models.ApplicationDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an managed application - definition. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an managed application - definition. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: Union[_models.ApplicationDefinition, IO], - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an managed application - definition. Is either a ApplicationDefinition type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition 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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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.ApplicationDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ApplicationDefinition") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @overload - async def update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: _models.ApplicationDefinitionPatchable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. - Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable - :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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. - Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: Union[_models.ApplicationDefinitionPatchable, IO], - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. Is - either a ApplicationDefinitionPatchable type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable 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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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.ApplicationDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ApplicationDefinitionPatchable") - - request = build_update_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ApplicationDefinition"]: - """Lists the managed application definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.ApplicationDefinition] - :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.ApplicationDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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("ApplicationDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ApplicationDefinition"]: - """Lists all the application definitions within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.ApplicationDefinition] - :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.ApplicationDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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("ApplicationDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions" - } - - @distributed_trace_async - async def get_by_id( - self, resource_group_name: str, application_definition_name: str, **kwargs: Any - ) -> Optional[_models.ApplicationDefinition]: - """Gets the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition 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.ApplicationDefinition]] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.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, 404]: - 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("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @distributed_trace_async - async def delete_by_id( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, application_definition_name: str, **kwargs: Any - ) -> None: - """Deletes the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 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_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_by_id.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_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @overload - async def create_or_update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: _models.ApplicationDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update a managed application - definition. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update a managed application - definition. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: Union[_models.ApplicationDefinition, IO], - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update a managed application - definition. Is either a ApplicationDefinition type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition 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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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.ApplicationDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ApplicationDefinition") - - request = build_create_or_update_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @overload - async def update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: _models.ApplicationDefinitionPatchable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. - Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable - :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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. - Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: Union[_models.ApplicationDefinitionPatchable, IO], - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. Is - either a ApplicationDefinitionPatchable type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable 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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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.ApplicationDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ApplicationDefinitionPatchable") - - request = build_update_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_applications_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_applications_operations.py deleted file mode 100644 index e8a432e12e3c..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_applications_operations.py +++ /dev/null @@ -1,2036 +0,0 @@ -# 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, cast, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._applications_operations import ( - build_create_or_update_by_id_request, - build_create_or_update_request, - build_delete_by_id_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_allowed_upgrade_plans_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_list_tokens_request, - build_refresh_permissions_request, - build_update_access_request, - build_update_by_id_request, - build_update_request, -) -from .._vendor import ManagedApplicationsMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApplicationsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient`'s - :attr:`applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> Optional[_models.Application]: - """Gets the managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.Application 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.Application]] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - 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("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> None: - 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, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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, 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_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - application_name=application_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - async def _create_or_update_initial( - self, resource_group_name: str, application_name: str, parameters: Union[_models.Application, IO], **kwargs: Any - ) -> _models.Application: - 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.Application] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Application") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Application", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - application_name: str, - parameters: _models.Application, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Application]: - """Creates or updates a managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to the create or update a managed application. Required. - :type parameters: ~azure.mgmt.managedapplications.models.Application - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - application_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Application]: - """Creates or updates a managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to the create or update a managed application. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, application_name: str, parameters: Union[_models.Application, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.Application]: - """Creates or updates a managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to the create or update a managed application. Is either - a Application type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.Application or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - application_name=application_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Application", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - async def _update_initial( - self, - resource_group_name: str, - application_name: str, - parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, - **kwargs: Any - ) -> _models.ApplicationPatchable: - 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.ApplicationPatchable] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ApplicationPatchable") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 response.status_code == 200: - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - @overload - async def begin_update( - self, - resource_group_name: str, - application_name: str, - parameters: Optional[_models.ApplicationPatchable] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - application_name: str, - parameters: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - application_name: str, - parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to update an existing managed application. Is either a - ApplicationPatchable type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ApplicationPatchable] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - application_name=application_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Application"]: - """Lists all the applications within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Application or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.Application] - :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.ApplicationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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("ApplicationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Application"]: - """Lists all the applications within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Application or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.Application] - :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.ApplicationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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("ApplicationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications" - } - - @distributed_trace_async - async def get_by_id(self, application_id: str, **kwargs: Any) -> Optional[_models.Application]: - """Gets the managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.Application 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.Application]] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - application_id=application_id, - api_version=api_version, - template_url=self.get_by_id.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, 404]: - 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("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{applicationId}"} - - async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, application_id: str, **kwargs: Any - ) -> None: - 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_by_id_request( - application_id=application_id, - api_version=api_version, - template_url=self._delete_by_id_initial.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, 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_by_id_initial.metadata = {"url": "/{applicationId}"} - - @distributed_trace_async - async def begin_delete_by_id(self, application_id: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes the managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_by_id_initial( # type: ignore - application_id=application_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete_by_id.metadata = {"url": "/{applicationId}"} - - async def _create_or_update_by_id_initial( - self, application_id: str, parameters: Union[_models.Application, IO], **kwargs: Any - ) -> _models.Application: - 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.Application] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Application") - - request = build_create_or_update_by_id_request( - application_id=application_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_by_id_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Application", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_by_id_initial.metadata = {"url": "/{applicationId}"} - - @overload - async def begin_create_or_update_by_id( - self, - application_id: str, - parameters: _models.Application, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Application]: - """Creates or updates a managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to the create or update a managed application. Required. - :type parameters: ~azure.mgmt.managedapplications.models.Application - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update_by_id( - self, application_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Application]: - """Creates or updates a managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to the create or update a managed application. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update_by_id( - self, application_id: str, parameters: Union[_models.Application, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.Application]: - """Creates or updates a managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to the create or update a managed application. Is either - a Application type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.Application or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( - application_id=application_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Application", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update_by_id.metadata = {"url": "/{applicationId}"} - - async def _update_by_id_initial( - self, application_id: str, parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, **kwargs: Any - ) -> _models.ApplicationPatchable: - 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.ApplicationPatchable] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ApplicationPatchable") - else: - _json = None - - request = build_update_by_id_request( - application_id=application_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_by_id_initial.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 response.status_code == 200: - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_by_id_initial.metadata = {"url": "/{applicationId}"} - - @overload - async def begin_update_by_id( - self, - application_id: str, - parameters: Optional[_models.ApplicationPatchable] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_by_id( - self, - application_id: str, - parameters: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_by_id( - self, application_id: str, parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to update an existing managed application. Is either a - ApplicationPatchable type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ApplicationPatchable or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ApplicationPatchable] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_by_id_initial( - application_id=application_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update_by_id.metadata = {"url": "/{applicationId}"} - - async def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> None: - 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_refresh_permissions_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._refresh_permissions_initial.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, {}) - - _refresh_permissions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions" - } - - @distributed_trace_async - async def begin_refresh_permissions( - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Refresh Permissions for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._refresh_permissions_initial( # type: ignore - resource_group_name=resource_group_name, - application_name=application_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh_permissions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions" - } - - @distributed_trace_async - async def list_allowed_upgrade_plans( - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> _models.AllowedUpgradePlansResult: - """List allowed upgrade plans for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AllowedUpgradePlansResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.AllowedUpgradePlansResult - :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.AllowedUpgradePlansResult] = kwargs.pop("cls", None) - - request = build_list_allowed_upgrade_plans_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_allowed_upgrade_plans.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AllowedUpgradePlansResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_allowed_upgrade_plans.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans" - } - - async def _update_access_initial( - self, - resource_group_name: str, - application_name: str, - parameters: Union[_models.UpdateAccessDefinition, IO], - **kwargs: Any - ) -> Optional[_models.UpdateAccessDefinition]: - 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.UpdateAccessDefinition]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "UpdateAccessDefinition") - - request = build_update_access_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_access_initial.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 == 202: - deserialized = self._deserialize("UpdateAccessDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_access_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess" - } - - @overload - async def begin_update_access( - self, - resource_group_name: str, - application_name: str, - parameters: _models.UpdateAccessDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: - """Update access for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Required. - :type parameters: ~azure.mgmt.managedapplications.models.UpdateAccessDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_access( - self, - resource_group_name: str, - application_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: - """Update access for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_access( - self, - resource_group_name: str, - application_name: str, - parameters: Union[_models.UpdateAccessDefinition, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: - """Update access for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Is either a UpdateAccessDefinition - type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.UpdateAccessDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either UpdateAccessDefinition or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_access_initial( - resource_group_name=resource_group_name, - application_name=application_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("UpdateAccessDefinition", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update_access.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess" - } - - @overload - async def list_tokens( - self, - resource_group_name: str, - application_name: str, - parameters: _models.ListTokenRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedIdentityTokenResult: - """List tokens for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ListTokenRequest - :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: ManagedIdentityTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def list_tokens( - self, - resource_group_name: str, - application_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedIdentityTokenResult: - """List tokens for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedIdentityTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def list_tokens( - self, - resource_group_name: str, - application_name: str, - parameters: Union[_models.ListTokenRequest, IO], - **kwargs: Any - ) -> _models.ManagedIdentityTokenResult: - """List tokens for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Is either a ListTokenRequest type or - a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ListTokenRequest 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: ManagedIdentityTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult - :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.ManagedIdentityTokenResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ListTokenRequest") - - request = build_list_tokens_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.list_tokens.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedIdentityTokenResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_tokens.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens" - } diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_jit_requests_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_jit_requests_operations.py deleted file mode 100644 index 3200d5fa4e6d..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_jit_requests_operations.py +++ /dev/null @@ -1,681 +0,0 @@ -# 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, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._jit_requests_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) -from .._vendor import ManagedApplicationsMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class JitRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient`'s - :attr:`jit_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, jit_request_name: str, **kwargs: Any - ) -> Optional[_models.JitRequestDefinition]: - """Gets the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitRequestDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition 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.JitRequestDefinition]] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - jit_request_name=jit_request_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - 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("JitRequestDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - jit_request_name: str, - parameters: Union[_models.JitRequestDefinition, IO], - **kwargs: Any - ) -> _models.JitRequestDefinition: - 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.JitRequestDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JitRequestDefinition") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - jit_request_name=jit_request_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("JitRequestDefinition", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("JitRequestDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: _models.JitRequestDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.JitRequestDefinition]: - """Creates or updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Required. - :type parameters: ~azure.mgmt.managedapplications.models.JitRequestDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.JitRequestDefinition]: - """Creates or updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: Union[_models.JitRequestDefinition, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.JitRequestDefinition]: - """Creates or updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Is either a - JitRequestDefinition type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.JitRequestDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either JitRequestDefinition or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JitRequestDefinition] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - jit_request_name=jit_request_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JitRequestDefinition", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - @overload - async def update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: _models.JitRequestPatchable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitRequestDefinition: - """Updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Required. - :type parameters: ~azure.mgmt.managedapplications.models.JitRequestPatchable - :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: JitRequestDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitRequestDefinition: - """Updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitRequestDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: Union[_models.JitRequestPatchable, IO], - **kwargs: Any - ) -> _models.JitRequestDefinition: - """Updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Is either a - JitRequestPatchable type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.JitRequestPatchable 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: JitRequestDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition - :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.JitRequestDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JitRequestPatchable") - - request = build_update_request( - resource_group_name=resource_group_name, - jit_request_name=jit_request_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitRequestDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, jit_request_name: str, **kwargs: Any - ) -> None: - """Deletes the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_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, - jit_request_name=jit_request_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - @distributed_trace_async - async def list_by_subscription(self, **kwargs: Any) -> _models.JitRequestDefinitionListResult: - """Lists all JIT requests within the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitRequestDefinitionListResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinitionListResult - :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.JitRequestDefinitionListResult] = kwargs.pop("cls", None) - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitRequestDefinitionListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} - - @distributed_trace_async - async def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> _models.JitRequestDefinitionListResult: - """Lists all JIT requests within the resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitRequestDefinitionListResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinitionListResult - :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.JitRequestDefinitionListResult] = kwargs.pop("cls", None) - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitRequestDefinitionListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests" - } diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_managed_applications_mgmt_client_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_managed_applications_mgmt_client_operations.py deleted file mode 100644 index 49a6f86db5b0..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_managed_applications_mgmt_client_operations.py +++ /dev/null @@ -1,117 +0,0 @@ -# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -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 ..._vendor import _convert_request -from ...operations._managed_applications_mgmt_client_operations import build_list_operations_request -from .._vendor import ManagedApplicationsMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ManagedApplicationsMgmtClientOperationsMixin(ManagedApplicationsMgmtClientMixinABC): - @distributed_trace - def list_operations(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available Microsoft.Solutions REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.Operation] - :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.OperationListResult] = 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_operations_request( - api_version=api_version, - template_url=self.list_operations.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("OperationListResult", 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( # type: ignore # 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_operations.metadata = {"url": "/providers/Microsoft.Solutions/operations"} diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_operations.py new file mode 100644 index 000000000000..782210b283a5 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_operations.py @@ -0,0 +1,4269 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models, types as _types +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ..._utils.utils import ClientMixinABC +from ...operations._operations import ( + build_application_definitions_create_or_update_by_id_request, + build_application_definitions_create_or_update_request, + build_application_definitions_delete_by_id_request, + build_application_definitions_delete_request, + build_application_definitions_get_by_id_request, + build_application_definitions_get_request, + build_application_definitions_list_by_resource_group_request, + build_application_definitions_list_by_subscription_request, + build_application_definitions_update_by_id_request, + build_application_definitions_update_request, + build_applications_create_or_update_by_id_request, + build_applications_create_or_update_request, + build_applications_delete_by_id_request, + build_applications_delete_request, + build_applications_get_by_id_request, + build_applications_get_request, + build_applications_list_allowed_upgrade_plans_request, + build_applications_list_by_resource_group_request, + build_applications_list_by_subscription_request, + build_applications_list_tokens_request, + build_applications_refresh_permissions_request, + build_applications_update_access_request, + build_applications_update_by_id_request, + build_applications_update_request, + build_jit_requests_create_or_update_request, + build_jit_requests_delete_request, + build_jit_requests_get_request, + build_jit_requests_list_by_resource_group_request, + build_jit_requests_list_by_subscription_request, + build_jit_requests_update_request, + build_managed_applications_mgmt_list_operations_request, + build_managed_applications_mgmt_portal_registry_package_request, +) +from .._configuration import ManagedApplicationsMgmtClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] + + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient`'s + :attr:`applications` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagedApplicationsMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :return: Application or None. The Application is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.Application or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.Application]] = kwargs.pop("cls", None) + + _request = build_applications_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Application, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.Application, _types.Application, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_applications_create_or_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: ~azure.mgmt.managedapplications.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _types.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: ~azure.mgmt.managedapplications.types.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.Application, _types.Application, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Is either + a Application type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.Application or + ~azure.mgmt.managedapplications.types.Application or IO[bytes] + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Application, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Application].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Application]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[Union[_models.ApplicationPatchable, _types.ApplicationPatchable, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_applications_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_types.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[Union[_models.ApplicationPatchable, _types.ApplicationPatchable, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Is either a + ApplicationPatchable type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable or + ~azure.mgmt.managedapplications.types.ApplicationPatchable or IO[bytes] + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Application, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Application].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Application]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_applications_delete_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + application_name=application_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Application"]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Application + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.Application]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_applications_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.Application], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.Application"]: + """Lists all the applications within a subscription. + + :return: An iterator like instance of Application + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.Application]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_applications_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.Application], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _refresh_permissions_initial( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_applications_refresh_permissions_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_refresh_permissions( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_permissions_initial( + resource_group_name=resource_group_name, + application_name=application_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def list_allowed_upgrade_plans( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :return: AllowedUpgradePlansResult. The AllowedUpgradePlansResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.AllowedUpgradePlansResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AllowedUpgradePlansResult] = kwargs.pop("cls", None) + + _request = build_applications_list_allowed_upgrade_plans_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AllowedUpgradePlansResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.UpdateAccessDefinition, _types.UpdateAccessDefinition, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_applications_update_access_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to update access. Required. + :type parameters: ~azure.mgmt.managedapplications.models.UpdateAccessDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns UpdateAccessDefinition. The + UpdateAccessDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _types.UpdateAccessDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to update access. Required. + :type parameters: ~azure.mgmt.managedapplications.types.UpdateAccessDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns UpdateAccessDefinition. The + UpdateAccessDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to update access. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns UpdateAccessDefinition. The + UpdateAccessDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.UpdateAccessDefinition, _types.UpdateAccessDefinition, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to update access. Is either a UpdateAccessDefinition + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.UpdateAccessDefinition or + ~azure.mgmt.managedapplications.types.UpdateAccessDefinition or IO[bytes] + :return: An instance of AsyncLROPoller that returns UpdateAccessDefinition. The + UpdateAccessDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UpdateAccessDefinition] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_access_initial( + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.UpdateAccessDefinition, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.UpdateAccessDefinition].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.UpdateAccessDefinition]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to list tokens. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ListTokenRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedIdentityTokenResult. The ManagedIdentityTokenResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _types.ListTokenRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to list tokens. Required. + :type parameters: ~azure.mgmt.managedapplications.types.ListTokenRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedIdentityTokenResult. The ManagedIdentityTokenResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to list tokens. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedIdentityTokenResult. The ManagedIdentityTokenResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.ListTokenRequest, _types.ListTokenRequest, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to list tokens. Is either a ListTokenRequest type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ListTokenRequest or + ~azure.mgmt.managedapplications.types.ListTokenRequest or IO[bytes] + :return: ManagedIdentityTokenResult. The ManagedIdentityTokenResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedIdentityTokenResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_applications_list_tokens_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedIdentityTokenResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_by_id(self, application_id: str, **kwargs: Any) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :return: Application or None. The Application is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.Application or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.Application]] = kwargs.pop("cls", None) + + _request = build_applications_get_by_id_request( + application_id=application_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Application, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_by_id_initial( + self, application_id: str, parameters: Union[_models.Application, _types.Application, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_applications_create_or_update_by_id_request( + application_id=application_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to create or update a managed application. Required. + :type parameters: ~azure.mgmt.managedapplications.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _types.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to create or update a managed application. Required. + :type parameters: ~azure.mgmt.managedapplications.types.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_by_id( + self, application_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to create or update a managed application. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, application_id: str, parameters: Union[_models.Application, _types.Application, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to create or update a managed application. Is either a + Application type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.Application or + ~azure.mgmt.managedapplications.types.Application or IO[bytes] + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( + application_id=application_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Application, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Application].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Application]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[Union[_models.ApplicationPatchable, _types.ApplicationPatchable, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_applications_update_by_id_request( + application_id=application_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Updates an existing managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_types.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Updates an existing managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Updates an existing managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, + application_id: str, + parameters: Optional[Union[_models.ApplicationPatchable, _types.ApplicationPatchable, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Updates an existing managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Is either a + ApplicationPatchable type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable or + ~azure.mgmt.managedapplications.types.ApplicationPatchable or IO[bytes] + :return: An instance of AsyncLROPoller that returns Application. The Application is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_by_id_initial( + application_id=application_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Application, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Application].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Application]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_by_id_initial(self, application_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_applications_delete_by_id_request( + application_id=application_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete_by_id(self, application_id: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_by_id_initial( + application_id=application_id, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient`'s + :attr:`application_definitions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagedApplicationsMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :return: ApplicationDefinition or None. The ApplicationDefinition is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.ApplicationDefinition]] = kwargs.pop("cls", None) + + _request = build_application_definitions_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _types.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, _types.ApplicationDefinition, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Is either a ApplicationDefinition type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition or + ~azure.mgmt.managedapplications.types.ApplicationDefinition or IO[bytes] + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_application_definitions_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _types.ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + Required. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinitionPatchable, _types.ApplicationDefinitionPatchable, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. Is + either a ApplicationDefinitionPatchable type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable or + ~azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable or IO[bytes] + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_application_definitions_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, application_definition_name: str, **kwargs: Any) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_application_definitions_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get_by_id( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :return: ApplicationDefinition or None. The ApplicationDefinition is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.ApplicationDefinition]] = kwargs.pop("cls", None) + + _request = build_application_definitions_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _types.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, _types.ApplicationDefinition, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Is either a ApplicationDefinition type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition or + ~azure.mgmt.managedapplications.types.ApplicationDefinition or IO[bytes] + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_application_definitions_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _types.ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinitionPatchable, _types.ApplicationDefinitionPatchable, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Is either a ApplicationDefinitionPatchable type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable or + ~azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable or IO[bytes] + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_application_definitions_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_by_id(self, resource_group_name: str, application_definition_name: str, **kwargs: Any) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_application_definitions_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ApplicationDefinition"]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of ApplicationDefinition + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ApplicationDefinition]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_application_definitions_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ApplicationDefinition], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.ApplicationDefinition"]: + """Lists all the application definitions within a subscription. + + :return: An iterator like instance of ApplicationDefinition + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ApplicationDefinition]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_application_definitions_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ApplicationDefinition], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplications.aio.ManagedApplicationsMgmtClient`'s + :attr:`jit_requests` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagedApplicationsMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, jit_request_name: str, **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :return: JitRequestDefinition or None. The JitRequestDefinition is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.JitRequestDefinition]] = kwargs.pop("cls", None) + + _request = build_jit_requests_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JitRequestDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: Union[_models.JitRequestDefinition, _types.JitRequestDefinition, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_jit_requests_create_or_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JitRequestDefinition. The + JitRequestDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _types.JitRequestDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: ~azure.mgmt.managedapplications.types.JitRequestDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JitRequestDefinition. The + JitRequestDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JitRequestDefinition. The + JitRequestDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: Union[_models.JitRequestDefinition, _types.JitRequestDefinition, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Is either a + JitRequestDefinition type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.JitRequestDefinition or + ~azure.mgmt.managedapplications.types.JitRequestDefinition or IO[bytes] + :return: An instance of AsyncLROPoller that returns JitRequestDefinition. The + JitRequestDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JitRequestDefinition] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JitRequestDefinition, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.JitRequestDefinition].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.JitRequestDefinition]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: ~azure.mgmt.managedapplications.models.JitRequestPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JitRequestDefinition. The JitRequestDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _types.JitRequestPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: ~azure.mgmt.managedapplications.types.JitRequestPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JitRequestDefinition. The JitRequestDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JitRequestDefinition. The JitRequestDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: Union[_models.JitRequestPatchable, _types.JitRequestPatchable, IO[bytes]], + **kwargs: Any + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Is either a + JitRequestPatchable type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.JitRequestPatchable or + ~azure.mgmt.managedapplications.types.JitRequestPatchable or IO[bytes] + :return: JitRequestDefinition. The JitRequestDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JitRequestDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_jit_requests_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JitRequestDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, jit_request_name: str, **kwargs: Any) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_jit_requests_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: JitRequestDefinitionListResult. The JitRequestDefinitionListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinitionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JitRequestDefinitionListResult] = kwargs.pop("cls", None) + + _request = build_jit_requests_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JitRequestDefinitionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_by_subscription(self, **kwargs: Any) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :return: JitRequestDefinitionListResult. The JitRequestDefinitionListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinitionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JitRequestDefinitionListResult] = kwargs.pop("cls", None) + + _request = build_jit_requests_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JitRequestDefinitionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class _ManagedApplicationsMgmtClientOperationsMixin( + ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], ManagedApplicationsMgmtClientConfiguration] +): + + @overload + async def portal_registry_package( + self, parameters: _models.RegistryPackagePlan, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryPackage: + """Generates the registry package links for Managed Applications and Solution Templates. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.managedapplications.models.RegistryPackagePlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RegistryPackage. The RegistryPackage is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.RegistryPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def portal_registry_package( + self, parameters: _types.RegistryPackagePlan, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryPackage: + """Generates the registry package links for Managed Applications and Solution Templates. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.managedapplications.types.RegistryPackagePlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RegistryPackage. The RegistryPackage is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.RegistryPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def portal_registry_package( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryPackage: + """Generates the registry package links for Managed Applications and Solution Templates. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RegistryPackage. The RegistryPackage is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.RegistryPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def portal_registry_package( + self, parameters: Union[_models.RegistryPackagePlan, _types.RegistryPackagePlan, IO[bytes]], **kwargs: Any + ) -> _models.RegistryPackage: + """Generates the registry package links for Managed Applications and Solution Templates. + + :param parameters: The request body. Is either a RegistryPackagePlan type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.managedapplications.models.RegistryPackagePlan or + ~azure.mgmt.managedapplications.types.RegistryPackagePlan or IO[bytes] + :return: RegistryPackage. The RegistryPackage is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.RegistryPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryPackage] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_applications_mgmt_portal_registry_package_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RegistryPackage, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_operations(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of Operation + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedapplications.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_applications_mgmt_list_operations_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_patch.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_patch.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/aio/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/__init__.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/__init__.py index 3c4095860cbd..80a6d42d71e0 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/__init__.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/__init__.py @@ -2,76 +2,90 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import AllowedUpgradePlansResult -from ._models_py3 import Application -from ._models_py3 import ApplicationArtifact -from ._models_py3 import ApplicationAuthorization -from ._models_py3 import ApplicationBillingDetailsDefinition -from ._models_py3 import ApplicationClientDetails -from ._models_py3 import ApplicationDefinition -from ._models_py3 import ApplicationDefinitionArtifact -from ._models_py3 import ApplicationDefinitionListResult -from ._models_py3 import ApplicationDefinitionPatchable -from ._models_py3 import ApplicationDeploymentPolicy -from ._models_py3 import ApplicationJitAccessPolicy -from ._models_py3 import ApplicationListResult -from ._models_py3 import ApplicationManagementPolicy -from ._models_py3 import ApplicationNotificationEndpoint -from ._models_py3 import ApplicationNotificationPolicy -from ._models_py3 import ApplicationPackageContact -from ._models_py3 import ApplicationPackageLockingPolicyDefinition -from ._models_py3 import ApplicationPackageSupportUrls -from ._models_py3 import ApplicationPatchable -from ._models_py3 import ApplicationPolicy -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import GenericResource -from ._models_py3 import Identity -from ._models_py3 import JitApproverDefinition -from ._models_py3 import JitAuthorizationPolicies -from ._models_py3 import JitRequestDefinition -from ._models_py3 import JitRequestDefinitionListResult -from ._models_py3 import JitRequestMetadata -from ._models_py3 import JitRequestPatchable -from ._models_py3 import JitSchedulingPolicy -from ._models_py3 import ListTokenRequest -from ._models_py3 import ManagedIdentityToken -from ._models_py3 import ManagedIdentityTokenResult -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Plan -from ._models_py3 import PlanPatchable -from ._models_py3 import Resource -from ._models_py3 import Sku -from ._models_py3 import SystemData -from ._models_py3 import UpdateAccessDefinition -from ._models_py3 import UserAssignedResourceIdentity +from typing import TYPE_CHECKING -from ._managed_applications_mgmt_client_enums import ActionType -from ._managed_applications_mgmt_client_enums import ApplicationArtifactName -from ._managed_applications_mgmt_client_enums import ApplicationArtifactType -from ._managed_applications_mgmt_client_enums import ApplicationDefinitionArtifactName -from ._managed_applications_mgmt_client_enums import ApplicationLockLevel -from ._managed_applications_mgmt_client_enums import ApplicationManagementMode -from ._managed_applications_mgmt_client_enums import CreatedByType -from ._managed_applications_mgmt_client_enums import DeploymentMode -from ._managed_applications_mgmt_client_enums import JitApprovalMode -from ._managed_applications_mgmt_client_enums import JitApproverType -from ._managed_applications_mgmt_client_enums import JitRequestState -from ._managed_applications_mgmt_client_enums import JitSchedulingType -from ._managed_applications_mgmt_client_enums import Origin -from ._managed_applications_mgmt_client_enums import ProvisioningState -from ._managed_applications_mgmt_client_enums import ResourceIdentityType -from ._managed_applications_mgmt_client_enums import Status -from ._managed_applications_mgmt_client_enums import Substatus +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models import ( # type: ignore + AllowedUpgradePlansResult, + Application, + ApplicationArtifact, + ApplicationAuthorization, + ApplicationBillingDetailsDefinition, + ApplicationClientDetails, + ApplicationDefinition, + ApplicationDefinitionArtifact, + ApplicationDefinitionPatchable, + ApplicationDefinitionProperties, + ApplicationDeploymentPolicy, + ApplicationJitAccessPolicy, + ApplicationManagementPolicy, + ApplicationNotificationEndpoint, + ApplicationNotificationPolicy, + ApplicationPackageContact, + ApplicationPackageLockingPolicyDefinition, + ApplicationPackageSupportUrls, + ApplicationPatchable, + ApplicationPolicy, + ApplicationProperties, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + GenericResource, + Identity, + JitApproverDefinition, + JitAuthorizationPolicies, + JitRequestDefinition, + JitRequestDefinitionListResult, + JitRequestMetadata, + JitRequestPatchable, + JitRequestProperties, + JitSchedulingPolicy, + ListTokenRequest, + ManagedIdentityToken, + ManagedIdentityTokenResult, + Operation, + OperationDisplay, + Plan, + PlanPatchable, + RegistryPackage, + RegistryPackageLinks, + RegistryPackagePlan, + Resource, + Sku, + SystemData, + UpdateAccessDefinition, + UserAssignedResourceIdentity, +) + +from ._enums import ( # type: ignore + ActionType, + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + ApplicationManagementMode, + CreatedByType, + DeploymentMode, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + Origin, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -83,11 +97,10 @@ "ApplicationClientDetails", "ApplicationDefinition", "ApplicationDefinitionArtifact", - "ApplicationDefinitionListResult", "ApplicationDefinitionPatchable", + "ApplicationDefinitionProperties", "ApplicationDeploymentPolicy", "ApplicationJitAccessPolicy", - "ApplicationListResult", "ApplicationManagementPolicy", "ApplicationNotificationEndpoint", "ApplicationNotificationPolicy", @@ -96,6 +109,7 @@ "ApplicationPackageSupportUrls", "ApplicationPatchable", "ApplicationPolicy", + "ApplicationProperties", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", @@ -107,15 +121,18 @@ "JitRequestDefinitionListResult", "JitRequestMetadata", "JitRequestPatchable", + "JitRequestProperties", "JitSchedulingPolicy", "ListTokenRequest", "ManagedIdentityToken", "ManagedIdentityTokenResult", "Operation", "OperationDisplay", - "OperationListResult", "Plan", "PlanPatchable", + "RegistryPackage", + "RegistryPackageLinks", + "RegistryPackagePlan", "Resource", "Sku", "SystemData", @@ -139,5 +156,5 @@ "Status", "Substatus", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_managed_applications_mgmt_client_enums.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_enums.py similarity index 69% rename from sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_managed_applications_mgmt_client_enums.py rename to sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_enums.py index 3f6fba35b294..f39629089f41 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_managed_applications_mgmt_client_enums.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_enums.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -11,104 +11,147 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + """Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal + only APIs. + """ INTERNAL = "Internal" + """Actions are for internal-only APIs.""" class ApplicationArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The managed application artifact name.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" VIEW_DEFINITION = "ViewDefinition" + """ViewDefinition.""" AUTHORIZATIONS = "Authorizations" + """Authorizations.""" CUSTOM_ROLE_DEFINITION = "CustomRoleDefinition" + """CustomRoleDefinition.""" class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The managed application artifact type.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" TEMPLATE = "Template" + """Template.""" CUSTOM = "Custom" + """Custom.""" class ApplicationDefinitionArtifactName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The managed application artifact name.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" APPLICATION_RESOURCE_TEMPLATE = "ApplicationResourceTemplate" + """ApplicationResourceTemplate.""" CREATE_UI_DEFINITION = "CreateUiDefinition" + """CreateUiDefinition.""" MAIN_TEMPLATE_PARAMETERS = "MainTemplateParameters" + """MainTemplateParameters.""" class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The managed application lock level.""" CAN_NOT_DELETE = "CanNotDelete" + """CanNotDelete.""" READ_ONLY = "ReadOnly" + """ReadOnly.""" NONE = "None" + """None.""" class ApplicationManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The management mode.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" UNMANAGED = "Unmanaged" + """Unmanaged.""" MANAGED = "Managed" + """Managed.""" class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" + """The kind of entity that created the resource.""" USER = "User" + """The entity was created by a user.""" APPLICATION = "Application" + """The entity was created by an application.""" MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" KEY = "Key" + """The entity was created by a key.""" class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment mode.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" INCREMENTAL = "Incremental" + """Incremental.""" COMPLETE = "Complete" + """Complete.""" class JitApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Jit approval mode.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" AUTO_APPROVE = "AutoApprove" + """AutoApprove.""" MANUAL_APPROVE = "ManualApprove" + """ManualApprove.""" class JitApproverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The approver type.""" USER = "user" + """user.""" GROUP = "group" + """group.""" class JitRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The JIT request state.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" PENDING = "Pending" + """Pending.""" APPROVED = "Approved" + """Approved.""" DENIED = "Denied" + """Denied.""" FAILED = "Failed" + """Failed.""" CANCELED = "Canceled" + """Canceled.""" EXPIRED = "Expired" + """Expired.""" TIMEOUT = "Timeout" + """Timeout.""" class JitSchedulingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The JIT request scheduling type.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" ONCE = "Once" + """Once.""" RECURRING = "Recurring" + """Recurring.""" class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -117,47 +160,72 @@ class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ USER = "user" + """Indicates the operation is initiated by a user.""" SYSTEM = "system" + """Indicates the operation is initiated by a system.""" USER_SYSTEM = "user,system" + """Indicates the operation is initiated by a user or system.""" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status of the managed application.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" ACCEPTED = "Accepted" + """Accepted.""" RUNNING = "Running" + """Running.""" DELETING = "Deleting" + """Deleting.""" DELETED = "Deleted" + """Deleted.""" CANCELED = "Canceled" + """Canceled.""" FAILED = "Failed" + """Failed.""" SUCCEEDED = "Succeeded" + """Succeeded.""" UPDATING = "Updating" + """Updating.""" class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" + """SystemAssigned.""" USER_ASSIGNED = "UserAssigned" + """UserAssigned.""" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + """SystemAssigned, UserAssigned.""" NONE = "None" + """None.""" class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The JIT status.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" ELEVATE = "Elevate" + """Elevate.""" REMOVE = "Remove" + """Remove.""" class Substatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sub status.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" APPROVED = "Approved" + """Approved.""" DENIED = "Denied" + """Denied.""" FAILED = "Failed" + """Failed.""" EXPIRED = "Expired" + """Expired.""" TIMEOUT = "Timeout" + """Timeout.""" diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_models.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_models.py new file mode 100644 index 000000000000..cd811f67916e --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_models.py @@ -0,0 +1,2399 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_field + +if TYPE_CHECKING: + from .. import models as _models + + +class AllowedUpgradePlansResult(_Model): + """The array of plan. + + :ivar value: The array of plans. + :vartype value: list[~azure.mgmt.managedapplications.models.Plan] + """ + + value: Optional[list["_models.Plan"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The array of plans.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.Plan"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Resource(_Model): + """Resource information. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource ID.""" + name: Optional[str] = rest_field(visibility=["read"]) + """Resource name.""" + type: Optional[str] = rest_field(visibility=["read"]) + """Resource type.""" + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource location.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Metadata pertaining to creation and last modification of the resource.""" + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GenericResource(Resource): + """Resource information. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplications.models.Sku + """ + + managed_by: Optional[str] = rest_field(name="managedBy", visibility=["read", "create", "update", "delete", "query"]) + """ID of the resource that manages this resource.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU of the resource.""" + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Application(GenericResource): + """Information about managed application. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplications.models.Sku + :ivar properties: The managed application properties. Required. + :vartype properties: ~azure.mgmt.managedapplications.models.ApplicationProperties + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplications.models.Plan + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. Required. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplications.models.Identity + """ + + properties: "_models.ApplicationProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The managed application properties. Required.""" + plan: Optional["_models.Plan"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan information.""" + kind: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. + Required.""" + identity: Optional["_models.Identity"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identity of the resource.""" + + __flattened_items = [ + "managed_resource_group_id", + "application_definition_id", + "parameters", + "outputs", + "provisioning_state", + "billing_details", + "jit_access_policy", + "publisher_tenant_id", + "authorizations", + "management_mode", + "customer_support", + "support_urls", + "artifacts", + "created_by", + "updated_by", + ] + + @overload + def __init__( + self, + *, + properties: "_models.ApplicationProperties", + kind: str, + location: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.Identity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApplicationArtifact(_Model): + """Managed application artifact. + + :ivar name: The managed application artifact name. Required. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", and "CustomRoleDefinition". + :vartype name: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactName + :ivar uri: The managed application artifact blob uri. Required. + :vartype uri: str + :ivar type: The managed application artifact type. Required. Known values are: "NotSpecified", + "Template", and "Custom". + :vartype type: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactType + """ + + name: Union[str, "_models.ApplicationArtifactName"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application artifact name. Required. Known values are: \"NotSpecified\", + \"ViewDefinition\", \"Authorizations\", and \"CustomRoleDefinition\".""" + uri: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The managed application artifact blob uri. Required.""" + type: Union[str, "_models.ApplicationArtifactType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application artifact type. Required. Known values are: \"NotSpecified\", + \"Template\", and \"Custom\".""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.ApplicationArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationAuthorization(_Model): + """The managed application provider authorization. + + :ivar principal_id: The provider's principal identifier. This is the identity that the provider + will use to call ARM to manage the managed application resources. Required. + :vartype principal_id: str + :ivar role_definition_id: The provider's role definition identifier. This role will define all + the permissions that the provider must have on the managed application's container resource + group. This role definition cannot have permission to delete the resource group. Required. + :vartype role_definition_id: str + """ + + principal_id: str = rest_field(name="principalId", visibility=["read", "create", "update", "delete", "query"]) + """The provider's principal identifier. This is the identity that the provider will use to call + ARM to manage the managed application resources. Required.""" + role_definition_id: str = rest_field( + name="roleDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """The provider's role definition identifier. This role will define all the permissions that the + provider must have on the managed application's container resource group. This role definition + cannot have permission to delete the resource group. Required.""" + + @overload + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationBillingDetailsDefinition(_Model): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + resource_usage_id: Optional[str] = rest_field( + name="resourceUsageId", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application resource usage Id.""" + + @overload + def __init__( + self, + *, + resource_usage_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationClientDetails(_Model): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + oid: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The client Oid.""" + puid: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The client Puid.""" + application_id: Optional[str] = rest_field( + name="applicationId", visibility=["read", "create", "update", "delete", "query"] + ) + """The client application Id.""" + + @overload + def __init__( + self, + *, + oid: Optional[str] = None, + puid: Optional[str] = None, + application_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplications.models.Sku + :ivar properties: The managed application definition properties. Required. + :vartype properties: ~azure.mgmt.managedapplications.models.ApplicationDefinitionProperties + """ + + properties: "_models.ApplicationDefinitionProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application definition properties. Required.""" + + __flattened_items = [ + "lock_level", + "display_name", + "is_enabled", + "authorizations", + "artifacts", + "description", + "package_file_uri", + "storage_account_id", + "main_template", + "create_ui_definition", + "notification_policy", + "locking_policy", + "deployment_policy", + "management_policy", + "policies", + ] + + @overload + def __init__( + self, + *, + properties: "_models.ApplicationDefinitionProperties", + location: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApplicationDefinitionArtifact(_Model): + """Application definition artifact. + + :ivar name: The managed application definition artifact name. Required. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", and + "MainTemplateParameters". + :vartype name: str or ~azure.mgmt.managedapplications.models.ApplicationDefinitionArtifactName + :ivar uri: The managed application definition artifact blob uri. Required. + :vartype uri: str + :ivar type: The managed application definition artifact type. Required. Known values are: + "NotSpecified", "Template", and "Custom". + :vartype type: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactType + """ + + name: Union[str, "_models.ApplicationDefinitionArtifactName"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application definition artifact name. Required. Known values are: \"NotSpecified\", + \"ApplicationResourceTemplate\", \"CreateUiDefinition\", and \"MainTemplateParameters\".""" + uri: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The managed application definition artifact blob uri. Required.""" + type: Union[str, "_models.ApplicationArtifactType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application definition artifact type. Required. Known values are: \"NotSpecified\", + \"Template\", and \"Custom\".""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.ApplicationDefinitionArtifactName"], + uri: str, + type: Union[str, "_models.ApplicationArtifactType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationDefinitionPatchable(_Model): + """Information about an application definition request. + + :ivar tags: Application definition tags. + :vartype tags: dict[str, str] + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Application definition tags.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationDefinitionProperties(_Model): + """The managed application definition properties. + + :ivar lock_level: The managed application lock level. Required. Known values are: + "CanNotDelete", "ReadOnly", and "None". + :vartype lock_level: str or ~azure.mgmt.managedapplications.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: list[~azure.mgmt.managedapplications.models.ApplicationAuthorization] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: list[~azure.mgmt.managedapplications.models.ApplicationDefinitionArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar storage_account_id: The storage account id for bring your own storage scenario. + :vartype storage_account_id: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: any + :ivar notification_policy: The managed application notification policy. + :vartype notification_policy: + ~azure.mgmt.managedapplications.models.ApplicationNotificationPolicy + :ivar locking_policy: The managed application locking policy. + :vartype locking_policy: + ~azure.mgmt.managedapplications.models.ApplicationPackageLockingPolicyDefinition + :ivar deployment_policy: The managed application deployment policy. + :vartype deployment_policy: ~azure.mgmt.managedapplications.models.ApplicationDeploymentPolicy + :ivar management_policy: The managed application management policy that determines publisher's + access to the managed resource group. + :vartype management_policy: ~azure.mgmt.managedapplications.models.ApplicationManagementPolicy + :ivar policies: The managed application provider policies. + :vartype policies: list[~azure.mgmt.managedapplications.models.ApplicationPolicy] + """ + + lock_level: Union[str, "_models.ApplicationLockLevel"] = rest_field( + name="lockLevel", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application lock level. Required. Known values are: \"CanNotDelete\", \"ReadOnly\", + and \"None\".""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application definition display name.""" + is_enabled: Optional[bool] = rest_field( + name="isEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """A value indicating whether the package is enabled or not.""" + authorizations: Optional[list["_models.ApplicationAuthorization"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application provider authorizations.""" + artifacts: Optional[list["_models.ApplicationDefinitionArtifact"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The collection of managed application artifacts. The portal will use the files specified as + artifacts to construct the user experience of creating a managed application from a managed + application definition.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The managed application definition description.""" + package_file_uri: Optional[str] = rest_field( + name="packageFileUri", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application definition package file Uri. Use this element.""" + storage_account_id: Optional[str] = rest_field( + name="storageAccountId", visibility=["read", "create", "update", "delete", "query"] + ) + """The storage account id for bring your own storage scenario.""" + main_template: Optional[Any] = rest_field( + name="mainTemplate", visibility=["read", "create", "update", "delete", "query"] + ) + """The inline main template json which has resources to be provisioned. It can be a JObject or + well-formed JSON string.""" + create_ui_definition: Optional[Any] = rest_field( + name="createUiDefinition", visibility=["read", "create", "update", "delete", "query"] + ) + """The createUiDefinition json for the backing template with Microsoft.Solutions/applications + resource. It can be a JObject or well-formed JSON string.""" + notification_policy: Optional["_models.ApplicationNotificationPolicy"] = rest_field( + name="notificationPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application notification policy.""" + locking_policy: Optional["_models.ApplicationPackageLockingPolicyDefinition"] = rest_field( + name="lockingPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application locking policy.""" + deployment_policy: Optional["_models.ApplicationDeploymentPolicy"] = rest_field( + name="deploymentPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application deployment policy.""" + management_policy: Optional["_models.ApplicationManagementPolicy"] = rest_field( + name="managementPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application management policy that determines publisher's access to the managed + resource group.""" + policies: Optional[list["_models.ApplicationPolicy"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application provider policies.""" + + @overload + def __init__( + self, + *, + lock_level: Union[str, "_models.ApplicationLockLevel"], + display_name: Optional[str] = None, + is_enabled: Optional[bool] = None, + authorizations: Optional[list["_models.ApplicationAuthorization"]] = None, + artifacts: Optional[list["_models.ApplicationDefinitionArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + storage_account_id: Optional[str] = None, + main_template: Optional[Any] = None, + create_ui_definition: Optional[Any] = None, + notification_policy: Optional["_models.ApplicationNotificationPolicy"] = None, + locking_policy: Optional["_models.ApplicationPackageLockingPolicyDefinition"] = None, + deployment_policy: Optional["_models.ApplicationDeploymentPolicy"] = None, + management_policy: Optional["_models.ApplicationManagementPolicy"] = None, + policies: Optional[list["_models.ApplicationPolicy"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationDeploymentPolicy(_Model): + """Managed application deployment policy. + + :ivar deployment_mode: The managed application deployment mode. Required. Known values are: + "NotSpecified", "Incremental", and "Complete". + :vartype deployment_mode: str or ~azure.mgmt.managedapplications.models.DeploymentMode + """ + + deployment_mode: Union[str, "_models.DeploymentMode"] = rest_field( + name="deploymentMode", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application deployment mode. Required. Known values are: \"NotSpecified\", + \"Incremental\", and \"Complete\".""" + + @overload + def __init__( + self, + *, + deployment_mode: Union[str, "_models.DeploymentMode"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationJitAccessPolicy(_Model): + """Managed application Jit access policy. + + :ivar jit_access_enabled: Whether the JIT access is enabled. Required. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + and "ManualApprove". + :vartype jit_approval_mode: str or ~azure.mgmt.managedapplications.models.JitApprovalMode + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: list[~azure.mgmt.managedapplications.models.JitApproverDefinition] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + jit_access_enabled: bool = rest_field( + name="jitAccessEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the JIT access is enabled. Required.""" + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = rest_field( + name="jitApprovalMode", visibility=["read", "create", "update", "delete", "query"] + ) + """JIT approval mode. Known values are: \"NotSpecified\", \"AutoApprove\", and \"ManualApprove\".""" + jit_approvers: Optional[list["_models.JitApproverDefinition"]] = rest_field( + name="jitApprovers", visibility=["read", "create", "update", "delete", "query"] + ) + """The JIT approvers.""" + maximum_jit_access_duration: Optional[str] = rest_field( + name="maximumJitAccessDuration", visibility=["read", "create", "update", "delete", "query"] + ) + """The maximum duration JIT access is granted. This is an ISO8601 time period value.""" + + @overload + def __init__( + self, + *, + jit_access_enabled: bool, + jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, + jit_approvers: Optional[list["_models.JitApproverDefinition"]] = None, + maximum_jit_access_duration: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationManagementPolicy(_Model): + """Managed application management policy. + + :ivar mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", and "Managed". + :vartype mode: str or ~azure.mgmt.managedapplications.models.ApplicationManagementMode + """ + + mode: Optional[Union[str, "_models.ApplicationManagementMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application management mode. Known values are: \"NotSpecified\", \"Unmanaged\", and + \"Managed\".""" + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, "_models.ApplicationManagementMode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationNotificationEndpoint(_Model): + """Managed application notification endpoint. + + :ivar uri: The managed application notification endpoint uri. Required. + :vartype uri: str + """ + + uri: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The managed application notification endpoint uri. Required.""" + + @overload + def __init__( + self, + *, + uri: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationNotificationPolicy(_Model): + """Managed application notification policy. + + :ivar notification_endpoints: The managed application notification endpoint. Required. + :vartype notification_endpoints: + list[~azure.mgmt.managedapplications.models.ApplicationNotificationEndpoint] + """ + + notification_endpoints: list["_models.ApplicationNotificationEndpoint"] = rest_field( + name="notificationEndpoints", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application notification endpoint. Required.""" + + @overload + def __init__( + self, + *, + notification_endpoints: list["_models.ApplicationNotificationEndpoint"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationPackageContact(_Model): + """The application package contact information. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: The contact email. Required. + :vartype email: str + :ivar phone: The contact phone number. Required. + :vartype phone: str + """ + + contact_name: Optional[str] = rest_field( + name="contactName", visibility=["read", "create", "update", "delete", "query"] + ) + """The contact name.""" + email: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The contact email. Required.""" + phone: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The contact phone number. Required.""" + + @overload + def __init__( + self, + *, + email: str, + phone: str, + contact_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationPackageLockingPolicyDefinition(_Model): # pylint: disable=name-too-long + """Managed application locking policy. + + :ivar allowed_actions: The deny assignment excluded actions. + :vartype allowed_actions: list[str] + :ivar allowed_data_actions: The deny assignment excluded data actions. + :vartype allowed_data_actions: list[str] + """ + + allowed_actions: Optional[list[str]] = rest_field( + name="allowedActions", visibility=["read", "create", "update", "delete", "query"] + ) + """The deny assignment excluded actions.""" + allowed_data_actions: Optional[list[str]] = rest_field( + name="allowedDataActions", visibility=["read", "create", "update", "delete", "query"] + ) + """The deny assignment excluded data actions.""" + + @overload + def __init__( + self, + *, + allowed_actions: Optional[list[str]] = None, + allowed_data_actions: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationPackageSupportUrls(_Model): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + public_azure: Optional[str] = rest_field( + name="publicAzure", visibility=["read", "create", "update", "delete", "query"] + ) + """The public azure support URL.""" + government_cloud: Optional[str] = rest_field( + name="governmentCloud", visibility=["read", "create", "update", "delete", "query"] + ) + """The government cloud support URL.""" + + @overload + def __init__( + self, + *, + public_azure: Optional[str] = None, + government_cloud: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.managedapplications.models.Sku + :ivar properties: The managed application properties. + :vartype properties: ~azure.mgmt.managedapplications.models.ApplicationProperties + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.managedapplications.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.managedapplications.models.Identity + """ + + properties: Optional["_models.ApplicationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application properties.""" + plan: Optional["_models.PlanPatchable"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan information.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog.""" + identity: Optional["_models.Identity"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identity of the resource.""" + + __flattened_items = [ + "managed_resource_group_id", + "application_definition_id", + "parameters", + "outputs", + "provisioning_state", + "billing_details", + "jit_access_policy", + "publisher_tenant_id", + "authorizations", + "management_mode", + "customer_support", + "support_urls", + "artifacts", + "created_by", + "updated_by", + ] + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + properties: Optional["_models.ApplicationProperties"] = None, + plan: Optional["_models.PlanPatchable"] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApplicationPolicy(_Model): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The policy name.""" + policy_definition_id: Optional[str] = rest_field( + name="policyDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """The policy definition Id.""" + parameters: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The policy parameters.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + parameters: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationProperties(_Model): + """The managed application properties. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", + "Succeeded", and "Updating". + :vartype provisioning_state: str or ~azure.mgmt.managedapplications.models.ProvisioningState + :ivar billing_details: The managed application billing details. + :vartype billing_details: + ~azure.mgmt.managedapplications.models.ApplicationBillingDetailsDefinition + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: ~azure.mgmt.managedapplications.models.ApplicationJitAccessPolicy + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: list[~azure.mgmt.managedapplications.models.ApplicationAuthorization] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", and "Managed". + :vartype management_mode: str or + ~azure.mgmt.managedapplications.models.ApplicationManagementMode + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: ~azure.mgmt.managedapplications.models.ApplicationPackageContact + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: ~azure.mgmt.managedapplications.models.ApplicationPackageSupportUrls + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list[~azure.mgmt.managedapplications.models.ApplicationArtifact] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails + """ + + managed_resource_group_id: Optional[str] = rest_field( + name="managedResourceGroupId", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed resource group Id.""" + application_definition_id: Optional[str] = rest_field( + name="applicationDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """The fully qualified path of managed application definition Id.""" + parameters: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name and value pairs that define the managed application parameters. It can be a JObject or a + well formed JSON string.""" + outputs: Optional[Any] = rest_field(visibility=["read"]) + """Name and value pairs that define the managed application outputs.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The managed application provisioning state. Known values are: \"NotSpecified\", \"Accepted\", + \"Running\", \"Deleting\", \"Deleted\", \"Canceled\", \"Failed\", \"Succeeded\", and + \"Updating\".""" + billing_details: Optional["_models.ApplicationBillingDetailsDefinition"] = rest_field( + name="billingDetails", visibility=["read"] + ) + """The managed application billing details.""" + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = rest_field( + name="jitAccessPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed application Jit access policy.""" + publisher_tenant_id: Optional[str] = rest_field(name="publisherTenantId", visibility=["read"]) + """The publisher tenant Id.""" + authorizations: Optional[list["_models.ApplicationAuthorization"]] = rest_field(visibility=["read"]) + """The read-only authorizations property that is retrieved from the application package.""" + management_mode: Optional[Union[str, "_models.ApplicationManagementMode"]] = rest_field( + name="managementMode", visibility=["read"] + ) + """The managed application management mode. Known values are: \"NotSpecified\", \"Unmanaged\", and + \"Managed\".""" + customer_support: Optional["_models.ApplicationPackageContact"] = rest_field( + name="customerSupport", visibility=["read"] + ) + """The read-only customer support property that is retrieved from the application package.""" + support_urls: Optional["_models.ApplicationPackageSupportUrls"] = rest_field( + name="supportUrls", visibility=["read"] + ) + """The read-only support URLs property that is retrieved from the application package.""" + artifacts: Optional[list["_models.ApplicationArtifact"]] = rest_field(visibility=["read"]) + """The collection of managed application artifacts.""" + created_by: Optional["_models.ApplicationClientDetails"] = rest_field(name="createdBy", visibility=["read"]) + """The client entity that created the JIT request.""" + updated_by: Optional["_models.ApplicationClientDetails"] = rest_field(name="updatedBy", visibility=["read"]) + """The client entity that last updated the JIT request.""" + + @overload + def __init__( + self, + *, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[Any] = None, + jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_Model): + """The error detail. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.managedapplications.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.managedapplications.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.managedapplications.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Identity(_Model): + """Identity for the resource. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". + :vartype type: str or ~azure.mgmt.managedapplications.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.managedapplications.models.UserAssignedResourceIdentity] + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of resource identity.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The tenant ID of resource.""" + type: Optional[Union[str, "_models.ResourceIdentityType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The identity type. Known values are: \"SystemAssigned\", \"UserAssigned\", \"SystemAssigned, + UserAssigned\", and \"None\".""" + user_assigned_identities: Optional[dict[str, "_models.UserAssignedResourceIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of user identities associated with the resource. The user identity dictionary key + references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[dict[str, "_models.UserAssignedResourceIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JitApproverDefinition(_Model): + """JIT approver definition. + + :ivar id: The approver service principal Id. Required. + :vartype id: str + :ivar type: The approver type. Known values are: "user" and "group". + :vartype type: str or ~azure.mgmt.managedapplications.models.JitApproverType + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The approver service principal Id. Required.""" + type: Optional[Union[str, "_models.JitApproverType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The approver type. Known values are: \"user\" and \"group\".""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """The approver display name.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + type: Optional[Union[str, "_models.JitApproverType"]] = None, + display_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JitAuthorizationPolicies(_Model): + """The JIT authorization policies. + + :ivar principal_id: The the principal id that will be granted JIT access. Required. + :vartype principal_id: str + :ivar role_definition_id: The role definition id that will be granted to the Principal. + Required. + :vartype role_definition_id: str + """ + + principal_id: str = rest_field(name="principalId", visibility=["read", "create", "update", "delete", "query"]) + """The the principal id that will be granted JIT access. Required.""" + role_definition_id: str = rest_field( + name="roleDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """The role definition id that will be granted to the Principal. Required.""" + + @overload + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData + :ivar properties: The JIT request properties. + :vartype properties: ~azure.mgmt.managedapplications.models.JitRequestProperties + """ + + properties: Optional["_models.JitRequestProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JIT request properties.""" + + __flattened_items = [ + "application_resource_id", + "publisher_tenant_id", + "jit_authorization_policies", + "jit_scheduling_policy", + "provisioning_state", + "jit_request_state", + "created_by", + "updated_by", + ] + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.JitRequestProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class JitRequestDefinitionListResult(_Model): + """The response of a JitRequestDefinition list operation. + + :ivar value: The JitRequestDefinition items on this page. Required. + :vartype value: list[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: list["_models.JitRequestDefinition"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The JitRequestDefinition items on this page. Required.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """The link to the next page of items.""" + + @overload + def __init__( + self, + *, + value: list["_models.JitRequestDefinition"], + next_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JitRequestMetadata(_Model): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + origin_request_id: Optional[str] = rest_field( + name="originRequestId", visibility=["read", "create", "update", "delete", "query"] + ) + """The origin request id.""" + requestor_id: Optional[str] = rest_field( + name="requestorId", visibility=["read", "create", "update", "delete", "query"] + ) + """The requestor id.""" + tenant_display_name: Optional[str] = rest_field( + name="tenantDisplayName", visibility=["read", "create", "update", "delete", "query"] + ) + """The publisher's tenant name.""" + subject_display_name: Optional[str] = rest_field( + name="subjectDisplayName", visibility=["read", "create", "update", "delete", "query"] + ) + """The subject display name.""" + + @overload + def __init__( + self, + *, + origin_request_id: Optional[str] = None, + requestor_id: Optional[str] = None, + tenant_display_name: Optional[str] = None, + subject_display_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JitRequestPatchable(_Model): + """Information about JIT request. + + :ivar tags: Jit request tags. + :vartype tags: dict[str, str] + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Jit request tags.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JitRequestProperties(_Model): + """Information about JIT request properties. + + :ivar application_resource_id: The parent application id. Required. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. Required. + :vartype jit_authorization_policies: + list[~azure.mgmt.managedapplications.models.JitAuthorizationPolicies] + :ivar jit_scheduling_policy: The JIT request properties. Required. + :vartype jit_scheduling_policy: ~azure.mgmt.managedapplications.models.JitSchedulingPolicy + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", "Succeeded", and + "Updating". + :vartype provisioning_state: str or ~azure.mgmt.managedapplications.models.ProvisioningState + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", and "Timeout". + :vartype jit_request_state: str or ~azure.mgmt.managedapplications.models.JitRequestState + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails + """ + + application_resource_id: str = rest_field( + name="applicationResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The parent application id. Required.""" + publisher_tenant_id: Optional[str] = rest_field(name="publisherTenantId", visibility=["read"]) + """The publisher tenant id.""" + jit_authorization_policies: list["_models.JitAuthorizationPolicies"] = rest_field( + name="jitAuthorizationPolicies", visibility=["read", "create", "update", "delete", "query"] + ) + """The JIT authorization policies. Required.""" + jit_scheduling_policy: "_models.JitSchedulingPolicy" = rest_field( + name="jitSchedulingPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The JIT request properties. Required.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The JIT request provisioning state. Known values are: \"NotSpecified\", \"Accepted\", + \"Running\", \"Deleting\", \"Deleted\", \"Canceled\", \"Failed\", \"Succeeded\", and + \"Updating\".""" + jit_request_state: Optional[Union[str, "_models.JitRequestState"]] = rest_field( + name="jitRequestState", visibility=["read"] + ) + """The JIT request state. Known values are: \"NotSpecified\", \"Pending\", \"Approved\", + \"Denied\", \"Failed\", \"Canceled\", \"Expired\", and \"Timeout\".""" + created_by: Optional["_models.ApplicationClientDetails"] = rest_field(name="createdBy", visibility=["read"]) + """The client entity that created the JIT request.""" + updated_by: Optional["_models.ApplicationClientDetails"] = rest_field(name="updatedBy", visibility=["read"]) + """The client entity that last updated the JIT request.""" + + @overload + def __init__( + self, + *, + application_resource_id: str, + jit_authorization_policies: list["_models.JitAuthorizationPolicies"], + jit_scheduling_policy: "_models.JitSchedulingPolicy", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JitSchedulingPolicy(_Model): + """The JIT scheduling policies. + + :ivar type: The type of JIT schedule. Required. Known values are: "NotSpecified", "Once", and + "Recurring". + :vartype type: str or ~azure.mgmt.managedapplications.models.JitSchedulingType + :ivar duration: The required duration of the JIT request. Required. + :vartype duration: ~datetime.timedelta + :ivar start_time: The start time of the request. Required. + :vartype start_time: ~datetime.datetime + """ + + type: Union[str, "_models.JitSchedulingType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of JIT schedule. Required. Known values are: \"NotSpecified\", \"Once\", and + \"Recurring\".""" + duration: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The required duration of the JIT request. Required.""" + start_time: datetime.datetime = rest_field( + name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The start time of the request. Required.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.JitSchedulingType"], + duration: datetime.timedelta, + start_time: datetime.datetime, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ListTokenRequest(_Model): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + authorization_audience: Optional[str] = rest_field( + name="authorizationAudience", visibility=["read", "create", "update", "delete", "query"] + ) + """The authorization audience.""" + user_assigned_identities: Optional[list[str]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The user assigned identities.""" + + @overload + def __init__( + self, + *, + authorization_audience: Optional[str] = None, + user_assigned_identities: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedIdentityToken(_Model): + """The managed identity token for the managed app resource. + + :ivar access_token: The requested access token. + :vartype access_token: str + :ivar expires_in: The number of seconds the access token will be valid. + :vartype expires_in: str + :ivar expires_on: The timespan when the access token expires. This is represented as the number + of seconds from epoch. + :vartype expires_on: str + :ivar not_before: The timespan when the access token takes effect. This is represented as the + number of seconds from epoch. + :vartype not_before: str + :ivar authorization_audience: The aud (audience) the access token was request for. This is the + same as what was provided in the listTokens request. + :vartype authorization_audience: str + :ivar resource_id: The Azure resource ID for the issued token. This is either the managed + application ID or the user-assigned identity ID. + :vartype resource_id: str + :ivar token_type: The type of the token. + :vartype token_type: str + """ + + access_token: Optional[str] = rest_field( + name="accessToken", visibility=["read", "create", "update", "delete", "query"] + ) + """The requested access token.""" + expires_in: Optional[str] = rest_field(name="expiresIn", visibility=["read", "create", "update", "delete", "query"]) + """The number of seconds the access token will be valid.""" + expires_on: Optional[str] = rest_field(name="expiresOn", visibility=["read", "create", "update", "delete", "query"]) + """The timespan when the access token expires. This is represented as the number of seconds from + epoch.""" + not_before: Optional[str] = rest_field(name="notBefore", visibility=["read", "create", "update", "delete", "query"]) + """The timespan when the access token takes effect. This is represented as the number of seconds + from epoch.""" + authorization_audience: Optional[str] = rest_field( + name="authorizationAudience", visibility=["read", "create", "update", "delete", "query"] + ) + """The aud (audience) the access token was request for. This is the same as what was provided in + the listTokens request.""" + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Azure resource ID for the issued token. This is either the managed application ID or the + user-assigned identity ID.""" + token_type: Optional[str] = rest_field(name="tokenType", visibility=["read", "create", "update", "delete", "query"]) + """The type of the token.""" + + @overload + def __init__( + self, + *, + access_token: Optional[str] = None, + expires_in: Optional[str] = None, + expires_on: Optional[str] = None, + not_before: Optional[str] = None, + authorization_audience: Optional[str] = None, + resource_id: Optional[str] = None, + token_type: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedIdentityTokenResult(_Model): + """The array of managed identity tokens. + + :ivar value: The array of managed identity tokens. + :vartype value: list[~azure.mgmt.managedapplications.models.ManagedIdentityToken] + """ + + value: Optional[list["_models.ManagedIdentityToken"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The array of managed identity tokens.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.ManagedIdentityToken"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """REST API Operation. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for Azure Resource Manager/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.managedapplications.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.managedapplications.models.Origin + :ivar action_type: Extensible enum. Indicates the action type. "Internal" refers to actions + that are for internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.managedapplications.models.ActionType + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + \"Microsoft.Compute/virtualMachines/write\", + \"Microsoft.Compute/virtualMachines/capture/action\".""" + is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) + """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and + \"false\" for Azure Resource Manager/control-plane operations.""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Localized display information for this particular operation.""" + origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and + \"user,system\".""" + action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType", visibility=["read"]) + """Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for + internal only APIs. \"Internal\"""" + + @overload + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationDisplay(_Model): + """Localized display information for an operation. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring + Insights\" or \"Microsoft Compute\".""" + resource: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly name of the resource type related to this operation. E.g. \"Virtual + Machines\" or \"Job Schedule Collections\".""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create + or Update Virtual Machine\", \"Restart Virtual Machine\".""" + description: Optional[str] = rest_field(visibility=["read"]) + """The short, localized friendly description of the operation; suitable for tool tips and detailed + views.""" + + +class Plan(_Model): + """Plan for the managed application. + + :ivar name: The plan name. Required. + :vartype name: str + :ivar publisher: The publisher ID. Required. + :vartype publisher: str + :ivar product: The product code. Required. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. Required. + :vartype version: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan name. Required.""" + publisher: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The publisher ID. Required.""" + product: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The product code. Required.""" + promotion_code: Optional[str] = rest_field( + name="promotionCode", visibility=["read", "create", "update", "delete", "query"] + ) + """The promotion code.""" + version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan's version. Required.""" + + @overload + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PlanPatchable(_Model): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan name.""" + publisher: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The publisher ID.""" + product: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The product code.""" + promotion_code: Optional[str] = rest_field( + name="promotionCode", visibility=["read", "create", "update", "delete", "query"] + ) + """The promotion code.""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan's version.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RegistryPackage(_Model): + """Information about an application definition request. + + :ivar publisher: The publisher. Required. + :vartype publisher: str + :ivar offer: The offer Id. Required. + :vartype offer: str + :ivar plan: The plan Id. Required. + :vartype plan: str + :ivar version: The version of the plan. Required. + :vartype version: str + :ivar package_links: The registry package links. Required. + :vartype package_links: ~azure.mgmt.managedapplications.models.RegistryPackageLinks + """ + + publisher: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The publisher. Required.""" + offer: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The offer Id. Required.""" + plan: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan Id. Required.""" + version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The version of the plan. Required.""" + package_links: "_models.RegistryPackageLinks" = rest_field( + name="packageLinks", visibility=["read", "create", "update", "delete", "query"] + ) + """The registry package links. Required.""" + + @overload + def __init__( + self, + *, + publisher: str, + offer: str, + plan: str, + version: str, + package_links: "_models.RegistryPackageLinks", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RegistryPackageLinks(_Model): + """Resource information. + + :ivar create_ui_definition_link: The create ui definition link. + :vartype create_ui_definition_link: str + :ivar deployment_template_link: The deployment template link. + :vartype deployment_template_link: str + """ + + create_ui_definition_link: Optional[str] = rest_field( + name="createUiDefinitionLink", visibility=["read", "create", "update", "delete", "query"] + ) + """The create ui definition link.""" + deployment_template_link: Optional[str] = rest_field( + name="deploymentTemplateLink", visibility=["read", "create", "update", "delete", "query"] + ) + """The deployment template link.""" + + @overload + def __init__( + self, + *, + create_ui_definition_link: Optional[str] = None, + deployment_template_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RegistryPackagePlan(_Model): + """Plan for the managed application. + + :ivar publisher: The publisher ID. Required. + :vartype publisher: str + :ivar offer: The offer Id. Required. + :vartype offer: str + :ivar plan: The plan Id. Required. + :vartype plan: str + :ivar version: The plan's version. + :vartype version: str + """ + + publisher: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The publisher ID. Required.""" + offer: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The offer Id. Required.""" + plan: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan Id. Required.""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan's version.""" + + @overload + def __init__( + self, + *, + publisher: str, + offer: str, + plan: str, + version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Sku(_Model): + """SKU for the resource. + + :ivar name: The SKU name. Required. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU name. Required.""" + tier: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU tier.""" + size: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU size.""" + family: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU family.""" + model: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU model.""" + capacity: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU capacity.""" + + @overload + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.managedapplications.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.managedapplications.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UpdateAccessDefinition(_Model): + """Update access request definition. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: The JIT request metadata. Required. + :vartype metadata: ~azure.mgmt.managedapplications.models.JitRequestMetadata + :ivar status: The JIT status. Required. Known values are: "NotSpecified", "Elevate", and + "Remove". + :vartype status: str or ~azure.mgmt.managedapplications.models.Status + :ivar sub_status: The JIT status. Required. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", and "Timeout". + :vartype sub_status: str or ~azure.mgmt.managedapplications.models.Substatus + """ + + approver: Optional[str] = rest_field(name="Approver", visibility=["read", "create", "update", "delete", "query"]) + """The approver name.""" + metadata: "_models.JitRequestMetadata" = rest_field( + name="Metadata", visibility=["read", "create", "update", "delete", "query"] + ) + """The JIT request metadata. Required.""" + status: Union[str, "_models.Status"] = rest_field( + name="Status", visibility=["read", "create", "update", "delete", "query"] + ) + """The JIT status. Required. Known values are: \"NotSpecified\", \"Elevate\", and \"Remove\".""" + sub_status: Union[str, "_models.Substatus"] = rest_field( + name="SubStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """The JIT status. Required. Known values are: \"NotSpecified\", \"Approved\", \"Denied\", + \"Failed\", \"Expired\", and \"Timeout\".""" + + @overload + def __init__( + self, + *, + metadata: "_models.JitRequestMetadata", + status: Union[str, "_models.Status"], + sub_status: Union[str, "_models.Substatus"], + approver: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserAssignedResourceIdentity(_Model): + """Represents the user assigned identity that is contained within the UserAssignedIdentities + dictionary on ResourceIdentity. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal id of user assigned identity.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The tenant id of user assigned identity.""" diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_models_py3.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_models_py3.py deleted file mode 100644 index 3c036b7aa023..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_models_py3.py +++ /dev/null @@ -1,2360 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -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 AllowedUpgradePlansResult(_serialization.Model): - """The array of plan. - - :ivar value: The array of plans. - :vartype value: list[~azure.mgmt.managedapplications.models.Plan] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Plan]"}, - } - - def __init__(self, *, value: Optional[List["_models.Plan"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The array of plans. - :paramtype value: list[~azure.mgmt.managedapplications.models.Plan] - """ - super().__init__(**kwargs) - self.value = value - - -class Resource(_serialization.Model): - """Resource information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.managedapplications.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"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.system_data = None - - -class GenericResource(Resource): - """Resource information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData - :ivar managed_by: ID of the resource that manages this resource. - :vartype managed_by: str - :ivar sku: The SKU of the resource. - :vartype sku: ~azure.mgmt.managedapplications.models.Sku - """ - - _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"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - managed_by: Optional[str] = None, - sku: Optional["_models.Sku"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword managed_by: ID of the resource that manages this resource. - :paramtype managed_by: str - :keyword sku: The SKU of the resource. - :paramtype sku: ~azure.mgmt.managedapplications.models.Sku - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by = managed_by - self.sku = sku - - -class Application(GenericResource): # pylint: disable=too-many-instance-attributes - """Information about managed application. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData - :ivar managed_by: ID of the resource that manages this resource. - :vartype managed_by: str - :ivar sku: The SKU of the resource. - :vartype sku: ~azure.mgmt.managedapplications.models.Sku - :ivar plan: The plan information. - :vartype plan: ~azure.mgmt.managedapplications.models.Plan - :ivar kind: The kind of the managed application. Allowed values are MarketPlace and - ServiceCatalog. Required. - :vartype kind: str - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.managedapplications.models.Identity - :ivar managed_resource_group_id: The managed resource group Id. - :vartype managed_resource_group_id: str - :ivar application_definition_id: The fully qualified path of managed application definition Id. - :vartype application_definition_id: str - :ivar parameters: Name and value pairs that define the managed application parameters. It can - be a JObject or a well formed JSON string. - :vartype parameters: JSON - :ivar outputs: Name and value pairs that define the managed application outputs. - :vartype outputs: JSON - :ivar provisioning_state: The managed application provisioning state. Known values are: - "NotSpecified", "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", - "Succeeded", and "Updating". - :vartype provisioning_state: str or ~azure.mgmt.managedapplications.models.ProvisioningState - :ivar billing_details: The managed application billing details. - :vartype billing_details: - ~azure.mgmt.managedapplications.models.ApplicationBillingDetailsDefinition - :ivar jit_access_policy: The managed application Jit access policy. - :vartype jit_access_policy: ~azure.mgmt.managedapplications.models.ApplicationJitAccessPolicy - :ivar publisher_tenant_id: The publisher tenant Id. - :vartype publisher_tenant_id: str - :ivar authorizations: The read-only authorizations property that is retrieved from the - application package. - :vartype authorizations: list[~azure.mgmt.managedapplications.models.ApplicationAuthorization] - :ivar management_mode: The managed application management mode. Known values are: - "NotSpecified", "Unmanaged", and "Managed". - :vartype management_mode: str or - ~azure.mgmt.managedapplications.models.ApplicationManagementMode - :ivar customer_support: The read-only customer support property that is retrieved from the - application package. - :vartype customer_support: ~azure.mgmt.managedapplications.models.ApplicationPackageContact - :ivar support_urls: The read-only support URLs property that is retrieved from the application - package. - :vartype support_urls: ~azure.mgmt.managedapplications.models.ApplicationPackageSupportUrls - :ivar artifacts: The collection of managed application artifacts. - :vartype artifacts: list[~azure.mgmt.managedapplications.models.ApplicationArtifact] - :ivar created_by: The client entity that created the JIT request. - :vartype created_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails - :ivar updated_by: The client entity that last updated the JIT request. - :vartype updated_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "kind": {"required": True, "pattern": r"^[-\w\._,\(\)]+$"}, - "outputs": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "billing_details": {"readonly": True}, - "publisher_tenant_id": {"readonly": True}, - "authorizations": {"readonly": True}, - "management_mode": {"readonly": True}, - "customer_support": {"readonly": True}, - "support_urls": {"readonly": True}, - "artifacts": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "kind": {"key": "kind", "type": "str"}, - "identity": {"key": "identity", "type": "Identity"}, - "managed_resource_group_id": {"key": "properties.managedResourceGroupId", "type": "str"}, - "application_definition_id": {"key": "properties.applicationDefinitionId", "type": "str"}, - "parameters": {"key": "properties.parameters", "type": "object"}, - "outputs": {"key": "properties.outputs", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "billing_details": {"key": "properties.billingDetails", "type": "ApplicationBillingDetailsDefinition"}, - "jit_access_policy": {"key": "properties.jitAccessPolicy", "type": "ApplicationJitAccessPolicy"}, - "publisher_tenant_id": {"key": "properties.publisherTenantId", "type": "str"}, - "authorizations": {"key": "properties.authorizations", "type": "[ApplicationAuthorization]"}, - "management_mode": {"key": "properties.managementMode", "type": "str"}, - "customer_support": {"key": "properties.customerSupport", "type": "ApplicationPackageContact"}, - "support_urls": {"key": "properties.supportUrls", "type": "ApplicationPackageSupportUrls"}, - "artifacts": {"key": "properties.artifacts", "type": "[ApplicationArtifact]"}, - "created_by": {"key": "properties.createdBy", "type": "ApplicationClientDetails"}, - "updated_by": {"key": "properties.updatedBy", "type": "ApplicationClientDetails"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - kind: str, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - managed_by: Optional[str] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.Identity"] = None, - managed_resource_group_id: Optional[str] = None, - application_definition_id: Optional[str] = None, - parameters: Optional[JSON] = None, - jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword managed_by: ID of the resource that manages this resource. - :paramtype managed_by: str - :keyword sku: The SKU of the resource. - :paramtype sku: ~azure.mgmt.managedapplications.models.Sku - :keyword plan: The plan information. - :paramtype plan: ~azure.mgmt.managedapplications.models.Plan - :keyword kind: The kind of the managed application. Allowed values are MarketPlace and - ServiceCatalog. Required. - :paramtype kind: str - :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.managedapplications.models.Identity - :keyword managed_resource_group_id: The managed resource group Id. - :paramtype managed_resource_group_id: str - :keyword application_definition_id: The fully qualified path of managed application definition - Id. - :paramtype application_definition_id: str - :keyword parameters: Name and value pairs that define the managed application parameters. It - can be a JObject or a well formed JSON string. - :paramtype parameters: JSON - :keyword jit_access_policy: The managed application Jit access policy. - :paramtype jit_access_policy: ~azure.mgmt.managedapplications.models.ApplicationJitAccessPolicy - """ - super().__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) - self.plan = plan - self.kind = kind - self.identity = identity - self.managed_resource_group_id = managed_resource_group_id - self.application_definition_id = application_definition_id - self.parameters = parameters - self.outputs = None - self.provisioning_state = None - self.billing_details = None - self.jit_access_policy = jit_access_policy - self.publisher_tenant_id = None - self.authorizations = None - self.management_mode = None - self.customer_support = None - self.support_urls = None - self.artifacts = None - self.created_by = None - self.updated_by = None - - -class ApplicationArtifact(_serialization.Model): - """Managed application artifact. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The managed application artifact name. Required. Known values are: "NotSpecified", - "ViewDefinition", "Authorizations", and "CustomRoleDefinition". - :vartype name: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactName - :ivar uri: The managed application artifact blob uri. Required. - :vartype uri: str - :ivar type: The managed application artifact type. Required. Known values are: "NotSpecified", - "Template", and "Custom". - :vartype type: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactType - """ - - _validation = { - "name": {"required": True}, - "uri": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "uri": {"key": "uri", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Union[str, "_models.ApplicationArtifactName"], - uri: str, - type: Union[str, "_models.ApplicationArtifactType"], - **kwargs: Any - ) -> None: - """ - :keyword name: The managed application artifact name. Required. Known values are: - "NotSpecified", "ViewDefinition", "Authorizations", and "CustomRoleDefinition". - :paramtype name: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactName - :keyword uri: The managed application artifact blob uri. Required. - :paramtype uri: str - :keyword type: The managed application artifact type. Required. Known values are: - "NotSpecified", "Template", and "Custom". - :paramtype type: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactType - """ - super().__init__(**kwargs) - self.name = name - self.uri = uri - self.type = type - - -class ApplicationAuthorization(_serialization.Model): - """The managed application provider authorization. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The provider's principal identifier. This is the identity that the provider - will use to call ARM to manage the managed application resources. Required. - :vartype principal_id: str - :ivar role_definition_id: The provider's role definition identifier. This role will define all - the permissions that the provider must have on the managed application's container resource - group. This role definition cannot have permission to delete the resource group. Required. - :vartype role_definition_id: str - """ - - _validation = { - "principal_id": {"required": True}, - "role_definition_id": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - } - - def __init__(self, *, principal_id: str, role_definition_id: str, **kwargs: Any) -> None: - """ - :keyword principal_id: The provider's principal identifier. This is the identity that the - provider will use to call ARM to manage the managed application resources. Required. - :paramtype principal_id: str - :keyword role_definition_id: The provider's role definition identifier. This role will define - all the permissions that the provider must have on the managed application's container resource - group. This role definition cannot have permission to delete the resource group. Required. - :paramtype role_definition_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - - -class ApplicationBillingDetailsDefinition(_serialization.Model): - """Managed application billing details definition. - - :ivar resource_usage_id: The managed application resource usage Id. - :vartype resource_usage_id: str - """ - - _attribute_map = { - "resource_usage_id": {"key": "resourceUsageId", "type": "str"}, - } - - def __init__(self, *, resource_usage_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword resource_usage_id: The managed application resource usage Id. - :paramtype resource_usage_id: str - """ - super().__init__(**kwargs) - self.resource_usage_id = resource_usage_id - - -class ApplicationClientDetails(_serialization.Model): - """The application client details to track the entity creating/updating the managed app resource. - - :ivar oid: The client Oid. - :vartype oid: str - :ivar puid: The client Puid. - :vartype puid: str - :ivar application_id: The client application Id. - :vartype application_id: str - """ - - _attribute_map = { - "oid": {"key": "oid", "type": "str"}, - "puid": {"key": "puid", "type": "str"}, - "application_id": {"key": "applicationId", "type": "str"}, - } - - def __init__( - self, - *, - oid: Optional[str] = None, - puid: Optional[str] = None, - application_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword oid: The client Oid. - :paramtype oid: str - :keyword puid: The client Puid. - :paramtype puid: str - :keyword application_id: The client application Id. - :paramtype application_id: str - """ - super().__init__(**kwargs) - self.oid = oid - self.puid = puid - self.application_id = application_id - - -class ApplicationDefinition(GenericResource): # pylint: disable=too-many-instance-attributes - """Information about managed application definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData - :ivar managed_by: ID of the resource that manages this resource. - :vartype managed_by: str - :ivar sku: The SKU of the resource. - :vartype sku: ~azure.mgmt.managedapplications.models.Sku - :ivar lock_level: The managed application lock level. Required. Known values are: - "CanNotDelete", "ReadOnly", and "None". - :vartype lock_level: str or ~azure.mgmt.managedapplications.models.ApplicationLockLevel - :ivar display_name: The managed application definition display name. - :vartype display_name: str - :ivar is_enabled: A value indicating whether the package is enabled or not. - :vartype is_enabled: bool - :ivar authorizations: The managed application provider authorizations. - :vartype authorizations: list[~azure.mgmt.managedapplications.models.ApplicationAuthorization] - :ivar artifacts: The collection of managed application artifacts. The portal will use the files - specified as artifacts to construct the user experience of creating a managed application from - a managed application definition. - :vartype artifacts: list[~azure.mgmt.managedapplications.models.ApplicationDefinitionArtifact] - :ivar description: The managed application definition description. - :vartype description: str - :ivar package_file_uri: The managed application definition package file Uri. Use this element. - :vartype package_file_uri: str - :ivar storage_account_id: The storage account id for bring your own storage scenario. - :vartype storage_account_id: str - :ivar main_template: The inline main template json which has resources to be provisioned. It - can be a JObject or well-formed JSON string. - :vartype main_template: JSON - :ivar create_ui_definition: The createUiDefinition json for the backing template with - Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. - :vartype create_ui_definition: JSON - :ivar notification_policy: The managed application notification policy. - :vartype notification_policy: - ~azure.mgmt.managedapplications.models.ApplicationNotificationPolicy - :ivar locking_policy: The managed application locking policy. - :vartype locking_policy: - ~azure.mgmt.managedapplications.models.ApplicationPackageLockingPolicyDefinition - :ivar deployment_policy: The managed application deployment policy. - :vartype deployment_policy: ~azure.mgmt.managedapplications.models.ApplicationDeploymentPolicy - :ivar management_policy: The managed application management policy that determines publisher's - access to the managed resource group. - :vartype management_policy: ~azure.mgmt.managedapplications.models.ApplicationManagementPolicy - :ivar policies: The managed application provider policies. - :vartype policies: list[~azure.mgmt.managedapplications.models.ApplicationPolicy] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "lock_level": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "lock_level": {"key": "properties.lockLevel", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "authorizations": {"key": "properties.authorizations", "type": "[ApplicationAuthorization]"}, - "artifacts": {"key": "properties.artifacts", "type": "[ApplicationDefinitionArtifact]"}, - "description": {"key": "properties.description", "type": "str"}, - "package_file_uri": {"key": "properties.packageFileUri", "type": "str"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "main_template": {"key": "properties.mainTemplate", "type": "object"}, - "create_ui_definition": {"key": "properties.createUiDefinition", "type": "object"}, - "notification_policy": {"key": "properties.notificationPolicy", "type": "ApplicationNotificationPolicy"}, - "locking_policy": {"key": "properties.lockingPolicy", "type": "ApplicationPackageLockingPolicyDefinition"}, - "deployment_policy": {"key": "properties.deploymentPolicy", "type": "ApplicationDeploymentPolicy"}, - "management_policy": {"key": "properties.managementPolicy", "type": "ApplicationManagementPolicy"}, - "policies": {"key": "properties.policies", "type": "[ApplicationPolicy]"}, - } - - def __init__( - self, - *, - lock_level: Union[str, "_models.ApplicationLockLevel"], - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - managed_by: Optional[str] = None, - sku: Optional["_models.Sku"] = None, - display_name: Optional[str] = None, - is_enabled: Optional[bool] = None, - authorizations: Optional[List["_models.ApplicationAuthorization"]] = None, - artifacts: Optional[List["_models.ApplicationDefinitionArtifact"]] = None, - description: Optional[str] = None, - package_file_uri: Optional[str] = None, - storage_account_id: Optional[str] = None, - main_template: Optional[JSON] = None, - create_ui_definition: Optional[JSON] = None, - notification_policy: Optional["_models.ApplicationNotificationPolicy"] = None, - locking_policy: Optional["_models.ApplicationPackageLockingPolicyDefinition"] = None, - deployment_policy: Optional["_models.ApplicationDeploymentPolicy"] = None, - management_policy: Optional["_models.ApplicationManagementPolicy"] = None, - policies: Optional[List["_models.ApplicationPolicy"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword managed_by: ID of the resource that manages this resource. - :paramtype managed_by: str - :keyword sku: The SKU of the resource. - :paramtype sku: ~azure.mgmt.managedapplications.models.Sku - :keyword lock_level: The managed application lock level. Required. Known values are: - "CanNotDelete", "ReadOnly", and "None". - :paramtype lock_level: str or ~azure.mgmt.managedapplications.models.ApplicationLockLevel - :keyword display_name: The managed application definition display name. - :paramtype display_name: str - :keyword is_enabled: A value indicating whether the package is enabled or not. - :paramtype is_enabled: bool - :keyword authorizations: The managed application provider authorizations. - :paramtype authorizations: - list[~azure.mgmt.managedapplications.models.ApplicationAuthorization] - :keyword artifacts: The collection of managed application artifacts. The portal will use the - files specified as artifacts to construct the user experience of creating a managed application - from a managed application definition. - :paramtype artifacts: - list[~azure.mgmt.managedapplications.models.ApplicationDefinitionArtifact] - :keyword description: The managed application definition description. - :paramtype description: str - :keyword package_file_uri: The managed application definition package file Uri. Use this - element. - :paramtype package_file_uri: str - :keyword storage_account_id: The storage account id for bring your own storage scenario. - :paramtype storage_account_id: str - :keyword main_template: The inline main template json which has resources to be provisioned. It - can be a JObject or well-formed JSON string. - :paramtype main_template: JSON - :keyword create_ui_definition: The createUiDefinition json for the backing template with - Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. - :paramtype create_ui_definition: JSON - :keyword notification_policy: The managed application notification policy. - :paramtype notification_policy: - ~azure.mgmt.managedapplications.models.ApplicationNotificationPolicy - :keyword locking_policy: The managed application locking policy. - :paramtype locking_policy: - ~azure.mgmt.managedapplications.models.ApplicationPackageLockingPolicyDefinition - :keyword deployment_policy: The managed application deployment policy. - :paramtype deployment_policy: - ~azure.mgmt.managedapplications.models.ApplicationDeploymentPolicy - :keyword management_policy: The managed application management policy that determines - publisher's access to the managed resource group. - :paramtype management_policy: - ~azure.mgmt.managedapplications.models.ApplicationManagementPolicy - :keyword policies: The managed application provider policies. - :paramtype policies: list[~azure.mgmt.managedapplications.models.ApplicationPolicy] - """ - super().__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) - self.lock_level = lock_level - self.display_name = display_name - self.is_enabled = is_enabled - self.authorizations = authorizations - self.artifacts = artifacts - self.description = description - self.package_file_uri = package_file_uri - self.storage_account_id = storage_account_id - self.main_template = main_template - self.create_ui_definition = create_ui_definition - self.notification_policy = notification_policy - self.locking_policy = locking_policy - self.deployment_policy = deployment_policy - self.management_policy = management_policy - self.policies = policies - - -class ApplicationDefinitionArtifact(_serialization.Model): - """Application definition artifact. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The managed application definition artifact name. Required. Known values are: - "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", and - "MainTemplateParameters". - :vartype name: str or ~azure.mgmt.managedapplications.models.ApplicationDefinitionArtifactName - :ivar uri: The managed application definition artifact blob uri. Required. - :vartype uri: str - :ivar type: The managed application definition artifact type. Required. Known values are: - "NotSpecified", "Template", and "Custom". - :vartype type: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactType - """ - - _validation = { - "name": {"required": True}, - "uri": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "uri": {"key": "uri", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Union[str, "_models.ApplicationDefinitionArtifactName"], - uri: str, - type: Union[str, "_models.ApplicationArtifactType"], - **kwargs: Any - ) -> None: - """ - :keyword name: The managed application definition artifact name. Required. Known values are: - "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", and - "MainTemplateParameters". - :paramtype name: str or - ~azure.mgmt.managedapplications.models.ApplicationDefinitionArtifactName - :keyword uri: The managed application definition artifact blob uri. Required. - :paramtype uri: str - :keyword type: The managed application definition artifact type. Required. Known values are: - "NotSpecified", "Template", and "Custom". - :paramtype type: str or ~azure.mgmt.managedapplications.models.ApplicationArtifactType - """ - super().__init__(**kwargs) - self.name = name - self.uri = uri - self.type = type - - -class ApplicationDefinitionListResult(_serialization.Model): - """List of managed application definitions. - - :ivar value: The array of managed application definitions. - :vartype value: list[~azure.mgmt.managedapplications.models.ApplicationDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ApplicationDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ApplicationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The array of managed application definitions. - :paramtype value: list[~azure.mgmt.managedapplications.models.ApplicationDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ApplicationDefinitionPatchable(_serialization.Model): - """Information about an application definition request. - - :ivar tags: Application definition tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Application definition tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class ApplicationDeploymentPolicy(_serialization.Model): - """Managed application deployment policy. - - All required parameters must be populated in order to send to Azure. - - :ivar deployment_mode: The managed application deployment mode. Required. Known values are: - "NotSpecified", "Incremental", and "Complete". - :vartype deployment_mode: str or ~azure.mgmt.managedapplications.models.DeploymentMode - """ - - _validation = { - "deployment_mode": {"required": True}, - } - - _attribute_map = { - "deployment_mode": {"key": "deploymentMode", "type": "str"}, - } - - def __init__(self, *, deployment_mode: Union[str, "_models.DeploymentMode"], **kwargs: Any) -> None: - """ - :keyword deployment_mode: The managed application deployment mode. Required. Known values are: - "NotSpecified", "Incremental", and "Complete". - :paramtype deployment_mode: str or ~azure.mgmt.managedapplications.models.DeploymentMode - """ - super().__init__(**kwargs) - self.deployment_mode = deployment_mode - - -class ApplicationJitAccessPolicy(_serialization.Model): - """Managed application Jit access policy. - - All required parameters must be populated in order to send to Azure. - - :ivar jit_access_enabled: Whether the JIT access is enabled. Required. - :vartype jit_access_enabled: bool - :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", - and "ManualApprove". - :vartype jit_approval_mode: str or ~azure.mgmt.managedapplications.models.JitApprovalMode - :ivar jit_approvers: The JIT approvers. - :vartype jit_approvers: list[~azure.mgmt.managedapplications.models.JitApproverDefinition] - :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an - ISO8601 time period value. - :vartype maximum_jit_access_duration: str - """ - - _validation = { - "jit_access_enabled": {"required": True}, - } - - _attribute_map = { - "jit_access_enabled": {"key": "jitAccessEnabled", "type": "bool"}, - "jit_approval_mode": {"key": "jitApprovalMode", "type": "str"}, - "jit_approvers": {"key": "jitApprovers", "type": "[JitApproverDefinition]"}, - "maximum_jit_access_duration": {"key": "maximumJitAccessDuration", "type": "str"}, - } - - def __init__( - self, - *, - jit_access_enabled: bool, - jit_approval_mode: Optional[Union[str, "_models.JitApprovalMode"]] = None, - jit_approvers: Optional[List["_models.JitApproverDefinition"]] = None, - maximum_jit_access_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword jit_access_enabled: Whether the JIT access is enabled. Required. - :paramtype jit_access_enabled: bool - :keyword jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", - and "ManualApprove". - :paramtype jit_approval_mode: str or ~azure.mgmt.managedapplications.models.JitApprovalMode - :keyword jit_approvers: The JIT approvers. - :paramtype jit_approvers: list[~azure.mgmt.managedapplications.models.JitApproverDefinition] - :keyword maximum_jit_access_duration: The maximum duration JIT access is granted. This is an - ISO8601 time period value. - :paramtype maximum_jit_access_duration: str - """ - super().__init__(**kwargs) - self.jit_access_enabled = jit_access_enabled - self.jit_approval_mode = jit_approval_mode - self.jit_approvers = jit_approvers - self.maximum_jit_access_duration = maximum_jit_access_duration - - -class ApplicationListResult(_serialization.Model): - """List of managed applications. - - :ivar value: The array of managed applications. - :vartype value: list[~azure.mgmt.managedapplications.models.Application] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Application]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Application"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The array of managed applications. - :paramtype value: list[~azure.mgmt.managedapplications.models.Application] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ApplicationManagementPolicy(_serialization.Model): - """Managed application management policy. - - :ivar mode: The managed application management mode. Known values are: "NotSpecified", - "Unmanaged", and "Managed". - :vartype mode: str or ~azure.mgmt.managedapplications.models.ApplicationManagementMode - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - } - - def __init__( - self, *, mode: Optional[Union[str, "_models.ApplicationManagementMode"]] = None, **kwargs: Any - ) -> None: - """ - :keyword mode: The managed application management mode. Known values are: "NotSpecified", - "Unmanaged", and "Managed". - :paramtype mode: str or ~azure.mgmt.managedapplications.models.ApplicationManagementMode - """ - super().__init__(**kwargs) - self.mode = mode - - -class ApplicationNotificationEndpoint(_serialization.Model): - """Managed application notification endpoint. - - All required parameters must be populated in order to send to Azure. - - :ivar uri: The managed application notification endpoint uri. Required. - :vartype uri: str - """ - - _validation = { - "uri": {"required": True}, - } - - _attribute_map = { - "uri": {"key": "uri", "type": "str"}, - } - - def __init__(self, *, uri: str, **kwargs: Any) -> None: - """ - :keyword uri: The managed application notification endpoint uri. Required. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.uri = uri - - -class ApplicationNotificationPolicy(_serialization.Model): - """Managed application notification policy. - - All required parameters must be populated in order to send to Azure. - - :ivar notification_endpoints: The managed application notification endpoint. Required. - :vartype notification_endpoints: - list[~azure.mgmt.managedapplications.models.ApplicationNotificationEndpoint] - """ - - _validation = { - "notification_endpoints": {"required": True}, - } - - _attribute_map = { - "notification_endpoints": {"key": "notificationEndpoints", "type": "[ApplicationNotificationEndpoint]"}, - } - - def __init__( - self, *, notification_endpoints: List["_models.ApplicationNotificationEndpoint"], **kwargs: Any - ) -> None: - """ - :keyword notification_endpoints: The managed application notification endpoint. Required. - :paramtype notification_endpoints: - list[~azure.mgmt.managedapplications.models.ApplicationNotificationEndpoint] - """ - super().__init__(**kwargs) - self.notification_endpoints = notification_endpoints - - -class ApplicationPackageContact(_serialization.Model): - """The application package contact information. - - All required parameters must be populated in order to send to Azure. - - :ivar contact_name: The contact name. - :vartype contact_name: str - :ivar email: The contact email. Required. - :vartype email: str - :ivar phone: The contact phone number. Required. - :vartype phone: str - """ - - _validation = { - "email": {"required": True}, - "phone": {"required": True}, - } - - _attribute_map = { - "contact_name": {"key": "contactName", "type": "str"}, - "email": {"key": "email", "type": "str"}, - "phone": {"key": "phone", "type": "str"}, - } - - def __init__(self, *, email: str, phone: str, contact_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword contact_name: The contact name. - :paramtype contact_name: str - :keyword email: The contact email. Required. - :paramtype email: str - :keyword phone: The contact phone number. Required. - :paramtype phone: str - """ - super().__init__(**kwargs) - self.contact_name = contact_name - self.email = email - self.phone = phone - - -class ApplicationPackageLockingPolicyDefinition(_serialization.Model): - """Managed application locking policy. - - :ivar allowed_actions: The deny assignment excluded actions. - :vartype allowed_actions: list[str] - :ivar allowed_data_actions: The deny assignment excluded data actions. - :vartype allowed_data_actions: list[str] - """ - - _attribute_map = { - "allowed_actions": {"key": "allowedActions", "type": "[str]"}, - "allowed_data_actions": {"key": "allowedDataActions", "type": "[str]"}, - } - - def __init__( - self, - *, - allowed_actions: Optional[List[str]] = None, - allowed_data_actions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword allowed_actions: The deny assignment excluded actions. - :paramtype allowed_actions: list[str] - :keyword allowed_data_actions: The deny assignment excluded data actions. - :paramtype allowed_data_actions: list[str] - """ - super().__init__(**kwargs) - self.allowed_actions = allowed_actions - self.allowed_data_actions = allowed_data_actions - - -class ApplicationPackageSupportUrls(_serialization.Model): - """The appliance package support URLs. - - :ivar public_azure: The public azure support URL. - :vartype public_azure: str - :ivar government_cloud: The government cloud support URL. - :vartype government_cloud: str - """ - - _attribute_map = { - "public_azure": {"key": "publicAzure", "type": "str"}, - "government_cloud": {"key": "governmentCloud", "type": "str"}, - } - - def __init__( - self, *, public_azure: Optional[str] = None, government_cloud: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword public_azure: The public azure support URL. - :paramtype public_azure: str - :keyword government_cloud: The government cloud support URL. - :paramtype government_cloud: str - """ - super().__init__(**kwargs) - self.public_azure = public_azure - self.government_cloud = government_cloud - - -class ApplicationPatchable(GenericResource): # pylint: disable=too-many-instance-attributes - """Information about managed application. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData - :ivar managed_by: ID of the resource that manages this resource. - :vartype managed_by: str - :ivar sku: The SKU of the resource. - :vartype sku: ~azure.mgmt.managedapplications.models.Sku - :ivar plan: The plan information. - :vartype plan: ~azure.mgmt.managedapplications.models.PlanPatchable - :ivar kind: The kind of the managed application. Allowed values are MarketPlace and - ServiceCatalog. - :vartype kind: str - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.managedapplications.models.Identity - :ivar managed_resource_group_id: The managed resource group Id. - :vartype managed_resource_group_id: str - :ivar application_definition_id: The fully qualified path of managed application definition Id. - :vartype application_definition_id: str - :ivar parameters: Name and value pairs that define the managed application parameters. It can - be a JObject or a well formed JSON string. - :vartype parameters: JSON - :ivar outputs: Name and value pairs that define the managed application outputs. - :vartype outputs: JSON - :ivar provisioning_state: The managed application provisioning state. Known values are: - "NotSpecified", "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", - "Succeeded", and "Updating". - :vartype provisioning_state: str or ~azure.mgmt.managedapplications.models.ProvisioningState - :ivar billing_details: The managed application billing details. - :vartype billing_details: - ~azure.mgmt.managedapplications.models.ApplicationBillingDetailsDefinition - :ivar jit_access_policy: The managed application Jit access policy. - :vartype jit_access_policy: ~azure.mgmt.managedapplications.models.ApplicationJitAccessPolicy - :ivar publisher_tenant_id: The publisher tenant Id. - :vartype publisher_tenant_id: str - :ivar authorizations: The read-only authorizations property that is retrieved from the - application package. - :vartype authorizations: list[~azure.mgmt.managedapplications.models.ApplicationAuthorization] - :ivar management_mode: The managed application management mode. Known values are: - "NotSpecified", "Unmanaged", and "Managed". - :vartype management_mode: str or - ~azure.mgmt.managedapplications.models.ApplicationManagementMode - :ivar customer_support: The read-only customer support property that is retrieved from the - application package. - :vartype customer_support: ~azure.mgmt.managedapplications.models.ApplicationPackageContact - :ivar support_urls: The read-only support URLs property that is retrieved from the application - package. - :vartype support_urls: ~azure.mgmt.managedapplications.models.ApplicationPackageSupportUrls - :ivar artifacts: The collection of managed application artifacts. - :vartype artifacts: list[~azure.mgmt.managedapplications.models.ApplicationArtifact] - :ivar created_by: The client entity that created the JIT request. - :vartype created_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails - :ivar updated_by: The client entity that last updated the JIT request. - :vartype updated_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, - "outputs": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "billing_details": {"readonly": True}, - "publisher_tenant_id": {"readonly": True}, - "authorizations": {"readonly": True}, - "management_mode": {"readonly": True}, - "customer_support": {"readonly": True}, - "support_urls": {"readonly": True}, - "artifacts": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "PlanPatchable"}, - "kind": {"key": "kind", "type": "str"}, - "identity": {"key": "identity", "type": "Identity"}, - "managed_resource_group_id": {"key": "properties.managedResourceGroupId", "type": "str"}, - "application_definition_id": {"key": "properties.applicationDefinitionId", "type": "str"}, - "parameters": {"key": "properties.parameters", "type": "object"}, - "outputs": {"key": "properties.outputs", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "billing_details": {"key": "properties.billingDetails", "type": "ApplicationBillingDetailsDefinition"}, - "jit_access_policy": {"key": "properties.jitAccessPolicy", "type": "ApplicationJitAccessPolicy"}, - "publisher_tenant_id": {"key": "properties.publisherTenantId", "type": "str"}, - "authorizations": {"key": "properties.authorizations", "type": "[ApplicationAuthorization]"}, - "management_mode": {"key": "properties.managementMode", "type": "str"}, - "customer_support": {"key": "properties.customerSupport", "type": "ApplicationPackageContact"}, - "support_urls": {"key": "properties.supportUrls", "type": "ApplicationPackageSupportUrls"}, - "artifacts": {"key": "properties.artifacts", "type": "[ApplicationArtifact]"}, - "created_by": {"key": "properties.createdBy", "type": "ApplicationClientDetails"}, - "updated_by": {"key": "properties.updatedBy", "type": "ApplicationClientDetails"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - managed_by: Optional[str] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.PlanPatchable"] = None, - kind: Optional[str] = None, - identity: Optional["_models.Identity"] = None, - managed_resource_group_id: Optional[str] = None, - application_definition_id: Optional[str] = None, - parameters: Optional[JSON] = None, - jit_access_policy: Optional["_models.ApplicationJitAccessPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword managed_by: ID of the resource that manages this resource. - :paramtype managed_by: str - :keyword sku: The SKU of the resource. - :paramtype sku: ~azure.mgmt.managedapplications.models.Sku - :keyword plan: The plan information. - :paramtype plan: ~azure.mgmt.managedapplications.models.PlanPatchable - :keyword kind: The kind of the managed application. Allowed values are MarketPlace and - ServiceCatalog. - :paramtype kind: str - :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.managedapplications.models.Identity - :keyword managed_resource_group_id: The managed resource group Id. - :paramtype managed_resource_group_id: str - :keyword application_definition_id: The fully qualified path of managed application definition - Id. - :paramtype application_definition_id: str - :keyword parameters: Name and value pairs that define the managed application parameters. It - can be a JObject or a well formed JSON string. - :paramtype parameters: JSON - :keyword jit_access_policy: The managed application Jit access policy. - :paramtype jit_access_policy: ~azure.mgmt.managedapplications.models.ApplicationJitAccessPolicy - """ - super().__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, **kwargs) - self.plan = plan - self.kind = kind - self.identity = identity - self.managed_resource_group_id = managed_resource_group_id - self.application_definition_id = application_definition_id - self.parameters = parameters - self.outputs = None - self.provisioning_state = None - self.billing_details = None - self.jit_access_policy = jit_access_policy - self.publisher_tenant_id = None - self.authorizations = None - self.management_mode = None - self.customer_support = None - self.support_urls = None - self.artifacts = None - self.created_by = None - self.updated_by = None - - -class ApplicationPolicy(_serialization.Model): - """Managed application policy. - - :ivar name: The policy name. - :vartype name: str - :ivar policy_definition_id: The policy definition Id. - :vartype policy_definition_id: str - :ivar parameters: The policy parameters. - :vartype parameters: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "parameters": {"key": "parameters", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - policy_definition_id: Optional[str] = None, - parameters: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The policy name. - :paramtype name: str - :keyword policy_definition_id: The policy definition Id. - :paramtype policy_definition_id: str - :keyword parameters: The policy parameters. - :paramtype parameters: str - """ - super().__init__(**kwargs) - self.name = name - self.policy_definition_id = policy_definition_id - self.parameters = parameters - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.managedapplications.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.managedapplications.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.managedapplications.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.managedapplications.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Identity(_serialization.Model): - """Identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.managedapplications.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the resource. The - user identity dictionary key references will be resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.managedapplications.models.UserAssignedResourceIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedResourceIdentity}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedResourceIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.managedapplications.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the resource. - The user identity dictionary key references will be resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.managedapplications.models.UserAssignedResourceIdentity] - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class JitApproverDefinition(_serialization.Model): - """JIT approver definition. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The approver service principal Id. Required. - :vartype id: str - :ivar type: The approver type. Known values are: "user" and "group". - :vartype type: str or ~azure.mgmt.managedapplications.models.JitApproverType - :ivar display_name: The approver display name. - :vartype display_name: str - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - type: Optional[Union[str, "_models.JitApproverType"]] = None, - display_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The approver service principal Id. Required. - :paramtype id: str - :keyword type: The approver type. Known values are: "user" and "group". - :paramtype type: str or ~azure.mgmt.managedapplications.models.JitApproverType - :keyword display_name: The approver display name. - :paramtype display_name: str - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.display_name = display_name - - -class JitAuthorizationPolicies(_serialization.Model): - """The JIT authorization policies. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The the principal id that will be granted JIT access. Required. - :vartype principal_id: str - :ivar role_definition_id: The role definition id that will be granted to the Principal. - Required. - :vartype role_definition_id: str - """ - - _validation = { - "principal_id": {"required": True}, - "role_definition_id": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - } - - def __init__(self, *, principal_id: str, role_definition_id: str, **kwargs: Any) -> None: - """ - :keyword principal_id: The the principal id that will be granted JIT access. Required. - :paramtype principal_id: str - :keyword role_definition_id: The role definition id that will be granted to the Principal. - Required. - :paramtype role_definition_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - - -class JitRequestDefinition(Resource): # pylint: disable=too-many-instance-attributes - """Information about JIT request definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.managedapplications.models.SystemData - :ivar application_resource_id: The parent application id. - :vartype application_resource_id: str - :ivar publisher_tenant_id: The publisher tenant id. - :vartype publisher_tenant_id: str - :ivar jit_authorization_policies: The JIT authorization policies. - :vartype jit_authorization_policies: - list[~azure.mgmt.managedapplications.models.JitAuthorizationPolicies] - :ivar jit_scheduling_policy: The JIT request properties. - :vartype jit_scheduling_policy: ~azure.mgmt.managedapplications.models.JitSchedulingPolicy - :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", - "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", "Succeeded", and - "Updating". - :vartype provisioning_state: str or ~azure.mgmt.managedapplications.models.ProvisioningState - :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", - "Approved", "Denied", "Failed", "Canceled", "Expired", and "Timeout". - :vartype jit_request_state: str or ~azure.mgmt.managedapplications.models.JitRequestState - :ivar created_by: The client entity that created the JIT request. - :vartype created_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails - :ivar updated_by: The client entity that last updated the JIT request. - :vartype updated_by: ~azure.mgmt.managedapplications.models.ApplicationClientDetails - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "publisher_tenant_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "jit_request_state": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "application_resource_id": {"key": "properties.applicationResourceId", "type": "str"}, - "publisher_tenant_id": {"key": "properties.publisherTenantId", "type": "str"}, - "jit_authorization_policies": { - "key": "properties.jitAuthorizationPolicies", - "type": "[JitAuthorizationPolicies]", - }, - "jit_scheduling_policy": {"key": "properties.jitSchedulingPolicy", "type": "JitSchedulingPolicy"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "jit_request_state": {"key": "properties.jitRequestState", "type": "str"}, - "created_by": {"key": "properties.createdBy", "type": "ApplicationClientDetails"}, - "updated_by": {"key": "properties.updatedBy", "type": "ApplicationClientDetails"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - application_resource_id: Optional[str] = None, - jit_authorization_policies: Optional[List["_models.JitAuthorizationPolicies"]] = None, - jit_scheduling_policy: Optional["_models.JitSchedulingPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword application_resource_id: The parent application id. - :paramtype application_resource_id: str - :keyword jit_authorization_policies: The JIT authorization policies. - :paramtype jit_authorization_policies: - list[~azure.mgmt.managedapplications.models.JitAuthorizationPolicies] - :keyword jit_scheduling_policy: The JIT request properties. - :paramtype jit_scheduling_policy: ~azure.mgmt.managedapplications.models.JitSchedulingPolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.application_resource_id = application_resource_id - self.publisher_tenant_id = None - self.jit_authorization_policies = jit_authorization_policies - self.jit_scheduling_policy = jit_scheduling_policy - self.provisioning_state = None - self.jit_request_state = None - self.created_by = None - self.updated_by = None - - -class JitRequestDefinitionListResult(_serialization.Model): - """List of JIT requests. - - :ivar value: The array of Jit request definition. - :vartype value: list[~azure.mgmt.managedapplications.models.JitRequestDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[JitRequestDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.JitRequestDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The array of Jit request definition. - :paramtype value: list[~azure.mgmt.managedapplications.models.JitRequestDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class JitRequestMetadata(_serialization.Model): - """The JIT request metadata. - - :ivar origin_request_id: The origin request id. - :vartype origin_request_id: str - :ivar requestor_id: The requestor id. - :vartype requestor_id: str - :ivar tenant_display_name: The publisher's tenant name. - :vartype tenant_display_name: str - :ivar subject_display_name: The subject display name. - :vartype subject_display_name: str - """ - - _attribute_map = { - "origin_request_id": {"key": "originRequestId", "type": "str"}, - "requestor_id": {"key": "requestorId", "type": "str"}, - "tenant_display_name": {"key": "tenantDisplayName", "type": "str"}, - "subject_display_name": {"key": "subjectDisplayName", "type": "str"}, - } - - def __init__( - self, - *, - origin_request_id: Optional[str] = None, - requestor_id: Optional[str] = None, - tenant_display_name: Optional[str] = None, - subject_display_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword origin_request_id: The origin request id. - :paramtype origin_request_id: str - :keyword requestor_id: The requestor id. - :paramtype requestor_id: str - :keyword tenant_display_name: The publisher's tenant name. - :paramtype tenant_display_name: str - :keyword subject_display_name: The subject display name. - :paramtype subject_display_name: str - """ - super().__init__(**kwargs) - self.origin_request_id = origin_request_id - self.requestor_id = requestor_id - self.tenant_display_name = tenant_display_name - self.subject_display_name = subject_display_name - - -class JitRequestPatchable(_serialization.Model): - """Information about JIT request. - - :ivar tags: Jit request tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Jit request tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class JitSchedulingPolicy(_serialization.Model): - """The JIT scheduling policies. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of JIT schedule. Required. Known values are: "NotSpecified", "Once", and - "Recurring". - :vartype type: str or ~azure.mgmt.managedapplications.models.JitSchedulingType - :ivar duration: The required duration of the JIT request. Required. - :vartype duration: ~datetime.timedelta - :ivar start_time: The start time of the request. Required. - :vartype start_time: ~datetime.datetime - """ - - _validation = { - "type": {"required": True}, - "duration": {"required": True}, - "start_time": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "duration": {"key": "duration", "type": "duration"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.JitSchedulingType"], - duration: datetime.timedelta, - start_time: datetime.datetime, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of JIT schedule. Required. Known values are: "NotSpecified", "Once", - and "Recurring". - :paramtype type: str or ~azure.mgmt.managedapplications.models.JitSchedulingType - :keyword duration: The required duration of the JIT request. Required. - :paramtype duration: ~datetime.timedelta - :keyword start_time: The start time of the request. Required. - :paramtype start_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.type = type - self.duration = duration - self.start_time = start_time - - -class ListTokenRequest(_serialization.Model): - """List token request body. - - :ivar authorization_audience: The authorization audience. - :vartype authorization_audience: str - :ivar user_assigned_identities: The user assigned identities. - :vartype user_assigned_identities: list[str] - """ - - _attribute_map = { - "authorization_audience": {"key": "authorizationAudience", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "[str]"}, - } - - def __init__( - self, - *, - authorization_audience: Optional[str] = None, - user_assigned_identities: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword authorization_audience: The authorization audience. - :paramtype authorization_audience: str - :keyword user_assigned_identities: The user assigned identities. - :paramtype user_assigned_identities: list[str] - """ - super().__init__(**kwargs) - self.authorization_audience = authorization_audience - self.user_assigned_identities = user_assigned_identities - - -class ManagedIdentityToken(_serialization.Model): - """The managed identity token for the managed app resource. - - :ivar access_token: The requested access token. - :vartype access_token: str - :ivar expires_in: The number of seconds the access token will be valid. - :vartype expires_in: str - :ivar expires_on: The timespan when the access token expires. This is represented as the number - of seconds from epoch. - :vartype expires_on: str - :ivar not_before: The timespan when the access token takes effect. This is represented as the - number of seconds from epoch. - :vartype not_before: str - :ivar authorization_audience: The aud (audience) the access token was request for. This is the - same as what was provided in the listTokens request. - :vartype authorization_audience: str - :ivar resource_id: The Azure resource ID for the issued token. This is either the managed - application ID or the user-assigned identity ID. - :vartype resource_id: str - :ivar token_type: The type of the token. - :vartype token_type: str - """ - - _attribute_map = { - "access_token": {"key": "accessToken", "type": "str"}, - "expires_in": {"key": "expiresIn", "type": "str"}, - "expires_on": {"key": "expiresOn", "type": "str"}, - "not_before": {"key": "notBefore", "type": "str"}, - "authorization_audience": {"key": "authorizationAudience", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "token_type": {"key": "tokenType", "type": "str"}, - } - - def __init__( - self, - *, - access_token: Optional[str] = None, - expires_in: Optional[str] = None, - expires_on: Optional[str] = None, - not_before: Optional[str] = None, - authorization_audience: Optional[str] = None, - resource_id: Optional[str] = None, - token_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword access_token: The requested access token. - :paramtype access_token: str - :keyword expires_in: The number of seconds the access token will be valid. - :paramtype expires_in: str - :keyword expires_on: The timespan when the access token expires. This is represented as the - number of seconds from epoch. - :paramtype expires_on: str - :keyword not_before: The timespan when the access token takes effect. This is represented as - the number of seconds from epoch. - :paramtype not_before: str - :keyword authorization_audience: The aud (audience) the access token was request for. This is - the same as what was provided in the listTokens request. - :paramtype authorization_audience: str - :keyword resource_id: The Azure resource ID for the issued token. This is either the managed - application ID or the user-assigned identity ID. - :paramtype resource_id: str - :keyword token_type: The type of the token. - :paramtype token_type: str - """ - super().__init__(**kwargs) - self.access_token = access_token - self.expires_in = expires_in - self.expires_on = expires_on - self.not_before = not_before - self.authorization_audience = authorization_audience - self.resource_id = resource_id - self.token_type = token_type - - -class ManagedIdentityTokenResult(_serialization.Model): - """The array of managed identity tokens. - - :ivar value: The array of managed identity tokens. - :vartype value: list[~azure.mgmt.managedapplications.models.ManagedIdentityToken] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedIdentityToken]"}, - } - - def __init__(self, *, value: Optional[List["_models.ManagedIdentityToken"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The array of managed identity tokens. - :paramtype value: list[~azure.mgmt.managedapplications.models.ManagedIdentityToken] - """ - super().__init__(**kwargs) - self.value = value - - -class Operation(_serialization.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". - :vartype name: str - :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for - data-plane operations and "false" for ARM/control-plane operations. - :vartype is_data_action: bool - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.managedapplications.models.OperationDisplay - :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", - and "user,system". - :vartype origin: str or ~azure.mgmt.managedapplications.models.Origin - :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. "Internal" - :vartype action_type: str or ~azure.mgmt.managedapplications.models.ActionType - """ - - _validation = { - "name": {"readonly": True}, - "is_data_action": {"readonly": True}, - "origin": {"readonly": True}, - "action_type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "action_type": {"key": "actionType", "type": "str"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Localized display information for this particular operation. - :paramtype display: ~azure.mgmt.managedapplications.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.is_data_action = None - self.display = display - self.origin = None - self.action_type = None - - -class OperationDisplay(_serialization.Model): - """Localized display information for this particular operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link - to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.managedapplications.models.Operation] - :ivar next_link: URL to get the next set of operation list results (if there are any). - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class Plan(_serialization.Model): - """Plan for the managed application. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The plan name. Required. - :vartype name: str - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar product: The product code. Required. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - :ivar version: The plan's version. Required. - :vartype version: str - """ - - _validation = { - "name": {"required": True}, - "publisher": {"required": True}, - "product": {"required": True}, - "version": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - "version": {"key": "version", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - publisher: str, - product: str, - version: str, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan name. Required. - :paramtype name: str - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword product: The product code. Required. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - :keyword version: The plan's version. Required. - :paramtype version: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - self.version = version - - -class PlanPatchable(_serialization.Model): - """Plan for the managed application. - - :ivar name: The plan name. - :vartype name: str - :ivar publisher: The publisher ID. - :vartype publisher: str - :ivar product: The product code. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - :ivar version: The plan's version. - :vartype version: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - "version": {"key": "version", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan name. - :paramtype name: str - :keyword publisher: The publisher ID. - :paramtype publisher: str - :keyword product: The product code. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - :keyword version: The plan's version. - :paramtype version: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - self.version = version - - -class Sku(_serialization.Model): - """SKU for the resource. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The SKU name. Required. - :vartype name: str - :ivar tier: The SKU tier. - :vartype tier: str - :ivar size: The SKU size. - :vartype size: str - :ivar family: The SKU family. - :vartype family: str - :ivar model: The SKU model. - :vartype model: str - :ivar capacity: The SKU capacity. - :vartype capacity: int - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "size": {"key": "size", "type": "str"}, - "family": {"key": "family", "type": "str"}, - "model": {"key": "model", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, - *, - name: str, - tier: Optional[str] = None, - size: Optional[str] = None, - family: Optional[str] = None, - model: Optional[str] = None, - capacity: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The SKU name. Required. - :paramtype name: str - :keyword tier: The SKU tier. - :paramtype tier: str - :keyword size: The SKU size. - :paramtype size: str - :keyword family: The SKU family. - :paramtype family: str - :keyword model: The SKU model. - :paramtype model: str - :keyword capacity: The SKU capacity. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.size = size - self.family = family - self.model = model - self.capacity = capacity - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.managedapplications.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.managedapplications.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.managedapplications.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.managedapplications.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class UpdateAccessDefinition(_serialization.Model): - """Update access request definition. - - All required parameters must be populated in order to send to Azure. - - :ivar approver: The approver name. - :vartype approver: str - :ivar metadata: The JIT request metadata. Required. - :vartype metadata: ~azure.mgmt.managedapplications.models.JitRequestMetadata - :ivar status: The JIT status. Required. Known values are: "NotSpecified", "Elevate", and - "Remove". - :vartype status: str or ~azure.mgmt.managedapplications.models.Status - :ivar sub_status: The JIT status. Required. Known values are: "NotSpecified", "Approved", - "Denied", "Failed", "Expired", and "Timeout". - :vartype sub_status: str or ~azure.mgmt.managedapplications.models.Substatus - """ - - _validation = { - "metadata": {"required": True}, - "status": {"required": True}, - "sub_status": {"required": True}, - } - - _attribute_map = { - "approver": {"key": "approver", "type": "str"}, - "metadata": {"key": "metadata", "type": "JitRequestMetadata"}, - "status": {"key": "status", "type": "str"}, - "sub_status": {"key": "subStatus", "type": "str"}, - } - - def __init__( - self, - *, - metadata: "_models.JitRequestMetadata", - status: Union[str, "_models.Status"], - sub_status: Union[str, "_models.Substatus"], - approver: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword approver: The approver name. - :paramtype approver: str - :keyword metadata: The JIT request metadata. Required. - :paramtype metadata: ~azure.mgmt.managedapplications.models.JitRequestMetadata - :keyword status: The JIT status. Required. Known values are: "NotSpecified", "Elevate", and - "Remove". - :paramtype status: str or ~azure.mgmt.managedapplications.models.Status - :keyword sub_status: The JIT status. Required. Known values are: "NotSpecified", "Approved", - "Denied", "Failed", "Expired", and "Timeout". - :paramtype sub_status: str or ~azure.mgmt.managedapplications.models.Substatus - """ - super().__init__(**kwargs) - self.approver = approver - self.metadata = metadata - self.status = status - self.sub_status = sub_status - - -class UserAssignedResourceIdentity(_serialization.Model): - """Represents the user assigned identity that is contained within the UserAssignedIdentities - dictionary on ResourceIdentity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of user assigned identity. - :vartype tenant_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_patch.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_patch.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/models/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/__init__.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/__init__.py index 0597df909301..c2139abdd693 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/__init__.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/__init__.py @@ -2,24 +2,29 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._managed_applications_mgmt_client_operations import ManagedApplicationsMgmtClientOperationsMixin -from ._applications_operations import ApplicationsOperations -from ._application_definitions_operations import ApplicationDefinitionsOperations -from ._jit_requests_operations import JitRequestsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import ApplicationsOperations # type: ignore +from ._operations import ApplicationDefinitionsOperations # type: ignore +from ._operations import JitRequestsOperations # type: ignore +from ._operations import _ManagedApplicationsMgmtClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ManagedApplicationsMgmtClientOperationsMixin", "ApplicationsOperations", "ApplicationDefinitionsOperations", "JitRequestsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_application_definitions_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_application_definitions_operations.py deleted file mode 100644 index 0cdbad152614..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_application_definitions_operations.py +++ /dev/null @@ -1,1425 +0,0 @@ -# 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 ManagedApplicationsMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, application_definition_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationDefinitionName": _SERIALIZER.url( - "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, application_definition_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationDefinitionName": _SERIALIZER.url( - "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 - ), - } - - _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_create_or_update_request( - resource_group_name: str, application_definition_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", "2021-07-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.Solutions/applicationDefinitions/{applicationDefinitionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationDefinitionName": _SERIALIZER.url( - "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 - ), - } - - _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_update_request( - resource_group_name: str, application_definition_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", "2021-07-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.Solutions/applicationDefinitions/{applicationDefinitionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationDefinitionName": _SERIALIZER.url( - "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request( - resource_group_name: str, application_definition_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "applicationDefinitionName": _SERIALIZER.url( - "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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_delete_by_id_request( - resource_group_name: str, application_definition_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "applicationDefinitionName": _SERIALIZER.url( - "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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_create_or_update_by_id_request( - resource_group_name: str, application_definition_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", "2021-07-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.Solutions/applicationDefinitions/{applicationDefinitionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "applicationDefinitionName": _SERIALIZER.url( - "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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_update_by_id_request( - resource_group_name: str, application_definition_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", "2021-07-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.Solutions/applicationDefinitions/{applicationDefinitionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationDefinitionName": _SERIALIZER.url( - "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class ApplicationDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.managedapplications.ManagedApplicationsMgmtClient`'s - :attr:`application_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 get( - self, resource_group_name: str, application_definition_name: str, **kwargs: Any - ) -> Optional[_models.ApplicationDefinition]: - """Gets the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition 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.ApplicationDefinition]] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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, 404]: - 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("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, application_definition_name: str, **kwargs: Any - ) -> None: - """Deletes the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 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, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: _models.ApplicationDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an managed application - definition. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an managed application - definition. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: Union[_models.ApplicationDefinition, IO], - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an managed application - definition. Is either a ApplicationDefinition type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition 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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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.ApplicationDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ApplicationDefinition") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @overload - def update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: _models.ApplicationDefinitionPatchable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. - Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable - :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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. - Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: Union[_models.ApplicationDefinitionPatchable, IO], - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. Is - either a ApplicationDefinitionPatchable type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable 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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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.ApplicationDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ApplicationDefinitionPatchable") - - request = build_update_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ApplicationDefinition"]: - """Lists the managed application definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.ApplicationDefinition] - :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.ApplicationDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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("ApplicationDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ApplicationDefinition"]: - """Lists all the application definitions within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.ApplicationDefinition] - :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.ApplicationDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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("ApplicationDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions" - } - - @distributed_trace - def get_by_id( - self, resource_group_name: str, application_definition_name: str, **kwargs: Any - ) -> Optional[_models.ApplicationDefinition]: - """Gets the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition 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.ApplicationDefinition]] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.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, 404]: - 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("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @distributed_trace - def delete_by_id( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, application_definition_name: str, **kwargs: Any - ) -> None: - """Deletes the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 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_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_by_id.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_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @overload - def create_or_update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: _models.ApplicationDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update a managed application - definition. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update a managed application - definition. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: Union[_models.ApplicationDefinition, IO], - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Creates or updates a managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update a managed application - definition. Is either a ApplicationDefinition type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition 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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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.ApplicationDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ApplicationDefinition") - - request = build_create_or_update_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } - - @overload - def update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: _models.ApplicationDefinitionPatchable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. - Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable - :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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. - Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: Union[_models.ApplicationDefinitionPatchable, IO], - **kwargs: Any - ) -> _models.ApplicationDefinition: - """Updates the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. Required. - :type application_definition_name: str - :param parameters: Parameters supplied to the update a managed application definition. Is - either a ApplicationDefinitionPatchable type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable 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: ApplicationDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition - :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.ApplicationDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ApplicationDefinitionPatchable") - - request = build_update_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ApplicationDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" - } diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_applications_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_applications_operations.py deleted file mode 100644 index 1cb06a936e03..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_applications_operations.py +++ /dev/null @@ -1,2442 +0,0 @@ -# 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, cast, 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.polling import LROPoller, NoPolling, PollingMethod -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 azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import ManagedApplicationsMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, application_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, application_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), - } - - _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_create_or_update_request( - resource_group_name: str, application_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", "2021-07-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.Solutions/applications/{applicationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), - } - - _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_update_request( - resource_group_name: str, application_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", "2021-07-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.Solutions/applications/{applicationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(application_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{applicationId}") - path_format_arguments = { - "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request(application_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{applicationId}") - path_format_arguments = { - "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), - } - - _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_create_or_update_by_id_request(application_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", "2021-07-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", "/{applicationId}") - path_format_arguments = { - "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), - } - - _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_update_by_id_request(application_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", "2021-07-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", "/{applicationId}") - path_format_arguments = { - "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_refresh_permissions_request( - resource_group_name: str, application_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_allowed_upgrade_plans_request( - resource_group_name: str, application_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_access_request( - resource_group_name: str, application_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", "2021-07-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.Solutions/applications/{applicationName}/updateAccess", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_tokens_request( - resource_group_name: str, application_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", "2021-07-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.Solutions/applications/{applicationName}/listTokens", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), - } - - _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 ApplicationsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.managedapplications.ManagedApplicationsMgmtClient`'s - :attr:`applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, application_name: str, **kwargs: Any) -> Optional[_models.Application]: - """Gets the managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.Application 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.Application]] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - 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("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> None: - 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, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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, 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_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - @distributed_trace - def begin_delete(self, resource_group_name: str, application_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes the managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - application_name=application_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - def _create_or_update_initial( - self, resource_group_name: str, application_name: str, parameters: Union[_models.Application, IO], **kwargs: Any - ) -> _models.Application: - 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.Application] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Application") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Application", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - application_name: str, - parameters: _models.Application, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Application]: - """Creates or updates a managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to the create or update a managed application. Required. - :type parameters: ~azure.mgmt.managedapplications.models.Application - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - application_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Application]: - """Creates or updates a managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to the create or update a managed application. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, application_name: str, parameters: Union[_models.Application, IO], **kwargs: Any - ) -> LROPoller[_models.Application]: - """Creates or updates a managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to the create or update a managed application. Is either - a Application type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.Application or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - application_name=application_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Application", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - def _update_initial( - self, - resource_group_name: str, - application_name: str, - parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, - **kwargs: Any - ) -> _models.ApplicationPatchable: - 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.ApplicationPatchable] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ApplicationPatchable") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 response.status_code == 200: - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - @overload - def begin_update( - self, - resource_group_name: str, - application_name: str, - parameters: Optional[_models.ApplicationPatchable] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ApplicationPatchable or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - application_name: str, - parameters: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ApplicationPatchable or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - application_name: str, - parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, - **kwargs: Any - ) -> LROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Parameters supplied to update an existing managed application. Is either a - ApplicationPatchable type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ApplicationPatchable or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ApplicationPatchable] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - application_name=application_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" - } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Application"]: - """Lists all the applications within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Application or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.Application] - :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.ApplicationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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("ApplicationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Application"]: - """Lists all the applications within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Application or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.Application] - :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.ApplicationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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("ApplicationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications" - } - - @distributed_trace - def get_by_id(self, application_id: str, **kwargs: Any) -> Optional[_models.Application]: - """Gets the managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.Application 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.Application]] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - application_id=application_id, - api_version=api_version, - template_url=self.get_by_id.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, 404]: - 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("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{applicationId}"} - - def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, application_id: str, **kwargs: Any - ) -> None: - 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_by_id_request( - application_id=application_id, - api_version=api_version, - template_url=self._delete_by_id_initial.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, 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_by_id_initial.metadata = {"url": "/{applicationId}"} - - @distributed_trace - def begin_delete_by_id(self, application_id: str, **kwargs: Any) -> LROPoller[None]: - """Deletes the managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_by_id_initial( # type: ignore - application_id=application_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete_by_id.metadata = {"url": "/{applicationId}"} - - def _create_or_update_by_id_initial( - self, application_id: str, parameters: Union[_models.Application, IO], **kwargs: Any - ) -> _models.Application: - 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.Application] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Application") - - request = build_create_or_update_by_id_request( - application_id=application_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_by_id_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("Application", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Application", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_by_id_initial.metadata = {"url": "/{applicationId}"} - - @overload - def begin_create_or_update_by_id( - self, - application_id: str, - parameters: _models.Application, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Application]: - """Creates or updates a managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to the create or update a managed application. Required. - :type parameters: ~azure.mgmt.managedapplications.models.Application - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update_by_id( - self, application_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Application]: - """Creates or updates a managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to the create or update a managed application. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update_by_id( - self, application_id: str, parameters: Union[_models.Application, IO], **kwargs: Any - ) -> LROPoller[_models.Application]: - """Creates or updates a managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to the create or update a managed application. Is either - a Application type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.Application or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either Application or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Application] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_by_id_initial( - application_id=application_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Application", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update_by_id.metadata = {"url": "/{applicationId}"} - - def _update_by_id_initial( - self, application_id: str, parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, **kwargs: Any - ) -> _models.ApplicationPatchable: - 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.ApplicationPatchable] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ApplicationPatchable") - else: - _json = None - - request = build_update_by_id_request( - application_id=application_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_by_id_initial.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 response.status_code == 200: - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _update_by_id_initial.metadata = {"url": "/{applicationId}"} - - @overload - def begin_update_by_id( - self, - application_id: str, - parameters: Optional[_models.ApplicationPatchable] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ApplicationPatchable or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_by_id( - self, - application_id: str, - parameters: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ApplicationPatchable or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_by_id( - self, application_id: str, parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, **kwargs: Any - ) -> LROPoller[_models.ApplicationPatchable]: - """Updates an existing managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - Required. - :type application_id: str - :param parameters: Parameters supplied to update an existing managed application. Is either a - ApplicationPatchable type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ApplicationPatchable or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.ApplicationPatchable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ApplicationPatchable] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_by_id_initial( - application_id=application_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApplicationPatchable", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update_by_id.metadata = {"url": "/{applicationId}"} - - def _refresh_permissions_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> None: - 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_refresh_permissions_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._refresh_permissions_initial.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, {}) - - _refresh_permissions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions" - } - - @distributed_trace - def begin_refresh_permissions( - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Refresh Permissions for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._refresh_permissions_initial( # type: ignore - resource_group_name=resource_group_name, - application_name=application_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh_permissions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions" - } - - @distributed_trace - def list_allowed_upgrade_plans( - self, resource_group_name: str, application_name: str, **kwargs: Any - ) -> _models.AllowedUpgradePlansResult: - """List allowed upgrade plans for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AllowedUpgradePlansResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.AllowedUpgradePlansResult - :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.AllowedUpgradePlansResult] = kwargs.pop("cls", None) - - request = build_list_allowed_upgrade_plans_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_allowed_upgrade_plans.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AllowedUpgradePlansResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_allowed_upgrade_plans.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans" - } - - def _update_access_initial( - self, - resource_group_name: str, - application_name: str, - parameters: Union[_models.UpdateAccessDefinition, IO], - **kwargs: Any - ) -> Optional[_models.UpdateAccessDefinition]: - 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.UpdateAccessDefinition]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "UpdateAccessDefinition") - - request = build_update_access_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_access_initial.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 == 202: - deserialized = self._deserialize("UpdateAccessDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_access_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess" - } - - @overload - def begin_update_access( - self, - resource_group_name: str, - application_name: str, - parameters: _models.UpdateAccessDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.UpdateAccessDefinition]: - """Update access for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Required. - :type parameters: ~azure.mgmt.managedapplications.models.UpdateAccessDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_access( - self, - resource_group_name: str, - application_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.UpdateAccessDefinition]: - """Update access for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_access( - self, - resource_group_name: str, - application_name: str, - parameters: Union[_models.UpdateAccessDefinition, IO], - **kwargs: Any - ) -> LROPoller[_models.UpdateAccessDefinition]: - """Update access for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Is either a UpdateAccessDefinition - type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.UpdateAccessDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either UpdateAccessDefinition or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_access_initial( - resource_group_name=resource_group_name, - application_name=application_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("UpdateAccessDefinition", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update_access.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess" - } - - @overload - def list_tokens( - self, - resource_group_name: str, - application_name: str, - parameters: _models.ListTokenRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedIdentityTokenResult: - """List tokens for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ListTokenRequest - :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: ManagedIdentityTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def list_tokens( - self, - resource_group_name: str, - application_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedIdentityTokenResult: - """List tokens for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedIdentityTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def list_tokens( - self, - resource_group_name: str, - application_name: str, - parameters: Union[_models.ListTokenRequest, IO], - **kwargs: Any - ) -> _models.ManagedIdentityTokenResult: - """List tokens for application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param application_name: The name of the managed application. Required. - :type application_name: str - :param parameters: Request body parameters to list tokens. Is either a ListTokenRequest type or - a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.ListTokenRequest 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: ManagedIdentityTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult - :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.ManagedIdentityTokenResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ListTokenRequest") - - request = build_list_tokens_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.list_tokens.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedIdentityTokenResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_tokens.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens" - } diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_jit_requests_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_jit_requests_operations.py deleted file mode 100644 index d2b5b2ef0389..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_jit_requests_operations.py +++ /dev/null @@ -1,865 +0,0 @@ -# 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, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -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 azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import ManagedApplicationsMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, jit_request_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, jit_request_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", "2021-07-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.Solutions/jitRequests/{jitRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, jit_request_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", "2021-07-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.Solutions/jitRequests/{jitRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, jit_request_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class JitRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.managedapplications.ManagedApplicationsMgmtClient`'s - :attr:`jit_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, jit_request_name: str, **kwargs: Any - ) -> Optional[_models.JitRequestDefinition]: - """Gets the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitRequestDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition 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.JitRequestDefinition]] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - jit_request_name=jit_request_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - 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("JitRequestDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - jit_request_name: str, - parameters: Union[_models.JitRequestDefinition, IO], - **kwargs: Any - ) -> _models.JitRequestDefinition: - 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.JitRequestDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JitRequestDefinition") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - jit_request_name=jit_request_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("JitRequestDefinition", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("JitRequestDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: _models.JitRequestDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.JitRequestDefinition]: - """Creates or updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Required. - :type parameters: ~azure.mgmt.managedapplications.models.JitRequestDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either JitRequestDefinition or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.JitRequestDefinition]: - """Creates or updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either JitRequestDefinition or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: Union[_models.JitRequestDefinition, IO], - **kwargs: Any - ) -> LROPoller[_models.JitRequestDefinition]: - """Creates or updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Is either a - JitRequestDefinition type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.JitRequestDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either JitRequestDefinition or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JitRequestDefinition] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - jit_request_name=jit_request_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JitRequestDefinition", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - @overload - def update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: _models.JitRequestPatchable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitRequestDefinition: - """Updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Required. - :type parameters: ~azure.mgmt.managedapplications.models.JitRequestPatchable - :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: JitRequestDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JitRequestDefinition: - """Updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitRequestDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - jit_request_name: str, - parameters: Union[_models.JitRequestPatchable, IO], - **kwargs: Any - ) -> _models.JitRequestDefinition: - """Updates the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_name: str - :param parameters: Parameters supplied to the update JIT request. Is either a - JitRequestPatchable type or a IO type. Required. - :type parameters: ~azure.mgmt.managedapplications.models.JitRequestPatchable 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: JitRequestDefinition or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition - :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.JitRequestDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JitRequestPatchable") - - request = build_update_request( - resource_group_name=resource_group_name, - jit_request_name=jit_request_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitRequestDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, jit_request_name: str, **kwargs: Any - ) -> None: - """Deletes the JIT request. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param jit_request_name: The name of the JIT request. Required. - :type jit_request_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, - jit_request_name=jit_request_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> _models.JitRequestDefinitionListResult: - """Lists all JIT requests within the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitRequestDefinitionListResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinitionListResult - :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.JitRequestDefinitionListResult] = kwargs.pop("cls", None) - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitRequestDefinitionListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests"} - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> _models.JitRequestDefinitionListResult: - """Lists all JIT requests within the resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitRequestDefinitionListResult or the result of cls(response) - :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinitionListResult - :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.JitRequestDefinitionListResult] = kwargs.pop("cls", None) - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JitRequestDefinitionListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests" - } diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_managed_applications_mgmt_client_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_managed_applications_mgmt_client_operations.py deleted file mode 100644 index beb856a0dc6d..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_managed_applications_mgmt_client_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.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 ManagedApplicationsMgmtClientMixinABC, _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_operations_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedApplicationsMgmtClientOperationsMixin(ManagedApplicationsMgmtClientMixinABC): - @distributed_trace - def list_operations(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available Microsoft.Solutions REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.Operation] - :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.OperationListResult] = 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_operations_request( - api_version=api_version, - template_url=self.list_operations.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("OperationListResult", 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_operations.metadata = {"url": "/providers/Microsoft.Solutions/operations"} diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_operations.py new file mode 100644 index 000000000000..074a8c4232cc --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_operations.py @@ -0,0 +1,5098 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models, types as _types +from .._configuration import ManagedApplicationsMgmtClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer +from .._utils.utils import ClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_applications_get_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_update_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_delete_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_applications_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_refresh_permissions_request( # pylint: disable=name-too-long + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/refreshPermissions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_applications_list_allowed_upgrade_plans_request( # pylint: disable=name-too-long + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listAllowedUpgradePlans" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_update_access_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_list_tokens_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_get_by_id_request(application_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{applicationId}" + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), + } + + _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_applications_create_or_update_by_id_request( # pylint: disable=name-too-long + application_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{applicationId}" + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), + } + + _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_applications_update_by_id_request(application_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{applicationId}" + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_delete_by_id_request(application_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + # Construct URL + _url = "/{applicationId}" + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_application_definitions_get_request( # pylint: disable=name-too-long + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_update_request( # pylint: disable=name-too-long + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_delete_request( # pylint: disable=name-too-long + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_application_definitions_get_by_id_request( # pylint: disable=name-too-long + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}?disambiguation_dummy" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_create_or_update_by_id_request( # pylint: disable=name-too-long + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}?disambiguation_dummy" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_update_by_id_request( # pylint: disable=name-too-long + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}?disambiguation_dummy" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_delete_by_id_request( # pylint: disable=name-too-long + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}?disambiguation_dummy" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_application_definitions_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applicationDefinitions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_jit_requests_get_request( + resource_group_name: str, jit_request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_jit_requests_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, jit_request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_jit_requests_update_request( + resource_group_name: str, jit_request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_jit_requests_delete_request( + resource_group_name: str, jit_request_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests/{jitRequestName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "jitRequestName": _SERIALIZER.url("jit_request_name", jit_request_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_jit_requests_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/jitRequests" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_jit_requests_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/jitRequests" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_applications_mgmt_portal_registry_package_request( # pylint: disable=name-too-long + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.Solutions/portalRegistryPackage" + + # 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_managed_applications_mgmt_list_operations_request( # pylint: disable=name-too-long + **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-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.Solutions/operations" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApplicationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplications.ManagedApplicationsMgmtClient`'s + :attr:`applications` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagedApplicationsMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, application_name: str, **kwargs: Any) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :return: Application or None. The Application is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.Application or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.Application]] = kwargs.pop("cls", None) + + _request = build_applications_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Application, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.Application, _types.Application, IO[bytes]], + **kwargs: Any, + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_applications_create_or_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: ~azure.mgmt.managedapplications.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _types.Application, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: ~azure.mgmt.managedapplications.types.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.Application, _types.Application, IO[bytes]], + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Is either + a Application type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.Application or + ~azure.mgmt.managedapplications.types.Application or IO[bytes] + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Application, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Application].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Application]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[Union[_models.ApplicationPatchable, _types.ApplicationPatchable, IO[bytes]]] = None, + **kwargs: Any, + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_applications_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_types.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[Union[_models.ApplicationPatchable, _types.ApplicationPatchable, IO[bytes]]] = None, + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Updates an existing managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Is either a + ApplicationPatchable type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable or + ~azure.mgmt.managedapplications.types.ApplicationPatchable or IO[bytes] + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Application, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Application].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Application]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, application_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_applications_delete_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, application_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + application_name=application_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Application"]: + """Lists all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Application + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.Application]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_applications_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.Application], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.Application"]: + """Lists all the applications within a subscription. + + :return: An iterator like instance of Application + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.Application]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_applications_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.Application], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _refresh_permissions_initial( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_applications_refresh_permissions_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_refresh_permissions( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Refresh Permissions for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._refresh_permissions_initial( + resource_group_name=resource_group_name, + application_name=application_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_allowed_upgrade_plans( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> _models.AllowedUpgradePlansResult: + """List allowed upgrade plans for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :return: AllowedUpgradePlansResult. The AllowedUpgradePlansResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.AllowedUpgradePlansResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AllowedUpgradePlansResult] = kwargs.pop("cls", None) + + _request = build_applications_list_allowed_upgrade_plans_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AllowedUpgradePlansResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_access_initial( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.UpdateAccessDefinition, _types.UpdateAccessDefinition, IO[bytes]], + **kwargs: Any, + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_applications_update_access_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _models.UpdateAccessDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to update access. Required. + :type parameters: ~azure.mgmt.managedapplications.models.UpdateAccessDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns UpdateAccessDefinition. The + UpdateAccessDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: _types.UpdateAccessDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to update access. Required. + :type parameters: ~azure.mgmt.managedapplications.types.UpdateAccessDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns UpdateAccessDefinition. The + UpdateAccessDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to update access. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns UpdateAccessDefinition. The + UpdateAccessDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_access( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.UpdateAccessDefinition, _types.UpdateAccessDefinition, IO[bytes]], + **kwargs: Any, + ) -> LROPoller[_models.UpdateAccessDefinition]: + """Update access for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to update access. Is either a UpdateAccessDefinition + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.UpdateAccessDefinition or + ~azure.mgmt.managedapplications.types.UpdateAccessDefinition or IO[bytes] + :return: An instance of LROPoller that returns UpdateAccessDefinition. The + UpdateAccessDefinition is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.UpdateAccessDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UpdateAccessDefinition] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_access_initial( + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.UpdateAccessDefinition, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.UpdateAccessDefinition].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.UpdateAccessDefinition]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _models.ListTokenRequest, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to list tokens. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ListTokenRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedIdentityTokenResult. The ManagedIdentityTokenResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: _types.ListTokenRequest, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to list tokens. Required. + :type parameters: ~azure.mgmt.managedapplications.types.ListTokenRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedIdentityTokenResult. The ManagedIdentityTokenResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to list tokens. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedIdentityTokenResult. The ManagedIdentityTokenResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_tokens( + self, + resource_group_name: str, + application_name: str, + parameters: Union[_models.ListTokenRequest, _types.ListTokenRequest, IO[bytes]], + **kwargs: Any, + ) -> _models.ManagedIdentityTokenResult: + """List tokens for application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Request body parameters to list tokens. Is either a ListTokenRequest type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ListTokenRequest or + ~azure.mgmt.managedapplications.types.ListTokenRequest or IO[bytes] + :return: ManagedIdentityTokenResult. The ManagedIdentityTokenResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ManagedIdentityTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedIdentityTokenResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_applications_list_tokens_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedIdentityTokenResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_by_id(self, application_id: str, **kwargs: Any) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :return: Application or None. The Application is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.Application or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.Application]] = kwargs.pop("cls", None) + + _request = build_applications_get_by_id_request( + application_id=application_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Application, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_by_id_initial( + self, application_id: str, parameters: Union[_models.Application, _types.Application, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_applications_create_or_update_by_id_request( + application_id=application_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to create or update a managed application. Required. + :type parameters: ~azure.mgmt.managedapplications.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _types.Application, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to create or update a managed application. Required. + :type parameters: ~azure.mgmt.managedapplications.types.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_by_id( + self, application_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to create or update a managed application. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, application_id: str, parameters: Union[_models.Application, _types.Application, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates or updates a managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to create or update a managed application. Is either a + Application type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.Application or + ~azure.mgmt.managedapplications.types.Application or IO[bytes] + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( + application_id=application_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Application, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Application].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Application]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_by_id_initial( + self, + application_id: str, + parameters: Optional[Union[_models.ApplicationPatchable, _types.ApplicationPatchable, IO[bytes]]] = None, + **kwargs: Any, + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_applications_update_by_id_request( + application_id=application_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_models.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Updates an existing managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[_types.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Updates an existing managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Updates an existing managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, + application_id: str, + parameters: Optional[Union[_models.ApplicationPatchable, _types.ApplicationPatchable, IO[bytes]]] = None, + **kwargs: Any, + ) -> LROPoller[_models.Application]: + """Updates an existing managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Is either a + ApplicationPatchable type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationPatchable or + ~azure.mgmt.managedapplications.types.ApplicationPatchable or IO[bytes] + :return: An instance of LROPoller that returns Application. The Application is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.Application] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_by_id_initial( + application_id=application_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Application, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Application].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Application]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_by_id_initial(self, application_id: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_applications_delete_by_id_request( + application_id=application_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete_by_id(self, application_id: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The ID of the managed application. Required. + :type application_id: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_by_id_initial( + application_id=application_id, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplications.ManagedApplicationsMgmtClient`'s + :attr:`application_definitions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagedApplicationsMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :return: ApplicationDefinition or None. The ApplicationDefinition is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.ApplicationDefinition]] = kwargs.pop("cls", None) + + _request = build_application_definitions_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _types.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, _types.ApplicationDefinition, IO[bytes]], + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Is either a ApplicationDefinition type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition or + ~azure.mgmt.managedapplications.types.ApplicationDefinition or IO[bytes] + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_application_definitions_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _types.ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + Required. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinitionPatchable, _types.ApplicationDefinitionPatchable, IO[bytes]], + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the update a managed application definition. Is + either a ApplicationDefinitionPatchable type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable or + ~azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable or IO[bytes] + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_application_definitions_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_application_definitions_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_by_id( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :return: ApplicationDefinition or None. The ApplicationDefinition is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.ApplicationDefinition]] = kwargs.pop("cls", None) + + _request = build_application_definitions_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _types.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, _types.ApplicationDefinition, IO[bytes]], + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Creates or updates a managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Is either a ApplicationDefinition type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinition or + ~azure.mgmt.managedapplications.types.ApplicationDefinition or IO[bytes] + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_application_definitions_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _types.ApplicationDefinitionPatchable, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinitionPatchable, _types.ApplicationDefinitionPatchable, IO[bytes]], + **kwargs: Any, + ) -> _models.ApplicationDefinition: + """Updates the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Resource create parameters. Is either a ApplicationDefinitionPatchable type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.ApplicationDefinitionPatchable or + ~azure.mgmt.managedapplications.types.ApplicationDefinitionPatchable or IO[bytes] + :return: ApplicationDefinition. The ApplicationDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_application_definitions_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApplicationDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_application_definitions_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.ApplicationDefinition"]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of ApplicationDefinition + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ApplicationDefinition]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_application_definitions_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ApplicationDefinition], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.ApplicationDefinition"]: + """Lists all the application definitions within a subscription. + + :return: An iterator like instance of ApplicationDefinition + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ApplicationDefinition]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_application_definitions_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ApplicationDefinition], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JitRequestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.managedapplications.ManagedApplicationsMgmtClient`'s + :attr:`jit_requests` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagedApplicationsMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, jit_request_name: str, **kwargs: Any + ) -> Optional[_models.JitRequestDefinition]: + """Gets the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :return: JitRequestDefinition or None. The JitRequestDefinition is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.JitRequestDefinition]] = kwargs.pop("cls", None) + + _request = build_jit_requests_get_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JitRequestDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + jit_request_name: str, + parameters: Union[_models.JitRequestDefinition, _types.JitRequestDefinition, IO[bytes]], + **kwargs: Any, + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_jit_requests_create_or_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JitRequestDefinition. The JitRequestDefinition + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _types.JitRequestDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: ~azure.mgmt.managedapplications.types.JitRequestDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JitRequestDefinition. The JitRequestDefinition + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JitRequestDefinition. The JitRequestDefinition + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: Union[_models.JitRequestDefinition, _types.JitRequestDefinition, IO[bytes]], + **kwargs: Any, + ) -> LROPoller[_models.JitRequestDefinition]: + """Creates or updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Is either a + JitRequestDefinition type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.JitRequestDefinition or + ~azure.mgmt.managedapplications.types.JitRequestDefinition or IO[bytes] + :return: An instance of LROPoller that returns JitRequestDefinition. The JitRequestDefinition + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedapplications.models.JitRequestDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JitRequestDefinition] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JitRequestDefinition, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.JitRequestDefinition].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.JitRequestDefinition]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _models.JitRequestPatchable, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: ~azure.mgmt.managedapplications.models.JitRequestPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JitRequestDefinition. The JitRequestDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: _types.JitRequestPatchable, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: ~azure.mgmt.managedapplications.types.JitRequestPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JitRequestDefinition. The JitRequestDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JitRequestDefinition. The JitRequestDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + jit_request_name: str, + parameters: Union[_models.JitRequestPatchable, _types.JitRequestPatchable, IO[bytes]], + **kwargs: Any, + ) -> _models.JitRequestDefinition: + """Updates the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :param parameters: Parameters supplied to the update JIT request. Is either a + JitRequestPatchable type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.managedapplications.models.JitRequestPatchable or + ~azure.mgmt.managedapplications.types.JitRequestPatchable or IO[bytes] + :return: JitRequestDefinition. The JitRequestDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JitRequestDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_jit_requests_update_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JitRequestDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, jit_request_name: str, **kwargs: Any + ) -> None: + """Deletes the JIT request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param jit_request_name: The name of the JIT request. Required. + :type jit_request_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_jit_requests_delete_request( + resource_group_name=resource_group_name, + jit_request_name=jit_request_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: JitRequestDefinitionListResult. The JitRequestDefinitionListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinitionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JitRequestDefinitionListResult] = kwargs.pop("cls", None) + + _request = build_jit_requests_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JitRequestDefinitionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> _models.JitRequestDefinitionListResult: + """Lists all JIT requests within the subscription. + + :return: JitRequestDefinitionListResult. The JitRequestDefinitionListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.JitRequestDefinitionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JitRequestDefinitionListResult] = kwargs.pop("cls", None) + + _request = build_jit_requests_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JitRequestDefinitionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class _ManagedApplicationsMgmtClientOperationsMixin( + ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], ManagedApplicationsMgmtClientConfiguration] +): + + @overload + def portal_registry_package( + self, parameters: _models.RegistryPackagePlan, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryPackage: + """Generates the registry package links for Managed Applications and Solution Templates. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.managedapplications.models.RegistryPackagePlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RegistryPackage. The RegistryPackage is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.RegistryPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def portal_registry_package( + self, parameters: _types.RegistryPackagePlan, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryPackage: + """Generates the registry package links for Managed Applications and Solution Templates. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.managedapplications.types.RegistryPackagePlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RegistryPackage. The RegistryPackage is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.RegistryPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def portal_registry_package( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryPackage: + """Generates the registry package links for Managed Applications and Solution Templates. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RegistryPackage. The RegistryPackage is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.RegistryPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def portal_registry_package( + self, parameters: Union[_models.RegistryPackagePlan, _types.RegistryPackagePlan, IO[bytes]], **kwargs: Any + ) -> _models.RegistryPackage: + """Generates the registry package links for Managed Applications and Solution Templates. + + :param parameters: The request body. Is either a RegistryPackagePlan type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.managedapplications.models.RegistryPackagePlan or + ~azure.mgmt.managedapplications.types.RegistryPackagePlan or IO[bytes] + :return: RegistryPackage. The RegistryPackage is compatible with MutableMapping + :rtype: ~azure.mgmt.managedapplications.models.RegistryPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryPackage] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_applications_mgmt_portal_registry_package_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RegistryPackage, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_operations(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedapplications.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_applications_mgmt_list_operations_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_patch.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_patch.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/types.py b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/types.py new file mode 100644 index 000000000000..4c5db1280d0f --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/azure/mgmt/managedapplications/types.py @@ -0,0 +1,990 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING, Union +from typing_extensions import Required, TypedDict + +if TYPE_CHECKING: + from .models import ( + ApplicationArtifactName, + ApplicationArtifactType, + ApplicationDefinitionArtifactName, + ApplicationLockLevel, + ApplicationManagementMode, + CreatedByType, + DeploymentMode, + JitApprovalMode, + JitApproverType, + JitRequestState, + JitSchedulingType, + ProvisioningState, + ResourceIdentityType, + Status, + Substatus, + ) + + +class Resource(TypedDict, total=False): + """Resource information. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: "SystemData" + """ + + id: str + """Resource ID.""" + name: str + """Resource name.""" + type: str + """Resource type.""" + location: str + """Resource location.""" + tags: dict[str, str] + """Resource tags.""" + systemData: "SystemData" + """Metadata pertaining to creation and last modification of the resource.""" + + +class GenericResource(Resource): + """Resource information. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: "SystemData" + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: "Sku" + """ + + managedBy: str + """ID of the resource that manages this resource.""" + sku: "Sku" + """The SKU of the resource.""" + + +class Application(GenericResource): + """Information about managed application. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: "SystemData" + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: "Sku" + :ivar properties: The managed application properties. Required. + :vartype properties: "ApplicationProperties" + :ivar plan: The plan information. + :vartype plan: "Plan" + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. Required. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: "Identity" + """ + + properties: Required["ApplicationProperties"] + """The managed application properties. Required.""" + plan: "Plan" + """The plan information.""" + kind: Required[str] + """The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. + Required.""" + identity: "Identity" + """The identity of the resource.""" + + +class ApplicationArtifact(TypedDict, total=False): + """Managed application artifact. + + :ivar name: The managed application artifact name. Required. Known values are: "NotSpecified", + "ViewDefinition", "Authorizations", and "CustomRoleDefinition". + :vartype name: Union[str, "ApplicationArtifactName"] + :ivar uri: The managed application artifact blob uri. Required. + :vartype uri: str + :ivar type: The managed application artifact type. Required. Known values are: "NotSpecified", + "Template", and "Custom". + :vartype type: Union[str, "ApplicationArtifactType"] + """ + + name: Required[Union[str, "ApplicationArtifactName"]] + """The managed application artifact name. Required. Known values are: \"NotSpecified\", + \"ViewDefinition\", \"Authorizations\", and \"CustomRoleDefinition\".""" + uri: Required[str] + """The managed application artifact blob uri. Required.""" + type: Required[Union[str, "ApplicationArtifactType"]] + """The managed application artifact type. Required. Known values are: \"NotSpecified\", + \"Template\", and \"Custom\".""" + + +class ApplicationAuthorization(TypedDict, total=False): + """The managed application provider authorization. + + :ivar principal_id: The provider's principal identifier. This is the identity that the provider + will use to call ARM to manage the managed application resources. Required. + :vartype principal_id: str + :ivar role_definition_id: The provider's role definition identifier. This role will define all + the permissions that the provider must have on the managed application's container resource + group. This role definition cannot have permission to delete the resource group. Required. + :vartype role_definition_id: str + """ + + principalId: Required[str] + """The provider's principal identifier. This is the identity that the provider will use to call + ARM to manage the managed application resources. Required.""" + roleDefinitionId: Required[str] + """The provider's role definition identifier. This role will define all the permissions that the + provider must have on the managed application's container resource group. This role definition + cannot have permission to delete the resource group. Required.""" + + +class ApplicationBillingDetailsDefinition(TypedDict, total=False): + """Managed application billing details definition. + + :ivar resource_usage_id: The managed application resource usage Id. + :vartype resource_usage_id: str + """ + + resourceUsageId: str + """The managed application resource usage Id.""" + + +class ApplicationClientDetails(TypedDict, total=False): + """The application client details to track the entity creating/updating the managed app resource. + + :ivar oid: The client Oid. + :vartype oid: str + :ivar puid: The client Puid. + :vartype puid: str + :ivar application_id: The client application Id. + :vartype application_id: str + """ + + oid: str + """The client Oid.""" + puid: str + """The client Puid.""" + applicationId: str + """The client application Id.""" + + +class ApplicationDefinition(GenericResource): + """Information about managed application definition. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: "SystemData" + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: "Sku" + :ivar properties: The managed application definition properties. Required. + :vartype properties: "ApplicationDefinitionProperties" + """ + + properties: Required["ApplicationDefinitionProperties"] + """The managed application definition properties. Required.""" + + +class ApplicationDefinitionArtifact(TypedDict, total=False): + """Application definition artifact. + + :ivar name: The managed application definition artifact name. Required. Known values are: + "NotSpecified", "ApplicationResourceTemplate", "CreateUiDefinition", and + "MainTemplateParameters". + :vartype name: Union[str, "ApplicationDefinitionArtifactName"] + :ivar uri: The managed application definition artifact blob uri. Required. + :vartype uri: str + :ivar type: The managed application definition artifact type. Required. Known values are: + "NotSpecified", "Template", and "Custom". + :vartype type: Union[str, "ApplicationArtifactType"] + """ + + name: Required[Union[str, "ApplicationDefinitionArtifactName"]] + """The managed application definition artifact name. Required. Known values are: \"NotSpecified\", + \"ApplicationResourceTemplate\", \"CreateUiDefinition\", and \"MainTemplateParameters\".""" + uri: Required[str] + """The managed application definition artifact blob uri. Required.""" + type: Required[Union[str, "ApplicationArtifactType"]] + """The managed application definition artifact type. Required. Known values are: \"NotSpecified\", + \"Template\", and \"Custom\".""" + + +class ApplicationDefinitionPatchable(TypedDict, total=False): + """Information about an application definition request. + + :ivar tags: Application definition tags. + :vartype tags: dict[str, str] + """ + + tags: dict[str, str] + """Application definition tags.""" + + +class ApplicationDefinitionProperties(TypedDict, total=False): + """The managed application definition properties. + + :ivar lock_level: The managed application lock level. Required. Known values are: + "CanNotDelete", "ReadOnly", and "None". + :vartype lock_level: Union[str, "ApplicationLockLevel"] + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: bool + :ivar authorizations: The managed application provider authorizations. + :vartype authorizations: list["ApplicationAuthorization"] + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: list["ApplicationDefinitionArtifact"] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar storage_account_id: The storage account id for bring your own storage scenario. + :vartype storage_account_id: str + :ivar main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :vartype main_template: Any + :ivar create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :vartype create_ui_definition: Any + :ivar notification_policy: The managed application notification policy. + :vartype notification_policy: "ApplicationNotificationPolicy" + :ivar locking_policy: The managed application locking policy. + :vartype locking_policy: "ApplicationPackageLockingPolicyDefinition" + :ivar deployment_policy: The managed application deployment policy. + :vartype deployment_policy: "ApplicationDeploymentPolicy" + :ivar management_policy: The managed application management policy that determines publisher's + access to the managed resource group. + :vartype management_policy: "ApplicationManagementPolicy" + :ivar policies: The managed application provider policies. + :vartype policies: list["ApplicationPolicy"] + """ + + lockLevel: Required[Union[str, "ApplicationLockLevel"]] + """The managed application lock level. Required. Known values are: \"CanNotDelete\", \"ReadOnly\", + and \"None\".""" + displayName: str + """The managed application definition display name.""" + isEnabled: bool + """A value indicating whether the package is enabled or not.""" + authorizations: list["ApplicationAuthorization"] + """The managed application provider authorizations.""" + artifacts: list["ApplicationDefinitionArtifact"] + """The collection of managed application artifacts. The portal will use the files specified as + artifacts to construct the user experience of creating a managed application from a managed + application definition.""" + description: str + """The managed application definition description.""" + packageFileUri: str + """The managed application definition package file Uri. Use this element.""" + storageAccountId: str + """The storage account id for bring your own storage scenario.""" + mainTemplate: Any + """The inline main template json which has resources to be provisioned. It can be a JObject or + well-formed JSON string.""" + createUiDefinition: Any + """The createUiDefinition json for the backing template with Microsoft.Solutions/applications + resource. It can be a JObject or well-formed JSON string.""" + notificationPolicy: "ApplicationNotificationPolicy" + """The managed application notification policy.""" + lockingPolicy: "ApplicationPackageLockingPolicyDefinition" + """The managed application locking policy.""" + deploymentPolicy: "ApplicationDeploymentPolicy" + """The managed application deployment policy.""" + managementPolicy: "ApplicationManagementPolicy" + """The managed application management policy that determines publisher's access to the managed + resource group.""" + policies: list["ApplicationPolicy"] + """The managed application provider policies.""" + + +class ApplicationDeploymentPolicy(TypedDict, total=False): + """Managed application deployment policy. + + :ivar deployment_mode: The managed application deployment mode. Required. Known values are: + "NotSpecified", "Incremental", and "Complete". + :vartype deployment_mode: Union[str, "DeploymentMode"] + """ + + deploymentMode: Required[Union[str, "DeploymentMode"]] + """The managed application deployment mode. Required. Known values are: \"NotSpecified\", + \"Incremental\", and \"Complete\".""" + + +class ApplicationJitAccessPolicy(TypedDict, total=False): + """Managed application Jit access policy. + + :ivar jit_access_enabled: Whether the JIT access is enabled. Required. + :vartype jit_access_enabled: bool + :ivar jit_approval_mode: JIT approval mode. Known values are: "NotSpecified", "AutoApprove", + and "ManualApprove". + :vartype jit_approval_mode: Union[str, "JitApprovalMode"] + :ivar jit_approvers: The JIT approvers. + :vartype jit_approvers: list["JitApproverDefinition"] + :ivar maximum_jit_access_duration: The maximum duration JIT access is granted. This is an + ISO8601 time period value. + :vartype maximum_jit_access_duration: str + """ + + jitAccessEnabled: Required[bool] + """Whether the JIT access is enabled. Required.""" + jitApprovalMode: Union[str, "JitApprovalMode"] + """JIT approval mode. Known values are: \"NotSpecified\", \"AutoApprove\", and \"ManualApprove\".""" + jitApprovers: list["JitApproverDefinition"] + """The JIT approvers.""" + maximumJitAccessDuration: str + """The maximum duration JIT access is granted. This is an ISO8601 time period value.""" + + +class ApplicationManagementPolicy(TypedDict, total=False): + """Managed application management policy. + + :ivar mode: The managed application management mode. Known values are: "NotSpecified", + "Unmanaged", and "Managed". + :vartype mode: Union[str, "ApplicationManagementMode"] + """ + + mode: Union[str, "ApplicationManagementMode"] + """The managed application management mode. Known values are: \"NotSpecified\", \"Unmanaged\", and + \"Managed\".""" + + +class ApplicationNotificationEndpoint(TypedDict, total=False): + """Managed application notification endpoint. + + :ivar uri: The managed application notification endpoint uri. Required. + :vartype uri: str + """ + + uri: Required[str] + """The managed application notification endpoint uri. Required.""" + + +class ApplicationNotificationPolicy(TypedDict, total=False): + """Managed application notification policy. + + :ivar notification_endpoints: The managed application notification endpoint. Required. + :vartype notification_endpoints: list["ApplicationNotificationEndpoint"] + """ + + notificationEndpoints: Required[list["ApplicationNotificationEndpoint"]] + """The managed application notification endpoint. Required.""" + + +class ApplicationPackageContact(TypedDict, total=False): + """The application package contact information. + + :ivar contact_name: The contact name. + :vartype contact_name: str + :ivar email: The contact email. Required. + :vartype email: str + :ivar phone: The contact phone number. Required. + :vartype phone: str + """ + + contactName: str + """The contact name.""" + email: Required[str] + """The contact email. Required.""" + phone: Required[str] + """The contact phone number. Required.""" + + +class ApplicationPackageLockingPolicyDefinition(TypedDict, total=False): # pylint: disable=name-too-long + """Managed application locking policy. + + :ivar allowed_actions: The deny assignment excluded actions. + :vartype allowed_actions: list[str] + :ivar allowed_data_actions: The deny assignment excluded data actions. + :vartype allowed_data_actions: list[str] + """ + + allowedActions: list[str] + """The deny assignment excluded actions.""" + allowedDataActions: list[str] + """The deny assignment excluded data actions.""" + + +class ApplicationPackageSupportUrls(TypedDict, total=False): + """The appliance package support URLs. + + :ivar public_azure: The public azure support URL. + :vartype public_azure: str + :ivar government_cloud: The government cloud support URL. + :vartype government_cloud: str + """ + + publicAzure: str + """The public azure support URL.""" + governmentCloud: str + """The government cloud support URL.""" + + +class ApplicationPatchable(GenericResource): + """Information about managed application. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: "SystemData" + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: "Sku" + :ivar properties: The managed application properties. + :vartype properties: "ApplicationProperties" + :ivar plan: The plan information. + :vartype plan: "PlanPatchable" + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: "Identity" + """ + + properties: "ApplicationProperties" + """The managed application properties.""" + plan: "PlanPatchable" + """The plan information.""" + kind: str + """The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog.""" + identity: "Identity" + """The identity of the resource.""" + + +class ApplicationPolicy(TypedDict, total=False): + """Managed application policy. + + :ivar name: The policy name. + :vartype name: str + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar parameters: The policy parameters. + :vartype parameters: str + """ + + name: str + """The policy name.""" + policyDefinitionId: str + """The policy definition Id.""" + parameters: str + """The policy parameters.""" + + +class ApplicationProperties(TypedDict, total=False): + """The managed application properties. + + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. + :vartype parameters: Any + :ivar outputs: Name and value pairs that define the managed application outputs. + :vartype outputs: Any + :ivar provisioning_state: The managed application provisioning state. Known values are: + "NotSpecified", "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", + "Succeeded", and "Updating". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar billing_details: The managed application billing details. + :vartype billing_details: "ApplicationBillingDetailsDefinition" + :ivar jit_access_policy: The managed application Jit access policy. + :vartype jit_access_policy: "ApplicationJitAccessPolicy" + :ivar publisher_tenant_id: The publisher tenant Id. + :vartype publisher_tenant_id: str + :ivar authorizations: The read-only authorizations property that is retrieved from the + application package. + :vartype authorizations: list["ApplicationAuthorization"] + :ivar management_mode: The managed application management mode. Known values are: + "NotSpecified", "Unmanaged", and "Managed". + :vartype management_mode: Union[str, "ApplicationManagementMode"] + :ivar customer_support: The read-only customer support property that is retrieved from the + application package. + :vartype customer_support: "ApplicationPackageContact" + :ivar support_urls: The read-only support URLs property that is retrieved from the application + package. + :vartype support_urls: "ApplicationPackageSupportUrls" + :ivar artifacts: The collection of managed application artifacts. + :vartype artifacts: list["ApplicationArtifact"] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: "ApplicationClientDetails" + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: "ApplicationClientDetails" + """ + + managedResourceGroupId: str + """The managed resource group Id.""" + applicationDefinitionId: str + """The fully qualified path of managed application definition Id.""" + parameters: Any + """Name and value pairs that define the managed application parameters. It can be a JObject or a + well formed JSON string.""" + outputs: Any + """Name and value pairs that define the managed application outputs.""" + provisioningState: Union[str, "ProvisioningState"] + """The managed application provisioning state. Known values are: \"NotSpecified\", \"Accepted\", + \"Running\", \"Deleting\", \"Deleted\", \"Canceled\", \"Failed\", \"Succeeded\", and + \"Updating\".""" + billingDetails: "ApplicationBillingDetailsDefinition" + """The managed application billing details.""" + jitAccessPolicy: "ApplicationJitAccessPolicy" + """The managed application Jit access policy.""" + publisherTenantId: str + """The publisher tenant Id.""" + authorizations: list["ApplicationAuthorization"] + """The read-only authorizations property that is retrieved from the application package.""" + managementMode: Union[str, "ApplicationManagementMode"] + """The managed application management mode. Known values are: \"NotSpecified\", \"Unmanaged\", and + \"Managed\".""" + customerSupport: "ApplicationPackageContact" + """The read-only customer support property that is retrieved from the application package.""" + supportUrls: "ApplicationPackageSupportUrls" + """The read-only support URLs property that is retrieved from the application package.""" + artifacts: list["ApplicationArtifact"] + """The collection of managed application artifacts.""" + createdBy: "ApplicationClientDetails" + """The client entity that created the JIT request.""" + updatedBy: "ApplicationClientDetails" + """The client entity that last updated the JIT request.""" + + +class Identity(TypedDict, total=False): + """Identity for the resource. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". + :vartype type: Union[str, "ResourceIdentityType"] + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, "UserAssignedResourceIdentity"] + """ + + principalId: str + """The principal ID of resource identity.""" + tenantId: str + """The tenant ID of resource.""" + type: Union[str, "ResourceIdentityType"] + """The identity type. Known values are: \"SystemAssigned\", \"UserAssigned\", \"SystemAssigned, + UserAssigned\", and \"None\".""" + userAssignedIdentities: dict[str, "UserAssignedResourceIdentity"] + """The list of user identities associated with the resource. The user identity dictionary key + references will be resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.""" + + +class JitApproverDefinition(TypedDict, total=False): + """JIT approver definition. + + :ivar id: The approver service principal Id. Required. + :vartype id: str + :ivar type: The approver type. Known values are: "user" and "group". + :vartype type: Union[str, "JitApproverType"] + :ivar display_name: The approver display name. + :vartype display_name: str + """ + + id: Required[str] + """The approver service principal Id. Required.""" + type: Union[str, "JitApproverType"] + """The approver type. Known values are: \"user\" and \"group\".""" + displayName: str + """The approver display name.""" + + +class JitAuthorizationPolicies(TypedDict, total=False): + """The JIT authorization policies. + + :ivar principal_id: The the principal id that will be granted JIT access. Required. + :vartype principal_id: str + :ivar role_definition_id: The role definition id that will be granted to the Principal. + Required. + :vartype role_definition_id: str + """ + + principalId: Required[str] + """The the principal id that will be granted JIT access. Required.""" + roleDefinitionId: Required[str] + """The role definition id that will be granted to the Principal. Required.""" + + +class JitRequestDefinition(Resource): + """Information about JIT request definition. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: "SystemData" + :ivar properties: The JIT request properties. + :vartype properties: "JitRequestProperties" + """ + + properties: "JitRequestProperties" + """The JIT request properties.""" + + +class JitRequestMetadata(TypedDict, total=False): + """The JIT request metadata. + + :ivar origin_request_id: The origin request id. + :vartype origin_request_id: str + :ivar requestor_id: The requestor id. + :vartype requestor_id: str + :ivar tenant_display_name: The publisher's tenant name. + :vartype tenant_display_name: str + :ivar subject_display_name: The subject display name. + :vartype subject_display_name: str + """ + + originRequestId: str + """The origin request id.""" + requestorId: str + """The requestor id.""" + tenantDisplayName: str + """The publisher's tenant name.""" + subjectDisplayName: str + """The subject display name.""" + + +class JitRequestPatchable(TypedDict, total=False): + """Information about JIT request. + + :ivar tags: Jit request tags. + :vartype tags: dict[str, str] + """ + + tags: dict[str, str] + """Jit request tags.""" + + +class JitRequestProperties(TypedDict, total=False): + """Information about JIT request properties. + + :ivar application_resource_id: The parent application id. Required. + :vartype application_resource_id: str + :ivar publisher_tenant_id: The publisher tenant id. + :vartype publisher_tenant_id: str + :ivar jit_authorization_policies: The JIT authorization policies. Required. + :vartype jit_authorization_policies: list["JitAuthorizationPolicies"] + :ivar jit_scheduling_policy: The JIT request properties. Required. + :vartype jit_scheduling_policy: "JitSchedulingPolicy" + :ivar provisioning_state: The JIT request provisioning state. Known values are: "NotSpecified", + "Accepted", "Running", "Deleting", "Deleted", "Canceled", "Failed", "Succeeded", and + "Updating". + :vartype provisioning_state: Union[str, "ProvisioningState"] + :ivar jit_request_state: The JIT request state. Known values are: "NotSpecified", "Pending", + "Approved", "Denied", "Failed", "Canceled", "Expired", and "Timeout". + :vartype jit_request_state: Union[str, "JitRequestState"] + :ivar created_by: The client entity that created the JIT request. + :vartype created_by: "ApplicationClientDetails" + :ivar updated_by: The client entity that last updated the JIT request. + :vartype updated_by: "ApplicationClientDetails" + """ + + applicationResourceId: Required[str] + """The parent application id. Required.""" + publisherTenantId: str + """The publisher tenant id.""" + jitAuthorizationPolicies: Required[list["JitAuthorizationPolicies"]] + """The JIT authorization policies. Required.""" + jitSchedulingPolicy: Required["JitSchedulingPolicy"] + """The JIT request properties. Required.""" + provisioningState: Union[str, "ProvisioningState"] + """The JIT request provisioning state. Known values are: \"NotSpecified\", \"Accepted\", + \"Running\", \"Deleting\", \"Deleted\", \"Canceled\", \"Failed\", \"Succeeded\", and + \"Updating\".""" + jitRequestState: Union[str, "JitRequestState"] + """The JIT request state. Known values are: \"NotSpecified\", \"Pending\", \"Approved\", + \"Denied\", \"Failed\", \"Canceled\", \"Expired\", and \"Timeout\".""" + createdBy: "ApplicationClientDetails" + """The client entity that created the JIT request.""" + updatedBy: "ApplicationClientDetails" + """The client entity that last updated the JIT request.""" + + +class JitSchedulingPolicy(TypedDict, total=False): + """The JIT scheduling policies. + + :ivar type: The type of JIT schedule. Required. Known values are: "NotSpecified", "Once", and + "Recurring". + :vartype type: Union[str, "JitSchedulingType"] + :ivar duration: The required duration of the JIT request. Required. + :vartype duration: str + :ivar start_time: The start time of the request. Required. + :vartype start_time: str + """ + + type: Required[Union[str, "JitSchedulingType"]] + """The type of JIT schedule. Required. Known values are: \"NotSpecified\", \"Once\", and + \"Recurring\".""" + duration: Required[str] + """The required duration of the JIT request. Required.""" + startTime: Required[str] + """The start time of the request. Required.""" + + +class ListTokenRequest(TypedDict, total=False): + """List token request body. + + :ivar authorization_audience: The authorization audience. + :vartype authorization_audience: str + :ivar user_assigned_identities: The user assigned identities. + :vartype user_assigned_identities: list[str] + """ + + authorizationAudience: str + """The authorization audience.""" + userAssignedIdentities: list[str] + """The user assigned identities.""" + + +class Plan(TypedDict, total=False): + """Plan for the managed application. + + :ivar name: The plan name. Required. + :vartype name: str + :ivar publisher: The publisher ID. Required. + :vartype publisher: str + :ivar product: The product code. Required. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. Required. + :vartype version: str + """ + + name: Required[str] + """The plan name. Required.""" + publisher: Required[str] + """The publisher ID. Required.""" + product: Required[str] + """The product code. Required.""" + promotionCode: str + """The promotion code.""" + version: Required[str] + """The plan's version. Required.""" + + +class PlanPatchable(TypedDict, total=False): + """Plan for the managed application. + + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str + """ + + name: str + """The plan name.""" + publisher: str + """The publisher ID.""" + product: str + """The product code.""" + promotionCode: str + """The promotion code.""" + version: str + """The plan's version.""" + + +class RegistryPackagePlan(TypedDict, total=False): + """Plan for the managed application. + + :ivar publisher: The publisher ID. Required. + :vartype publisher: str + :ivar offer: The offer Id. Required. + :vartype offer: str + :ivar plan: The plan Id. Required. + :vartype plan: str + :ivar version: The plan's version. + :vartype version: str + """ + + publisher: Required[str] + """The publisher ID. Required.""" + offer: Required[str] + """The offer Id. Required.""" + plan: Required[str] + """The plan Id. Required.""" + version: str + """The plan's version.""" + + +class Sku(TypedDict, total=False): + """SKU for the resource. + + :ivar name: The SKU name. Required. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int + """ + + name: Required[str] + """The SKU name. Required.""" + tier: str + """The SKU tier.""" + size: str + """The SKU size.""" + family: str + """The SKU family.""" + model: str + """The SKU model.""" + capacity: int + """The SKU capacity.""" + + +class SystemData(TypedDict, total=False): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: Union[str, "CreatedByType"] + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: str + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: Union[str, "CreatedByType"] + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: str + """ + + createdBy: str + """The identity that created the resource.""" + createdByType: Union[str, "CreatedByType"] + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + createdAt: str + """The timestamp of resource creation (UTC).""" + lastModifiedBy: str + """The identity that last modified the resource.""" + lastModifiedByType: Union[str, "CreatedByType"] + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + lastModifiedAt: str + """The timestamp of resource last modification (UTC).""" + + +class UpdateAccessDefinition(TypedDict, total=False): + """Update access request definition. + + :ivar approver: The approver name. + :vartype approver: str + :ivar metadata: The JIT request metadata. Required. + :vartype metadata: "JitRequestMetadata" + :ivar status: The JIT status. Required. Known values are: "NotSpecified", "Elevate", and + "Remove". + :vartype status: Union[str, "Status"] + :ivar sub_status: The JIT status. Required. Known values are: "NotSpecified", "Approved", + "Denied", "Failed", "Expired", and "Timeout". + :vartype sub_status: Union[str, "Substatus"] + """ + + Approver: str + """The approver name.""" + Metadata: Required["JitRequestMetadata"] + """The JIT request metadata. Required.""" + Status: Required[Union[str, "Status"]] + """The JIT status. Required. Known values are: \"NotSpecified\", \"Elevate\", and \"Remove\".""" + SubStatus: Required[Union[str, "Substatus"]] + """The JIT status. Required. Known values are: \"NotSpecified\", \"Approved\", \"Denied\", + \"Failed\", \"Expired\", and \"Timeout\".""" + + +class UserAssignedResourceIdentity(TypedDict, total=False): + """Represents the user assigned identity that is contained within the UserAssignedIdentities + dictionary on ResourceIdentity. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str + """ + + principalId: str + """The principal id of user assigned identity.""" + tenantId: str + """The tenant id of user assigned identity.""" diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/dev_requirements.txt b/sdk/managedapplications/azure-mgmt-managedapplications/dev_requirements.txt index 4a746c21163c..03dba171e250 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/dev_requirements.txt +++ b/sdk/managedapplications/azure-mgmt-managedapplications/dev_requirements.txt @@ -1,2 +1,3 @@ -e ../../../eng/tools/azure-sdk-tools ../../identity/azure-identity +aiohttp diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application.py index 08898561c234..4d8e0fe0017b 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application.py @@ -1,12 +1,14 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +28,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.applications.begin_create_or_update( @@ -43,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/createOrUpdateApplication.json +# x-ms-original-file: 2023-12-01-preview/createOrUpdateApplication.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_by_id.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_by_id.py index 6711bf627f13..024e3c0dbb35 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_by_id.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_by_id.py @@ -1,12 +1,14 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -42,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/createOrUpdateApplicationById.json +# x-ms-original-file: 2023-12-01-preview/createOrUpdateApplicationById.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_definition.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_definition.py index 9afa0e1f698d..749b2df3e6a1 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_definition.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_definition.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.application_definitions.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/createOrUpdateApplicationDefinition.json +# x-ms-original-file: 2023-12-01-preview/createOrUpdateApplicationDefinition.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_definition1.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_definition1.py new file mode 100644 index 000000000000..f8fe43ef1cec --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_application_definition1.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-managedapplications +# USAGE + python create_or_update_application_definition1.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 = ManagedApplicationsMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.application_definitions.create_or_update_by_id( + resource_group_name="rg", + application_definition_name="myManagedApplicationDef", + parameters={ + "properties": { + "authorizations": [{"principalId": "validprincipalguid", "roleDefinitionId": "validroleguid"}], + "description": "myManagedApplicationDef description", + "displayName": "myManagedApplicationDef", + "lockLevel": "None", + "packageFileUri": "https://path/to/packagezipfile", + } + }, + ) + print(response) + + +# x-ms-original-file: 2023-12-01-preview/createOrUpdateApplicationDefinition1.json +if __name__ == "__main__": + main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_jit_request.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_jit_request.py index e9fc7eead50c..bbc97ef5cf3c 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_jit_request.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/create_or_update_jit_request.py @@ -1,12 +1,14 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,12 +28,12 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.jit_requests.begin_create_or_update( resource_group_name="rg", - jit_request_name="myJitRequest", + jit_request_name="myRequest", parameters={ "properties": { "applicationResourceId": "/subscriptions/00c76877-e316-48a7-af60-4a09fec9d43f/resourceGroups/52F30DB2/providers/Microsoft.Solutions/applications/7E193158", @@ -52,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/createOrUpdateJitRequest.json +# x-ms-original-file: 2023-12-01-preview/createOrUpdateJitRequest.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application.py index 86595f38b21e..ced5dcb63f64 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.applications.begin_delete( @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/deleteApplication.json +# x-ms-original-file: 2023-12-01-preview/deleteApplication.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_by_id.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_by_id.py index 523912bdc9ce..56fcb9194fe4 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_by_id.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_by_id.py @@ -1,12 +1,14 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -34,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/deleteApplicationById.json +# x-ms-original-file: 2023-12-01-preview/deleteApplicationById.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_definition.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_definition.py index f36eee38abe1..740885bbd6d3 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_definition.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_definition.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.application_definitions.delete( @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/deleteApplicationDefinition.json +# x-ms-original-file: 2023-12-01-preview/deleteApplicationDefinition.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_definition1.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_definition1.py new file mode 100644 index 000000000000..2220bd9173ee --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_application_definition1.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-managedapplications +# USAGE + python delete_application_definition1.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 = ManagedApplicationsMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.application_definitions.delete_by_id( + resource_group_name="rg", + application_definition_name="myManagedApplicationDef", + ) + + +# x-ms-original-file: 2023-12-01-preview/deleteApplicationDefinition1.json +if __name__ == "__main__": + main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_jit_request.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_jit_request.py index d0ee61a14d37..700a95ee661f 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_jit_request.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/delete_jit_request.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,15 +27,15 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.jit_requests.delete( resource_group_name="rg", - jit_request_name="myJitRequest", + jit_request_name="myRequest", ) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/deleteJitRequest.json +# x-ms-original-file: 2023-12-01-preview/deleteJitRequest.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application.py index 151ddda10462..cc756f896d86 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.applications.get( @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/getApplication.json +# x-ms-original-file: 2023-12-01-preview/getApplication.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_by_id.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_by_id.py index b22a2f9930ec..8bdd669d7e9c 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_by_id.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_by_id.py @@ -1,12 +1,14 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -35,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/getApplicationById.json +# x-ms-original-file: 2023-12-01-preview/getApplicationById.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_definition.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_definition.py index 263a1992f8b3..15197d2dd205 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_definition.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_definition.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.application_definitions.get( @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/getApplicationDefinition.json +# x-ms-original-file: 2023-12-01-preview/getApplicationDefinition.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_definition1.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_definition1.py new file mode 100644 index 000000000000..b8b029a115ad --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_application_definition1.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-managedapplications +# USAGE + python get_application_definition1.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 = ManagedApplicationsMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.application_definitions.get_by_id( + resource_group_name="rg", + application_definition_name="myManagedApplicationDef", + ) + print(response) + + +# x-ms-original-file: 2023-12-01-preview/getApplicationDefinition1.json +if __name__ == "__main__": + main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_jit_request.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_jit_request.py index 382526070048..e082a2c1009f 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_jit_request.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/get_jit_request.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,16 +27,16 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.jit_requests.get( resource_group_name="rg", - jit_request_name="myJitRequest", + jit_request_name="myRequest", ) print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/getJitRequest.json +# x-ms-original-file: 2023-12-01-preview/getJitRequest.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_allowed_upgrade_plans.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_allowed_upgrade_plans.py index bd1357ed0ba8..11ec1eeb0ea9 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_allowed_upgrade_plans.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_allowed_upgrade_plans.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.applications.list_allowed_upgrade_plans( @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listAllowedUpgradePlans.json +# x-ms-original-file: 2023-12-01-preview/listAllowedUpgradePlans.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_application_definitions_by_resource_group.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_application_definitions_by_resource_group.py index 0bf214739269..f99bab9e3a2b 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_application_definitions_by_resource_group.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_application_definitions_by_resource_group.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.application_definitions.list_by_resource_group( @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listApplicationDefinitionsByResourceGroup.json +# x-ms-original-file: 2023-12-01-preview/listApplicationDefinitionsByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_application_definitions_by_subscription.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_application_definitions_by_subscription.py index 969e090466a8..5a5b0331ee7f 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_application_definitions_by_subscription.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_application_definitions_by_subscription.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.application_definitions.list_by_subscription() @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listApplicationDefinitionsBySubscription.json +# x-ms-original-file: 2023-12-01-preview/listApplicationDefinitionsBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_applications_by_resource_group.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_applications_by_resource_group.py index c9ba1e836fde..12c938dfb99a 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_applications_by_resource_group.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_applications_by_resource_group.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,16 +27,14 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.applications.list_by_resource_group( - resource_group_name="rg", - ) + response = client.applications.list_by_subscription() for item in response: print(item) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listApplicationsByResourceGroup.json +# x-ms-original-file: 2023-12-01-preview/listApplicationsByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_applications_by_resource_group1.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_applications_by_resource_group1.py new file mode 100644 index 000000000000..e5839c6f1eaf --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_applications_by_resource_group1.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-managedapplications +# USAGE + python list_applications_by_resource_group1.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 = ManagedApplicationsMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.applications.list_by_resource_group( + resource_group_name="rg", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2023-12-01-preview/listApplicationsByResourceGroup1.json +if __name__ == "__main__": + main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_jit_requests_by_resource_group.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_jit_requests_by_resource_group.py index 7f49e1732fbb..ffa91d5d2388 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_jit_requests_by_resource_group.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_jit_requests_by_resource_group.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,13 +27,13 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.jit_requests.list_by_subscription() print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listJitRequestsByResourceGroup.json +# x-ms-original-file: 2023-12-01-preview/listJitRequestsByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_jit_requests_by_resource_group1.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_jit_requests_by_resource_group1.py new file mode 100644 index 000000000000..0692bce5a4a8 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_jit_requests_by_resource_group1.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-managedapplications +# USAGE + python list_jit_requests_by_resource_group1.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 = ManagedApplicationsMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.jit_requests.list_by_resource_group( + resource_group_name="rg", + ) + print(response) + + +# x-ms-original-file: 2023-12-01-preview/listJitRequestsByResourceGroup1.json +if __name__ == "__main__": + main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_solutions_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_solutions_operations.py index 43bc28622a9e..f22734eea52e 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_solutions_operations.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_solutions_operations.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listSolutionsOperations.json +# x-ms-original-file: 2023-12-01-preview/listSolutionsOperations.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_token.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_token.py index 6b86480e81b4..3710f673d76f 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_token.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/list_token.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.applications.list_tokens( @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listToken.json +# x-ms-original-file: 2023-12-01-preview/listToken.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/portal_registry_package.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/portal_registry_package.py new file mode 100644 index 000000000000..e7089fbc6586 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/portal_registry_package.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-managedapplications +# USAGE + python portal_registry_package.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 = ManagedApplicationsMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.portal_registry_package( + parameters={"offer": "offerId", "plan": "planId", "publisher": "publisherId"}, + ) + print(response) + + +# x-ms-original-file: 2023-12-01-preview/portalRegistryPackage.json +if __name__ == "__main__": + main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/refresh_application_permissions.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/refresh_application_permissions.py index 0397af3a035b..57c9d828f489 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/refresh_application_permissions.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/refresh_application_permissions.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.applications.begin_refresh_permissions( @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/refreshApplicationPermissions.json +# x-ms-original-file: 2023-12-01-preview/refreshApplicationPermissions.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_access.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_access.py index e7614dfd1617..ca54a71af3a8 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_access.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_access.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,27 +27,27 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.applications.begin_update_access( resource_group_name="rg", application_name="myManagedApplication", parameters={ - "approver": "amauser", - "metadata": { + "Approver": "amauser", + "Metadata": { "originRequestId": "originRequestId", "requestorId": "RequestorId", "subjectDisplayName": "SubjectDisplayName", "tenantDisplayName": "TenantDisplayName", }, - "status": "Elevate", - "subStatus": "Approved", + "Status": "Elevate", + "SubStatus": "Approved", }, ).result() print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/updateAccess.json +# x-ms-original-file: 2023-12-01-preview/updateAccess.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application.py index ef8aed52269e..8bb87b99f874 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.applications.begin_update( @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/updateApplication.json +# x-ms-original-file: 2023-12-01-preview/updateApplication.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_by_id.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_by_id.py index cd9070ac28a8..d72874ce7569 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_by_id.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_by_id.py @@ -1,12 +1,14 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -35,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/updateApplicationById.json +# x-ms-original-file: 2023-12-01-preview/updateApplicationById.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_definition.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_definition.py index 340a2d881c4f..1def4959fcb7 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_definition.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_definition.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.application_definitions.update( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/updateApplicationDefinition.json +# x-ms-original-file: 2023-12-01-preview/updateApplicationDefinition.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_definition1.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_definition1.py new file mode 100644 index 000000000000..9d5253975168 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_application_definition1.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-managedapplications +# USAGE + python update_application_definition1.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 = ManagedApplicationsMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.application_definitions.update_by_id( + resource_group_name="rg", + application_definition_name="myManagedApplicationDef", + parameters={"tags": {"department": "Finance"}}, + ) + print(response) + + +# x-ms-original-file: 2023-12-01-preview/updateApplicationDefinition1.json +if __name__ == "__main__": + main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_jit_request.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_jit_request.py index 3f2046749bfe..7e5c0c3ac1e8 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_jit_request.py +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_samples/update_jit_request.py @@ -2,11 +2,12 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient """ @@ -26,17 +27,17 @@ def main(): client = ManagedApplicationsMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.jit_requests.update( resource_group_name="rg", - jit_request_name="myJitRequest", + jit_request_name="myRequest", parameters={"tags": {"department": "Finance"}}, ) print(response) -# x-ms-original-file: specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/updateJitRequest.json +# x-ms-original-file: 2023-12-01-preview/updateJitRequest.json if __name__ == "__main__": main() diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/conftest.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/conftest.py new file mode 100644 index 000000000000..ddaa3bcac1dc --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/conftest.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + managedapplicationsmgmt_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + managedapplicationsmgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + managedapplicationsmgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + managedapplicationsmgmt_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=managedapplicationsmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=managedapplicationsmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=managedapplicationsmgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=managedapplicationsmgmt_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt.py new file mode 100644 index 000000000000..d6d24cba771a --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestManagedApplicationsMgmt(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ManagedApplicationsMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_portal_registry_package(self, resource_group): + response = self.client.portal_registry_package( + parameters={"offer": "str", "plan": "str", "publisher": "str", "version": "str"}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_operations(self, resource_group): + response = self.client.list_operations() + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_application_definitions_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_application_definitions_operations.py new file mode 100644 index 000000000000..056930069daa --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_application_definitions_operations.py @@ -0,0 +1,195 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestManagedApplicationsMgmtApplicationDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ManagedApplicationsMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_get(self, resource_group): + response = self.client.application_definitions.get( + resource_group_name=resource_group.name, + application_definition_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_create_or_update(self, resource_group): + response = self.client.application_definitions.create_or_update( + resource_group_name=resource_group.name, + application_definition_name="str", + parameters={ + "properties": { + "lockLevel": "str", + "artifacts": [{"name": "str", "type": "str", "uri": "str"}], + "authorizations": [{"principalId": "str", "roleDefinitionId": "str"}], + "createUiDefinition": {}, + "deploymentPolicy": {"deploymentMode": "str"}, + "description": "str", + "displayName": "str", + "isEnabled": bool, + "lockingPolicy": {"allowedActions": ["str"], "allowedDataActions": ["str"]}, + "mainTemplate": {}, + "managementPolicy": {"mode": "str"}, + "notificationPolicy": {"notificationEndpoints": [{"uri": "str"}]}, + "packageFileUri": "str", + "policies": [{"name": "str", "parameters": "str", "policyDefinitionId": "str"}], + "storageAccountId": "str", + }, + "id": "str", + "location": "str", + "managedBy": "str", + "name": "str", + "sku": {"name": "str", "capacity": 0, "family": "str", "model": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_update(self, resource_group): + response = self.client.application_definitions.update( + resource_group_name=resource_group.name, + application_definition_name="str", + parameters={"tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_delete(self, resource_group): + response = self.client.application_definitions.delete( + resource_group_name=resource_group.name, + application_definition_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_get_by_id(self, resource_group): + response = self.client.application_definitions.get_by_id( + resource_group_name=resource_group.name, + application_definition_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_create_or_update_by_id(self, resource_group): + response = self.client.application_definitions.create_or_update_by_id( + resource_group_name=resource_group.name, + application_definition_name="str", + parameters={ + "properties": { + "lockLevel": "str", + "artifacts": [{"name": "str", "type": "str", "uri": "str"}], + "authorizations": [{"principalId": "str", "roleDefinitionId": "str"}], + "createUiDefinition": {}, + "deploymentPolicy": {"deploymentMode": "str"}, + "description": "str", + "displayName": "str", + "isEnabled": bool, + "lockingPolicy": {"allowedActions": ["str"], "allowedDataActions": ["str"]}, + "mainTemplate": {}, + "managementPolicy": {"mode": "str"}, + "notificationPolicy": {"notificationEndpoints": [{"uri": "str"}]}, + "packageFileUri": "str", + "policies": [{"name": "str", "parameters": "str", "policyDefinitionId": "str"}], + "storageAccountId": "str", + }, + "id": "str", + "location": "str", + "managedBy": "str", + "name": "str", + "sku": {"name": "str", "capacity": 0, "family": "str", "model": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_update_by_id(self, resource_group): + response = self.client.application_definitions.update_by_id( + resource_group_name=resource_group.name, + application_definition_name="str", + parameters={"tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_delete_by_id(self, resource_group): + response = self.client.application_definitions.delete_by_id( + resource_group_name=resource_group.name, + application_definition_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_list_by_resource_group(self, resource_group): + response = self.client.application_definitions.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_application_definitions_list_by_subscription(self, resource_group): + response = self.client.application_definitions.list_by_subscription() + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_application_definitions_operations_async.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_application_definitions_operations_async.py new file mode 100644 index 000000000000..5eba3a2e93e7 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_application_definitions_operations_async.py @@ -0,0 +1,196 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.managedapplications.aio import ManagedApplicationsMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestManagedApplicationsMgmtApplicationDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ManagedApplicationsMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_get(self, resource_group): + response = await self.client.application_definitions.get( + resource_group_name=resource_group.name, + application_definition_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_create_or_update(self, resource_group): + response = await self.client.application_definitions.create_or_update( + resource_group_name=resource_group.name, + application_definition_name="str", + parameters={ + "properties": { + "lockLevel": "str", + "artifacts": [{"name": "str", "type": "str", "uri": "str"}], + "authorizations": [{"principalId": "str", "roleDefinitionId": "str"}], + "createUiDefinition": {}, + "deploymentPolicy": {"deploymentMode": "str"}, + "description": "str", + "displayName": "str", + "isEnabled": bool, + "lockingPolicy": {"allowedActions": ["str"], "allowedDataActions": ["str"]}, + "mainTemplate": {}, + "managementPolicy": {"mode": "str"}, + "notificationPolicy": {"notificationEndpoints": [{"uri": "str"}]}, + "packageFileUri": "str", + "policies": [{"name": "str", "parameters": "str", "policyDefinitionId": "str"}], + "storageAccountId": "str", + }, + "id": "str", + "location": "str", + "managedBy": "str", + "name": "str", + "sku": {"name": "str", "capacity": 0, "family": "str", "model": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_update(self, resource_group): + response = await self.client.application_definitions.update( + resource_group_name=resource_group.name, + application_definition_name="str", + parameters={"tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_delete(self, resource_group): + response = await self.client.application_definitions.delete( + resource_group_name=resource_group.name, + application_definition_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_get_by_id(self, resource_group): + response = await self.client.application_definitions.get_by_id( + resource_group_name=resource_group.name, + application_definition_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_create_or_update_by_id(self, resource_group): + response = await self.client.application_definitions.create_or_update_by_id( + resource_group_name=resource_group.name, + application_definition_name="str", + parameters={ + "properties": { + "lockLevel": "str", + "artifacts": [{"name": "str", "type": "str", "uri": "str"}], + "authorizations": [{"principalId": "str", "roleDefinitionId": "str"}], + "createUiDefinition": {}, + "deploymentPolicy": {"deploymentMode": "str"}, + "description": "str", + "displayName": "str", + "isEnabled": bool, + "lockingPolicy": {"allowedActions": ["str"], "allowedDataActions": ["str"]}, + "mainTemplate": {}, + "managementPolicy": {"mode": "str"}, + "notificationPolicy": {"notificationEndpoints": [{"uri": "str"}]}, + "packageFileUri": "str", + "policies": [{"name": "str", "parameters": "str", "policyDefinitionId": "str"}], + "storageAccountId": "str", + }, + "id": "str", + "location": "str", + "managedBy": "str", + "name": "str", + "sku": {"name": "str", "capacity": 0, "family": "str", "model": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_update_by_id(self, resource_group): + response = await self.client.application_definitions.update_by_id( + resource_group_name=resource_group.name, + application_definition_name="str", + parameters={"tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_delete_by_id(self, resource_group): + response = await self.client.application_definitions.delete_by_id( + resource_group_name=resource_group.name, + application_definition_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_list_by_resource_group(self, resource_group): + response = self.client.application_definitions.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_application_definitions_list_by_subscription(self, resource_group): + response = self.client.application_definitions.list_by_subscription() + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_applications_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_applications_operations.py new file mode 100644 index 000000000000..fed8ba337223 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_applications_operations.py @@ -0,0 +1,271 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestManagedApplicationsMgmtApplicationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ManagedApplicationsMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_get(self, resource_group): + response = self.client.applications.get( + resource_group_name=resource_group.name, + application_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_begin_create_or_update(self, resource_group): + response = self.client.applications.begin_create_or_update( + resource_group_name=resource_group.name, + application_name="str", + parameters={ + "kind": "str", + "properties": { + "applicationDefinitionId": "str", + "artifacts": [{"name": "str", "type": "str", "uri": "str"}], + "authorizations": [{"principalId": "str", "roleDefinitionId": "str"}], + "billingDetails": {"resourceUsageId": "str"}, + "createdBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + "customerSupport": {"email": "str", "phone": "str", "contactName": "str"}, + "jitAccessPolicy": { + "jitAccessEnabled": bool, + "jitApprovalMode": "str", + "jitApprovers": [{"id": "str", "displayName": "str", "type": "str"}], + "maximumJitAccessDuration": "str", + }, + "managedResourceGroupId": "str", + "managementMode": "str", + "outputs": {}, + "parameters": {}, + "provisioningState": "str", + "publisherTenantId": "str", + "supportUrls": {"governmentCloud": "str", "publicAzure": "str"}, + "updatedBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + }, + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"principalId": "str", "tenantId": "str"}}, + }, + "location": "str", + "managedBy": "str", + "name": "str", + "plan": {"name": "str", "product": "str", "publisher": "str", "version": "str", "promotionCode": "str"}, + "sku": {"name": "str", "capacity": 0, "family": "str", "model": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_begin_update(self, resource_group): + response = self.client.applications.begin_update( + resource_group_name=resource_group.name, + application_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_begin_delete(self, resource_group): + response = self.client.applications.begin_delete( + resource_group_name=resource_group.name, + application_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_list_by_resource_group(self, resource_group): + response = self.client.applications.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_list_by_subscription(self, resource_group): + response = self.client.applications.list_by_subscription() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_begin_refresh_permissions(self, resource_group): + response = self.client.applications.begin_refresh_permissions( + resource_group_name=resource_group.name, + application_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_list_allowed_upgrade_plans(self, resource_group): + response = self.client.applications.list_allowed_upgrade_plans( + resource_group_name=resource_group.name, + application_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_begin_update_access(self, resource_group): + response = self.client.applications.begin_update_access( + resource_group_name=resource_group.name, + application_name="str", + parameters={ + "Metadata": { + "originRequestId": "str", + "requestorId": "str", + "subjectDisplayName": "str", + "tenantDisplayName": "str", + }, + "Status": "str", + "SubStatus": "str", + "Approver": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_list_tokens(self, resource_group): + response = self.client.applications.list_tokens( + resource_group_name=resource_group.name, + application_name="str", + parameters={"authorizationAudience": "str", "userAssignedIdentities": ["str"]}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_get_by_id(self, resource_group): + response = self.client.applications.get_by_id( + application_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_begin_create_or_update_by_id(self, resource_group): + response = self.client.applications.begin_create_or_update_by_id( + application_id="str", + parameters={ + "kind": "str", + "properties": { + "applicationDefinitionId": "str", + "artifacts": [{"name": "str", "type": "str", "uri": "str"}], + "authorizations": [{"principalId": "str", "roleDefinitionId": "str"}], + "billingDetails": {"resourceUsageId": "str"}, + "createdBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + "customerSupport": {"email": "str", "phone": "str", "contactName": "str"}, + "jitAccessPolicy": { + "jitAccessEnabled": bool, + "jitApprovalMode": "str", + "jitApprovers": [{"id": "str", "displayName": "str", "type": "str"}], + "maximumJitAccessDuration": "str", + }, + "managedResourceGroupId": "str", + "managementMode": "str", + "outputs": {}, + "parameters": {}, + "provisioningState": "str", + "publisherTenantId": "str", + "supportUrls": {"governmentCloud": "str", "publicAzure": "str"}, + "updatedBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + }, + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"principalId": "str", "tenantId": "str"}}, + }, + "location": "str", + "managedBy": "str", + "name": "str", + "plan": {"name": "str", "product": "str", "publisher": "str", "version": "str", "promotionCode": "str"}, + "sku": {"name": "str", "capacity": 0, "family": "str", "model": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_begin_update_by_id(self, resource_group): + response = self.client.applications.begin_update_by_id( + application_id="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_applications_begin_delete_by_id(self, resource_group): + response = self.client.applications.begin_delete_by_id( + application_id="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_applications_operations_async.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_applications_operations_async.py new file mode 100644 index 000000000000..471aacf5137d --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_applications_operations_async.py @@ -0,0 +1,314 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.managedapplications.aio import ManagedApplicationsMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestManagedApplicationsMgmtApplicationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ManagedApplicationsMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_get(self, resource_group): + response = await self.client.applications.get( + resource_group_name=resource_group.name, + application_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_begin_create_or_update(self, resource_group): + response = await ( + await self.client.applications.begin_create_or_update( + resource_group_name=resource_group.name, + application_name="str", + parameters={ + "kind": "str", + "properties": { + "applicationDefinitionId": "str", + "artifacts": [{"name": "str", "type": "str", "uri": "str"}], + "authorizations": [{"principalId": "str", "roleDefinitionId": "str"}], + "billingDetails": {"resourceUsageId": "str"}, + "createdBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + "customerSupport": {"email": "str", "phone": "str", "contactName": "str"}, + "jitAccessPolicy": { + "jitAccessEnabled": bool, + "jitApprovalMode": "str", + "jitApprovers": [{"id": "str", "displayName": "str", "type": "str"}], + "maximumJitAccessDuration": "str", + }, + "managedResourceGroupId": "str", + "managementMode": "str", + "outputs": {}, + "parameters": {}, + "provisioningState": "str", + "publisherTenantId": "str", + "supportUrls": {"governmentCloud": "str", "publicAzure": "str"}, + "updatedBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + }, + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"principalId": "str", "tenantId": "str"}}, + }, + "location": "str", + "managedBy": "str", + "name": "str", + "plan": { + "name": "str", + "product": "str", + "publisher": "str", + "version": "str", + "promotionCode": "str", + }, + "sku": { + "name": "str", + "capacity": 0, + "family": "str", + "model": "str", + "size": "str", + "tier": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_begin_update(self, resource_group): + response = await ( + await self.client.applications.begin_update( + resource_group_name=resource_group.name, + application_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_begin_delete(self, resource_group): + response = await ( + await self.client.applications.begin_delete( + resource_group_name=resource_group.name, + application_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_list_by_resource_group(self, resource_group): + response = self.client.applications.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_list_by_subscription(self, resource_group): + response = self.client.applications.list_by_subscription() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_begin_refresh_permissions(self, resource_group): + response = await ( + await self.client.applications.begin_refresh_permissions( + resource_group_name=resource_group.name, + application_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_list_allowed_upgrade_plans(self, resource_group): + response = await self.client.applications.list_allowed_upgrade_plans( + resource_group_name=resource_group.name, + application_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_begin_update_access(self, resource_group): + response = await ( + await self.client.applications.begin_update_access( + resource_group_name=resource_group.name, + application_name="str", + parameters={ + "Metadata": { + "originRequestId": "str", + "requestorId": "str", + "subjectDisplayName": "str", + "tenantDisplayName": "str", + }, + "Status": "str", + "SubStatus": "str", + "Approver": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_list_tokens(self, resource_group): + response = await self.client.applications.list_tokens( + resource_group_name=resource_group.name, + application_name="str", + parameters={"authorizationAudience": "str", "userAssignedIdentities": ["str"]}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_get_by_id(self, resource_group): + response = await self.client.applications.get_by_id( + application_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_begin_create_or_update_by_id(self, resource_group): + response = await ( + await self.client.applications.begin_create_or_update_by_id( + application_id="str", + parameters={ + "kind": "str", + "properties": { + "applicationDefinitionId": "str", + "artifacts": [{"name": "str", "type": "str", "uri": "str"}], + "authorizations": [{"principalId": "str", "roleDefinitionId": "str"}], + "billingDetails": {"resourceUsageId": "str"}, + "createdBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + "customerSupport": {"email": "str", "phone": "str", "contactName": "str"}, + "jitAccessPolicy": { + "jitAccessEnabled": bool, + "jitApprovalMode": "str", + "jitApprovers": [{"id": "str", "displayName": "str", "type": "str"}], + "maximumJitAccessDuration": "str", + }, + "managedResourceGroupId": "str", + "managementMode": "str", + "outputs": {}, + "parameters": {}, + "provisioningState": "str", + "publisherTenantId": "str", + "supportUrls": {"governmentCloud": "str", "publicAzure": "str"}, + "updatedBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + }, + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"principalId": "str", "tenantId": "str"}}, + }, + "location": "str", + "managedBy": "str", + "name": "str", + "plan": { + "name": "str", + "product": "str", + "publisher": "str", + "version": "str", + "promotionCode": "str", + }, + "sku": { + "name": "str", + "capacity": 0, + "family": "str", + "model": "str", + "size": "str", + "tier": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_begin_update_by_id(self, resource_group): + response = await ( + await self.client.applications.begin_update_by_id( + application_id="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_applications_begin_delete_by_id(self, resource_group): + response = await ( + await self.client.applications.begin_delete_by_id( + application_id="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_async.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_async.py new file mode 100644 index 000000000000..76289c82478d --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_async.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.managedapplications.aio import ManagedApplicationsMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestManagedApplicationsMgmtAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ManagedApplicationsMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_portal_registry_package(self, resource_group): + response = await self.client.portal_registry_package( + parameters={"offer": "str", "plan": "str", "publisher": "str", "version": "str"}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_operations(self, resource_group): + response = self.client.list_operations() + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_jit_requests_operations.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_jit_requests_operations.py new file mode 100644 index 000000000000..61ed8d04a885 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_jit_requests_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.managedapplications import ManagedApplicationsMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestManagedApplicationsMgmtJitRequestsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ManagedApplicationsMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_requests_get(self, resource_group): + response = self.client.jit_requests.get( + resource_group_name=resource_group.name, + jit_request_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_requests_begin_create_or_update(self, resource_group): + response = self.client.jit_requests.begin_create_or_update( + resource_group_name=resource_group.name, + jit_request_name="str", + parameters={ + "id": "str", + "location": "str", + "name": "str", + "properties": { + "applicationResourceId": "str", + "jitAuthorizationPolicies": [{"principalId": "str", "roleDefinitionId": "str"}], + "jitSchedulingPolicy": { + "duration": "1 day, 0:00:00", + "startTime": "2020-02-20 00:00:00", + "type": "str", + }, + "createdBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + "jitRequestState": "str", + "provisioningState": "str", + "publisherTenantId": "str", + "updatedBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_requests_update(self, resource_group): + response = self.client.jit_requests.update( + resource_group_name=resource_group.name, + jit_request_name="str", + parameters={"tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_requests_delete(self, resource_group): + response = self.client.jit_requests.delete( + resource_group_name=resource_group.name, + jit_request_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_requests_list_by_resource_group(self, resource_group): + response = self.client.jit_requests.list_by_resource_group( + resource_group_name=resource_group.name, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jit_requests_list_by_subscription(self, resource_group): + response = self.client.jit_requests.list_by_subscription() + + # please add some check logic here by yourself + # ... diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_jit_requests_operations_async.py b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_jit_requests_operations_async.py new file mode 100644 index 000000000000..3efd7e8ff3a8 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/generated_tests/test_managed_applications_mgmt_jit_requests_operations_async.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.managedapplications.aio import ManagedApplicationsMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestManagedApplicationsMgmtJitRequestsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ManagedApplicationsMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_requests_get(self, resource_group): + response = await self.client.jit_requests.get( + resource_group_name=resource_group.name, + jit_request_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_requests_begin_create_or_update(self, resource_group): + response = await ( + await self.client.jit_requests.begin_create_or_update( + resource_group_name=resource_group.name, + jit_request_name="str", + parameters={ + "id": "str", + "location": "str", + "name": "str", + "properties": { + "applicationResourceId": "str", + "jitAuthorizationPolicies": [{"principalId": "str", "roleDefinitionId": "str"}], + "jitSchedulingPolicy": { + "duration": "1 day, 0:00:00", + "startTime": "2020-02-20 00:00:00", + "type": "str", + }, + "createdBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + "jitRequestState": "str", + "provisioningState": "str", + "publisherTenantId": "str", + "updatedBy": {"applicationId": "str", "oid": "str", "puid": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_requests_update(self, resource_group): + response = await self.client.jit_requests.update( + resource_group_name=resource_group.name, + jit_request_name="str", + parameters={"tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_requests_delete(self, resource_group): + response = await self.client.jit_requests.delete( + resource_group_name=resource_group.name, + jit_request_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_requests_list_by_resource_group(self, resource_group): + response = await self.client.jit_requests.list_by_resource_group( + resource_group_name=resource_group.name, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jit_requests_list_by_subscription(self, resource_group): + response = await self.client.jit_requests.list_by_subscription() + + # please add some check logic here by yourself + # ... diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/pyproject.toml b/sdk/managedapplications/azure-mgmt-managedapplications/pyproject.toml index 540da07d41af..0bd645e2af7c 100644 --- a/sdk/managedapplications/azure-mgmt-managedapplications/pyproject.toml +++ b/sdk/managedapplications/azure-mgmt-managedapplications/pyproject.toml @@ -1,6 +1,88 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-managedapplications" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Managedapplications Management Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +requires-python = ">=3.10" +keywords = [ + "azure", + "azure sdk", +] +dependencies = [ + "isodate>=0.6.1", + "azure-mgmt-core>=1.6.0", + "typing-extensions>=4.6.0", +] +dynamic = [ + "version", + "readme", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic.version] +attr = "azure.mgmt.managedapplications._version.VERSION" + +[tool.setuptools.dynamic.readme] +file = [ + "README.md", + "CHANGELOG.md", +] +content-type = "text/markdown" + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.mgmt", +] + +[tool.setuptools.package-data] +pytyped = [ + "py.typed", +] + [tool.azure-sdk-build] breaking = false mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-managedapplications" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Managedapplications Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +sample_link = "" +exclude_folders = "" +title = "ManagedApplicationsMgmtClient" diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/sdk_packaging.toml b/sdk/managedapplications/azure-mgmt-managedapplications/sdk_packaging.toml deleted file mode 100644 index da8ca7758f42..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/sdk_packaging.toml +++ /dev/null @@ -1,12 +0,0 @@ -[packaging] -package_name = "azure-mgmt-managedapplications" -package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "Managedapplications Management" -package_doc_id = "" -is_stable = true -is_arm = true -need_msrestazure = false -need_azuremgmtcore = true -sample_link = "" -exclude_folders = "" -title = "ManagedApplicationsMgmtClient" diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/setup.py b/sdk/managedapplications/azure-mgmt-managedapplications/setup.py deleted file mode 100644 index 1e220d76611c..000000000000 --- a/sdk/managedapplications/azure-mgmt-managedapplications/setup.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -import re -import os.path -from io import open -from setuptools import find_packages, setup - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-mgmt-managedapplications" -PACKAGE_PPRINT_NAME = "Managedapplications Management" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") - -# Version extraction inspired from 'requests' -with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), - "r", -) as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -with open("README.md", encoding="utf-8") as f: - readme = f.read() -with open("CHANGELOG.md", encoding="utf-8") as f: - changelog = f.read() - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=readme + "\n\n" + changelog, - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.mgmt", - ] - ), - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", - ], - python_requires=">=3.7", -) diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/tsp-location.yaml b/sdk/managedapplications/azure-mgmt-managedapplications/tsp-location.yaml new file mode 100644 index 000000000000..5a7758e73b92 --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/solutions/Solutions.Management +commit: ea850a065dc8679f82dc3fdbba9ceff53eeba116 +repo: Azure/azure-rest-api-specs +additionalDirectories: