diff --git a/sdk/resources/azure-mgmt-resource/CHANGELOG.md b/sdk/resources/azure-mgmt-resource/CHANGELOG.md index 520c3c659038..b30315765b3a 100644 --- a/sdk/resources/azure-mgmt-resource/CHANGELOG.md +++ b/sdk/resources/azure-mgmt-resource/CHANGELOG.md @@ -1,5 +1,61 @@ # Release History +## 26.0.0b1 (2026-06-08) + +### Features Added + + - Client `ResourceManagementClient` added method `send_request` + - Model `GenericResource` added property `system_data` + - Model `GenericResourceExpanded` added property `system_data` + - Model `Operation` added property `is_data_action` + - Model `Operation` added property `origin` + - Model `Operation` added property `action_type` + - Model `Resource` added property `system_data` + - Model `ResourceGroup` added property `system_data` + - Model `TagDetails` added property `values_property` + - Model `TagsResource` added property `system_data` + - Added enum `ActionType` + - Added model `CloudError` + - Added enum `CreatedByType` + - Added model `ErrorDetail` + - Added model `ExtensionResource` + - Added enum `Origin` + - Added model `SystemData` + - Added model `TrackedResource` + +### Breaking Changes + + - Model `Resource` deleted or renamed its instance variable `location` + - Model `Resource` deleted or renamed its instance variable `extended_location` + - Model `Resource` deleted or renamed its instance variable `tags` + - Model `TagDetails` deleted or renamed its instance variable `values` + - Deleted or renamed model `GenericResourceFilter` + - Deleted or renamed model `ResourceGroupFilter` + - Deleted or renamed model `ResourceProviderOperationDisplayProperties` + - Deleted or renamed model `SubResource` + - Method `ProviderResourceTypesOperations.list` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ProvidersOperations.get` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ProvidersOperations.get_at_tenant_scope` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ProvidersOperations.list` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ProvidersOperations.list_at_tenant_scope` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ResourceGroupsOperations.begin_delete` changed its parameter `force_deletion_types` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.begin_create_or_update` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.begin_create_or_update_by_id` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.begin_delete` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.begin_delete_by_id` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.begin_update` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.begin_update_by_id` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.check_existence` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.check_existence_by_id` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.get` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.get_by_id` changed its parameter `api_version` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.list` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.list_by_resource_group` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ResourcesOperations.begin_create_or_update_by_id` re-ordered its parameters from `['self', 'resource_id', 'api_version', 'parameters', 'kwargs']` to `['self', 'resource_id', 'parameters', 'api_version', 'kwargs']` + - Method `ResourcesOperations.begin_create_or_update` re-ordered its parameters from `['self', 'resource_group_name', 'resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name', 'api_version', 'parameters', 'kwargs']` to `['self', 'resource_group_name', 'resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name', 'parameters', 'api_version', 'kwargs']` + - Method `ResourcesOperations.begin_update_by_id` re-ordered its parameters from `['self', 'resource_id', 'api_version', 'parameters', 'kwargs']` to `['self', 'resource_id', 'parameters', 'api_version', 'kwargs']` + - Method `ResourcesOperations.begin_update` re-ordered its parameters from `['self', 'resource_group_name', 'resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name', 'api_version', 'parameters', 'kwargs']` to `['self', 'resource_group_name', 'resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name', 'parameters', 'api_version', 'kwargs']` + ## 25.0.0 (2026-02-04) ### Breaking Changes diff --git a/sdk/resources/azure-mgmt-resource/MANIFEST.in b/sdk/resources/azure-mgmt-resource/MANIFEST.in index f0b6ddfb00ba..54c17119e298 100644 --- a/sdk/resources/azure-mgmt-resource/MANIFEST.in +++ b/sdk/resources/azure-mgmt-resource/MANIFEST.in @@ -1,7 +1,8 @@ include *.md include LICENSE -include azure/mgmt/resource/py.typed +include azure/mgmt/resource/resources/py.typed recursive-include tests *.py recursive-include samples *.py *.md include azure/__init__.py include azure/mgmt/__init__.py +include azure/mgmt/resource/__init__.py diff --git a/sdk/resources/azure-mgmt-resource/README.md b/sdk/resources/azure-mgmt-resource/README.md index 675ec9531260..4c74fe0c31d8 100644 --- a/sdk/resources/azure-mgmt-resource/README.md +++ b/sdk/resources/azure-mgmt-resource/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Resource Management Client Library. -This package has been tested with Python 3.9+. +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.9+ 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 configuration of the 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. diff --git a/sdk/resources/azure-mgmt-resource/_metadata.json b/sdk/resources/azure-mgmt-resource/_metadata.json index 9606fb861fb7..d74fbd8c10e1 100644 --- a/sdk/resources/azure-mgmt-resource/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/_metadata.json @@ -1,11 +1,10 @@ { - "commit": "bd379a19745963b51c41b0928bac7cab7803d92a", + "apiVersion": "2025-04-01", + "apiVersions": { + "Microsoft.Resources": "2025-04-01" + }, + "commit": "a70a8a6457e2f1d56fea576a652196346ba42c14", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.48.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/resources/resource-manager/Microsoft.Resources/resources/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-resources-2025-04 --use=@autorest/python@6.48.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/resources/resource-manager/Microsoft.Resources/resources/readme.md" + "typespec_src": "specification/resources/resource-manager/Microsoft.Resources/resources", + "emitterVersion": "0.63.0" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/apiview-properties.json b/sdk/resources/azure-mgmt-resource/apiview-properties.json index 120c22a51e8a..0dd9d0937600 100644 --- a/sdk/resources/azure-mgmt-resource/apiview-properties.json +++ b/sdk/resources/azure-mgmt-resource/apiview-properties.json @@ -1,143 +1,143 @@ { - "CrossLanguagePackageId": null, + "CrossLanguagePackageId": "Microsoft.Resources", "CrossLanguageDefinitionId": { - "azure.mgmt.resource.resources.models.Alias": null, - "azure.mgmt.resource.resources.models.AliasPath": null, - "azure.mgmt.resource.resources.models.AliasPathMetadata": null, - "azure.mgmt.resource.resources.models.AliasPattern": null, - "azure.mgmt.resource.resources.models.ApiProfile": null, - "azure.mgmt.resource.resources.models.ErrorAdditionalInfo": null, - "azure.mgmt.resource.resources.models.ErrorResponse": null, - "azure.mgmt.resource.resources.models.ExportTemplateRequest": null, - "azure.mgmt.resource.resources.models.ExtendedLocation": null, - "azure.mgmt.resource.resources.models.Resource": null, - "azure.mgmt.resource.resources.models.GenericResource": null, - "azure.mgmt.resource.resources.models.GenericResourceExpanded": null, - "azure.mgmt.resource.resources.models.GenericResourceFilter": null, - "azure.mgmt.resource.resources.models.Identity": null, - "azure.mgmt.resource.resources.models.IdentityUserAssignedIdentitiesValue": null, - "azure.mgmt.resource.resources.models.Operation": null, - "azure.mgmt.resource.resources.models.OperationDisplay": null, - "azure.mgmt.resource.resources.models.OperationListResult": null, - "azure.mgmt.resource.resources.models.Permission": null, - "azure.mgmt.resource.resources.models.Plan": null, - "azure.mgmt.resource.resources.models.Provider": null, - "azure.mgmt.resource.resources.models.ProviderConsentDefinition": null, - "azure.mgmt.resource.resources.models.ProviderExtendedLocation": null, - "azure.mgmt.resource.resources.models.ProviderListResult": null, - "azure.mgmt.resource.resources.models.ProviderPermission": null, - "azure.mgmt.resource.resources.models.ProviderPermissionListResult": null, - "azure.mgmt.resource.resources.models.ProviderRegistrationRequest": null, - "azure.mgmt.resource.resources.models.ProviderResourceType": null, - "azure.mgmt.resource.resources.models.ProviderResourceTypeListResult": null, - "azure.mgmt.resource.resources.models.ResourceGroup": null, - "azure.mgmt.resource.resources.models.ResourceGroupExportResult": null, - "azure.mgmt.resource.resources.models.ResourceGroupFilter": null, - "azure.mgmt.resource.resources.models.ResourceGroupListResult": null, - "azure.mgmt.resource.resources.models.ResourceGroupPatchable": null, - "azure.mgmt.resource.resources.models.ResourceGroupProperties": null, - "azure.mgmt.resource.resources.models.ResourceListResult": null, - "azure.mgmt.resource.resources.models.ResourceProviderOperationDisplayProperties": null, - "azure.mgmt.resource.resources.models.ResourcesMoveInfo": null, - "azure.mgmt.resource.resources.models.RoleDefinition": null, - "azure.mgmt.resource.resources.models.Sku": null, - "azure.mgmt.resource.resources.models.SubResource": null, - "azure.mgmt.resource.resources.models.TagCount": null, - "azure.mgmt.resource.resources.models.TagDetails": null, - "azure.mgmt.resource.resources.models.Tags": null, - "azure.mgmt.resource.resources.models.TagsListResult": null, - "azure.mgmt.resource.resources.models.TagsPatchResource": null, - "azure.mgmt.resource.resources.models.TagsResource": null, - "azure.mgmt.resource.resources.models.TagValue": null, - "azure.mgmt.resource.resources.models.ZoneMapping": null, - "azure.mgmt.resource.resources.models.AliasPatternType": null, - "azure.mgmt.resource.resources.models.AliasPathTokenType": null, - "azure.mgmt.resource.resources.models.AliasPathAttributes": null, - "azure.mgmt.resource.resources.models.AliasType": null, - "azure.mgmt.resource.resources.models.ProviderAuthorizationConsentState": null, - "azure.mgmt.resource.resources.models.ExtendedLocationType": null, - "azure.mgmt.resource.resources.models.ResourceIdentityType": null, - "azure.mgmt.resource.resources.models.ExportTemplateOutputFormat": null, - "azure.mgmt.resource.resources.models.TagsPatchOperation": null, - "azure.mgmt.resource.resources.operations.Operations.list": null, - "azure.mgmt.resource.resources.aio.operations.Operations.list": null, - "azure.mgmt.resource.resources.operations.ProvidersOperations.unregister": null, - "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.unregister": null, - "azure.mgmt.resource.resources.operations.ProvidersOperations.register_at_management_group_scope": null, - "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.register_at_management_group_scope": null, - "azure.mgmt.resource.resources.operations.ProvidersOperations.provider_permissions": null, - "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.provider_permissions": null, - "azure.mgmt.resource.resources.operations.ProvidersOperations.register": null, - "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.register": null, - "azure.mgmt.resource.resources.operations.ProvidersOperations.list": null, - "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.list": null, - "azure.mgmt.resource.resources.operations.ProvidersOperations.list_at_tenant_scope": null, - "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.list_at_tenant_scope": null, - "azure.mgmt.resource.resources.operations.ProvidersOperations.get": null, - "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.get": null, - "azure.mgmt.resource.resources.operations.ProvidersOperations.get_at_tenant_scope": null, - "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.get_at_tenant_scope": null, - "azure.mgmt.resource.resources.operations.ProviderResourceTypesOperations.list": null, - "azure.mgmt.resource.resources.aio.operations.ProviderResourceTypesOperations.list": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.list_by_resource_group": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.list_by_resource_group": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_move_resources": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_move_resources": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_validate_move_resources": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_validate_move_resources": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.list": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.list": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.check_existence": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.check_existence": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_delete": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_delete": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_create_or_update": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_create_or_update": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_update": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_update": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.get": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.get": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.check_existence_by_id": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.check_existence_by_id": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_delete_by_id": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_delete_by_id": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_create_or_update_by_id": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_create_or_update_by_id": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_update_by_id": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_update_by_id": null, - "azure.mgmt.resource.resources.operations.ResourcesOperations.get_by_id": null, - "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.get_by_id": null, - "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.check_existence": null, - "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.check_existence": null, - "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.create_or_update": null, - "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.create_or_update": null, - "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.begin_delete": null, - "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.begin_delete": null, - "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.get": null, - "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.get": null, - "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.update": null, - "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.update": null, - "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.begin_export_template": null, - "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.begin_export_template": null, - "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.list": null, - "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.list": null, - "azure.mgmt.resource.resources.operations.TagsOperations.delete_value": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.delete_value": null, - "azure.mgmt.resource.resources.operations.TagsOperations.create_or_update_value": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.create_or_update_value": null, - "azure.mgmt.resource.resources.operations.TagsOperations.create_or_update": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.create_or_update": null, - "azure.mgmt.resource.resources.operations.TagsOperations.delete": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.delete": null, - "azure.mgmt.resource.resources.operations.TagsOperations.list": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.list": null, - "azure.mgmt.resource.resources.operations.TagsOperations.begin_create_or_update_at_scope": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.begin_create_or_update_at_scope": null, - "azure.mgmt.resource.resources.operations.TagsOperations.begin_update_at_scope": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.begin_update_at_scope": null, - "azure.mgmt.resource.resources.operations.TagsOperations.get_at_scope": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.get_at_scope": null, - "azure.mgmt.resource.resources.operations.TagsOperations.begin_delete_at_scope": null, - "azure.mgmt.resource.resources.aio.operations.TagsOperations.begin_delete_at_scope": null - } + "azure.mgmt.resource.resources.models.Alias": "Microsoft.Resources.Alias", + "azure.mgmt.resource.resources.models.AliasPath": "Microsoft.Resources.AliasPath", + "azure.mgmt.resource.resources.models.AliasPathMetadata": "Microsoft.Resources.AliasPathMetadata", + "azure.mgmt.resource.resources.models.AliasPattern": "Microsoft.Resources.AliasPattern", + "azure.mgmt.resource.resources.models.ApiProfile": "Microsoft.Resources.ApiProfile", + "azure.mgmt.resource.resources.models.CloudError": "Microsoft.Resources.CloudError", + "azure.mgmt.resource.resources.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.resource.resources.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.resource.resources.models.ErrorResponse": "Microsoft.Resources.ErrorResponse", + "azure.mgmt.resource.resources.models.ExportTemplateRequest": "Microsoft.Resources.ExportTemplateRequest", + "azure.mgmt.resource.resources.models.ExtendedLocation": "Microsoft.Resources.ExtendedLocation", + "azure.mgmt.resource.resources.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.resource.resources.models.ExtensionResource": "Azure.ResourceManager.CommonTypes.ExtensionResource", + "azure.mgmt.resource.resources.models.GenericResource": "Microsoft.Resources.GenericResource", + "azure.mgmt.resource.resources.models.GenericResourceExpanded": "Microsoft.Resources.GenericResourceExpanded", + "azure.mgmt.resource.resources.models.Identity": "Microsoft.Resources.Identity", + "azure.mgmt.resource.resources.models.IdentityUserAssignedIdentitiesValue": "Microsoft.Resources.IdentityUserAssignedIdentitiesValue", + "azure.mgmt.resource.resources.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", + "azure.mgmt.resource.resources.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "azure.mgmt.resource.resources.models.Permission": "Microsoft.Resources.Permission", + "azure.mgmt.resource.resources.models.Plan": "Microsoft.Resources.Plan", + "azure.mgmt.resource.resources.models.Provider": "Microsoft.Resources.Provider", + "azure.mgmt.resource.resources.models.ProviderConsentDefinition": "Microsoft.Resources.ProviderConsentDefinition", + "azure.mgmt.resource.resources.models.ProviderExtendedLocation": "Microsoft.Resources.ProviderExtendedLocation", + "azure.mgmt.resource.resources.models.ProviderPermission": "Microsoft.Resources.ProviderPermission", + "azure.mgmt.resource.resources.models.ProviderPermissionListResult": "Microsoft.Resources.ProviderPermissionListResult", + "azure.mgmt.resource.resources.models.ProviderRegistrationRequest": "Microsoft.Resources.ProviderRegistrationRequest", + "azure.mgmt.resource.resources.models.ProviderResourceType": "Microsoft.Resources.ProviderResourceType", + "azure.mgmt.resource.resources.models.ProviderResourceTypeListResult": "Microsoft.Resources.ProviderResourceTypeListResult", + "azure.mgmt.resource.resources.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.resource.resources.models.ResourceGroup": "Microsoft.Resources.ResourceGroup", + "azure.mgmt.resource.resources.models.ResourceGroupExportResult": "Microsoft.Resources.ResourceGroupExportResult", + "azure.mgmt.resource.resources.models.ResourceGroupPatchable": "Microsoft.Resources.ResourceGroupPatchable", + "azure.mgmt.resource.resources.models.ResourceGroupProperties": "Microsoft.Resources.ResourceGroupProperties", + "azure.mgmt.resource.resources.models.ResourcesMoveInfo": "Microsoft.Resources.ResourcesMoveInfo", + "azure.mgmt.resource.resources.models.RoleDefinition": "Microsoft.Resources.RoleDefinition", + "azure.mgmt.resource.resources.models.Sku": "Microsoft.Resources.Sku", + "azure.mgmt.resource.resources.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.resource.resources.models.TagCount": "Microsoft.Resources.TagCount", + "azure.mgmt.resource.resources.models.TagDetails": "Microsoft.Resources.TagDetails", + "azure.mgmt.resource.resources.models.Tags": "Microsoft.Resources.Tags", + "azure.mgmt.resource.resources.models.TagsPatchResource": "Microsoft.Resources.TagsPatchResource", + "azure.mgmt.resource.resources.models.TagsResource": "Microsoft.Resources.TagsResource", + "azure.mgmt.resource.resources.models.TagValue": "Microsoft.Resources.TagValue", + "azure.mgmt.resource.resources.models.ZoneMapping": "Microsoft.Resources.ZoneMapping", + "azure.mgmt.resource.resources.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.resource.resources.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.resource.resources.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.resource.resources.models.ExportTemplateOutputFormat": "Microsoft.Resources.ExportTemplateOutputFormat", + "azure.mgmt.resource.resources.models.ResourceIdentityType": "Microsoft.Resources.ResourceIdentityType", + "azure.mgmt.resource.resources.models.ExtendedLocationType": "Microsoft.Resources.ExtendedLocationType", + "azure.mgmt.resource.resources.models.TagsPatchOperation": "Microsoft.Resources.TagsPatchOperation", + "azure.mgmt.resource.resources.models.AliasPatternType": "Microsoft.Resources.AliasPatternType", + "azure.mgmt.resource.resources.models.AliasPathTokenType": "Microsoft.Resources.AliasPathTokenType", + "azure.mgmt.resource.resources.models.AliasPathAttributes": "Microsoft.Resources.AliasPathAttributes", + "azure.mgmt.resource.resources.models.AliasType": "Microsoft.Resources.AliasType", + "azure.mgmt.resource.resources.models.ProviderAuthorizationConsentState": "Microsoft.Resources.ProviderAuthorizationConsentState", + "azure.mgmt.resource.resources.operations.Operations.list": "Microsoft.Resources.Operations.list", + "azure.mgmt.resource.resources.aio.operations.Operations.list": "Microsoft.Resources.Operations.list", + "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.get": "Microsoft.Resources.ResourceGroups.get", + "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.get": "Microsoft.Resources.ResourceGroups.get", + "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.check_existence": "Microsoft.Resources.ResourceGroups.checkExistence", + "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.check_existence": "Microsoft.Resources.ResourceGroups.checkExistence", + "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.create_or_update": "Microsoft.Resources.ResourceGroups.createOrUpdate", + "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.create_or_update": "Microsoft.Resources.ResourceGroups.createOrUpdate", + "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.update": "Microsoft.Resources.ResourceGroups.update", + "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.update": "Microsoft.Resources.ResourceGroups.update", + "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.begin_delete": "Microsoft.Resources.ResourceGroups.delete", + "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.begin_delete": "Microsoft.Resources.ResourceGroups.delete", + "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.list": "Microsoft.Resources.ResourceGroups.list", + "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.list": "Microsoft.Resources.ResourceGroups.list", + "azure.mgmt.resource.resources.operations.ResourceGroupsOperations.begin_export_template": "Microsoft.Resources.ResourceGroups.exportTemplate", + "azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations.begin_export_template": "Microsoft.Resources.ResourceGroups.exportTemplate", + "azure.mgmt.resource.resources.operations.ResourcesOperations.list_by_resource_group": "Microsoft.Resources.ResourceGroups.listByResourceGroup", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.list_by_resource_group": "Microsoft.Resources.ResourceGroups.listByResourceGroup", + "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_move_resources": "Microsoft.Resources.ResourceGroups.moveResources", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_move_resources": "Microsoft.Resources.ResourceGroups.moveResources", + "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_validate_move_resources": "Microsoft.Resources.ResourceGroups.validateMoveResources", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_validate_move_resources": "Microsoft.Resources.ResourceGroups.validateMoveResources", + "azure.mgmt.resource.resources.operations.ResourcesOperations.check_existence_by_id": "Microsoft.Resources.Resources.checkExistenceById", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.check_existence_by_id": "Microsoft.Resources.Resources.checkExistenceById", + "azure.mgmt.resource.resources.operations.ResourcesOperations.get_by_id": "Microsoft.Resources.Resources.getById", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.get_by_id": "Microsoft.Resources.Resources.getById", + "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_create_or_update_by_id": "Microsoft.Resources.Resources.createOrUpdateById", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_create_or_update_by_id": "Microsoft.Resources.Resources.createOrUpdateById", + "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_update_by_id": "Microsoft.Resources.Resources.updateById", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_update_by_id": "Microsoft.Resources.Resources.updateById", + "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_delete_by_id": "Microsoft.Resources.Resources.deleteById", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_delete_by_id": "Microsoft.Resources.Resources.deleteById", + "azure.mgmt.resource.resources.operations.ResourcesOperations.check_existence": "Microsoft.Resources.SpecificResources.checkExistence", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.check_existence": "Microsoft.Resources.SpecificResources.checkExistence", + "azure.mgmt.resource.resources.operations.ResourcesOperations.get": "Microsoft.Resources.SpecificResources.get", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.get": "Microsoft.Resources.SpecificResources.get", + "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_create_or_update": "Microsoft.Resources.SpecificResources.createOrUpdate", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_create_or_update": "Microsoft.Resources.SpecificResources.createOrUpdate", + "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_update": "Microsoft.Resources.SpecificResources.update", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_update": "Microsoft.Resources.SpecificResources.update", + "azure.mgmt.resource.resources.operations.ResourcesOperations.begin_delete": "Microsoft.Resources.SpecificResources.delete", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.begin_delete": "Microsoft.Resources.SpecificResources.delete", + "azure.mgmt.resource.resources.operations.ResourcesOperations.list": "Microsoft.Resources.ResourcesOperationGroup.list", + "azure.mgmt.resource.resources.aio.operations.ResourcesOperations.list": "Microsoft.Resources.ResourcesOperationGroup.list", + "azure.mgmt.resource.resources.operations.TagsOperations.get_at_scope": "Microsoft.Resources.TagsResources.getAtScope", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.get_at_scope": "Microsoft.Resources.TagsResources.getAtScope", + "azure.mgmt.resource.resources.operations.TagsOperations.begin_create_or_update_at_scope": "Microsoft.Resources.TagsResources.createOrUpdateAtScope", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.begin_create_or_update_at_scope": "Microsoft.Resources.TagsResources.createOrUpdateAtScope", + "azure.mgmt.resource.resources.operations.TagsOperations.begin_update_at_scope": "Microsoft.Resources.TagsResources.updateAtScope", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.begin_update_at_scope": "Microsoft.Resources.TagsResources.updateAtScope", + "azure.mgmt.resource.resources.operations.TagsOperations.begin_delete_at_scope": "Microsoft.Resources.TagsResources.deleteAtScope", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.begin_delete_at_scope": "Microsoft.Resources.TagsResources.deleteAtScope", + "azure.mgmt.resource.resources.operations.TagsOperations.delete_value": "Microsoft.Resources.TagsOperationGroup.deleteValue", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.delete_value": "Microsoft.Resources.TagsOperationGroup.deleteValue", + "azure.mgmt.resource.resources.operations.TagsOperations.create_or_update_value": "Microsoft.Resources.TagsOperationGroup.createOrUpdateValue", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.create_or_update_value": "Microsoft.Resources.TagsOperationGroup.createOrUpdateValue", + "azure.mgmt.resource.resources.operations.TagsOperations.create_or_update": "Microsoft.Resources.TagsOperationGroup.createOrUpdate", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.create_or_update": "Microsoft.Resources.TagsOperationGroup.createOrUpdate", + "azure.mgmt.resource.resources.operations.TagsOperations.delete": "Microsoft.Resources.TagsOperationGroup.delete", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.delete": "Microsoft.Resources.TagsOperationGroup.delete", + "azure.mgmt.resource.resources.operations.TagsOperations.list": "Microsoft.Resources.TagsOperationGroup.list", + "azure.mgmt.resource.resources.aio.operations.TagsOperations.list": "Microsoft.Resources.TagsOperationGroup.list", + "azure.mgmt.resource.resources.operations.ProvidersOperations.list_at_tenant_scope": "Microsoft.Resources.ProvidersOperationGroup.listAtTenantScope", + "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.list_at_tenant_scope": "Microsoft.Resources.ProvidersOperationGroup.listAtTenantScope", + "azure.mgmt.resource.resources.operations.ProvidersOperations.unregister": "Microsoft.Resources.ProvidersOperationGroup.unregister", + "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.unregister": "Microsoft.Resources.ProvidersOperationGroup.unregister", + "azure.mgmt.resource.resources.operations.ProvidersOperations.register_at_management_group_scope": "Microsoft.Resources.ProvidersOperationGroup.registerAtManagementGroupScope", + "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.register_at_management_group_scope": "Microsoft.Resources.ProvidersOperationGroup.registerAtManagementGroupScope", + "azure.mgmt.resource.resources.operations.ProvidersOperations.provider_permissions": "Microsoft.Resources.ProvidersOperationGroup.providerPermissions", + "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.provider_permissions": "Microsoft.Resources.ProvidersOperationGroup.providerPermissions", + "azure.mgmt.resource.resources.operations.ProvidersOperations.register": "Microsoft.Resources.ProvidersOperationGroup.register", + "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.register": "Microsoft.Resources.ProvidersOperationGroup.register", + "azure.mgmt.resource.resources.operations.ProvidersOperations.list": "Microsoft.Resources.ProvidersOperationGroup.list", + "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.list": "Microsoft.Resources.ProvidersOperationGroup.list", + "azure.mgmt.resource.resources.operations.ProvidersOperations.get": "Microsoft.Resources.ProvidersOperationGroup.get", + "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.get": "Microsoft.Resources.ProvidersOperationGroup.get", + "azure.mgmt.resource.resources.operations.ProvidersOperations.get_at_tenant_scope": "Microsoft.Resources.ProvidersOperationGroup.getAtTenantScope", + "azure.mgmt.resource.resources.aio.operations.ProvidersOperations.get_at_tenant_scope": "Microsoft.Resources.ProvidersOperationGroup.getAtTenantScope", + "azure.mgmt.resource.resources.operations.ProviderResourceTypesOperations.list": "Microsoft.Resources.ProviderResourceTypesOperationGroup.list", + "azure.mgmt.resource.resources.aio.operations.ProviderResourceTypesOperations.list": "Microsoft.Resources.ProviderResourceTypesOperationGroup.list" + }, + "CrossLanguageVersion": "973c3b884529" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/__init__.py index cf83175351e9..d55ccad1f573 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/__init__.py @@ -1,13 +1 @@ -# 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 .resources import ResourceManagementClient - -__all__ = [ - "ResourceManagementClient", -] +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/_version.py deleted file mode 100644 index 268d9f9e1fac..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/_version.py +++ /dev/null @@ -1,8 +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. -# -------------------------------------------------------------------------- - -VERSION = "25.0.0" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py index 1425a43e3809..cca1d2c47d54 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.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. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._resource_management_client import ResourceManagementClient # type: ignore +from ._client import ResourceManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_client.py similarity index 82% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_client.py index 8c44056c5a8c..30ee2dabb722 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_client.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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 copy import deepcopy +import sys from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -17,7 +17,6 @@ from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models from ._configuration import ResourceManagementClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( @@ -29,38 +28,44 @@ TagsOperations, ) +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 ResourceManagementClient: - """ResourceManagement Client. + """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.operations.Operations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.operations.ResourceGroupsOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.operations.ResourcesOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.operations.TagsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.operations.ProvidersOperations :ivar provider_resource_types: ProviderResourceTypesOperations operations :vartype provider_resource_types: azure.mgmt.resource.resources.operations.ProviderResourceTypesOperations - :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.operations.ResourcesOperations - :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.operations.ResourceGroupsOperations - :ivar tags: TagsOperations operations - :vartype tags: azure.mgmt.resource.resources.operations.TagsOperations - :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 Microsoft Azure subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :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: Api Version. Default value is "2025-04-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Known values are "2025-04-01" + 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. @@ -75,6 +80,7 @@ def __init__( 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: @@ -83,6 +89,7 @@ def __init__( self._config = ResourceManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -106,28 +113,27 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) self.provider_resource_types = ProviderResourceTypesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -140,7 +146,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + 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: diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py index 15539b19705c..ec2a8966ee35 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.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. # -------------------------------------------------------------------------- @@ -24,15 +24,18 @@ class ResourceManagementClientConfiguration: # pylint: disable=too-many-instanc 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 Microsoft Azure subscription ID. Required. + :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 "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: Api Version. Default value is "2025-04-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Known values are "2025-04-01" + 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 """ @@ -40,6 +43,7 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: @@ -52,6 +56,7 @@ def __init__( 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"]) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_patch.py index 2be8919280c2..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_patch.py @@ -3,14 +3,13 @@ # 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/__init__.py @@ -1,6 +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) 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. # -------------------------------------------------------------------------- diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/model_base.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/model_base.py new file mode 100644 index 000000000000..bd5b9caf1022 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/model_base.py @@ -0,0 +1,1755 @@ +# 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_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_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, +} + + +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 _timedelta_as_isostr(o) + 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()) + cls._backcompat_attr_to_rest_field: dict[str, _RestField] = { + Model._get_backcompat_attribute_name(cls._attr_to_rest_field, attr): rf + for attr, rf in cls._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_backcompat_attribute_name(cls, attr_to_rest_field: dict[str, "_RestField"], attr_name: str) -> str: + rest_field_obj = attr_to_rest_field.get(attr_name) # pylint: disable=protected-access + if rest_field_obj is None: + return attr_name + original_tsp_name = getattr(rest_field_obj, "_original_tsp_name", None) # pylint: disable=protected-access + if original_tsp_name: + return original_tsp_name + return attr_name + + @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, + original_tsp_name: typing.Optional[str] = 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 + self._original_tsp_name = original_tsp_name + + @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, + original_tsp_name: typing.Optional[str] = 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, + original_tsp_name=original_tsp_name, + ) + + +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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/serialization.py index 6da830e0cf4a..a088671e9c51 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/serialization.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_utils/serialization.py @@ -3,7 +3,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. # -------------------------------------------------------------------------- @@ -39,11 +39,15 @@ import xml.etree.ElementTree as ET import isodate # type: ignore -from typing_extensions import Self 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") JSON = MutableMapping[str, Any] @@ -1401,7 +1405,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> 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. @@ -1411,6 +1415,27 @@ def __call__(self, target_obj, response_data, content_type=None): :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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_version.py index e67545fce879..a84ed935f516 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_version.py @@ -1,9 +1,9 @@ # 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. +# 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. # -------------------------------------------------------------------------- - -VERSION = "25.0.0" +VERSION = "26.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/__init__.py index f06ef4b18a05..ef5300030ab9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/__init__.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. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._resource_management_client import ResourceManagementClient # type: ignore +from ._client import ResourceManagementClient # type: ignore try: from ._patch import __all__ as _patch_all diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_client.py similarity index 83% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_client.py index 2c707cb24a6d..3a31bb21ef9a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_client.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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 copy import deepcopy +import sys from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -17,7 +17,6 @@ from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from .. import models as _models from .._utils.serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration from .operations import ( @@ -29,38 +28,44 @@ TagsOperations, ) +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 ResourceManagementClient: - """ResourceManagement Client. + """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.aio.operations.Operations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.aio.operations.ResourcesOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.aio.operations.TagsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.aio.operations.ProvidersOperations :ivar provider_resource_types: ProviderResourceTypesOperations operations :vartype provider_resource_types: azure.mgmt.resource.resources.aio.operations.ProviderResourceTypesOperations - :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.aio.operations.ResourcesOperations - :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.aio.operations.ResourceGroupsOperations - :ivar tags: TagsOperations operations - :vartype tags: azure.mgmt.resource.resources.aio.operations.TagsOperations - :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 Microsoft Azure subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :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: Api Version. Default value is "2025-04-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Known values are "2025-04-01" + 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. @@ -75,6 +80,7 @@ def __init__( 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: @@ -83,6 +89,7 @@ def __init__( self._config = ResourceManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -107,23 +114,22 @@ def __init__( self._config.http_logging_policy, ] self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs + base_url=cast(str, _endpoint), policies=_policies, **kwargs ) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) self.provider_resource_types = ProviderResourceTypesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -131,7 +137,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -144,7 +150,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + 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: diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py index 088548f988b8..9c8b8f0283e8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.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. # -------------------------------------------------------------------------- @@ -24,15 +24,18 @@ class ResourceManagementClientConfiguration: # pylint: disable=too-many-instanc 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 Microsoft Azure subscription ID. Required. + :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 "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: Api Version. Default value is "2025-04-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Known values are "2025-04-01" + 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 """ @@ -40,6 +43,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: @@ -52,6 +56,7 @@ def __init__( 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"]) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_patch.py index 2be8919280c2..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_patch.py @@ -3,14 +3,13 @@ # 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/__init__.py index c95b954380a9..9471cdcfdeed 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/__init__.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. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,11 +13,11 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import Operations # type: ignore -from ._operations import ProvidersOperations # type: ignore -from ._operations import ProviderResourceTypesOperations # type: ignore -from ._operations import ResourcesOperations # type: ignore from ._operations import ResourceGroupsOperations # type: ignore +from ._operations import ResourcesOperations # type: ignore from ._operations import TagsOperations # type: ignore +from ._operations import ProvidersOperations # type: ignore +from ._operations import ProviderResourceTypesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -25,11 +25,11 @@ __all__ = [ "Operations", - "ProvidersOperations", - "ProviderResourceTypesOperations", - "ResourcesOperations", "ResourceGroupsOperations", + "ResourcesOperations", "TagsOperations", + "ProvidersOperations", + "ProviderResourceTypesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/_operations.py index ff5d7c1e7bf1..e8535a043891 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/_operations.py @@ -1,13 +1,14 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines +# 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. +# 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 @@ -33,6 +34,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import ( build_operations_list_request, @@ -80,6 +82,7 @@ T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list @@ -93,8 +96,6 @@ class Operations: :attr:`operations` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -104,18 +105,17 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: - """Lists all of the available Microsoft.Resources REST API operations. + """List the operations for the provider. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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) + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -129,11 +129,16 @@ def prepare_request(next_link=None): if not next_link: _request = build_operations_list_request( - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -146,18 +151,29 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + 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 = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + 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.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -170,25 +186,27 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) -class ProvidersOperations: +class ResourceGroupsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.resource.resources.aio.ResourceManagementClient`'s - :attr:`providers` attribute. + :attr:`resource_groups` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -197,14 +215,14 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: - """Unregisters a subscription from a resource provider. + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: + """Gets a resource group. - :param resource_provider_namespace: The namespace of the resource provider to unregister. - Required. - :type resource_provider_namespace: str - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -216,21 +234,24 @@ async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _ error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Provider] = kwargs.pop("cls", None) + cls: ClsType[_models.ResourceGroup] = kwargs.pop("cls", None) - _request = build_providers_unregister_request( - resource_provider_namespace=resource_provider_namespace, + _request = build_resource_groups_get_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -238,10 +259,22 @@ async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _ 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Provider", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceGroup, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -249,21 +282,14 @@ async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _ return deserialized # type: ignore @distributed_trace_async - async def register_at_management_group_scope( - self, resource_provider_namespace: str, group_id: str, **kwargs: Any - ) -> None: - """Registers a management group with a resource provider. Use this operation to register a - resource provider with resource types that can be deployed at the management group scope. It - does not recursively register subscriptions within the management group. Instead, you must - register subscriptions individually. + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: + """Checks whether a resource group exists. - :param resource_provider_namespace: The namespace of the resource provider to register. - Required. - :type resource_provider_namespace: str - :param group_id: The management group ID. Required. - :type group_id: str - :return: None or the result of cls(response) - :rtype: None + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :return: bool + :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -275,68 +301,21 @@ async def register_at_management_group_scope( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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_providers_register_at_management_group_scope_request( - resource_provider_namespace=resource_provider_namespace, - group_id=group_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def provider_permissions( - self, resource_provider_namespace: str, **kwargs: Any - ) -> _models.ProviderPermissionListResult: - """Get the provider permissions. - - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :return: ProviderPermissionListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ProviderPermissionListResult - :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 = 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.ProviderPermissionListResult] = kwargs.pop("cls", None) - - _request = build_providers_provider_permissions_request( - resource_provider_namespace=resource_provider_namespace, + _request = build_resource_groups_check_existence_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -345,83 +324,94 @@ async def provider_permissions( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProviderPermissionListResult", pipeline_response.http_response) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 @overload - async def register( + async def create_or_update( self, - resource_provider_namespace: str, - properties: Optional[_models.ProviderRegistrationRequest] = None, + resource_group_name: str, + parameters: _models.ResourceGroup, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Provider: - """Registers a subscription with a resource provider. + ) -> _models.ResourceGroup: + """Creates or updates a resource group. - :param resource_provider_namespace: The namespace of the resource provider to register. - Required. - :type resource_provider_namespace: str - :param properties: The third party consent for S2S. Default value is None. - :type properties: ~azure.mgmt.resource.resources.models.ProviderRegistrationRequest + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroup :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def register( - self, - resource_provider_namespace: str, - properties: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Provider: - """Registers a subscription with a resource provider. + async def create_or_update( + self, resource_group_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. - :param resource_provider_namespace: The namespace of the resource provider to register. - Required. - :type resource_provider_namespace: str - :param properties: The third party consent for S2S. Default value is None. - :type properties: IO[bytes] + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. 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: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - properties: Optional[Union[_models.ProviderRegistrationRequest, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.Provider: - """Registers a subscription with a resource provider. + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, JSON, IO[bytes]], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. - :param resource_provider_namespace: The namespace of the resource provider to register. - Required. - :type resource_provider_namespace: str - :param properties: The third party consent for S2S. Is either a ProviderRegistrationRequest - type or a IO[bytes] type. Default value is None. - :type properties: ~azure.mgmt.resource.resources.models.ProviderRegistrationRequest or - IO[bytes] - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is one of the + following types: ResourceGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroup or JSON or IO[bytes] + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -433,150 +423,375 @@ async def register( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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)) - content_type = content_type if properties else None - cls: ClsType[_models.Provider] = kwargs.pop("cls", None) + cls: ClsType[_models.ResourceGroup] = kwargs.pop("cls", None) - content_type = content_type or "application/json" if properties else None - _json = None + content_type = content_type or "application/json" _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if properties is not None: - _json = self._serialize.body(properties, "ProviderRegistrationRequest") - else: - _json = None + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_providers_register_request( - resource_provider_namespace=resource_provider_namespace, + _request = build_resource_groups_create_or_update_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Provider", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceGroup, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list(self, expand: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.Provider"]: - """Gets all resource providers for a subscription. + @overload + async def update( + self, + resource_group_name: str, + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. - :param expand: The properties to include in the results. For example, use &$expand=metadata in - the query string to retrieve resource provider metadata. To include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: An iterator like instance of either Provider or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.Provider] + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :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.ProviderListResult] = kwargs.pop("cls", None) + @overload + async def update( + self, resource_group_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. 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: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + parameters: Union[_models.ResourceGroupPatchable, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is one of the following + types: ResourceGroupPatchable, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroupPatchable or JSON or + IO[bytes] + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _request = build_providers_list_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceGroup] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + 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 - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProviderListResult", 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) + _request = build_resource_groups_update_request( + resource_group_name=resource_group_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) - async def get_next(next_link=None): - _request = prepare_request(next_link) + _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 + ) - _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.CloudError, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceGroup, response.json()) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, *, force_deletion_types: Optional[str] = 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 = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_resource_groups_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + force_deletion_types=force_deletion_types, + 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.CloudError, + 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 + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, *, force_deletion_types: Optional[str] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a resource group. + + When you delete a resource group, all of its resources are also deleted. Deleting a resource + group deletes all of its template deployments and currently stored operations. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :keyword force_deletion_types: The resource types you want to force delete. Currently, only the + following is supported: + forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets. + Default value is None. + :paramtype force_deletion_types: 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, + force_deletion_types=force_deletion_types, + 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_at_tenant_scope(self, expand: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.Provider"]: - """Gets all resource providers for the tenant. + def list( + self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ResourceGroup"]: + """Gets all the resource groups for a subscription. - :param expand: The properties to include in the results. For example, use &$expand=metadata in - the query string to retrieve resource provider metadata. To include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: An iterator like instance of either Provider or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.Provider] + :keyword filter: The filter to apply on the operation.

You can filter by tag names and + values. For example, to filter for a tag name and value, use $filter=tagName eq 'tag1' and + tagValue eq 'Value1'. Default value is None. + :paramtype filter: str + :keyword top: The number of results to return. If null is passed, returns all resource groups. + Default value is None. + :paramtype top: int + :return: An iterator like instance of ResourceGroup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.ResourceGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ProviderListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ResourceGroup]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -589,13 +804,20 @@ def list_at_tenant_scope(self, expand: Optional[str] = None, **kwargs: Any) -> A def prepare_request(next_link=None): if not next_link: - _request = build_providers_list_at_tenant_scope_request( - expand=expand, - api_version=api_version, + _request = build_resource_groups_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -608,18 +830,29 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + 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 = self._deserialize("ProviderListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceGroup], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -632,27 +865,19 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def get( - self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Provider: - """Gets the specified resource provider. - - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _export_template_initial( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -661,173 +886,203 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Provider] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_providers_get_request( - resource_provider_namespace=resource_provider_namespace, + 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_resource_groups_export_template_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Provider", pipeline_response.http_response) + 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, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get_at_tenant_scope( - self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Provider: - """Gets the specified resource provider at the tenant level. + @overload + async def begin_export_template( + self, + resource_group_name: str, + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.models.ExportTemplateRequest + :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 ResourceGroupExportResult. The + ResourceGroupExportResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] :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 = 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.Provider] = kwargs.pop("cls", None) - - _request = build_providers_get_at_tenant_scope_request( - resource_provider_namespace=resource_provider_namespace, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Provider", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class ProviderResourceTypesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @overload + async def begin_export_template( + self, resource_group_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.resources.aio.ResourceManagementClient`'s - :attr:`provider_resource_types` attribute. - """ + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: JSON + :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 ResourceGroupExportResult. The + ResourceGroupExportResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - models = _models + @overload + async def begin_export_template( + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. - 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: ResourceManagementClientConfiguration = 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") + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. 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 ResourceGroupExportResult. The + ResourceGroupExportResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def list( - self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.ProviderResourceTypeListResult: - """List the resource types for a specified resource provider. - - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: ProviderResourceTypeListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ProviderResourceTypeListResult + async def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is one of the following types: + ExportTemplateRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ExportTemplateRequest or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ResourceGroupExportResult. The + ResourceGroupExportResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] :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 {} - _headers = 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)) + cls: ClsType[_models.ResourceGroupExportResult] = 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._export_template_initial( + resource_group_name=resource_group_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) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ProviderResourceTypeListResult] = kwargs.pop("cls", None) + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ResourceGroupExportResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - _request = build_provider_resource_types_list_request( - resource_provider_namespace=resource_provider_namespace, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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.ResourceGroupExportResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ResourceGroupExportResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProviderResourceTypeListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - class ResourcesOperations: # pylint: disable=too-many-public-methods """ @@ -839,8 +1094,6 @@ class ResourcesOperations: # pylint: disable=too-many-public-methods :attr:`resources` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -852,6 +1105,7 @@ def __init__(self, *args, **kwargs) -> None: def list_by_resource_group( self, resource_group_name: str, + *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, @@ -859,43 +1113,40 @@ def list_by_resource_group( ) -> AsyncItemPaged["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. Required. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type resource_group_name: str - :param filter: The filter to apply on the operation.\\ :code:`
`\\ :code:`
`The - properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, - resourceGroup, identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.\\ :code:`
`\\ :code:`
`For example, to filter by a - resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'\\ - :code:`
`\\ :code:`
`You can use substringof(value, property) in the filter. The - properties you can use for substring are: name and resourceGroup.\\ :code:`
`\\ - :code:`
`For example, to get all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)\\ :code:`
`\\ :code:`
`You can link more than one - substringof together by adding and/or operators.\\ :code:`
`\\ :code:`
`You can filter by - tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq - 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, the tags for each - resource are not returned in the results.\\ :code:`
`\\ :code:`
`You can use some - properties together when filtering. The combinations you can use are: substringof and/or - resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. Default - value is None. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Valid values include ``createdTime``\\ , ``changedTime`` and ``provisioningState``. For - example, ``$expand=createdTime,changedTime``. Default value is None. - :type expand: str - :param top: The number of results to return. If null is passed, returns all resources. Default - value is None. - :type top: int - :return: An iterator like instance of either GenericResourceExpanded or the result of - cls(response) + :keyword filter: The filter to apply on the operation.

The properties you can use for eq + (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, identity, + identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, and + plan/promotionCode.

For example, to filter by a resource type, use: $filter=resourceType + eq 'Microsoft.Network/virtualNetworks'

You can use substringof(value, property) in the + filter. The properties you can use for substring are: name and resourceGroup.

For + example, to get all resources with 'demo' anywhere in the name, use: + $filter=substringof('demo', name)

You can link more than one substringof together by + adding and/or operators.

You can filter by tag names and values. For example, to filter + for a tag name and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you + filter by a tag name and value, the tags for each resource are not returned in the + results.

You can use some properties together when filtering. The combinations you can + use are: substringof and/or resourceType, plan and plan/publisher and plan/name, identity and + identity/principalId. Default value is None. + :paramtype filter: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``, ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. Default value is None. + :paramtype expand: str + :keyword top: The number of results to return. If null is passed, returns all resources. + Default value is None. + :paramtype top: int + :return: An iterator like instance of GenericResourceExpanded :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.GenericResourceExpanded] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.GenericResourceExpanded]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -914,11 +1165,16 @@ def prepare_request(next_link=None): filter=filter, expand=expand, top=top, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -931,18 +1187,29 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + 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 = self._deserialize("ResourceListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GenericResourceExpanded], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -955,14 +1222,21 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) async def _move_resources_initial( - self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO[bytes]], **kwargs: Any + self, + source_resource_group_name: str, + parameters: Union[_models.ResourcesMoveInfo, JSON, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -973,31 +1247,31 @@ async def _move_resources_initial( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" - _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ResourcesMoveInfo") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -1013,12 +1287,20 @@ async def _move_resources_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1038,15 +1320,44 @@ async def begin_move_resources( resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be moved. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_move_resources( + self, + source_resource_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to be moved must be in the same source resource group in the source subscription + being used. The target resource group may be in a different subscription. When moving + resources, both the source group and the target group are locked for the duration of the + operation. Write and delete operations are blocked on the groups until the move completes. + + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: JSON + :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 None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1067,22 +1378,25 @@ async def begin_move_resources( resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be moved. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str :param parameters: Parameters for moving resources. 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 either None or the result of cls(response) + :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def begin_move_resources( - self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO[bytes]], **kwargs: Any + self, + source_resource_group_name: str, + parameters: Union[_models.ResourcesMoveInfo, JSON, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -1091,20 +1405,19 @@ async def begin_move_resources( resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be moved. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. Is either a ResourcesMoveInfo type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :param parameters: Parameters for moving resources. Is one of the following types: + ResourcesMoveInfo, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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) @@ -1114,7 +1427,6 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, - api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -1128,8 +1440,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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, **kwargs)) + 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: @@ -1144,7 +1462,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _validate_move_resources_initial( - self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO[bytes]], **kwargs: Any + self, + source_resource_group_name: str, + parameters: Union[_models.ResourcesMoveInfo, JSON, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1155,31 +1476,31 @@ async def _validate_move_resources_initial( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" - _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ResourcesMoveInfo") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -1195,12 +1516,20 @@ async def _validate_move_resources_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1222,15 +1551,46 @@ async def begin_validate_move_resources( 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be validated for move. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_move_resources( + self, + source_resource_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to be moved must be in the same source resource group in the source subscription being used. + The target resource group may be in a different subscription. If validation succeeds, it + returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code + 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check + the result of the long-running operation. + + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: JSON + :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 None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1253,22 +1613,25 @@ async def begin_validate_move_resources( 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be validated for move. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str :param parameters: Parameters for moving resources. 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 either None or the result of cls(response) + :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def begin_validate_move_resources( - self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO[bytes]], **kwargs: Any + self, + source_resource_group_name: str, + parameters: Union[_models.ResourcesMoveInfo, JSON, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -1279,20 +1642,19 @@ async def begin_validate_move_resources( 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be validated for move. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. Is either a ResourcesMoveInfo type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :param parameters: Parameters for moving resources. Is one of the following types: + ResourcesMoveInfo, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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) @@ -1302,7 +1664,6 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, - api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -1310,169 +1671,45 @@ async def begin_validate_move_resources( **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 - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[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( - self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.GenericResourceExpanded"]: - """Get all the resources in a subscription. - - :param filter: The filter to apply on the operation.\\ :code:`
`\\ :code:`
`Filter - comparison operators include ``eq`` (equals) and ``ne`` (not equals) and may be used with the - following properties: ``location``\\ , ``resourceType``\\ , ``name``\\ , ``resourceGroup``\\ , - ``identity``\\ , ``identity/principalId``\\ , ``plan``\\ , ``plan/publisher``\\ , - ``plan/product``\\ , ``plan/name``\\ , ``plan/version``\\ , and ``plan/promotionCode``.\\ - :code:`
`\\ :code:`
`For example, to filter by a resource type, use - ``$filter=resourceType eq 'Microsoft.Network/virtualNetworks'``\\ :code:`
`\\ :code:`
`\\ - :code:`
`\\ ``substringof(value, property)`` can be used to filter for substrings of the - following currently-supported properties: ``name`` and ``resourceGroup``\\ :code:`
`\\ - :code:`
`For example, to get all resources with 'demo' anywhere in the resource name, use - ``$filter=substringof('demo', name)``\\ :code:`
`\\ :code:`
`Multiple substring - operations can also be combined using ``and``\\ /\\ ``or`` operators.\\ :code:`
`\\ - :code:`
`Note that any truncated number of results queried via ``$top`` may also not be - compatible when using a filter.\\ :code:`
`\\ :code:`
`\\ :code:`
`Resources can be - filtered by tag names and values. For example, to filter for a tag name and value, use - ``$filter=tagName eq 'tag1' and tagValue eq 'Value1'``. Note that when resources are filtered - by tag name and value, :code:`the original tags for each resource will not be returned in - the results.` Any list of additional properties queried via ``$expand`` may also not be - compatible when filtering by tag names/values. :code:`
`\\ :code:`
`For tag names only, - resources can be filtered by prefix using the following syntax: ``$filter=startswith(tagName, - 'depart')``. This query will return all resources with a tag name prefixed by the phrase - ``depart`` (i.e.\\ ``department``\\ , ``departureDate``\\ , ``departureTime``\\ , etc.)\\ - :code:`
`\\ :code:`
`\\ :code:`
`Note that some properties can be combined when - filtering resources, which include the following: ``substringof() and/or resourceType``\\ , - ``plan and plan/publisher and plan/name``\\ , and ``identity and identity/principalId``. - Default value is None. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Valid values include ``createdTime``\\ , ``changedTime`` and ``provisioningState``. For - example, ``$expand=createdTime,changedTime``. Default value is None. - :type expand: str - :param top: The number of recommendations per page if a paged version of this API is being - used. Default value is None. - :type top: int - :return: An iterator like instance of either GenericResourceExpanded or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.GenericResourceExpanded] - :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.ResourceListResult] = 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_resources_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return cls(pipeline_response, None, {}) # type: ignore - async def get_next(next_link=None): - _request = prepare_request(next_link) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) + 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 check_existence( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - **kwargs: Any - ) -> bool: - """Checks whether a resource exists. + async def check_existence_by_id(self, resource_id: str, *, api_version: str, **kwargs: Any) -> bool: + """Checks by ID whether a resource exists. This API currently works only for a limited set of + Resource providers. In the event that a Resource provider does not implement this API, ARM will + respond with a 405. The alternative then is to use the GET API to check for the existence of + the resource. - :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type. Required. - :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: bool or the result of cls(response) + :param resource_id: Required. + :type resource_id: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: bool :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1489,18 +1726,16 @@ async def check_existence( cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_resources_check_existence_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_check_existence_by_id_request( + resource_id=resource_id, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -1511,22 +1746,28 @@ async def check_existence( if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - async def _delete_initial( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: + @distributed_trace_async + async def get_by_id(self, resource_id: str, *, api_version: str, **kwargs: Any) -> _models.GenericResource: + """Gets a resource by ID. + + :param resource_id: Required. + :type resource_id: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: GenericResource. The GenericResource is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1538,125 +1779,56 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.GenericResource] = kwargs.pop("cls", None) - _request = build_resources_delete_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_get_by_id_request( + resource_id=resource_id, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GenericResource, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a resource. - - :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type. Required. - :type resource_type: str - :param resource_name: The name of the resource to delete. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :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 = 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, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - 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 - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[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 - - async def _create_or_update_initial( + async def _create_or_update_by_id_initial( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, api_version: str, - parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1674,28 +1846,24 @@ async def _create_or_update_initial( cls: ClsType[AsyncIterator[bytes]] = 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, "GenericResource") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resources_create_or_update_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_create_or_update_by_id_request( + resource_id=resource_id, api_version=api_version, content_type=content_type, - json=_json, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -1711,129 +1879,131 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + 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, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_or_update( + async def begin_create_or_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, + resource_id: str, parameters: _models.GenericResource, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Creates a resource. + """Create a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. Required. - :type resource_type: str - :param resource_name: The name of the resource to create. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for creating or updating the resource. Required. + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. :type parameters: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update( + async def begin_create_or_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - parameters: IO[bytes], + resource_id: str, + parameters: JSON, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Creates a resource. + """Create a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. Required. - :type resource_type: str - :param resource_name: The name of the resource to create. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for creating or updating the resource. Required. + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. + :type parameters: JSON + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + parameters: IO[bytes], + *, + api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. :type parameters: IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_or_update( + async def begin_create_or_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, api_version: str, - parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Creates a resource. + """Create a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. Required. - :type resource_type: str - :param resource_name: The name of the resource to create. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for creating or updating the resource. Is either a - GenericResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Is one of the following types: GenericResource, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or JSON or IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1847,14 +2017,10 @@ async def begin_create_or_update( 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, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -1865,13 +2031,20 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.GenericResource, 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, **kwargs)) + 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: @@ -1887,15 +2060,12 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _update_initial( + async def _update_by_id_initial( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, api_version: str, - parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1913,28 +2083,24 @@ async def _update_initial( cls: ClsType[AsyncIterator[bytes]] = 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, "GenericResource") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resources_update_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_update_by_id_request( + resource_id=resource_id, api_version=api_version, content_type=content_type, - json=_json, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -1950,129 +2116,128 @@ async def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update( + async def begin_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, + resource_id: str, parameters: _models.GenericResource, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Updates a resource. + """Update a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. Required. - :type resource_type: str - :param resource_name: The name of the resource to update. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for updating the resource. Required. + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. :type parameters: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: JSON, + *, api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Update a resource by ID. + + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. + :type parameters: JSON + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_by_id( + self, + resource_id: str, parameters: IO[bytes], *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Updates a resource. + """Update a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. Required. - :type resource_type: str - :param resource_name: The name of the resource to update. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for updating the resource. Required. + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. :type parameters: IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, api_version: str, - parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Updates a resource. + """Update a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. Required. - :type resource_type: str - :param resource_name: The name of the resource to update. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for updating the resource. Is either a GenericResource type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Is one of the following types: GenericResource, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or JSON or IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -2086,14 +2251,10 @@ async def begin_update( 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, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, + raw_result = await self._update_by_id_initial( + resource_id=resource_id, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -2104,56 +2265,177 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.GenericResource, 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.GenericResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GenericResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_by_id_initial(self, resource_id: str, *, api_version: 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_resources_delete_by_id_request( + resource_id=resource_id, + api_version=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.CloudError, + 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 + + @distributed_trace_async + async def begin_delete_by_id(self, resource_id: str, *, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a resource by ID. + + :param resource_id: Required. + :type resource_id: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: 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( + resource_id=resource_id, + api_version=api_version, + 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, **kwargs)) + 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.GenericResource].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.GenericResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async - async def get( + async def check_existence( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, + *, api_version: str, **kwargs: Any - ) -> _models.GenericResource: - """Gets a resource. + ) -> bool: + """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to get. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to get. Required. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: GenericResource or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: bool + :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2167,9 +2449,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.GenericResource] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_resources_get_request( + _request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2180,7 +2462,10 @@ async def get( headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2189,33 +2474,47 @@ async def get( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 @distributed_trace_async - async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: - """Checks by ID whether a resource exists. This API currently works only for a limited set of - Resource providers. In the event that a Resource provider does not implement this API, ARM will - respond with a 405. The alternative then is to use the GET API to check for the existence of - the resource. + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + *, + api_version: str, + **kwargs: Any + ) -> _models.GenericResource: + """Gets a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: bool or the result of cls(response) - :rtype: bool + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: GenericResource. The GenericResource is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.GenericResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2229,32 +2528,67 @@ async def check_existence_by_id(self, resource_id: str, api_version: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.GenericResource] = kwargs.pop("cls", None) - _request = build_resources_check_existence_by_id_request( - resource_id=resource_id, + _request = build_resources_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 [204, 404]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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.GenericResource, response.json()) if cls: - return cls(pipeline_response, None, {}) # type: ignore - return 200 <= response.status_code <= 299 + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore - async def _delete_by_id_initial(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncIterator[bytes]: + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, + api_version: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2263,18 +2597,36 @@ async def _delete_by_id_initial(self, resource_id: str, api_version: str, **kwar } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) 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) - _request = build_resources_delete_by_id_request( - resource_id=resource_id, + 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_resources_create_or_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2284,47 +2636,211 @@ async def _delete_by_id_initial(self, resource_id: str, api_version: str, **kwar response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 201, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: _models.GenericResource, + *, + api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: JSON, + *, + api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. + :type parameters: JSON + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: IO[bytes], + *, + api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. + :type parameters: IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a resource by ID. + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, + api_version: str, + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Is one of the following types: GenericResource, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or JSON or IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenericResource] = 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( - resource_id=resource_id, + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2333,27 +2849,47 @@ async def begin_delete_by_id(self, resource_id: str, api_version: str, **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 + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.GenericResource, response.json()) if cls: - return cls(pipeline_response, None, {}) # type: ignore + 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, **kwargs)) + 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( + return AsyncLROPoller[_models.GenericResource].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 + return AsyncLROPoller[_models.GenericResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _create_or_update_by_id_initial( - self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any + async def _update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, + api_version: str, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2370,23 +2906,29 @@ async def _create_or_update_by_id_initial( cls: ClsType[AsyncIterator[bytes]] = 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, "GenericResource") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resources_create_or_update_by_id_request( - resource_id=resource_id, + _request = build_resources_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, - json=_json, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2396,101 +2938,186 @@ async def _create_or_update_by_id_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_or_update_by_id( + async def begin_update( self, - resource_id: str, - api_version: str, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, parameters: _models.GenericResource, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Create a resource by ID. + """Updates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Create or update resource parameters. Required. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. :type parameters: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update_by_id( + async def begin_update( self, - resource_id: str, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: JSON, + *, api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. + :type parameters: JSON + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, parameters: IO[bytes], *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Create a resource by ID. + """Updates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Create or update resource parameters. Required. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. :type parameters: IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_or_update_by_id( - self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, + api_version: str, + **kwargs: Any ) -> AsyncLROPoller[_models.GenericResource]: - """Create a resource by ID. + """Updates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Create or update resource parameters. Is either a GenericResource type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Is one of the following types: GenericResource, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or JSON or IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of AsyncLROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -2504,10 +3131,14 @@ async def begin_create_or_update_by_id( 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( - resource_id=resource_id, - api_version=api_version, + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -2518,13 +3149,20 @@ async def begin_create_or_update_by_id( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.GenericResource, 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, **kwargs)) + 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: @@ -2540,8 +3178,16 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _update_by_id_initial( - self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any + async def _delete_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + *, + api_version: str, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2551,30 +3197,26 @@ async def _update_by_id_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "GenericResource") - - _request = build_resources_update_by_id_request( - resource_id=resource_id, + _request = build_resources_delete_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2584,119 +3226,76 @@ async def _update_by_id_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return deserialized # type: ignore + 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")) - @overload - async def begin_update_by_id( - self, - resource_id: str, - api_version: str, - parameters: _models.GenericResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GenericResource]: - """Updates a resource by ID. + deserialized = response.iter_bytes() if _decompress else response.iter_raw() - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Update resource parameters. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - @overload - async def begin_update_by_id( + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( self, - resource_id: str, - api_version: str, - parameters: IO[bytes], + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, *, - content_type: str = "application/json", + api_version: str, **kwargs: Any - ) -> AsyncLROPoller[_models.GenericResource]: - """Updates a resource by ID. - - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Update resource 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: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_by_id( - self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.GenericResource]: - """Updates a resource by ID. + ) -> AsyncLROPoller[None]: + """Deletes a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Update resource parameters. Is either a GenericResource type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GenericResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = 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.GenericResource] = kwargs.pop("cls", 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_by_id_initial( - resource_id=resource_id, + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, api_version=api_version, - parameters=parameters, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2705,44 +3304,78 @@ async def begin_update_by_id( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + 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, **kwargs)) + 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.GenericResource].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.GenericResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: - """Gets a resource by ID. + @distributed_trace + def list( + self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.GenericResourceExpanded"]: + """Get all the resources in a subscription. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: GenericResource or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.GenericResource + :keyword filter: The filter to apply on the operation.

Filter comparison operators + include ``eq`` (equals) and ``ne`` (not equals) and may be used with the following properties: + ``location``, ``resourceType``, ``name``, ``resourceGroup``, ``identity``, + ``identity/principalId``, ``plan``, ``plan/publisher``, ``plan/product``, ``plan/name``, + ``plan/version``, and ``plan/promotionCode``.

For example, to filter by a resource type, + use ``$filter=resourceType eq + 'Microsoft.Network/virtualNetworks'``


``substringof(value, property)`` can be used + to filter for substrings of the following currently-supported properties: ``name`` and + ``resourceGroup``

For example, to get all resources with 'demo' anywhere in the resource + name, use ``$filter=substringof('demo', name)``

Multiple substring operations can also + be combined using ``and``/``or`` operators.

Note that any truncated number of results + queried via ``$top`` may also not be compatible when using a filter.


Resources can + be filtered by tag names and values. For example, to filter for a tag name and value, use + ``$filter=tagName eq 'tag1' and tagValue eq 'Value1'``. Note that when resources are filtered + by tag name and value, the original tags for each resource will not be returned in the + results. Any list of additional properties queried via ``$expand`` may also not be + compatible when filtering by tag names/values.

For tag names only, resources can be + filtered by prefix using the following syntax: ``$filter=startswith(tagName, 'depart')``. This + query will return all resources with a tag name prefixed by the phrase ``depart`` + (i.e.``department``, ``departureDate``, ``departureTime``, etc.)


Note that some + properties can be combined when filtering resources, which include the following: + ``substringof() and/or resourceType``, ``plan and plan/publisher and plan/name``, and + ``identity and identity/principalId``. Default value is None. + :paramtype filter: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``, ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. Default value is None. + :paramtype expand: str + :keyword top: The number of recommendations per page if a paged version of this API is being + used. Default value is None. + :paramtype top: int + :return: An iterator like instance of GenericResourceExpanded + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.GenericResourceExpanded] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GenericResourceExpanded]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2751,50 +3384,92 @@ async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - cls: ClsType[_models.GenericResource] = kwargs.pop("cls", None) + _request = build_resources_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + 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) - _request = build_resources_get_by_id_request( - resource_id=resource_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + 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) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return _request - response = pipeline_response.http_response + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GenericResourceExpanded], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + async def get_next(next_link=None): + _request = prepare_request(next_link) - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return deserialized # type: ignore + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) -class ResourceGroupsOperations: +class TagsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.resource.resources.aio.ResourceManagementClient`'s - :attr:`resource_groups` attribute. + :attr:`tags` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -2803,114 +3478,15 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: - """Checks whether a resource group exists. - - :param resource_group_name: The name of the resource group to check. The name is case - insensitive. Required. - :type resource_group_name: str - :return: bool or the result of cls(response) - :rtype: bool - :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 = 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_resource_groups_check_existence_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - return 200 <= response.status_code <= 299 - - @overload - async def create_or_update( - self, - resource_group_name: str, - parameters: _models.ResourceGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResourceGroup: - """Creates or updates a resource group. - - :param resource_group_name: The name of the resource group to create or update. Can include - alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ResourceGroup: - """Creates or updates a resource group. - - :param resource_group_name: The name of the resource group to create or update. Can include - alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. 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: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: + """Gets the entire set of tags on a resource or subscription. - @distributed_trace_async - async def create_or_update( - self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO[bytes]], **kwargs: Any - ) -> _models.ResourceGroup: - """Creates or updates a resource group. + Gets the entire set of tags on a resource or subscription. - :param resource_group_name: The name of the resource group to create or update. Can include - alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. Is either a - ResourceGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroup or IO[bytes] - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :return: TagsResource. The TagsResource is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.TagsResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2919,55 +3495,57 @@ async def create_or_update( 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 {}) + error_map.update(kwargs.pop("error_map", {}) 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.ResourceGroup] = kwargs.pop("cls", None) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ResourceGroup") + cls: ClsType[_models.TagsResource] = kwargs.pop("cls", None) - _request = build_resource_groups_create_or_update_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, + _request = build_tags_get_at_scope_request( + scope=scope, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGroup", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagsResource, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_initial( - self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any + async def _create_or_update_at_scope_initial( + self, scope: str, parameters: Union[_models.TagsResource, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2977,21 +3555,31 @@ async def _delete_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_resource_groups_delete_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - force_deletion_types=force_deletion_types, - api_version=api_version, + 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_tags_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3007,258 +3595,161 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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, force_deletion_types: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a resource group. - - When you delete a resource group, all of its resources are also deleted. Deleting a resource - group deletes all of its template deployments and currently stored operations. - - :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. Required. - :type resource_group_name: str - :param force_deletion_types: The resource types you want to force delete. Currently, only the - following is supported: - forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets. - Default value is None. - :type force_deletion_types: str - :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( - resource_group_name=resource_group_name, - force_deletion_types=force_deletion_types, - api_version=api_version, - 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 - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[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 + @overload + async def begin_create_or_update_at_scope( + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TagsResource]: + """Creates or updates the entire set of tags on a resource or subscription. - @distributed_trace_async - async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: - """Gets a resource group. + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. - :param resource_group_name: The name of the resource group to get. The name is case - insensitive. Required. - :type resource_group_name: str - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Required. + :type parameters: ~azure.mgmt.resource.resources.models.TagsResource + :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 TagsResource. The TagsResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] :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 = 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.ResourceGroup] = kwargs.pop("cls", None) - - _request = build_resource_groups_get_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ResourceGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore @overload - async def update( - self, - resource_group_name: str, - parameters: _models.ResourceGroupPatchable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResourceGroup: - """Updates a resource group. + async def begin_create_or_update_at_scope( + self, scope: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TagsResource]: + """Creates or updates the entire set of tags on a resource or subscription. - Resource groups can be updated through a simple PATCH operation to a group address. The format - of the request is the same as that for creating a resource group. If a field is unspecified, - the current value is retained. + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. - :param resource_group_name: The name of the resource group to update. The name is case - insensitive. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroupPatchable + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Required. + :type parameters: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :return: An instance of AsyncLROPoller that returns TagsResource. The TagsResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ResourceGroup: - """Updates a resource group. + async def begin_create_or_update_at_scope( + self, scope: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TagsResource]: + """Creates or updates the entire set of tags on a resource or subscription. - Resource groups can be updated through a simple PATCH operation to a group address. The format - of the request is the same as that for creating a resource group. If a field is unspecified, - the current value is retained. + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. - :param resource_group_name: The name of the resource group to update. The name is case - insensitive. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. Required. + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param 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: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :return: An instance of AsyncLROPoller that returns TagsResource. The TagsResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( - self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO[bytes]], **kwargs: Any - ) -> _models.ResourceGroup: - """Updates a resource group. + async def begin_create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.TagsResource]: + """Creates or updates the entire set of tags on a resource or subscription. - Resource groups can be updated through a simple PATCH operation to a group address. The format - of the request is the same as that for creating a resource group. If a field is unspecified, - the current value is retained. + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. - :param resource_group_name: The name of the resource group to update. The name is case - insensitive. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. Is either a - ResourceGroupPatchable type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroupPatchable or IO[bytes] - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Is one of the following types: TagsResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.TagsResource or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns TagsResource. The TagsResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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.ResourceGroup] = 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, "ResourceGroupPatchable") - - _request = build_resource_groups_update_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + cls: ClsType[_models.TagsResource] = 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_at_scope_initial( + scope=scope, + 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) - deserialized = self._deserialize("ResourceGroup", pipeline_response.http_response) + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.TagsResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } - return deserialized # type: ignore + 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.TagsResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.TagsResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _export_template_initial( - self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO[bytes]], **kwargs: Any + async def _update_at_scope_initial( + self, scope: str, parameters: Union[_models.TagsPatchResource, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3269,31 +3760,30 @@ async def _export_template_initial( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" - _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ExportTemplateRequest") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resource_groups_export_template_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, + _request = build_tags_update_at_scope_request( + scope=scope, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3309,94 +3799,141 @@ async def _export_template_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_export_template( + async def begin_update_at_scope( self, - resource_group_name: str, - parameters: _models.ExportTemplateRequest, + scope: str, + parameters: _models.TagsPatchResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: - """Captures the specified resource group as a template. + ) -> AsyncLROPoller[_models.TagsResource]: + """Selectively updates the set of tags on a resource or subscription. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Parameters for exporting the template. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ExportTemplateRequest + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Required. + :type parameters: ~azure.mgmt.resource.resources.models.TagsPatchResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + :return: An instance of AsyncLROPoller that returns TagsResource. The TagsResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_export_template( - self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: - """Captures the specified resource group as a template. + async def begin_update_at_scope( + self, scope: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TagsResource]: + """Selectively updates the set of tags on a resource or subscription. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Parameters for exporting the template. Required. + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Required. + :type parameters: JSON + :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 TagsResource. The TagsResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_at_scope( + self, scope: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TagsResource]: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param 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: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + :return: An instance of AsyncLROPoller that returns TagsResource. The TagsResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_export_template( - self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: - """Captures the specified resource group as a template. + async def begin_update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.TagsResource]: + """Selectively updates the set of tags on a resource or subscription. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Parameters for exporting the template. Is either a ExportTemplateRequest - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ExportTemplateRequest or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Is one of the following types: TagsPatchResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.TagsPatchResource or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns TagsResource. The TagsResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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.ResourceGroupExportResult] = kwargs.pop("cls", None) + cls: ClsType[_models.TagsResource] = 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._export_template_initial( - resource_group_name=resource_group_name, + raw_result = await self._update_at_scope_initial( + scope=scope, parameters=parameters, - api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -3407,54 +3944,36 @@ async def begin_export_template( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.TagsResource, 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, lro_options={"final-state-via": "location"}, **kwargs) + 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.ResourceGroupExportResult].from_continuation_token( + return AsyncLROPoller[_models.TagsResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.ResourceGroupExportResult]( + return AsyncLROPoller[_models.TagsResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def list( - self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ResourceGroup"]: - """Gets all the resource groups for a subscription. - - :param filter: The filter to apply on the operation.\\ :code:`
`\\ :code:`
`You can - filter by tag names and values. For example, to filter for a tag name and value, use - $filter=tagName eq 'tag1' and tagValue eq 'Value1'. Default value is None. - :type filter: str - :param top: The number of results to return. If null is passed, returns all resource groups. - Default value is None. - :type top: int - :return: An iterator like instance of either ResourceGroup or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.ResourceGroup] - :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.ResourceGroupListResult] = kwargs.pop("cls", None) - + async def _delete_at_scope_initial(self, scope: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3463,79 +3982,104 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_tags_delete_at_scope_request( + scope=scope, + 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) - async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceGroupListResult", 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) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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.CloudError, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, 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")) - return pipeline_response + deserialized = response.iter_bytes() if _decompress else response.iter_raw() - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized # type: ignore -class TagsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @distributed_trace_async + async def begin_delete_at_scope(self, scope: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the entire set of tags on a resource or subscription. + + Deletes the entire set of tags on a resource or subscription. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: 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_at_scope_initial( + scope=scope, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.resources.aio.ResourceManagementClient`'s - :attr:`tags` attribute. - """ + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - models = _models + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } - 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: ResourceManagementClientConfiguration = 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") + 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 delete_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> None: @@ -3549,7 +4093,7 @@ async def delete_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> No :type tag_name: str :param tag_value: The value of the tag to delete. Required. :type tag_value: str - :return: None or the result of cls(response) + :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3562,20 +4106,22 @@ async def delete_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> No error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3586,7 +4132,11 @@ async def delete_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> No if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore @@ -3602,7 +4152,7 @@ async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: :type tag_name: str :param tag_value: The value of the tag to create. Required. :type tag_value: str - :return: TagValue or the result of cls(response) + :return: TagValue. The TagValue is compatible with MutableMapping :rtype: ~azure.mgmt.resource.resources.models.TagValue :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3615,22 +4165,25 @@ async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagValue] = kwargs.pop("cls", None) _request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -3638,10 +4191,22 @@ async def create_or_update_value(self, tag_name: str, tag_value: str, **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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TagValue", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagValue, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3659,7 +4224,7 @@ async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDet :param tag_name: The name of the tag to create. Required. :type tag_name: str - :return: TagDetails or the result of cls(response) + :return: TagDetails. The TagDetails is compatible with MutableMapping :rtype: ~azure.mgmt.resource.resources.models.TagDetails :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3672,21 +4237,24 @@ async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDet error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagDetails] = kwargs.pop("cls", None) _request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -3694,10 +4262,22 @@ async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDet 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TagDetails", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3714,7 +4294,7 @@ async def delete(self, tag_name: str, **kwargs: Any) -> None: :param tag_name: The name of the tag. Required. :type tag_name: str - :return: None or the result of cls(response) + :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3727,19 +4307,21 @@ async def delete(self, tag_name: str, **kwargs: Any) -> None: error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3750,7 +4332,11 @@ async def delete(self, tag_name: str, **kwargs: Any) -> None: if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore @@ -3764,16 +4350,15 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.TagDetails"]: subscription. In case of a large number of tags, this operation may return a previously cached result. - :return: An iterator like instance of either TagDetails or the result of cls(response) + :return: An iterator like instance of TagDetails :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.TagDetails] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.TagsListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.TagDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3788,11 +4373,16 @@ def prepare_request(next_link=None): _request = build_tags_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3805,18 +4395,29 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + 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 = self._deserialize("TagsListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagDetails], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -3829,15 +4430,272 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - async def _create_or_update_at_scope_initial( - self, scope: str, parameters: Union[_models.TagsResource, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: + +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.aio.ResourceManagementClient`'s + :attr:`providers` 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: ResourceManagementClientConfiguration = 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 list_at_tenant_scope( + self, *, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Provider"]: + """Gets all resource providers for the tenant. + + :keyword expand: The properties to include in the results. Default value is None. + :paramtype expand: str + :return: An iterator like instance of Provider + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Provider]] = 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_providers_list_at_tenant_scope_request( + expand=expand, + 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.Provider], + 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.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. + :type resource_provider_namespace: str + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider + :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.Provider] = kwargs.pop("cls", None) + + _request = build_providers_unregister_request( + resource_provider_namespace=resource_provider_namespace, + 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.CloudError, + 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.Provider, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def register_at_management_group_scope( + self, resource_provider_namespace: str, group_id: str, **kwargs: Any + ) -> None: + """Registers a management group with a resource provider. Use this operation to register a + resource provider with resource types that can be deployed at the management group scope. It + does not recursively register subscriptions within the management group. Instead, you must + register subscriptions individually. + + :param resource_provider_namespace: The management group ID.The namespace of the resource + provider to register. Required. + :type resource_provider_namespace: str + :param group_id: Required. + :type group_id: 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_providers_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def provider_permissions( + self, resource_provider_namespace: str, **kwargs: Any + ) -> _models.ProviderPermissionListResult: + """Get the provider permissions. + + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :return: ProviderPermissionListResult. The ProviderPermissionListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ProviderPermissionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3846,170 +4704,146 @@ async def _create_or_update_at_scope_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "TagsResource") + cls: ClsType[_models.ProviderPermissionListResult] = kwargs.pop("cls", None) - _request = build_tags_create_or_update_at_scope_request( - scope=scope, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, + _request = build_providers_provider_permissions_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProviderPermissionListResult, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload - async def begin_create_or_update_at_scope( - self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TagsResource]: - """Creates or updates the entire set of tags on a resource or subscription. - - This operation allows adding or replacing the entire set of tags on the specified resource or - subscription. The specified entity can have a maximum of 50 tags. + async def register( + self, + resource_provider_namespace: str, + properties: Optional[_models.ProviderRegistrationRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Required. - :type parameters: ~azure.mgmt.resource.resources.models.TagsResource + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Default value is None. + :type properties: ~azure.mgmt.resource.resources.models.ProviderRegistrationRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update_at_scope( - self, scope: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TagsResource]: - """Creates or updates the entire set of tags on a resource or subscription. + async def register( + self, + resource_provider_namespace: str, + properties: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. - This operation allows adding or replacing the entire set of tags on the specified resource or - subscription. The specified entity can have a maximum of 50 tags. + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Default value is None. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Required. - :type parameters: IO[bytes] + @overload + async def register( + self, + resource_provider_namespace: str, + properties: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Default value is None. + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_or_update_at_scope( - self, scope: str, parameters: Union[_models.TagsResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.TagsResource]: - """Creates or updates the entire set of tags on a resource or subscription. - - This operation allows adding or replacing the entire set of tags on the specified resource or - subscription. The specified entity can have a maximum of 50 tags. + async def register( + self, + resource_provider_namespace: str, + properties: Optional[Union[_models.ProviderRegistrationRequest, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Is either a TagsResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.TagsResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Is one of the following types: + ProviderRegistrationRequest, JSON, IO[bytes] Default value is None. + :type properties: ~azure.mgmt.resource.resources.models.ProviderRegistrationRequest or JSON or + IO[bytes] + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider :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.TagsResource] = 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_at_scope_initial( - scope=scope, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TagsResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.TagsResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.TagsResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_at_scope_initial( - self, scope: str, parameters: Union[_models.TagsPatchResource, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4019,193 +4853,178 @@ async def _update_at_scope_initial( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + content_type = content_type if properties else None + cls: ClsType[_models.Provider] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None + content_type = content_type or "application/json" if properties else None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(properties, (IOBase, bytes)): + _content = properties else: - _json = self._serialize.body(parameters, "TagsPatchResource") + if properties is not None: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None - _request = build_tags_update_at_scope_request( - scope=scope, - api_version=api_version, + _request = build_providers_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Provider, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_update_at_scope( - self, - scope: str, - parameters: _models.TagsPatchResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TagsResource]: - """Selectively updates the set of tags on a resource or subscription. - - This operation allows replacing, merging or selectively deleting tags on the specified resource - or subscription. The specified entity can have a maximum of 50 tags at the end of the - operation. The 'replace' option replaces the entire set of existing tags with a new set. The - 'merge' option allows adding tags with new names and updating the values of tags with existing - names. The 'delete' option allows selectively deleting tags based on given names or name/value - pairs. - - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Required. - :type parameters: ~azure.mgmt.resource.resources.models.TagsPatchResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_at_scope( - self, scope: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TagsResource]: - """Selectively updates the set of tags on a resource or subscription. - - This operation allows replacing, merging or selectively deleting tags on the specified resource - or subscription. The specified entity can have a maximum of 50 tags at the end of the - operation. The 'replace' option replaces the entire set of existing tags with a new set. The - 'merge' option allows adding tags with new names and updating the values of tags with existing - names. The 'delete' option allows selectively deleting tags based on given names or name/value - pairs. + @distributed_trace + def list(self, *, expand: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.Provider"]: + """Gets all resource providers for a subscription. - :param scope: The resource scope. Required. - :type scope: str - :param 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: An instance of AsyncLROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :keyword expand: The properties to include in the results. For example, use &$expand=metadata + in the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. Default value is None. + :paramtype expand: str + :return: An iterator like instance of Provider + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.models.Provider] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @distributed_trace_async - async def begin_update_at_scope( - self, scope: str, parameters: Union[_models.TagsPatchResource, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.TagsResource]: - """Selectively updates the set of tags on a resource or subscription. + cls: ClsType[List[_models.Provider]] = kwargs.pop("cls", None) - This operation allows replacing, merging or selectively deleting tags on the specified resource - or subscription. The specified entity can have a maximum of 50 tags at the end of the - operation. The 'replace' option replaces the entire set of existing tags with a new set. The - 'merge' option allows adding tags with new names and updating the values of tags with existing - names. The 'delete' option allows selectively deleting tags based on given names or name/value - pairs. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Is either a TagsPatchResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.TagsPatchResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.models.TagsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - 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.TagsResource] = 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_at_scope_initial( - scope=scope, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + _request = build_providers_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TagsResource", pipeline_response.http_response) + 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.Provider], + deserialized.get("value", []), + ) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.TagsResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + 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 ) - return AsyncLROPoller[_models.TagsResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response - @distributed_trace_async - async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: - """Gets the entire set of tags on a resource or subscription. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - Gets the entire set of tags on a resource or subscription. + return pipeline_response - :param scope: The resource scope. Required. - :type scope: str - :return: TagsResource or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.TagsResource + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :keyword expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. Default value is None. + :paramtype expand: str + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4217,20 +5036,25 @@ async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.TagsResource] = kwargs.pop("cls", None) + cls: ClsType[_models.Provider] = kwargs.pop("cls", None) - _request = build_tags_get_at_scope_request( - scope=scope, - api_version=api_version, + _request = build_providers_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -4238,17 +5062,43 @@ async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TagsResource", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Provider, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_at_scope_initial(self, scope: str, **kwargs: Any) -> AsyncIterator[bytes]: + @distributed_trace_async + async def get_at_tenant_scope( + self, resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: + """Gets the specified resource provider at the tenant level. + + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :keyword expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. Default value is None. + :paramtype expand: str + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4258,88 +5108,139 @@ async def _delete_at_scope_initial(self, scope: str, **kwargs: Any) -> AsyncIter error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.Provider] = kwargs.pop("cls", None) - _request = build_tags_delete_at_scope_request( - scope=scope, - api_version=api_version, + _request = build_providers_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Provider, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def begin_delete_at_scope(self, scope: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes the entire set of tags on a resource or subscription. - Deletes the entire set of tags on a resource or subscription. +class ProviderResourceTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param scope: The resource scope. Required. - :type scope: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.aio.ResourceManagementClient`'s + :attr:`provider_resource_types` 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: ResourceManagementClientConfiguration = 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 list( + self, resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ProviderResourceTypeListResult: + """List the resource types for a specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :keyword expand: The $expand query parameter. Default value is None. + :paramtype expand: str + :return: ProviderResourceTypeListResult. The ProviderResourceTypeListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ProviderResourceTypeListResult :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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_at_scope_initial( - scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.ProviderResourceTypeListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _request = build_provider_resource_types_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + 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) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + _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.CloudError, + response, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + 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.ProviderResourceTypeListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/_patch.py index 2be8919280c2..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/operations/_patch.py @@ -3,14 +3,13 @@ # 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/__init__.py index d6079c12b31e..fb19025b8764 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/__init__.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. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,30 +13,30 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore +from ._models import ( # type: ignore Alias, AliasPath, AliasPathMetadata, AliasPattern, ApiProfile, + CloudError, ErrorAdditionalInfo, + ErrorDetail, ErrorResponse, ExportTemplateRequest, ExtendedLocation, + ExtensionResource, GenericResource, GenericResourceExpanded, - GenericResourceFilter, Identity, IdentityUserAssignedIdentitiesValue, Operation, OperationDisplay, - OperationListResult, Permission, Plan, Provider, ProviderConsentDefinition, ProviderExtendedLocation, - ProviderListResult, ProviderPermission, ProviderPermissionListResult, ProviderRegistrationRequest, @@ -45,33 +45,32 @@ Resource, ResourceGroup, ResourceGroupExportResult, - ResourceGroupFilter, - ResourceGroupListResult, ResourceGroupPatchable, ResourceGroupProperties, - ResourceListResult, - ResourceProviderOperationDisplayProperties, ResourcesMoveInfo, RoleDefinition, Sku, - SubResource, + SystemData, TagCount, TagDetails, TagValue, Tags, - TagsListResult, TagsPatchResource, TagsResource, + TrackedResource, ZoneMapping, ) -from ._resource_management_client_enums import ( # type: ignore +from ._enums import ( # type: ignore + ActionType, AliasPathAttributes, AliasPathTokenType, AliasPatternType, AliasType, + CreatedByType, ExportTemplateOutputFormat, ExtendedLocationType, + Origin, ProviderAuthorizationConsentState, ResourceIdentityType, TagsPatchOperation, @@ -86,24 +85,24 @@ "AliasPathMetadata", "AliasPattern", "ApiProfile", + "CloudError", "ErrorAdditionalInfo", + "ErrorDetail", "ErrorResponse", "ExportTemplateRequest", "ExtendedLocation", + "ExtensionResource", "GenericResource", "GenericResourceExpanded", - "GenericResourceFilter", "Identity", "IdentityUserAssignedIdentitiesValue", "Operation", "OperationDisplay", - "OperationListResult", "Permission", "Plan", "Provider", "ProviderConsentDefinition", "ProviderExtendedLocation", - "ProviderListResult", "ProviderPermission", "ProviderPermissionListResult", "ProviderRegistrationRequest", @@ -112,30 +111,29 @@ "Resource", "ResourceGroup", "ResourceGroupExportResult", - "ResourceGroupFilter", - "ResourceGroupListResult", "ResourceGroupPatchable", "ResourceGroupProperties", - "ResourceListResult", - "ResourceProviderOperationDisplayProperties", "ResourcesMoveInfo", "RoleDefinition", "Sku", - "SubResource", + "SystemData", "TagCount", "TagDetails", "TagValue", "Tags", - "TagsListResult", "TagsPatchResource", "TagsResource", + "TrackedResource", "ZoneMapping", + "ActionType", "AliasPathAttributes", "AliasPathTokenType", "AliasPatternType", "AliasType", + "CreatedByType", "ExportTemplateOutputFormat", "ExtendedLocationType", + "Origin", "ProviderAuthorizationConsentState", "ResourceIdentityType", "TagsPatchOperation", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_enums.py similarity index 69% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_resource_management_client_enums.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_enums.py index 301bd8839a5c..67c8cca7b933 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/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. # -------------------------------------------------------------------------- @@ -10,6 +10,15 @@ from azure.core import CaseInsensitiveEnumMeta +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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 AliasPathAttributes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The attributes of the token that the alias path is referring to.""" @@ -60,35 +69,72 @@ class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Alias value is secret.""" +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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 ExportTemplateOutputFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The output format for the exported resources.""" JSON = "Json" + """Json.""" BICEP = "Bicep" + """Bicep.""" class ExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The extended location type.""" EDGE_ZONE = "EdgeZone" + """EdgeZone.""" + + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + 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 ProviderAuthorizationConsentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider authorization consent state.""" NOT_SPECIFIED = "NotSpecified" + """NotSpecified.""" REQUIRED = "Required" + """Required.""" NOT_REQUIRED = "NotRequired" + """NotRequired.""" CONSENTED = "Consented" + """Consented.""" 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 TagsPatchOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_models.py new file mode 100644 index 000000000000..b8fcd2b33623 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_models.py @@ -0,0 +1,1845 @@ +# 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 Alias(_Model): + """The alias type. + + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.models.AliasPath] + :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". + :vartype type: str or ~azure.mgmt.resource.resources.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.models.AliasPattern + :ivar default_metadata: The default alias path metadata. Applies to the default path and to any + alias path that doesn't have metadata. + :vartype default_metadata: ~azure.mgmt.resource.resources.models.AliasPathMetadata + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The alias name.""" + paths: Optional[list["_models.AliasPath"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The paths for an alias.""" + type: Optional[Union[str, "_models.AliasType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of the alias. Known values are: \"NotSpecified\", \"PlainText\", and \"Mask\".""" + default_path: Optional[str] = rest_field( + name="defaultPath", visibility=["read", "create", "update", "delete", "query"] + ) + """The default path for an alias.""" + default_pattern: Optional["_models.AliasPattern"] = rest_field( + name="defaultPattern", visibility=["read", "create", "update", "delete", "query"] + ) + """The default pattern for an alias.""" + default_metadata: Optional["_models.AliasPathMetadata"] = rest_field(name="defaultMetadata", visibility=["read"]) + """The default alias path metadata. Applies to the default path and to any alias path that doesn't + have metadata.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[list["_models.AliasPath"]] = None, + type: Optional[Union[str, "_models.AliasType"]] = None, + default_path: Optional[str] = None, + default_pattern: Optional["_models.AliasPattern"] = 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 AliasPath(_Model): + """The type of the paths for alias. + + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.models.AliasPattern + :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata + of the alias. + :vartype metadata: ~azure.mgmt.resource.resources.models.AliasPathMetadata + """ + + path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The path of an alias.""" + api_versions: Optional[list[str]] = rest_field( + name="apiVersions", visibility=["read", "create", "update", "delete", "query"] + ) + """The API versions.""" + pattern: Optional["_models.AliasPattern"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The pattern for an alias path.""" + metadata: Optional["_models.AliasPathMetadata"] = rest_field(visibility=["read"]) + """The metadata of the alias path. If missing, fall back to the default metadata of the alias.""" + + @overload + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[list[str]] = None, + pattern: Optional["_models.AliasPattern"] = 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 AliasPathMetadata(_Model): + """AliasPathMetadata. + + :ivar type: The type of the token that the alias path is referring to. Known values are: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", and "Boolean". + :vartype type: str or ~azure.mgmt.resource.resources.models.AliasPathTokenType + :ivar attributes: The attributes of the token that the alias path is referring to. Known values + are: "None" and "Modifiable". + :vartype attributes: str or ~azure.mgmt.resource.resources.models.AliasPathAttributes + """ + + type: Optional[Union[str, "_models.AliasPathTokenType"]] = rest_field(visibility=["read"]) + """The type of the token that the alias path is referring to. Known values are: \"NotSpecified\", + \"Any\", \"String\", \"Object\", \"Array\", \"Integer\", \"Number\", and \"Boolean\".""" + attributes: Optional[Union[str, "_models.AliasPathAttributes"]] = rest_field(visibility=["read"]) + """The attributes of the token that the alias path is referring to. Known values are: \"None\" and + \"Modifiable\".""" + + +class AliasPattern(_Model): + """The type of the pattern for an alias path. + + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.models.AliasPatternType + """ + + phrase: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The alias pattern phrase.""" + variable: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The alias pattern variable.""" + type: Optional[Union[str, "_models.AliasPatternType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of alias pattern. Known values are: \"NotSpecified\" and \"Extract\".""" + + @overload + def __init__( + self, + *, + phrase: Optional[str] = None, + variable: Optional[str] = None, + type: Optional[Union[str, "_models.AliasPatternType"]] = 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 ApiProfile(_Model): + """ApiProfile. + + :ivar profile_version: The profile version. + :vartype profile_version: str + :ivar api_version: The API version. + :vartype api_version: str + """ + + profile_version: Optional[str] = rest_field(name="profileVersion", visibility=["read"]) + """The profile version.""" + api_version: Optional[str] = rest_field(name="apiVersion", visibility=["read"]) + """The API version.""" + + +class CloudError(_Model): + """An error response for a resource management request. + + :ivar error: Common error response for all Azure Resource Manager APIs to return error details + for failed operations. (This also follows the OData error response format.). + :vartype error: ~azure.mgmt.resource.resources.models.ErrorResponse + """ + + error: Optional["_models.ErrorResponse"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.).""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorResponse"] = 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.resource.resources.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.resource.resources.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): + """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 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.resource.resources.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.resource.resources.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.ErrorResponse"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ExportTemplateRequest(_Model): + """Export resource group template request parameters. + + :ivar resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :vartype options: str + :ivar output_format: The output format for the exported resources. Known values are: "Json" and + "Bicep". + :vartype output_format: str or ~azure.mgmt.resource.resources.models.ExportTemplateOutputFormat + """ + + resources: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The IDs of the resources to filter the export by. To export all resources, supply an array with + single entry '*'.""" + options: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The export template options. A CSV-formatted list containing zero or more of the following: + 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', + 'SkipAllParameterization'.""" + output_format: Optional[Union[str, "_models.ExportTemplateOutputFormat"]] = rest_field( + name="outputFormat", visibility=["read", "create", "update", "delete", "query"] + ) + """The output format for the exported resources. Known values are: \"Json\" and \"Bicep\".""" + + @overload + def __init__( + self, + *, + resources: Optional[list[str]] = None, + options: Optional[str] = None, + output_format: Optional[Union[str, "_models.ExportTemplateOutputFormat"]] = 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 ExtendedLocation(_Model): + """Resource extended location. + + :ivar type: The extended location type. "EdgeZone" + :vartype type: str or ~azure.mgmt.resource.resources.models.ExtendedLocationType + :ivar name: The extended location name. + :vartype name: str + """ + + type: Optional[Union[str, "_models.ExtendedLocationType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The extended location type. \"EdgeZone\"""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The extended location name.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.ExtendedLocationType"]] = None, + 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 Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.resources.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ExtensionResource(Resource): + """The base extension resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.resources.models.SystemData + """ + + +class GenericResource(Resource): + """Resource information. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.resources.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: any + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.models.Plan + :ivar kind: The kind of the resource. + :vartype kind: str + :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.resource.resources.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.models.ExtendedLocation + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource-specific properties for this resource.""" + plan: Optional["_models.Plan"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The plan of the resource.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind of the resource.""" + 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.""" + identity: Optional["_models.Identity"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identity of the resource.""" + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource location.""" + extended_location: Optional["_models.ExtendedLocation"] = rest_field( + name="extendedLocation", visibility=["read", "create"] + ) + """Resource extended location.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + location: Optional[str] = None, + extended_location: Optional["_models.ExtendedLocation"] = 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 GenericResourceExpanded(GenericResource): + """Resource information. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.resources.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: any + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.models.Plan + :ivar kind: The kind of the resource. + :vartype kind: str + :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.resource.resources.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.models.ExtendedLocation + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar created_time: The created time of the resource. This is only present if requested via the + $expand query parameter. + :vartype created_time: ~datetime.datetime + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. + :vartype provisioning_state: str + """ + + created_time: Optional[datetime.datetime] = rest_field(name="createdTime", visibility=["read"], format="rfc3339") + """The created time of the resource. This is only present if requested via the $expand query + parameter.""" + changed_time: Optional[datetime.datetime] = rest_field(name="changedTime", visibility=["read"], format="rfc3339") + """The changed time of the resource. This is only present if requested via the $expand query + parameter.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state of the resource. This is only present if requested via the $expand query + parameter.""" + + @overload + def __init__( + self, + *, + properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + location: Optional[str] = None, + extended_location: Optional["_models.ExtendedLocation"] = 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 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.resource.resources.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.resource.resources.models.IdentityUserAssignedIdentitiesValue] + """ + + 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.IdentityUserAssignedIdentitiesValue"]] = 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 ARM 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.IdentityUserAssignedIdentitiesValue"]] = 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 IdentityUserAssignedIdentitiesValue(_Model): + """IdentityUserAssignedIdentitiesValue. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal id of user assigned identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The client id of user assigned identity.""" + + +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.resource.resources.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.resource.resources.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.resource.resources.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 Permission(_Model): + """Role definition permissions. + + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] + :ivar data_actions: Allowed Data actions. + :vartype data_actions: list[str] + :ivar not_data_actions: Denied Data actions. + :vartype not_data_actions: list[str] + """ + + actions: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Allowed actions.""" + not_actions: Optional[list[str]] = rest_field( + name="notActions", visibility=["read", "create", "update", "delete", "query"] + ) + """Denied actions.""" + data_actions: Optional[list[str]] = rest_field( + name="dataActions", visibility=["read", "create", "update", "delete", "query"] + ) + """Allowed Data actions.""" + not_data_actions: Optional[list[str]] = rest_field( + name="notDataActions", visibility=["read", "create", "update", "delete", "query"] + ) + """Denied Data actions.""" + + @overload + def __init__( + self, + *, + actions: Optional[list[str]] = None, + not_actions: Optional[list[str]] = None, + data_actions: Optional[list[str]] = None, + not_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 Plan(_Model): + """Plan for the resource. + + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :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 ID.""" + 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 offer ID.""" + 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 Provider(_Model): + """Resource provider information. + + :ivar id: The provider ID. + :vartype id: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str + :ivar registration_state: The registration state of the resource provider. + :vartype registration_state: str + :ivar registration_policy: The registration policy of the resource provider. + :vartype registration_policy: str + :ivar resource_types: The collection of provider resource types. + :vartype resource_types: list[~azure.mgmt.resource.resources.models.ProviderResourceType] + :ivar provider_authorization_consent_state: The provider authorization consent state. Known + values are: "NotSpecified", "Required", "NotRequired", and "Consented". + :vartype provider_authorization_consent_state: str or + ~azure.mgmt.resource.resources.models.ProviderAuthorizationConsentState + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The provider ID.""" + namespace: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The namespace of the resource provider.""" + registration_state: Optional[str] = rest_field(name="registrationState", visibility=["read"]) + """The registration state of the resource provider.""" + registration_policy: Optional[str] = rest_field(name="registrationPolicy", visibility=["read"]) + """The registration policy of the resource provider.""" + resource_types: Optional[list["_models.ProviderResourceType"]] = rest_field( + name="resourceTypes", visibility=["read"] + ) + """The collection of provider resource types.""" + provider_authorization_consent_state: Optional[Union[str, "_models.ProviderAuthorizationConsentState"]] = ( + rest_field(name="providerAuthorizationConsentState", visibility=["read", "create", "update", "delete", "query"]) + ) + """The provider authorization consent state. Known values are: \"NotSpecified\", \"Required\", + \"NotRequired\", and \"Consented\".""" + + @overload + def __init__( + self, + *, + namespace: Optional[str] = None, + provider_authorization_consent_state: Optional[Union[str, "_models.ProviderAuthorizationConsentState"]] = 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 ProviderConsentDefinition(_Model): + """The provider consent. + + :ivar consent_to_authorization: A value indicating whether authorization is consented or not. + :vartype consent_to_authorization: bool + """ + + consent_to_authorization: Optional[bool] = rest_field( + name="consentToAuthorization", visibility=["read", "create", "update", "delete", "query"] + ) + """A value indicating whether authorization is consented or not.""" + + @overload + def __init__( + self, + *, + consent_to_authorization: Optional[bool] = 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 ProviderExtendedLocation(_Model): + """The provider extended location. + + :ivar location: The azure location. + :vartype location: str + :ivar type: The extended location type. + :vartype type: str + :ivar extended_locations: The extended locations for the azure location. + :vartype extended_locations: list[str] + """ + + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The azure location.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The extended location type.""" + extended_locations: Optional[list[str]] = rest_field( + name="extendedLocations", visibility=["read", "create", "update", "delete", "query"] + ) + """The extended locations for the azure location.""" + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + type: Optional[str] = None, + extended_locations: 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 ProviderPermission(_Model): + """The provider permission. + + :ivar application_id: The application id. + :vartype application_id: str + :ivar role_definition: Role definition properties. + :vartype role_definition: ~azure.mgmt.resource.resources.models.RoleDefinition + :ivar managed_by_role_definition: Role definition properties. + :vartype managed_by_role_definition: ~azure.mgmt.resource.resources.models.RoleDefinition + :ivar provider_authorization_consent_state: The provider authorization consent state. Known + values are: "NotSpecified", "Required", "NotRequired", and "Consented". + :vartype provider_authorization_consent_state: str or + ~azure.mgmt.resource.resources.models.ProviderAuthorizationConsentState + """ + + application_id: Optional[str] = rest_field( + name="applicationId", visibility=["read", "create", "update", "delete", "query"] + ) + """The application id.""" + role_definition: Optional["_models.RoleDefinition"] = rest_field( + name="roleDefinition", visibility=["read", "create", "update", "delete", "query"] + ) + """Role definition properties.""" + managed_by_role_definition: Optional["_models.RoleDefinition"] = rest_field( + name="managedByRoleDefinition", visibility=["read", "create", "update", "delete", "query"] + ) + """Role definition properties.""" + provider_authorization_consent_state: Optional[Union[str, "_models.ProviderAuthorizationConsentState"]] = ( + rest_field(name="providerAuthorizationConsentState", visibility=["read", "create", "update", "delete", "query"]) + ) + """The provider authorization consent state. Known values are: \"NotSpecified\", \"Required\", + \"NotRequired\", and \"Consented\".""" + + @overload + def __init__( + self, + *, + application_id: Optional[str] = None, + role_definition: Optional["_models.RoleDefinition"] = None, + managed_by_role_definition: Optional["_models.RoleDefinition"] = None, + provider_authorization_consent_state: Optional[Union[str, "_models.ProviderAuthorizationConsentState"]] = 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 ProviderPermissionListResult(_Model): + """List of provider permissions. + + :ivar value: The ProviderPermission items on this page. Required. + :vartype value: list[~azure.mgmt.resource.resources.models.ProviderPermission] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: list["_models.ProviderPermission"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ProviderPermission 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.ProviderPermission"], + 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 ProviderRegistrationRequest(_Model): + """The provider registration definition. + + :ivar third_party_provider_consent: The provider consent. + :vartype third_party_provider_consent: + ~azure.mgmt.resource.resources.models.ProviderConsentDefinition + """ + + third_party_provider_consent: Optional["_models.ProviderConsentDefinition"] = rest_field( + name="thirdPartyProviderConsent", visibility=["read", "create", "update", "delete", "query"] + ) + """The provider consent.""" + + @overload + def __init__( + self, + *, + third_party_provider_consent: Optional["_models.ProviderConsentDefinition"] = 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 ProviderResourceType(_Model): + """Resource type managed by the resource provider. + + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar location_mappings: The location mappings that are supported by this resource type. + :vartype location_mappings: + list[~azure.mgmt.resource.resources.models.ProviderExtendedLocation] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar default_api_version: The default API version. + :vartype default_api_version: str + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.models.ZoneMapping] + :ivar api_profiles: The API profiles for the resource provider. + :vartype api_profiles: list[~azure.mgmt.resource.resources.models.ApiProfile] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] + """ + + resource_type: Optional[str] = rest_field( + name="resourceType", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource type.""" + locations: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The collection of locations where this resource type can be created.""" + location_mappings: Optional[list["_models.ProviderExtendedLocation"]] = rest_field( + name="locationMappings", visibility=["read", "create", "update", "delete", "query"] + ) + """The location mappings that are supported by this resource type.""" + aliases: Optional[list["_models.Alias"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The aliases that are supported by this resource type.""" + api_versions: Optional[list[str]] = rest_field( + name="apiVersions", visibility=["read", "create", "update", "delete", "query"] + ) + """The API version.""" + default_api_version: Optional[str] = rest_field(name="defaultApiVersion", visibility=["read"]) + """The default API version.""" + zone_mappings: Optional[list["_models.ZoneMapping"]] = rest_field( + name="zoneMappings", visibility=["read", "create", "update", "delete", "query"] + ) + api_profiles: Optional[list["_models.ApiProfile"]] = rest_field(name="apiProfiles", visibility=["read"]) + """The API profiles for the resource provider.""" + capabilities: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The additional capabilities offered by this resource type.""" + properties: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties.""" + + @overload + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[list[str]] = None, + location_mappings: Optional[list["_models.ProviderExtendedLocation"]] = None, + aliases: Optional[list["_models.Alias"]] = None, + api_versions: Optional[list[str]] = None, + zone_mappings: Optional[list["_models.ZoneMapping"]] = None, + capabilities: Optional[str] = None, + properties: 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 ProviderResourceTypeListResult(_Model): + """List of resource types of a resource provider. + + :ivar value: The ProviderResourceType items on this page. Required. + :vartype value: list[~azure.mgmt.resource.resources.models.ProviderResourceType] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: list["_models.ProviderResourceType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ProviderResourceType 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.ProviderResourceType"], + 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 TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.resources.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + + @overload + def __init__( + self, + *, + location: str, + 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 ResourceGroup(TrackedResource): + """Resource group information. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.resources.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + """ + + properties: Optional["_models.ResourceGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource group properties.""" + managed_by: Optional[str] = rest_field(name="managedBy", visibility=["read", "create", "update", "delete", "query"]) + """The ID of the resource that manages this resource group.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, + managed_by: 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 ResourceGroupExportResult(_Model): + """Resource group export result. + + :ivar template: The template content. Used if outputFormat is empty or set to 'Json'. + :vartype template: any + :ivar output: The formatted export content. Used if outputFormat is set to 'Bicep'. + :vartype output: str + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.models.ErrorDetail + """ + + template: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The template content. Used if outputFormat is empty or set to 'Json'.""" + output: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The formatted export content. Used if outputFormat is set to 'Bicep'.""" + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The template export error.""" + + @overload + def __init__( + self, + *, + template: Optional[Any] = None, + output: Optional[str] = None, + 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 ResourceGroupPatchable(_Model): + """Resource group information. + + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: The tags attached to the resource group. + :vartype tags: dict[str, str] + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the resource group.""" + properties: Optional["_models.ResourceGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource group properties.""" + managed_by: Optional[str] = rest_field(name="managedBy", visibility=["read", "create", "update", "delete", "query"]) + """The ID of the resource that manages this resource group.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tags attached to the resource group.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, + managed_by: 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 ResourceGroupProperties(_Model): + """The resource group properties. + + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state.""" + + +class ResourcesMoveInfo(_Model): + """Parameters of move resources. + + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str + """ + + resources: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The IDs of the resources.""" + target_resource_group: Optional[str] = rest_field( + name="targetResourceGroup", visibility=["read", "create", "update", "delete", "query"] + ) + """The target resource group.""" + + @overload + def __init__( + self, + *, + resources: Optional[list[str]] = None, + target_resource_group: 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 RoleDefinition(_Model): + """Role definition properties. + + :ivar id: The role definition ID. + :vartype id: str + :ivar name: The role definition name. + :vartype name: str + :ivar is_service_role: If this is a service role. + :vartype is_service_role: bool + :ivar permissions: Role definition permissions. + :vartype permissions: list[~azure.mgmt.resource.resources.models.Permission] + :ivar scopes: Role definition assignable scopes. + :vartype scopes: list[str] + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The role definition ID.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The role definition name.""" + is_service_role: Optional[bool] = rest_field( + name="isServiceRole", visibility=["read", "create", "update", "delete", "query"] + ) + """If this is a service role.""" + permissions: Optional[list["_models.Permission"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Role definition permissions.""" + scopes: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Role definition assignable scopes.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + is_service_role: Optional[bool] = None, + permissions: Optional[list["_models.Permission"]] = None, + scopes: 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 Sku(_Model): + """SKU for the resource. + + :ivar name: The SKU name. + :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: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU name.""" + 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: Optional[str] = None, + 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.resource.resources.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.resource.resources.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 TagCount(_Model): + """Tag count. + + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int + """ + + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Type of count.""" + value: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of count.""" + + @overload + def __init__( + self, + *, + type: Optional[str] = None, + value: 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 TagDetails(_Model): + """Tag details. + + :ivar id: The tag name ID. + :vartype id: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially + created and has no associated resources, the value is 0. + :vartype count: ~azure.mgmt.resource.resources.models.TagCount + :ivar values_property: The list of tag values. + :vartype values_property: list[~azure.mgmt.resource.resources.models.TagValue] + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The tag name ID.""" + tag_name: Optional[str] = rest_field(name="tagName", visibility=["read", "create", "update", "delete", "query"]) + """The tag name.""" + count: Optional["_models.TagCount"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The total number of resources that use the resource tag. When a tag is initially created and + has no associated resources, the value is 0.""" + values_property: Optional[list["_models.TagValue"]] = rest_field( + name="values", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="values" + ) + """The list of tag values.""" + + @overload + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["_models.TagCount"] = None, + values_property: Optional[list["_models.TagValue"]] = 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 Tags(_Model): + """A dictionary of name and value pairs. + + :ivar tags: Dictionary of . + :vartype tags: dict[str, str] + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Dictionary of .""" + + @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 TagsPatchResource(_Model): + """Wrapper resource for tags patch API request only. + + :ivar operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". + :vartype operation: str or ~azure.mgmt.resource.resources.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.models.Tags + """ + + operation: Optional[Union[str, "_models.TagsPatchOperation"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The operation type for the patch API. Known values are: \"Replace\", \"Merge\", and \"Delete\".""" + properties: Optional["_models.Tags"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The set of tags.""" + + @overload + def __init__( + self, + *, + operation: Optional[Union[str, "_models.TagsPatchOperation"]] = None, + properties: Optional["_models.Tags"] = 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 TagsResource(ExtensionResource): + """Wrapper resource for tags API requests and responses. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.resources.models.SystemData + :ivar properties: The set of tags. Required. + :vartype properties: ~azure.mgmt.resource.resources.models.Tags + """ + + properties: "_models.Tags" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The set of tags. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.Tags", + ) -> 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 TagValue(_Model): + """Tag information. + + :ivar id: The tag value ID. + :vartype id: str + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.models.TagCount + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The tag value ID.""" + tag_value: Optional[str] = rest_field(name="tagValue", visibility=["read", "create", "update", "delete", "query"]) + """The tag value.""" + count: Optional["_models.TagCount"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tag value count.""" + + @overload + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["_models.TagCount"] = 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 ZoneMapping(_Model): + """ZoneMapping. + + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] + """ + + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The location of the zone mapping.""" + zones: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + zones: 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_models_py3.py deleted file mode 100644 index da8c8b8dca74..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_models_py3.py +++ /dev/null @@ -1,2103 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class Alias(_serialization.Model): - """The alias type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The alias name. - :vartype name: str - :ivar paths: The paths for an alias. - :vartype paths: list[~azure.mgmt.resource.resources.models.AliasPath] - :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". - :vartype type: str or ~azure.mgmt.resource.resources.models.AliasType - :ivar default_path: The default path for an alias. - :vartype default_path: str - :ivar default_pattern: The default pattern for an alias. - :vartype default_pattern: ~azure.mgmt.resource.resources.models.AliasPattern - :ivar default_metadata: The default alias path metadata. Applies to the default path and to any - alias path that doesn't have metadata. - :vartype default_metadata: ~azure.mgmt.resource.resources.models.AliasPathMetadata - """ - - _validation = { - "default_metadata": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "paths": {"key": "paths", "type": "[AliasPath]"}, - "type": {"key": "type", "type": "str"}, - "default_path": {"key": "defaultPath", "type": "str"}, - "default_pattern": {"key": "defaultPattern", "type": "AliasPattern"}, - "default_metadata": {"key": "defaultMetadata", "type": "AliasPathMetadata"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[list["_models.AliasPath"]] = None, - type: Optional[Union[str, "_models.AliasType"]] = None, - default_path: Optional[str] = None, - default_pattern: Optional["_models.AliasPattern"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The alias name. - :paramtype name: str - :keyword paths: The paths for an alias. - :paramtype paths: list[~azure.mgmt.resource.resources.models.AliasPath] - :keyword type: The type of the alias. Known values are: "NotSpecified", "PlainText", and - "Mask". - :paramtype type: str or ~azure.mgmt.resource.resources.models.AliasType - :keyword default_path: The default path for an alias. - :paramtype default_path: str - :keyword default_pattern: The default pattern for an alias. - :paramtype default_pattern: ~azure.mgmt.resource.resources.models.AliasPattern - """ - super().__init__(**kwargs) - self.name = name - self.paths = paths - self.type = type - self.default_path = default_path - self.default_pattern = default_pattern - self.default_metadata: Optional["_models.AliasPathMetadata"] = None - - -class AliasPath(_serialization.Model): - """The type of the paths for alias. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar path: The path of an alias. - :vartype path: str - :ivar api_versions: The API versions. - :vartype api_versions: list[str] - :ivar pattern: The pattern for an alias path. - :vartype pattern: ~azure.mgmt.resource.resources.models.AliasPattern - :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata - of the alias. - :vartype metadata: ~azure.mgmt.resource.resources.models.AliasPathMetadata - """ - - _validation = { - "metadata": {"readonly": True}, - } - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "api_versions": {"key": "apiVersions", "type": "[str]"}, - "pattern": {"key": "pattern", "type": "AliasPattern"}, - "metadata": {"key": "metadata", "type": "AliasPathMetadata"}, - } - - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[list[str]] = None, - pattern: Optional["_models.AliasPattern"] = None, - **kwargs: Any - ) -> None: - """ - :keyword path: The path of an alias. - :paramtype path: str - :keyword api_versions: The API versions. - :paramtype api_versions: list[str] - :keyword pattern: The pattern for an alias path. - :paramtype pattern: ~azure.mgmt.resource.resources.models.AliasPattern - """ - super().__init__(**kwargs) - self.path = path - self.api_versions = api_versions - self.pattern = pattern - self.metadata: Optional["_models.AliasPathMetadata"] = None - - -class AliasPathMetadata(_serialization.Model): - """AliasPathMetadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the token that the alias path is referring to. Known values are: - "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", and "Boolean". - :vartype type: str or ~azure.mgmt.resource.resources.models.AliasPathTokenType - :ivar attributes: The attributes of the token that the alias path is referring to. Known values - are: "None" and "Modifiable". - :vartype attributes: str or ~azure.mgmt.resource.resources.models.AliasPathAttributes - """ - - _validation = { - "type": {"readonly": True}, - "attributes": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "attributes": {"key": "attributes", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[Union[str, "_models.AliasPathTokenType"]] = None - self.attributes: Optional[Union[str, "_models.AliasPathAttributes"]] = None - - -class AliasPattern(_serialization.Model): - """The type of the pattern for an alias path. - - :ivar phrase: The alias pattern phrase. - :vartype phrase: str - :ivar variable: The alias pattern variable. - :vartype variable: str - :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". - :vartype type: str or ~azure.mgmt.resource.resources.models.AliasPatternType - """ - - _attribute_map = { - "phrase": {"key": "phrase", "type": "str"}, - "variable": {"key": "variable", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - phrase: Optional[str] = None, - variable: Optional[str] = None, - type: Optional[Union[str, "_models.AliasPatternType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword phrase: The alias pattern phrase. - :paramtype phrase: str - :keyword variable: The alias pattern variable. - :paramtype variable: str - :keyword type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". - :paramtype type: str or ~azure.mgmt.resource.resources.models.AliasPatternType - """ - super().__init__(**kwargs) - self.phrase = phrase - self.variable = variable - self.type = type - - -class ApiProfile(_serialization.Model): - """ApiProfile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar profile_version: The profile version. - :vartype profile_version: str - :ivar api_version: The API version. - :vartype api_version: str - """ - - _validation = { - "profile_version": {"readonly": True}, - "api_version": {"readonly": True}, - } - - _attribute_map = { - "profile_version": {"key": "profileVersion", "type": "str"}, - "api_version": {"key": "apiVersion", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.profile_version: Optional[str] = None - self.api_version: Optional[str] = None - - -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: Optional[str] = None - self.info: Optional[JSON] = 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.). - - 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.resource.resources.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.resource.resources.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": "[ErrorResponse]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - self.target: Optional[str] = None - self.details: Optional[list["_models.ErrorResponse"]] = None - self.additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = None - - -class ExportTemplateRequest(_serialization.Model): - """Export resource group template request parameters. - - :ivar resources: The IDs of the resources to filter the export by. To export all resources, - supply an array with single entry '*'. - :vartype resources: list[str] - :ivar options: The export template options. A CSV-formatted list containing zero or more of the - following: 'IncludeParameterDefaultValue', 'IncludeComments', - 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :vartype options: str - :ivar output_format: The output format for the exported resources. Known values are: "Json" and - "Bicep". - :vartype output_format: str or ~azure.mgmt.resource.resources.models.ExportTemplateOutputFormat - """ - - _attribute_map = { - "resources": {"key": "resources", "type": "[str]"}, - "options": {"key": "options", "type": "str"}, - "output_format": {"key": "outputFormat", "type": "str"}, - } - - def __init__( - self, - *, - resources: Optional[list[str]] = None, - options: Optional[str] = None, - output_format: Optional[Union[str, "_models.ExportTemplateOutputFormat"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword resources: The IDs of the resources to filter the export by. To export all resources, - supply an array with single entry '*'. - :paramtype resources: list[str] - :keyword options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', - 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :paramtype options: str - :keyword output_format: The output format for the exported resources. Known values are: "Json" - and "Bicep". - :paramtype output_format: str or - ~azure.mgmt.resource.resources.models.ExportTemplateOutputFormat - """ - super().__init__(**kwargs) - self.resources = resources - self.options = options - self.output_format = output_format - - -class ExtendedLocation(_serialization.Model): - """Resource extended location. - - :ivar type: The extended location type. "EdgeZone" - :vartype type: str or ~azure.mgmt.resource.resources.models.ExtendedLocationType - :ivar name: The extended location name. - :vartype name: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ExtendedLocationType"]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The extended location type. "EdgeZone" - :paramtype type: str or ~azure.mgmt.resource.resources.models.ExtendedLocationType - :keyword name: The extended location name. - :paramtype name: str - """ - super().__init__(**kwargs) - self.type = type - self.name = name - - -class Resource(_serialization.Model): - """Specified resource. - - 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 extended_location: Resource extended location. - :vartype extended_location: ~azure.mgmt.resource.resources.models.ExtendedLocation - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - tags: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword extended_location: Resource extended location. - :paramtype extended_location: ~azure.mgmt.resource.resources.models.ExtendedLocation - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.extended_location = extended_location - self.tags = tags - - -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 extended_location: Resource extended location. - :vartype extended_location: ~azure.mgmt.resource.resources.models.ExtendedLocation - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar plan: The plan of the resource. - :vartype plan: ~azure.mgmt.resource.resources.models.Plan - :ivar properties: The resource properties. - :vartype properties: JSON - :ivar kind: The kind of the resource. - :vartype kind: str - :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.resource.resources.models.Sku - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.resource.resources.models.Identity - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "plan", "type": "Plan"}, - "properties": {"key": "properties", "type": "object"}, - "kind": {"key": "kind", "type": "str"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "identity": {"key": "identity", "type": "Identity"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - tags: Optional[dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - properties: Optional[JSON] = None, - kind: Optional[str] = None, - managed_by: Optional[str] = None, - sku: Optional["_models.Sku"] = None, - identity: Optional["_models.Identity"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword extended_location: Resource extended location. - :paramtype extended_location: ~azure.mgmt.resource.resources.models.ExtendedLocation - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword plan: The plan of the resource. - :paramtype plan: ~azure.mgmt.resource.resources.models.Plan - :keyword properties: The resource properties. - :paramtype properties: JSON - :keyword kind: The kind of the resource. - :paramtype kind: 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.resource.resources.models.Sku - :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.resource.resources.models.Identity - """ - super().__init__(location=location, extended_location=extended_location, tags=tags, **kwargs) - self.plan = plan - self.properties = properties - self.kind = kind - self.managed_by = managed_by - self.sku = sku - self.identity = identity - - -class GenericResourceExpanded(GenericResource): - """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 extended_location: Resource extended location. - :vartype extended_location: ~azure.mgmt.resource.resources.models.ExtendedLocation - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar plan: The plan of the resource. - :vartype plan: ~azure.mgmt.resource.resources.models.Plan - :ivar properties: The resource properties. - :vartype properties: JSON - :ivar kind: The kind of the resource. - :vartype kind: str - :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.resource.resources.models.Sku - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.resource.resources.models.Identity - :ivar created_time: The created time of the resource. This is only present if requested via the - $expand query parameter. - :vartype created_time: ~datetime.datetime - :ivar changed_time: The changed time of the resource. This is only present if requested via the - $expand query parameter. - :vartype changed_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state of the resource. This is only present if - requested via the $expand query parameter. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, - "created_time": {"readonly": True}, - "changed_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "plan", "type": "Plan"}, - "properties": {"key": "properties", "type": "object"}, - "kind": {"key": "kind", "type": "str"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "identity": {"key": "identity", "type": "Identity"}, - "created_time": {"key": "createdTime", "type": "iso-8601"}, - "changed_time": {"key": "changedTime", "type": "iso-8601"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - tags: Optional[dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - properties: Optional[JSON] = None, - kind: Optional[str] = None, - managed_by: Optional[str] = None, - sku: Optional["_models.Sku"] = None, - identity: Optional["_models.Identity"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. - :paramtype location: str - :keyword extended_location: Resource extended location. - :paramtype extended_location: ~azure.mgmt.resource.resources.models.ExtendedLocation - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword plan: The plan of the resource. - :paramtype plan: ~azure.mgmt.resource.resources.models.Plan - :keyword properties: The resource properties. - :paramtype properties: JSON - :keyword kind: The kind of the resource. - :paramtype kind: 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.resource.resources.models.Sku - :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.resource.resources.models.Identity - """ - super().__init__( - location=location, - extended_location=extended_location, - tags=tags, - plan=plan, - properties=properties, - kind=kind, - managed_by=managed_by, - sku=sku, - identity=identity, - **kwargs - ) - self.created_time: Optional[datetime.datetime] = None - self.changed_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - - -class GenericResourceFilter(_serialization.Model): - """Resource filter. - - :ivar resource_type: The resource type. - :vartype resource_type: str - :ivar tagname: The tag name. - :vartype tagname: str - :ivar tagvalue: The tag value. - :vartype tagvalue: str - """ - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "tagname": {"key": "tagname", "type": "str"}, - "tagvalue": {"key": "tagvalue", "type": "str"}, - } - - def __init__( - self, - *, - resource_type: Optional[str] = None, - tagname: Optional[str] = None, - tagvalue: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_type: The resource type. - :paramtype resource_type: str - :keyword tagname: The tag name. - :paramtype tagname: str - :keyword tagvalue: The tag value. - :paramtype tagvalue: str - """ - super().__init__(**kwargs) - self.resource_type = resource_type - self.tagname = tagname - self.tagvalue = tagvalue - - -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.resource.resources.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the resource. The - user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.resource.resources.models.IdentityUserAssignedIdentitiesValue] - """ - - _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": "{IdentityUserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[dict[str, "_models.IdentityUserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.resource.resources.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the resource. - The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.resource.resources.models.IdentityUserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class IdentityUserAssignedIdentitiesValue(_serialization.Model): - """IdentityUserAssignedIdentitiesValue. - - 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 client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.client_id: Optional[str] = None - - -class Operation(_serialization.Model): - """Microsoft.Resources operation. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar display: The object that represents the operation. - :vartype display: ~azure.mgmt.resource.resources.models.OperationDisplay - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - } - - def __init__( - self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Operation name: {provider}/{resource}/{operation}. - :paramtype name: str - :keyword display: The object that represents the operation. - :paramtype display: ~azure.mgmt.resource.resources.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = name - self.display = display - - -class OperationDisplay(_serialization.Model): - """The object that represents the operation. - - :ivar provider: Service provider: Microsoft.Resources. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - :ivar description: Description of the operation. - :vartype description: str - """ - - _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, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provider: Service provider: Microsoft.Resources. - :paramtype provider: str - :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. - :paramtype resource: str - :keyword operation: Operation type: Read, write, delete, etc. - :paramtype operation: str - :keyword description: Description of the operation. - :paramtype description: str - """ - super().__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class OperationListResult(_serialization.Model): - """Result of the request to list Microsoft.Resources operations. It contains a list of operations - and a URL link to get the next set of results. - - :ivar value: List of Microsoft.Resources operations. - :vartype value: list[~azure.mgmt.resource.resources.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of Microsoft.Resources operations. - :paramtype value: list[~azure.mgmt.resource.resources.models.Operation] - :keyword next_link: URL to get the next set of operation list results if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Permission(_serialization.Model): - """Role definition permissions. - - :ivar actions: Allowed actions. - :vartype actions: list[str] - :ivar not_actions: Denied actions. - :vartype not_actions: list[str] - :ivar data_actions: Allowed Data actions. - :vartype data_actions: list[str] - :ivar not_data_actions: Denied Data actions. - :vartype not_data_actions: list[str] - """ - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - } - - def __init__( - self, - *, - actions: Optional[list[str]] = None, - not_actions: Optional[list[str]] = None, - data_actions: Optional[list[str]] = None, - not_data_actions: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword actions: Allowed actions. - :paramtype actions: list[str] - :keyword not_actions: Denied actions. - :paramtype not_actions: list[str] - :keyword data_actions: Allowed Data actions. - :paramtype data_actions: list[str] - :keyword not_data_actions: Denied Data actions. - :paramtype not_data_actions: list[str] - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - self.data_actions = data_actions - self.not_data_actions = not_data_actions - - -class Plan(_serialization.Model): - """Plan for the resource. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :vartype publisher: str - :ivar product: The offer ID. - :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 ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :paramtype publisher: str - :keyword product: The offer ID. - :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 Provider(_serialization.Model): - """Resource provider information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The provider ID. - :vartype id: str - :ivar namespace: The namespace of the resource provider. - :vartype namespace: str - :ivar registration_state: The registration state of the resource provider. - :vartype registration_state: str - :ivar registration_policy: The registration policy of the resource provider. - :vartype registration_policy: str - :ivar resource_types: The collection of provider resource types. - :vartype resource_types: list[~azure.mgmt.resource.resources.models.ProviderResourceType] - :ivar provider_authorization_consent_state: The provider authorization consent state. Known - values are: "NotSpecified", "Required", "NotRequired", and "Consented". - :vartype provider_authorization_consent_state: str or - ~azure.mgmt.resource.resources.models.ProviderAuthorizationConsentState - """ - - _validation = { - "id": {"readonly": True}, - "registration_state": {"readonly": True}, - "registration_policy": {"readonly": True}, - "resource_types": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "namespace": {"key": "namespace", "type": "str"}, - "registration_state": {"key": "registrationState", "type": "str"}, - "registration_policy": {"key": "registrationPolicy", "type": "str"}, - "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, - "provider_authorization_consent_state": {"key": "providerAuthorizationConsentState", "type": "str"}, - } - - def __init__( - self, - *, - namespace: Optional[str] = None, - provider_authorization_consent_state: Optional[Union[str, "_models.ProviderAuthorizationConsentState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword namespace: The namespace of the resource provider. - :paramtype namespace: str - :keyword provider_authorization_consent_state: The provider authorization consent state. Known - values are: "NotSpecified", "Required", "NotRequired", and "Consented". - :paramtype provider_authorization_consent_state: str or - ~azure.mgmt.resource.resources.models.ProviderAuthorizationConsentState - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.namespace = namespace - self.registration_state: Optional[str] = None - self.registration_policy: Optional[str] = None - self.resource_types: Optional[list["_models.ProviderResourceType"]] = None - self.provider_authorization_consent_state = provider_authorization_consent_state - - -class ProviderConsentDefinition(_serialization.Model): - """The provider consent. - - :ivar consent_to_authorization: A value indicating whether authorization is consented or not. - :vartype consent_to_authorization: bool - """ - - _attribute_map = { - "consent_to_authorization": {"key": "consentToAuthorization", "type": "bool"}, - } - - def __init__(self, *, consent_to_authorization: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword consent_to_authorization: A value indicating whether authorization is consented or - not. - :paramtype consent_to_authorization: bool - """ - super().__init__(**kwargs) - self.consent_to_authorization = consent_to_authorization - - -class ProviderExtendedLocation(_serialization.Model): - """The provider extended location. - - :ivar location: The azure location. - :vartype location: str - :ivar type: The extended location type. - :vartype type: str - :ivar extended_locations: The extended locations for the azure location. - :vartype extended_locations: list[str] - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "extended_locations": {"key": "extendedLocations", "type": "[str]"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - type: Optional[str] = None, - extended_locations: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The azure location. - :paramtype location: str - :keyword type: The extended location type. - :paramtype type: str - :keyword extended_locations: The extended locations for the azure location. - :paramtype extended_locations: list[str] - """ - super().__init__(**kwargs) - self.location = location - self.type = type - self.extended_locations = extended_locations - - -class ProviderListResult(_serialization.Model): - """List of resource providers. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of resource providers. - :vartype value: list[~azure.mgmt.resource.resources.models.Provider] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Provider]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.Provider"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of resource providers. - :paramtype value: list[~azure.mgmt.resource.resources.models.Provider] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None - - -class ProviderPermission(_serialization.Model): - """The provider permission. - - :ivar application_id: The application id. - :vartype application_id: str - :ivar role_definition: Role definition properties. - :vartype role_definition: ~azure.mgmt.resource.resources.models.RoleDefinition - :ivar managed_by_role_definition: Role definition properties. - :vartype managed_by_role_definition: ~azure.mgmt.resource.resources.models.RoleDefinition - :ivar provider_authorization_consent_state: The provider authorization consent state. Known - values are: "NotSpecified", "Required", "NotRequired", and "Consented". - :vartype provider_authorization_consent_state: str or - ~azure.mgmt.resource.resources.models.ProviderAuthorizationConsentState - """ - - _attribute_map = { - "application_id": {"key": "applicationId", "type": "str"}, - "role_definition": {"key": "roleDefinition", "type": "RoleDefinition"}, - "managed_by_role_definition": {"key": "managedByRoleDefinition", "type": "RoleDefinition"}, - "provider_authorization_consent_state": {"key": "providerAuthorizationConsentState", "type": "str"}, - } - - def __init__( - self, - *, - application_id: Optional[str] = None, - role_definition: Optional["_models.RoleDefinition"] = None, - managed_by_role_definition: Optional["_models.RoleDefinition"] = None, - provider_authorization_consent_state: Optional[Union[str, "_models.ProviderAuthorizationConsentState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword application_id: The application id. - :paramtype application_id: str - :keyword role_definition: Role definition properties. - :paramtype role_definition: ~azure.mgmt.resource.resources.models.RoleDefinition - :keyword managed_by_role_definition: Role definition properties. - :paramtype managed_by_role_definition: ~azure.mgmt.resource.resources.models.RoleDefinition - :keyword provider_authorization_consent_state: The provider authorization consent state. Known - values are: "NotSpecified", "Required", "NotRequired", and "Consented". - :paramtype provider_authorization_consent_state: str or - ~azure.mgmt.resource.resources.models.ProviderAuthorizationConsentState - """ - super().__init__(**kwargs) - self.application_id = application_id - self.role_definition = role_definition - self.managed_by_role_definition = managed_by_role_definition - self.provider_authorization_consent_state = provider_authorization_consent_state - - -class ProviderPermissionListResult(_serialization.Model): - """List of provider permissions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of provider permissions. - :vartype value: list[~azure.mgmt.resource.resources.models.ProviderPermission] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ProviderPermission]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.ProviderPermission"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of provider permissions. - :paramtype value: list[~azure.mgmt.resource.resources.models.ProviderPermission] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None - - -class ProviderRegistrationRequest(_serialization.Model): - """The provider registration definition. - - :ivar third_party_provider_consent: The provider consent. - :vartype third_party_provider_consent: - ~azure.mgmt.resource.resources.models.ProviderConsentDefinition - """ - - _attribute_map = { - "third_party_provider_consent": {"key": "thirdPartyProviderConsent", "type": "ProviderConsentDefinition"}, - } - - def __init__( - self, *, third_party_provider_consent: Optional["_models.ProviderConsentDefinition"] = None, **kwargs: Any - ) -> None: - """ - :keyword third_party_provider_consent: The provider consent. - :paramtype third_party_provider_consent: - ~azure.mgmt.resource.resources.models.ProviderConsentDefinition - """ - super().__init__(**kwargs) - self.third_party_provider_consent = third_party_provider_consent - - -class ProviderResourceType(_serialization.Model): - """Resource type managed by the resource provider. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The resource type. - :vartype resource_type: str - :ivar locations: The collection of locations where this resource type can be created. - :vartype locations: list[str] - :ivar location_mappings: The location mappings that are supported by this resource type. - :vartype location_mappings: - list[~azure.mgmt.resource.resources.models.ProviderExtendedLocation] - :ivar aliases: The aliases that are supported by this resource type. - :vartype aliases: list[~azure.mgmt.resource.resources.models.Alias] - :ivar api_versions: The API version. - :vartype api_versions: list[str] - :ivar default_api_version: The default API version. - :vartype default_api_version: str - :ivar zone_mappings: - :vartype zone_mappings: list[~azure.mgmt.resource.resources.models.ZoneMapping] - :ivar api_profiles: The API profiles for the resource provider. - :vartype api_profiles: list[~azure.mgmt.resource.resources.models.ApiProfile] - :ivar capabilities: The additional capabilities offered by this resource type. - :vartype capabilities: str - :ivar properties: The properties. - :vartype properties: dict[str, str] - """ - - _validation = { - "default_api_version": {"readonly": True}, - "api_profiles": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "locations": {"key": "locations", "type": "[str]"}, - "location_mappings": {"key": "locationMappings", "type": "[ProviderExtendedLocation]"}, - "aliases": {"key": "aliases", "type": "[Alias]"}, - "api_versions": {"key": "apiVersions", "type": "[str]"}, - "default_api_version": {"key": "defaultApiVersion", "type": "str"}, - "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, - "api_profiles": {"key": "apiProfiles", "type": "[ApiProfile]"}, - "capabilities": {"key": "capabilities", "type": "str"}, - "properties": {"key": "properties", "type": "{str}"}, - } - - def __init__( - self, - *, - resource_type: Optional[str] = None, - locations: Optional[list[str]] = None, - location_mappings: Optional[list["_models.ProviderExtendedLocation"]] = None, - aliases: Optional[list["_models.Alias"]] = None, - api_versions: Optional[list[str]] = None, - zone_mappings: Optional[list["_models.ZoneMapping"]] = None, - capabilities: Optional[str] = None, - properties: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_type: The resource type. - :paramtype resource_type: str - :keyword locations: The collection of locations where this resource type can be created. - :paramtype locations: list[str] - :keyword location_mappings: The location mappings that are supported by this resource type. - :paramtype location_mappings: - list[~azure.mgmt.resource.resources.models.ProviderExtendedLocation] - :keyword aliases: The aliases that are supported by this resource type. - :paramtype aliases: list[~azure.mgmt.resource.resources.models.Alias] - :keyword api_versions: The API version. - :paramtype api_versions: list[str] - :keyword zone_mappings: - :paramtype zone_mappings: list[~azure.mgmt.resource.resources.models.ZoneMapping] - :keyword capabilities: The additional capabilities offered by this resource type. - :paramtype capabilities: str - :keyword properties: The properties. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.resource_type = resource_type - self.locations = locations - self.location_mappings = location_mappings - self.aliases = aliases - self.api_versions = api_versions - self.default_api_version: Optional[str] = None - self.zone_mappings = zone_mappings - self.api_profiles: Optional[list["_models.ApiProfile"]] = None - self.capabilities = capabilities - self.properties = properties - - -class ProviderResourceTypeListResult(_serialization.Model): - """List of resource types of a resource provider. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of resource types. - :vartype value: list[~azure.mgmt.resource.resources.models.ProviderResourceType] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ProviderResourceType]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.ProviderResourceType"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of resource types. - :paramtype value: list[~azure.mgmt.resource.resources.models.ProviderResourceType] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None - - -class ResourceGroup(_serialization.Model): - """Resource group information. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: The ID of the resource group. - :vartype id: str - :ivar name: The name of the resource group. - :vartype name: str - :ivar type: The type of the resource group. - :vartype type: str - :ivar properties: The resource group properties. - :vartype properties: ~azure.mgmt.resource.resources.models.ResourceGroupProperties - :ivar location: The location of the resource group. It cannot be changed after the resource - group has been created. It must be one of the supported Azure locations. Required. - :vartype location: str - :ivar managed_by: The ID of the resource that manages this resource group. - :vartype managed_by: str - :ivar tags: The tags attached to the resource group. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ResourceGroupProperties"}, - "location": {"key": "location", "type": "str"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - location: str, - properties: Optional["_models.ResourceGroupProperties"] = None, - managed_by: Optional[str] = None, - tags: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword properties: The resource group properties. - :paramtype properties: ~azure.mgmt.resource.resources.models.ResourceGroupProperties - :keyword location: The location of the resource group. It cannot be changed after the resource - group has been created. It must be one of the supported Azure locations. Required. - :paramtype location: str - :keyword managed_by: The ID of the resource that manages this resource group. - :paramtype managed_by: str - :keyword tags: The tags attached to the resource group. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.properties = properties - self.location = location - self.managed_by = managed_by - self.tags = tags - - -class ResourceGroupExportResult(_serialization.Model): - """Resource group export result. - - :ivar template: The template content. Used if outputFormat is empty or set to 'Json'. - :vartype template: JSON - :ivar output: The formatted export content. Used if outputFormat is set to 'Bicep'. - :vartype output: str - :ivar error: The template export error. - :vartype error: ~azure.mgmt.resource.resources.models.ErrorResponse - """ - - _attribute_map = { - "template": {"key": "template", "type": "object"}, - "output": {"key": "output", "type": "str"}, - "error": {"key": "error", "type": "ErrorResponse"}, - } - - def __init__( - self, - *, - template: Optional[JSON] = None, - output: Optional[str] = None, - error: Optional["_models.ErrorResponse"] = None, - **kwargs: Any - ) -> None: - """ - :keyword template: The template content. Used if outputFormat is empty or set to 'Json'. - :paramtype template: JSON - :keyword output: The formatted export content. Used if outputFormat is set to 'Bicep'. - :paramtype output: str - :keyword error: The template export error. - :paramtype error: ~azure.mgmt.resource.resources.models.ErrorResponse - """ - super().__init__(**kwargs) - self.template = template - self.output = output - self.error = error - - -class ResourceGroupFilter(_serialization.Model): - """Resource group filter. - - :ivar tag_name: The tag name. - :vartype tag_name: str - :ivar tag_value: The tag value. - :vartype tag_value: str - """ - - _attribute_map = { - "tag_name": {"key": "tagName", "type": "str"}, - "tag_value": {"key": "tagValue", "type": "str"}, - } - - def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword tag_name: The tag name. - :paramtype tag_name: str - :keyword tag_value: The tag value. - :paramtype tag_value: str - """ - super().__init__(**kwargs) - self.tag_name = tag_name - self.tag_value = tag_value - - -class ResourceGroupListResult(_serialization.Model): - """List of resource groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of resource groups. - :vartype value: list[~azure.mgmt.resource.resources.models.ResourceGroup] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ResourceGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.ResourceGroup"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of resource groups. - :paramtype value: list[~azure.mgmt.resource.resources.models.ResourceGroup] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None - - -class ResourceGroupPatchable(_serialization.Model): - """Resource group information. - - :ivar name: The name of the resource group. - :vartype name: str - :ivar properties: The resource group properties. - :vartype properties: ~azure.mgmt.resource.resources.models.ResourceGroupProperties - :ivar managed_by: The ID of the resource that manages this resource group. - :vartype managed_by: str - :ivar tags: The tags attached to the resource group. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "ResourceGroupProperties"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - properties: Optional["_models.ResourceGroupProperties"] = None, - managed_by: Optional[str] = None, - tags: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the resource group. - :paramtype name: str - :keyword properties: The resource group properties. - :paramtype properties: ~azure.mgmt.resource.resources.models.ResourceGroupProperties - :keyword managed_by: The ID of the resource that manages this resource group. - :paramtype managed_by: str - :keyword tags: The tags attached to the resource group. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.name = name - self.properties = properties - self.managed_by = managed_by - self.tags = tags - - -class ResourceGroupProperties(_serialization.Model): - """The resource group properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioning_state: Optional[str] = None - - -class ResourceListResult(_serialization.Model): - """List of resource groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of resources. - :vartype value: list[~azure.mgmt.resource.resources.models.GenericResourceExpanded] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GenericResourceExpanded]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.GenericResourceExpanded"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of resources. - :paramtype value: list[~azure.mgmt.resource.resources.models.GenericResourceExpanded] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None - - -class ResourceProviderOperationDisplayProperties(_serialization.Model): # pylint: disable=name-too-long - """Resource provider operation's display properties. - - :ivar publisher: Operation description. - :vartype publisher: str - :ivar provider: Operation provider. - :vartype provider: str - :ivar resource: Operation resource. - :vartype resource: str - :ivar operation: Resource provider operation. - :vartype operation: str - :ivar description: Operation description. - :vartype description: str - """ - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - publisher: Optional[str] = None, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher: Operation description. - :paramtype publisher: str - :keyword provider: Operation provider. - :paramtype provider: str - :keyword resource: Operation resource. - :paramtype resource: str - :keyword operation: Resource provider operation. - :paramtype operation: str - :keyword description: Operation description. - :paramtype description: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class ResourcesMoveInfo(_serialization.Model): - """Parameters of move resources. - - :ivar resources: The IDs of the resources. - :vartype resources: list[str] - :ivar target_resource_group: The target resource group. - :vartype target_resource_group: str - """ - - _attribute_map = { - "resources": {"key": "resources", "type": "[str]"}, - "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, - } - - def __init__( - self, *, resources: Optional[list[str]] = None, target_resource_group: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword resources: The IDs of the resources. - :paramtype resources: list[str] - :keyword target_resource_group: The target resource group. - :paramtype target_resource_group: str - """ - super().__init__(**kwargs) - self.resources = resources - self.target_resource_group = target_resource_group - - -class RoleDefinition(_serialization.Model): - """Role definition properties. - - :ivar id: The role definition ID. - :vartype id: str - :ivar name: The role definition name. - :vartype name: str - :ivar is_service_role: If this is a service role. - :vartype is_service_role: bool - :ivar permissions: Role definition permissions. - :vartype permissions: list[~azure.mgmt.resource.resources.models.Permission] - :ivar scopes: Role definition assignable scopes. - :vartype scopes: list[str] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "is_service_role": {"key": "isServiceRole", "type": "bool"}, - "permissions": {"key": "permissions", "type": "[Permission]"}, - "scopes": {"key": "scopes", "type": "[str]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - is_service_role: Optional[bool] = None, - permissions: Optional[list["_models.Permission"]] = None, - scopes: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The role definition ID. - :paramtype id: str - :keyword name: The role definition name. - :paramtype name: str - :keyword is_service_role: If this is a service role. - :paramtype is_service_role: bool - :keyword permissions: Role definition permissions. - :paramtype permissions: list[~azure.mgmt.resource.resources.models.Permission] - :keyword scopes: Role definition assignable scopes. - :paramtype scopes: list[str] - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.is_service_role = is_service_role - self.permissions = permissions - self.scopes = scopes - - -class Sku(_serialization.Model): - """SKU for the resource. - - :ivar name: The SKU name. - :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 - """ - - _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: Optional[str] = None, - 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. - :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 SubResource(_serialization.Model): - """Sub-resource. - - :ivar id: Resource ID. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource ID. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class TagCount(_serialization.Model): - """Tag count. - - :ivar type: Type of count. - :vartype type: str - :ivar value: Value of count. - :vartype value: int - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "value": {"key": "value", "type": "int"}, - } - - def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword type: Type of count. - :paramtype type: str - :keyword value: Value of count. - :paramtype value: int - """ - super().__init__(**kwargs) - self.type = type - self.value = value - - -class TagDetails(_serialization.Model): - """Tag details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The tag name ID. - :vartype id: str - :ivar tag_name: The tag name. - :vartype tag_name: str - :ivar count: The total number of resources that use the resource tag. When a tag is initially - created and has no associated resources, the value is 0. - :vartype count: ~azure.mgmt.resource.resources.models.TagCount - :ivar values: The list of tag values. - :vartype values: list[~azure.mgmt.resource.resources.models.TagValue] - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "tag_name": {"key": "tagName", "type": "str"}, - "count": {"key": "count", "type": "TagCount"}, - "values": {"key": "values", "type": "[TagValue]"}, - } - - def __init__( - self, - *, - tag_name: Optional[str] = None, - count: Optional["_models.TagCount"] = None, - values: Optional[list["_models.TagValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tag_name: The tag name. - :paramtype tag_name: str - :keyword count: The total number of resources that use the resource tag. When a tag is - initially created and has no associated resources, the value is 0. - :paramtype count: ~azure.mgmt.resource.resources.models.TagCount - :keyword values: The list of tag values. - :paramtype values: list[~azure.mgmt.resource.resources.models.TagValue] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.tag_name = tag_name - self.count = count - self.values = values - - -class Tags(_serialization.Model): - """A dictionary of name and value pairs. - - :ivar tags: Dictionary of :code:``. - :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: Dictionary of :code:``. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class TagsListResult(_serialization.Model): - """List of subscription tags. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of tags. - :vartype value: list[~azure.mgmt.resource.resources.models.TagDetails] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[TagDetails]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.TagDetails"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of tags. - :paramtype value: list[~azure.mgmt.resource.resources.models.TagDetails] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None - - -class TagsPatchResource(_serialization.Model): - """Wrapper resource for tags patch API request only. - - :ivar operation: The operation type for the patch API. Known values are: "Replace", "Merge", - and "Delete". - :vartype operation: str or ~azure.mgmt.resource.resources.models.TagsPatchOperation - :ivar properties: The set of tags. - :vartype properties: ~azure.mgmt.resource.resources.models.Tags - """ - - _attribute_map = { - "operation": {"key": "operation", "type": "str"}, - "properties": {"key": "properties", "type": "Tags"}, - } - - def __init__( - self, - *, - operation: Optional[Union[str, "_models.TagsPatchOperation"]] = None, - properties: Optional["_models.Tags"] = None, - **kwargs: Any - ) -> None: - """ - :keyword operation: The operation type for the patch API. Known values are: "Replace", "Merge", - and "Delete". - :paramtype operation: str or ~azure.mgmt.resource.resources.models.TagsPatchOperation - :keyword properties: The set of tags. - :paramtype properties: ~azure.mgmt.resource.resources.models.Tags - """ - super().__init__(**kwargs) - self.operation = operation - self.properties = properties - - -class TagsResource(_serialization.Model): - """Wrapper resource for tags API requests and responses. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: The ID of the tags wrapper resource. - :vartype id: str - :ivar name: The name of the tags wrapper resource. - :vartype name: str - :ivar type: The type of the tags wrapper resource. - :vartype type: str - :ivar properties: The set of tags. Required. - :vartype properties: ~azure.mgmt.resource.resources.models.Tags - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "Tags"}, - } - - def __init__(self, *, properties: "_models.Tags", **kwargs: Any) -> None: - """ - :keyword properties: The set of tags. Required. - :paramtype properties: ~azure.mgmt.resource.resources.models.Tags - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.properties = properties - - -class TagValue(_serialization.Model): - """Tag information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The tag value ID. - :vartype id: str - :ivar tag_value: The tag value. - :vartype tag_value: str - :ivar count: The tag value count. - :vartype count: ~azure.mgmt.resource.resources.models.TagCount - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "tag_value": {"key": "tagValue", "type": "str"}, - "count": {"key": "count", "type": "TagCount"}, - } - - def __init__( - self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs: Any - ) -> None: - """ - :keyword tag_value: The tag value. - :paramtype tag_value: str - :keyword count: The tag value count. - :paramtype count: ~azure.mgmt.resource.resources.models.TagCount - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.tag_value = tag_value - self.count = count - - -class ZoneMapping(_serialization.Model): - """ZoneMapping. - - :ivar location: The location of the zone mapping. - :vartype location: str - :ivar zones: - :vartype zones: list[str] - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, *, location: Optional[str] = None, zones: Optional[list[str]] = None, **kwargs: Any) -> None: - """ - :keyword location: The location of the zone mapping. - :paramtype location: str - :keyword zones: - :paramtype zones: list[str] - """ - super().__init__(**kwargs) - self.location = location - self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_patch.py index 2be8919280c2..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models/_patch.py @@ -3,14 +3,13 @@ # 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/__init__.py index c95b954380a9..9471cdcfdeed 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/__init__.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. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,11 +13,11 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import Operations # type: ignore -from ._operations import ProvidersOperations # type: ignore -from ._operations import ProviderResourceTypesOperations # type: ignore -from ._operations import ResourcesOperations # type: ignore from ._operations import ResourceGroupsOperations # type: ignore +from ._operations import ResourcesOperations # type: ignore from ._operations import TagsOperations # type: ignore +from ._operations import ProvidersOperations # type: ignore +from ._operations import ProviderResourceTypesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -25,11 +25,11 @@ __all__ = [ "Operations", - "ProvidersOperations", - "ProviderResourceTypesOperations", - "ResourcesOperations", "ResourceGroupsOperations", + "ResourcesOperations", "TagsOperations", + "ProvidersOperations", + "ProviderResourceTypesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/_operations.py index a5c4e0f53fed..2d17e0070d30 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/_operations.py @@ -3,11 +3,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 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 @@ -33,10 +34,12 @@ from .. import models as _models from .._configuration import ResourceManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list _SERIALIZER = Serializer() @@ -51,7 +54,7 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") + _url = "/providers/Microsoft.Resources/operations" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -62,9 +65,7 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_unregister_request( - resource_provider_namespace: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_resource_groups_get_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 {}) @@ -72,12 +73,10 @@ def build_providers_unregister_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "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 @@ -88,26 +87,20 @@ def build_providers_unregister_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_register_at_management_group_scope_request( # pylint: disable=name-too-long - resource_provider_namespace: str, group_id: str, **kwargs: Any +def build_resource_groups_check_existence_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", "2025-04-01")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register", - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), - "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "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 @@ -115,28 +108,24 @@ def build_providers_register_at_management_group_scope_request( # pylint: disab # 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) + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_providers_provider_permissions_request( # pylint: disable=name-too-long - resource_provider_namespace: str, subscription_id: str, **kwargs: Any +def build_resource_groups_create_or_update_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 {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions" - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "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 @@ -145,26 +134,26 @@ def build_providers_provider_permissions_request( # pylint: disable=name-too-lo _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_register_request( - resource_provider_namespace: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_resource_groups_update_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", "2025-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "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 @@ -177,10 +166,35 @@ def build_providers_register_request( _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) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_list_request(subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any) -> HttpRequest: +def build_resource_groups_delete_request( + resource_group_name: str, subscription_id: str, *, force_deletion_types: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" + 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") + if force_deletion_types is not None: + _params["forceDeletionTypes"] = _SERIALIZER.query("force_deletion_types", force_deletion_types, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_resource_groups_list_request( + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -188,7 +202,7 @@ def build_providers_list_request(subscription_id: str, *, expand: Optional[str] accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") + _url = "/subscriptions/{subscriptionId}/resourcegroups" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -196,9 +210,11 @@ def build_providers_list_request(subscription_id: str, *, expand: Optional[str] _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -206,31 +222,44 @@ def build_providers_list_request(subscription_id: str, *, expand: Optional[str] return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_list_at_tenant_scope_request( # pylint: disable=name-too-long - *, expand: Optional[str] = None, **kwargs: Any +def build_resource_groups_export_template_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 {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers") + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + 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 - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_get_request( - resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +def build_resources_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -239,18 +268,22 @@ def build_providers_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/resources" path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "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") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -258,98 +291,94 @@ def build_providers_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_get_at_tenant_scope_request( # pylint: disable=name-too-long - resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any +def build_resources_move_resources_request( + source_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 {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") + _url = "/subscriptions/{subscriptionId}/resourcegroups/{sourceResourceGroupName}/moveResources" path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_provider_resource_types_list_request( # pylint: disable=name-too-long - resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +def build_resources_validate_move_resources_request( # pylint: disable=name-too-long + source_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 {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes" - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{sourceResourceGroupName}/validateMoveResources" path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any +def build_resources_check_existence_by_id_request( # pylint: disable=name-too-long + resource_id: str, *, api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + # Construct URL + _url = "/{resourceId}" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_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="HEAD", url=_url, params=_params, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: 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", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") + _url = "/{resourceId}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -358,30 +387,19 @@ def build_resources_list_by_resource_group_request( # pylint: disable=name-too- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request( - source_resource_group_name: str, subscription_id: str, **kwargs: Any +def build_resources_create_or_update_by_id_request( # pylint: disable=name-too-long + resource_id: str, *, api_version: 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", "2025-04-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/{sourceResourceGroupName}/moveResources" - ) + _url = "/{resourceId}" path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url( - "source_resource_group_name", - source_resource_group_name, - "str", - max_length=90, - min_length=1, - pattern=r"^[-\w\._\(\)]+$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -394,33 +412,20 @@ def build_resources_move_resources_request( _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request( # pylint: disable=name-too-long - source_resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_resources_update_by_id_request(resource_id: str, *, api_version: 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", "2025-04-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/{sourceResourceGroupName}/validateMoveResources" - ) + _url = "/{resourceId}" path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url( - "source_resource_group_name", - source_resource_group_name, - "str", - max_length=90, - min_length=1, - pattern=r"^[-\w\._\(\)]+$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -433,44 +438,24 @@ def build_resources_validate_move_resources_request( # pylint: disable=name-too _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) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") + _url = "/{resourceId}" path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") _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) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_resources_check_existence_request( @@ -484,25 +469,17 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -510,13 +487,10 @@ def build_resources_check_existence_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_resources_delete_request( +def build_resources_get_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -533,19 +507,14 @@ def build_resources_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -556,7 +525,7 @@ def build_resources_delete_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_create_or_update_request( @@ -577,19 +546,14 @@ def build_resources_create_or_update_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -623,19 +587,14 @@ def build_resources_update_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -651,7 +610,7 @@ def build_resources_update_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_get_request( +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -662,25 +621,17 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", - ) + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -688,47 +639,57 @@ def build_resources_get_request( # 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) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_check_existence_by_id_request( # pylint: disable=name-too-long - resource_id: str, *, api_version: str, **kwargs: Any +def build_resources_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}") + _url = "/subscriptions/{subscriptionId}/resources" path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "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") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: +def build_tags_get_at_scope_request(scope: 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", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}") + _url = "/{scope}/providers/Microsoft.Resources/tags/default" path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -739,22 +700,23 @@ def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_by_id_request( # pylint: disable=name-too-long - resource_id: str, *, api_version: str, **kwargs: Any +def build_tags_create_or_update_at_scope_request( # pylint: disable=name-too-long + scope: 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", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}") + _url = "/{scope}/providers/Microsoft.Resources/tags/default" path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -770,17 +732,18 @@ def build_resources_create_or_update_by_id_request( # pylint: disable=name-too- return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: +def build_tags_update_at_scope_request(scope: 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", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}") + _url = "/{scope}/providers/Microsoft.Resources/tags/default" path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -796,16 +759,14 @@ def build_resources_update_by_id_request(resource_id: str, *, api_version: str, return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_tags_delete_at_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}") + _url = "/{scope}/providers/Microsoft.Resources/tags/default" path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -813,27 +774,18 @@ def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **k # 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) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_check_existence_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_tags_delete_value_request(tag_name: str, tag_value: 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", "2025-04-01")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") + _url = "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -842,28 +794,23 @@ def build_resource_groups_check_existence_request( # pylint: disable=name-too-l # 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, **kwargs) - return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) - -def build_resource_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_tags_create_or_update_value_request( # pylint: disable=name-too-long + tag_name: str, tag_value: 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", "2025-04-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}") + _url = "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -873,16 +820,12 @@ def build_resource_groups_create_or_update_request( # pylint: disable=name-too- _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_resource_groups_delete_request( - resource_group_name: str, subscription_id: str, *, force_deletion_types: Optional[str] = None, **kwargs: Any -) -> HttpRequest: +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -890,40 +833,31 @@ def build_resource_groups_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") + _url = "/subscriptions/{subscriptionId}/tagNames/{tagName}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if force_deletion_types is not None: - _params["forceDeletionTypes"] = _SERIALIZER.query("force_deletion_types", force_deletion_types, "str") _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_tags_delete_request(tag_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", "2025-04-01")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") + _url = "/subscriptions/{subscriptionId}/tagNames/{tagName}" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -932,26 +866,19 @@ def build_resource_groups_get_request(resource_group_name: str, subscription_id: # 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) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_tags_list_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", "2025-04-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}") + _url = "/subscriptions/{subscriptionId}/tagNames" path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -961,49 +888,36 @@ def build_resource_groups_update_request(resource_group_name: str, subscription_ _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_export_template_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_providers_list_at_tenant_scope_request( # pylint: disable=name-too-long + *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-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}/exportTemplate" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/providers" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_list_request( - subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_providers_unregister_request( + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1012,39 +926,34 @@ def build_resource_groups_list_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") + _url = "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_providers_register_at_management_group_scope_request( # pylint: disable=name-too-long + resource_provider_namespace: str, group_id: str, **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") + _url = "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register" path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), - "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1052,14 +961,11 @@ def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_ # 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) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_tags_create_or_update_value_request( # pylint: disable=name-too-long - tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any +def build_providers_provider_permissions_request( # pylint: disable=name-too-long + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1068,11 +974,10 @@ def build_tags_create_or_update_value_request( # pylint: disable=name-too-long accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") + _url = "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions" path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), - "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1083,21 +988,24 @@ def build_tags_create_or_update_value_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_providers_register_request( + resource_provider_namespace: 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", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") + _url = "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register" path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1106,12 +1014,14 @@ def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **k _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_providers_list_request(subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1119,9 +1029,8 @@ def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") + _url = "/subscriptions/{subscriptionId}/providers" path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -1129,14 +1038,18 @@ def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_providers_get_request( + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1144,8 +1057,9 @@ def build_tags_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") + _url = "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}" path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -1153,6 +1067,8 @@ def build_tags_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1160,79 +1076,27 @@ def build_tags_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_at_scope_request( # pylint: disable=name-too-long - scope: str, **kwargs: Any +def build_providers_get_at_tenant_scope_request( # pylint: disable=name-too-long + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-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", "/{scope}/providers/Microsoft.Resources/tags/default") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "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_tags_update_at_scope_request(scope: 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", "2025-04-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", "/{scope}/providers/Microsoft.Resources/tags/default") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "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_tags_get_at_scope_request(scope: 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", "2025-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") + _url = "/providers/{resourceProviderNamespace}" path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1240,7 +1104,9 @@ def build_tags_get_at_scope_request(scope: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_at_scope_request(scope: str, **kwargs: Any) -> HttpRequest: +def build_provider_resource_types_list_request( # pylint: disable=name-too-long + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1248,20 +1114,23 @@ def build_tags_delete_at_scope_request(scope: str, **kwargs: Any) -> HttpRequest accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") + _url = "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes" path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class Operations: @@ -1274,8 +1143,6 @@ class Operations: :attr:`operations` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -1285,17 +1152,16 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: - """Lists all of the available Microsoft.Resources REST API operations. + """List the operations for the provider. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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) + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1309,11 +1175,16 @@ def prepare_request(next_link=None): if not next_link: _request = build_operations_list_request( - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -1326,18 +1197,29 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + 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 = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + 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.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -1350,25 +1232,27 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) -class ProvidersOperations: +class ResourceGroupsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.resource.resources.ResourceManagementClient`'s - :attr:`providers` attribute. + :attr:`resource_groups` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -1377,14 +1261,14 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: - """Unregisters a subscription from a resource provider. + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: + """Gets a resource group. - :param resource_provider_namespace: The namespace of the resource provider to unregister. - Required. - :type resource_provider_namespace: str - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1396,21 +1280,24 @@ def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Provider] = kwargs.pop("cls", None) + cls: ClsType[_models.ResourceGroup] = kwargs.pop("cls", None) - _request = build_providers_unregister_request( - resource_provider_namespace=resource_provider_namespace, + _request = build_resource_groups_get_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -1418,10 +1305,22 @@ def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Provider", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceGroup, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1429,21 +1328,14 @@ def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models return deserialized # type: ignore @distributed_trace - def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, resource_provider_namespace: str, group_id: str, **kwargs: Any - ) -> None: - """Registers a management group with a resource provider. Use this operation to register a - resource provider with resource types that can be deployed at the management group scope. It - does not recursively register subscriptions within the management group. Instead, you must - register subscriptions individually. + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: + """Checks whether a resource group exists. - :param resource_provider_namespace: The namespace of the resource provider to register. - Required. - :type resource_provider_namespace: str - :param group_id: The management group ID. Required. - :type group_id: str - :return: None or the result of cls(response) - :rtype: None + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :return: bool + :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1455,19 +1347,21 @@ def register_at_management_group_scope( # pylint: disable=inconsistent-return-s error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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_providers_register_at_management_group_scope_request( - resource_provider_namespace=resource_provider_namespace, - group_id=group_id, - api_version=api_version, + _request = build_resource_groups_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -1476,23 +1370,94 @@ def register_at_management_group_scope( # pylint: disable=inconsistent-return-s response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + @overload + def create_or_update( + self, + resource_group_name: str, + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. 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: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def provider_permissions( - self, resource_provider_namespace: str, **kwargs: Any - ) -> _models.ProviderPermissionListResult: - """Get the provider permissions. + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, JSON, IO[bytes]], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :return: ProviderPermissionListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ProviderPermissionListResult + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is one of the + following types: ResourceGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroup or JSON or IO[bytes] + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1503,33 +1468,58 @@ def provider_permissions( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ProviderPermissionListResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceGroup] = kwargs.pop("cls", None) - _request = build_providers_provider_permissions_request( - resource_provider_namespace=resource_provider_namespace, + 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_resource_groups_create_or_update_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderPermissionListResult", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceGroup, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1537,71 +1527,101 @@ def provider_permissions( return deserialized # type: ignore @overload - def register( + def update( self, - resource_provider_namespace: str, - properties: Optional[_models.ProviderRegistrationRequest] = None, + resource_group_name: str, + parameters: _models.ResourceGroupPatchable, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Provider: - """Registers a subscription with a resource provider. + ) -> _models.ResourceGroup: + """Updates a resource group. - :param resource_provider_namespace: The namespace of the resource provider to register. - Required. - :type resource_provider_namespace: str - :param properties: The third party consent for S2S. Default value is None. - :type properties: ~azure.mgmt.resource.resources.models.ProviderRegistrationRequest + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroupPatchable :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def register( - self, - resource_provider_namespace: str, - properties: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Provider: - """Registers a subscription with a resource provider. + def update( + self, resource_group_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. - :param resource_provider_namespace: The namespace of the resource provider to register. - Required. - :type resource_provider_namespace: str - :param properties: The third party consent for S2S. Default value is None. - :type properties: IO[bytes] + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. 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: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def register( + def update( self, - resource_provider_namespace: str, - properties: Optional[Union[_models.ProviderRegistrationRequest, IO[bytes]]] = None, + resource_group_name: str, + parameters: Union[_models.ResourceGroupPatchable, JSON, IO[bytes]], **kwargs: Any - ) -> _models.Provider: - """Registers a subscription with a resource provider. + ) -> _models.ResourceGroup: + """Updates a resource group. - :param resource_provider_namespace: The namespace of the resource provider to register. - Required. - :type resource_provider_namespace: str - :param properties: The third party consent for S2S. Is either a ProviderRegistrationRequest - type or a IO[bytes] type. Default value is None. - :type properties: ~azure.mgmt.resource.resources.models.ProviderRegistrationRequest or + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is one of the following + types: ResourceGroupPatchable, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroupPatchable or JSON or IO[bytes] - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :return: ResourceGroup. The ResourceGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1613,37 +1633,34 @@ def register( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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)) - content_type = content_type if properties else None - cls: ClsType[_models.Provider] = kwargs.pop("cls", None) + cls: ClsType[_models.ResourceGroup] = kwargs.pop("cls", None) - content_type = content_type or "application/json" if properties else None - _json = None + content_type = content_type or "application/json" _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if properties is not None: - _json = self._serialize.body(properties, "ProviderRegistrationRequest") - else: - _json = None + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_providers_register_request( - resource_provider_namespace=resource_provider_namespace, + _request = build_resource_groups_update_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -1651,34 +1668,31 @@ def register( 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Provider", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceGroup, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list(self, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.Provider"]: - """Gets all resource providers for a subscription. - - :param expand: The properties to include in the results. For example, use &$expand=metadata in - the query string to retrieve resource provider metadata. To include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: An iterator like instance of either Provider or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.Provider] - :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.ProviderListResult] = kwargs.pop("cls", None) - + def _delete_initial( + self, resource_group_name: str, *, force_deletion_types: Optional[str] = None, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1687,76 +1701,142 @@ def list(self, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_model } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_providers_list_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_resource_groups_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + force_deletion_types=force_deletion_types, + 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) - def extract_data(pipeline_response): - deserialized = self._deserialize("ProviderListResult", 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) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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.CloudError, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, 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")) - return pipeline_response + deserialized = response.iter_bytes() if _decompress else response.iter_raw() - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list_at_tenant_scope(self, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.Provider"]: - """Gets all resource providers for the tenant. + def begin_delete( + self, resource_group_name: str, *, force_deletion_types: Optional[str] = None, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a resource group. - :param expand: The properties to include in the results. For example, use &$expand=metadata in - the query string to retrieve resource provider metadata. To include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: An iterator like instance of either Provider or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.Provider] + When you delete a resource group, all of its resources are also deleted. Deleting a resource + group deletes all of its template deployments and currently stored operations. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :keyword force_deletion_types: The resource types you want to force delete. Currently, only the + following is supported: + forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets. + Default value is None. + :paramtype force_deletion_types: 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, + force_deletion_types=force_deletion_types, + 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( + self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.ResourceGroup"]: + """Gets all the resource groups for a subscription. + + :keyword filter: The filter to apply on the operation.

You can filter by tag names and + values. For example, to filter for a tag name and value, use $filter=tagName eq 'tag1' and + tagValue eq 'Value1'. Default value is None. + :paramtype filter: str + :keyword top: The number of results to return. If null is passed, returns all resource groups. + Default value is None. + :paramtype top: int + :return: An iterator like instance of ResourceGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.ResourceGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ProviderListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ResourceGroup]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1769,13 +1849,20 @@ def list_at_tenant_scope(self, expand: Optional[str] = None, **kwargs: Any) -> I def prepare_request(next_link=None): if not next_link: - _request = build_providers_list_at_tenant_scope_request( - expand=expand, - api_version=api_version, + _request = build_resource_groups_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -1788,18 +1875,29 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + 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 = self._deserialize("ProviderListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceGroup], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -1812,25 +1910,19 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) - @distributed_trace - def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: - """Gets the specified resource provider. - - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _export_template_initial( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, JSON, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1839,173 +1931,203 @@ def get(self, resource_provider_namespace: str, expand: Optional[str] = None, ** } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Provider] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_providers_get_request( - resource_provider_namespace=resource_provider_namespace, + 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_resource_groups_export_template_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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 = self._deserialize("Provider", pipeline_response.http_response) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def get_at_tenant_scope( - self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Provider: - """Gets the specified resource provider at the tenant level. + @overload + def begin_export_template( + self, + resource_group_name: str, + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: Provider or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.Provider + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.models.ExportTemplateRequest + :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 ResourceGroupExportResult. The + ResourceGroupExportResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + @overload + def begin_export_template( + self, resource_group_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Provider] = kwargs.pop("cls", None) + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: JSON + :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 ResourceGroupExportResult. The + ResourceGroupExportResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _request = build_providers_get_at_tenant_scope_request( - resource_provider_namespace=resource_provider_namespace, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + @overload + def begin_export_template( + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Provider", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class ProviderResourceTypesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.resources.ResourceManagementClient`'s - :attr:`provider_resource_types` attribute. - """ - - models = _models - - 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: ResourceManagementClientConfiguration = 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") + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. 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 ResourceGroupExportResult. The + ResourceGroupExportResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list( - self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.ProviderResourceTypeListResult: - """List the resource types for a specified resource provider. + def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include property aliases in - response, use $expand=resourceTypes/aliases. Default value is None. - :type expand: str - :return: ProviderResourceTypeListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ProviderResourceTypeListResult + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is one of the following types: + ExportTemplateRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ExportTemplateRequest or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ResourceGroupExportResult. The + ResourceGroupExportResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] :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 {} - _headers = 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)) + cls: ClsType[_models.ResourceGroupExportResult] = 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._export_template_initial( + resource_group_name=resource_group_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) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ProviderResourceTypeListResult] = kwargs.pop("cls", None) + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ResourceGroupExportResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - _request = build_provider_resource_types_list_request( - resource_provider_namespace=resource_provider_namespace, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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.ResourceGroupExportResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ResourceGroupExportResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProviderResourceTypeListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - class ResourcesOperations: # pylint: disable=too-many-public-methods """ @@ -2017,8 +2139,6 @@ class ResourcesOperations: # pylint: disable=too-many-public-methods :attr:`resources` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -2030,6 +2150,7 @@ def __init__(self, *args, **kwargs) -> None: def list_by_resource_group( self, resource_group_name: str, + *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, @@ -2037,43 +2158,40 @@ def list_by_resource_group( ) -> ItemPaged["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. Required. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type resource_group_name: str - :param filter: The filter to apply on the operation.\\ :code:`
`\\ :code:`
`The - properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, - resourceGroup, identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.\\ :code:`
`\\ :code:`
`For example, to filter by a - resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'\\ - :code:`
`\\ :code:`
`You can use substringof(value, property) in the filter. The - properties you can use for substring are: name and resourceGroup.\\ :code:`
`\\ - :code:`
`For example, to get all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)\\ :code:`
`\\ :code:`
`You can link more than one - substringof together by adding and/or operators.\\ :code:`
`\\ :code:`
`You can filter by - tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq - 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, the tags for each - resource are not returned in the results.\\ :code:`
`\\ :code:`
`You can use some - properties together when filtering. The combinations you can use are: substringof and/or - resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. Default - value is None. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Valid values include ``createdTime``\\ , ``changedTime`` and ``provisioningState``. For - example, ``$expand=createdTime,changedTime``. Default value is None. - :type expand: str - :param top: The number of results to return. If null is passed, returns all resources. Default - value is None. - :type top: int - :return: An iterator like instance of either GenericResourceExpanded or the result of - cls(response) + :keyword filter: The filter to apply on the operation.

The properties you can use for eq + (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, identity, + identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, and + plan/promotionCode.

For example, to filter by a resource type, use: $filter=resourceType + eq 'Microsoft.Network/virtualNetworks'

You can use substringof(value, property) in the + filter. The properties you can use for substring are: name and resourceGroup.

For + example, to get all resources with 'demo' anywhere in the name, use: + $filter=substringof('demo', name)

You can link more than one substringof together by + adding and/or operators.

You can filter by tag names and values. For example, to filter + for a tag name and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you + filter by a tag name and value, the tags for each resource are not returned in the + results.

You can use some properties together when filtering. The combinations you can + use are: substringof and/or resourceType, plan and plan/publisher and plan/name, identity and + identity/principalId. Default value is None. + :paramtype filter: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``, ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. Default value is None. + :paramtype expand: str + :keyword top: The number of results to return. If null is passed, returns all resources. + Default value is None. + :paramtype top: int + :return: An iterator like instance of GenericResourceExpanded :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.GenericResourceExpanded] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ResourceListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.GenericResourceExpanded]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2092,11 +2210,16 @@ def prepare_request(next_link=None): filter=filter, expand=expand, top=top, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2109,18 +2232,29 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + 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 = self._deserialize("ResourceListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GenericResourceExpanded], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -2133,14 +2267,21 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) def _move_resources_initial( - self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO[bytes]], **kwargs: Any + self, + source_resource_group_name: str, + parameters: Union[_models.ResourcesMoveInfo, JSON, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2151,31 +2292,31 @@ def _move_resources_initial( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" - _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ResourcesMoveInfo") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2191,12 +2332,20 @@ def _move_resources_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -2216,15 +2365,44 @@ def begin_move_resources( resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be moved. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_move_resources( + self, + source_resource_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to be moved must be in the same source resource group in the source subscription + being used. The target resource group may be in a different subscription. When moving + resources, both the source group and the target group are locked for the duration of the + operation. Write and delete operations are blocked on the groups until the move completes. + + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: JSON + :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 None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2245,22 +2423,25 @@ def begin_move_resources( resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be moved. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str :param parameters: Parameters for moving resources. 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 either None or the result of cls(response) + :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def begin_move_resources( - self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO[bytes]], **kwargs: Any + self, + source_resource_group_name: str, + parameters: Union[_models.ResourcesMoveInfo, JSON, IO[bytes]], + **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -2269,20 +2450,19 @@ def begin_move_resources( resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be moved. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. Is either a ResourcesMoveInfo type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) + :param parameters: Parameters for moving resources. Is one of the following types: + ResourcesMoveInfo, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo or JSON or IO[bytes] + :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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) @@ -2292,7 +2472,6 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, - api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -2306,8 +2485,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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, **kwargs)) + 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: @@ -2322,7 +2507,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO[bytes]], **kwargs: Any + self, + source_resource_group_name: str, + parameters: Union[_models.ResourcesMoveInfo, JSON, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2333,31 +2521,31 @@ def _validate_move_resources_initial( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" - _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ResourcesMoveInfo") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2373,12 +2561,20 @@ def _validate_move_resources_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -2400,15 +2596,46 @@ def begin_validate_move_resources( 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be validated for move. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate_move_resources( + self, + source_resource_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to be moved must be in the same source resource group in the source subscription being used. + The target resource group may be in a different subscription. If validation succeeds, it + returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code + 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check + the result of the long-running operation. + + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: JSON + :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 None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2431,22 +2658,25 @@ def begin_validate_move_resources( 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be validated for move. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str :param parameters: Parameters for moving resources. 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 either None or the result of cls(response) + :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def begin_validate_move_resources( - self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO[bytes]], **kwargs: Any + self, + source_resource_group_name: str, + parameters: Union[_models.ResourcesMoveInfo, JSON, IO[bytes]], + **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -2457,20 +2687,19 @@ def begin_validate_move_resources( 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. - :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be validated for move. Required. + :param source_resource_group_name: The name of the resource group to get. The name is case + insensitive. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. Is either a ResourcesMoveInfo type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) + :param parameters: Parameters for moving resources. Is one of the following types: + ResourcesMoveInfo, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.ResourcesMoveInfo or JSON or IO[bytes] + :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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) @@ -2480,7 +2709,6 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, - api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -2494,8 +2722,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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, **kwargs)) + 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: @@ -2510,147 +2744,17 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list( - self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.GenericResourceExpanded"]: - """Get all the resources in a subscription. + def check_existence_by_id(self, resource_id: str, *, api_version: str, **kwargs: Any) -> bool: + """Checks by ID whether a resource exists. This API currently works only for a limited set of + Resource providers. In the event that a Resource provider does not implement this API, ARM will + respond with a 405. The alternative then is to use the GET API to check for the existence of + the resource. - :param filter: The filter to apply on the operation.\\ :code:`
`\\ :code:`
`Filter - comparison operators include ``eq`` (equals) and ``ne`` (not equals) and may be used with the - following properties: ``location``\\ , ``resourceType``\\ , ``name``\\ , ``resourceGroup``\\ , - ``identity``\\ , ``identity/principalId``\\ , ``plan``\\ , ``plan/publisher``\\ , - ``plan/product``\\ , ``plan/name``\\ , ``plan/version``\\ , and ``plan/promotionCode``.\\ - :code:`
`\\ :code:`
`For example, to filter by a resource type, use - ``$filter=resourceType eq 'Microsoft.Network/virtualNetworks'``\\ :code:`
`\\ :code:`
`\\ - :code:`
`\\ ``substringof(value, property)`` can be used to filter for substrings of the - following currently-supported properties: ``name`` and ``resourceGroup``\\ :code:`
`\\ - :code:`
`For example, to get all resources with 'demo' anywhere in the resource name, use - ``$filter=substringof('demo', name)``\\ :code:`
`\\ :code:`
`Multiple substring - operations can also be combined using ``and``\\ /\\ ``or`` operators.\\ :code:`
`\\ - :code:`
`Note that any truncated number of results queried via ``$top`` may also not be - compatible when using a filter.\\ :code:`
`\\ :code:`
`\\ :code:`
`Resources can be - filtered by tag names and values. For example, to filter for a tag name and value, use - ``$filter=tagName eq 'tag1' and tagValue eq 'Value1'``. Note that when resources are filtered - by tag name and value, :code:`the original tags for each resource will not be returned in - the results.` Any list of additional properties queried via ``$expand`` may also not be - compatible when filtering by tag names/values. :code:`
`\\ :code:`
`For tag names only, - resources can be filtered by prefix using the following syntax: ``$filter=startswith(tagName, - 'depart')``. This query will return all resources with a tag name prefixed by the phrase - ``depart`` (i.e.\\ ``department``\\ , ``departureDate``\\ , ``departureTime``\\ , etc.)\\ - :code:`
`\\ :code:`
`\\ :code:`
`Note that some properties can be combined when - filtering resources, which include the following: ``substringof() and/or resourceType``\\ , - ``plan and plan/publisher and plan/name``\\ , and ``identity and identity/principalId``. - Default value is None. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Valid values include ``createdTime``\\ , ``changedTime`` and ``provisioningState``. For - example, ``$expand=createdTime,changedTime``. Default value is None. - :type expand: str - :param top: The number of recommendations per page if a paged version of this API is being - used. Default value is None. - :type top: int - :return: An iterator like instance of either GenericResourceExpanded or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.GenericResourceExpanded] - :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.ResourceListResult] = 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_resources_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def check_existence( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - **kwargs: Any - ) -> bool: - """Checks whether a resource exists. - - :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type. Required. - :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: bool or the result of cls(response) + :param resource_id: Required. + :type resource_id: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: bool :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2667,18 +2771,16 @@ def check_existence( cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_resources_check_existence_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_check_existence_by_id_request( + resource_id=resource_id, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2689,22 +2791,28 @@ def check_existence( if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - def _delete_initial( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def get_by_id(self, resource_id: str, *, api_version: str, **kwargs: Any) -> _models.GenericResource: + """Gets a resource by ID. + + :param resource_id: Required. + :type resource_id: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: GenericResource. The GenericResource is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2716,125 +2824,56 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.GenericResource] = kwargs.pop("cls", None) - _request = build_resources_delete_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_get_by_id_request( + resource_id=resource_id, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GenericResource, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a resource. - - :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type. Required. - :type resource_type: str - :param resource_name: The name of the resource to delete. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :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 = 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, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - 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 - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[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 - - def _create_or_update_initial( + def _create_or_update_by_id_initial( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, api_version: str, - parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2852,28 +2891,24 @@ def _create_or_update_initial( cls: ClsType[Iterator[bytes]] = 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, "GenericResource") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resources_create_or_update_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_create_or_update_by_id_request( + resource_id=resource_id, api_version=api_version, content_type=content_type, - json=_json, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -2889,127 +2924,128 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if response.status_code == 202: + 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, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create_or_update( + def begin_create_or_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, + resource_id: str, parameters: _models.GenericResource, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Creates a resource. + """Create a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. Required. - :type resource_type: str - :param resource_name: The name of the resource to create. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for creating or updating the resource. Required. + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. :type parameters: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update( + def begin_create_or_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - parameters: IO[bytes], + resource_id: str, + parameters: JSON, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Creates a resource. + """Create a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. Required. - :type resource_type: str - :param resource_name: The name of the resource to create. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for creating or updating the resource. Required. + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. + :type parameters: JSON + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + parameters: IO[bytes], + *, + api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. :type parameters: IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update( + def begin_create_or_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, api_version: str, - parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Creates a resource. + """Create a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. Required. - :type resource_type: str - :param resource_name: The name of the resource to create. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for creating or updating the resource. Is either a - GenericResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or IO[bytes] - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Is one of the following types: GenericResource, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or JSON or IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3022,14 +3058,10 @@ def begin_create_or_update( 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, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, + raw_result = self._create_or_update_by_id_initial( + resource_id=resource_id, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -3040,13 +3072,20 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.GenericResource, 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, **kwargs)) + 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: @@ -3062,15 +3101,12 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _update_initial( + def _update_by_id_initial( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, api_version: str, - parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3088,28 +3124,24 @@ def _update_initial( cls: ClsType[Iterator[bytes]] = 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, "GenericResource") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resources_update_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_update_by_id_request( + resource_id=resource_id, api_version=api_version, content_type=content_type, - json=_json, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3125,127 +3157,125 @@ def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update( + def begin_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, + resource_id: str, parameters: _models.GenericResource, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Updates a resource. + """Update a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. Required. - :type resource_type: str - :param resource_name: The name of the resource to update. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for updating the resource. Required. + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. :type parameters: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: JSON, + *, api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Update a resource by ID. + + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. + :type parameters: JSON + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_by_id( + self, + resource_id: str, parameters: IO[bytes], *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Updates a resource. + """Update a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. Required. - :type resource_type: str - :param resource_name: The name of the resource to update. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for updating the resource. Required. + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Required. :type parameters: IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_update_by_id( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + resource_id: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, api_version: str, - parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Updates a resource. + """Update a resource by ID. - :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. Required. - :type resource_type: str - :param resource_name: The name of the resource to update. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Parameters for updating the resource. Is either a GenericResource type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or IO[bytes] - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :param resource_id: Required. + :type resource_id: str + :param parameters: Resource create parameters. Is one of the following types: GenericResource, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or JSON or IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3258,14 +3288,10 @@ def begin_update( 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, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, + raw_result = self._update_by_id_initial( + resource_id=resource_id, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -3276,13 +3302,20 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.GenericResource, 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, **kwargs)) + 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: @@ -3298,36 +3331,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - api_version: str, - **kwargs: Any - ) -> _models.GenericResource: - """Gets a resource. - - :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get. Required. - :type resource_name: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: GenericResource or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.GenericResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_by_id_initial(self, resource_id: str, *, api_version: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3339,77 +3343,166 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.GenericResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_resources_get_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_resources_delete_by_id_request( + resource_id=resource_id, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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 = self._deserialize("GenericResource", pipeline_response.http_response) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: - """Checks by ID whether a resource exists. This API currently works only for a limited set of - Resource providers. In the event that a Resource provider does not implement this API, ARM will - respond with a 405. The alternative then is to use the GET API to check for the existence of - the resource. + def begin_delete_by_id(self, resource_id: str, *, api_version: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. + :param resource_id: Required. :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: bool or the result of cls(response) - :rtype: bool + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[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_resources_check_existence_by_id_request( - resource_id=resource_id, - api_version=api_version, - headers=_headers, + 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( + resource_id=resource_id, + api_version=api_version, + 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 check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + *, + api_version: str, + **kwargs: Any + ) -> bool: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: bool + :rtype: bool + :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_resources_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3420,13 +3513,47 @@ def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: An if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore return 200 <= response.status_code <= 299 - def _delete_by_id_initial(self, resource_id: str, api_version: str, **kwargs: Any) -> Iterator[bytes]: + @distributed_trace + def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + *, + api_version: str, + **kwargs: Any + ) -> _models.GenericResource: + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: GenericResource. The GenericResource is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3438,94 +3565,66 @@ def _delete_by_id_initial(self, resource_id: str, api_version: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.GenericResource] = kwargs.pop("cls", None) - _request = build_resources_delete_by_id_request( - resource_id=resource_id, + _request = build_resources_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GenericResource, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a resource by ID. - - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :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 = 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( - resource_id=resource_id, - api_version=api_version, - 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 - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[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 - - def _create_or_update_by_id_initial( - self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any + def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, + api_version: str, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3542,23 +3641,29 @@ def _create_or_update_by_id_initial( cls: ClsType[Iterator[bytes]] = 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, "GenericResource") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resources_create_or_update_by_id_request( - resource_id=resource_id, + _request = build_resources_create_or_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, - json=_json, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3574,93 +3679,180 @@ def _create_or_update_by_id_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if response.status_code == 202: + 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, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create_or_update_by_id( + def begin_create_or_update( self, - resource_id: str, - api_version: str, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, parameters: _models.GenericResource, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Create a resource by ID. + """Creates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Create or update resource parameters. Required. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. :type parameters: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update_by_id( + def begin_create_or_update( self, - resource_id: str, - api_version: str, - parameters: IO[bytes], + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: JSON, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Create a resource by ID. + """Creates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Create or update resource 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: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. + :type parameters: JSON + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: IO[bytes], + *, + api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. + :type parameters: IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update_by_id( - self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, + api_version: str, + **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Create a resource by ID. + """Creates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Create or update resource parameters. Is either a GenericResource type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or IO[bytes] - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Is one of the following types: GenericResource, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or JSON or IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3673,10 +3865,14 @@ def begin_create_or_update_by_id( 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( - resource_id=resource_id, - api_version=api_version, + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -3687,13 +3883,20 @@ def begin_create_or_update_by_id( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.GenericResource, 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, **kwargs)) + 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: @@ -3709,8 +3912,17 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _update_by_id_initial( - self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any + def _update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, + api_version: str, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3727,23 +3939,29 @@ def _update_by_id_initial( cls: ClsType[Iterator[bytes]] = 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, "GenericResource") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resources_update_by_id_request( - resource_id=resource_id, + _request = build_resources_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, - json=_json, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -3759,93 +3977,177 @@ def _update_by_id_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update_by_id( + def begin_update( self, - resource_id: str, - api_version: str, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, parameters: _models.GenericResource, *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Updates a resource by ID. + """Updates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Update resource parameters. Required. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. :type parameters: ~azure.mgmt.resource.resources.models.GenericResource + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_by_id( + def begin_update( self, - resource_id: str, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: JSON, + *, api_version: str, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. + :type parameters: JSON + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :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 GenericResource. The GenericResource is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, parameters: IO[bytes], *, + api_version: str, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Updates a resource by ID. + """Updates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Update resource parameters. Required. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Required. :type parameters: IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_by_id( - self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO[bytes]], **kwargs: Any + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: Union[_models.GenericResource, JSON, IO[bytes]], + *, + api_version: str, + **kwargs: Any ) -> LROPoller[_models.GenericResource]: - """Updates a resource by ID. + """Updates a resource. - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :param parameters: Update resource parameters. Is either a GenericResource type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or IO[bytes] - :return: An instance of LROPoller that returns either GenericResource or the result of - cls(response) + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :param parameters: Resource create parameters. Is one of the following types: GenericResource, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.GenericResource or JSON or IO[bytes] + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: str + :return: An instance of LROPoller that returns GenericResource. The GenericResource is + compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.GenericResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3858,10 +4160,14 @@ def begin_update_by_id( 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( - resource_id=resource_id, - api_version=api_version, + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -3872,13 +4178,20 @@ def begin_update_by_id( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenericResource", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.GenericResource, 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, **kwargs)) + 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: @@ -3894,21 +4207,17 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: - """Gets a resource by ID. - - :param resource_id: The fully qualified ID of the resource, including the resource name and - resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. - Required. - :type resource_id: str - :param api_version: The API version to use for the operation. Required. - :type api_version: str - :return: GenericResource or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.GenericResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + *, + api_version: str, + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3920,65 +4229,182 @@ def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.GenericResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_resources_get_by_id_request( - resource_id=resource_id, + _request = build_resources_delete_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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]: + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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 = self._deserialize("GenericResource", pipeline_response.http_response) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + *, + api_version: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a resource. -class ResourceGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type. Required. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. Required. + :type resource_name: str + :keyword api_version: The API version to use for this operation. Required. + :paramtype api_version: 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 {} - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.resources.ResourceManagementClient`'s - :attr:`resource_groups` attribute. - """ + 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, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - models = _models + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - 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: ResourceManagementClientConfiguration = 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") + 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 check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: - """Checks whether a resource group exists. + def list( + self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.GenericResourceExpanded"]: + """Get all the resources in a subscription. - :param resource_group_name: The name of the resource group to check. The name is case - insensitive. Required. - :type resource_group_name: str - :return: bool or the result of cls(response) - :rtype: bool + :keyword filter: The filter to apply on the operation.

Filter comparison operators + include ``eq`` (equals) and ``ne`` (not equals) and may be used with the following properties: + ``location``, ``resourceType``, ``name``, ``resourceGroup``, ``identity``, + ``identity/principalId``, ``plan``, ``plan/publisher``, ``plan/product``, ``plan/name``, + ``plan/version``, and ``plan/promotionCode``.

For example, to filter by a resource type, + use ``$filter=resourceType eq + 'Microsoft.Network/virtualNetworks'``


``substringof(value, property)`` can be used + to filter for substrings of the following currently-supported properties: ``name`` and + ``resourceGroup``

For example, to get all resources with 'demo' anywhere in the resource + name, use ``$filter=substringof('demo', name)``

Multiple substring operations can also + be combined using ``and``/``or`` operators.

Note that any truncated number of results + queried via ``$top`` may also not be compatible when using a filter.


Resources can + be filtered by tag names and values. For example, to filter for a tag name and value, use + ``$filter=tagName eq 'tag1' and tagValue eq 'Value1'``. Note that when resources are filtered + by tag name and value, the original tags for each resource will not be returned in the + results. Any list of additional properties queried via ``$expand`` may also not be + compatible when filtering by tag names/values.

For tag names only, resources can be + filtered by prefix using the following syntax: ``$filter=startswith(tagName, 'depart')``. This + query will return all resources with a tag name prefixed by the phrase ``depart`` + (i.e.``department``, ``departureDate``, ``departureTime``, etc.)


Note that some + properties can be combined when filtering resources, which include the following: + ``substringof() and/or resourceType``, ``plan and plan/publisher and plan/name``, and + ``identity and identity/principalId``. Default value is None. + :paramtype filter: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``, ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. Default value is None. + :paramtype expand: str + :keyword top: The number of recommendations per page if a paged version of this API is being + used. Default value is None. + :paramtype top: int + :return: An iterator like instance of GenericResourceExpanded + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.GenericResourceExpanded] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GenericResourceExpanded]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3987,96 +4413,109 @@ def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_resources_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + 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) - _request = build_resource_groups_check_existence_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + 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) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return _request - response = pipeline_response.http_response + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GenericResourceExpanded], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - if response.status_code not in [204, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def get_next(next_link=None): + _request = prepare_request(next_link) - if cls: - return cls(pipeline_response, None, {}) # type: ignore - return 200 <= response.status_code <= 299 + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - @overload - def create_or_update( - self, - resource_group_name: str, - parameters: _models.ResourceGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResourceGroup: - """Creates or updates a resource group. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - :param resource_group_name: The name of the resource group to create or update. Can include - alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + return pipeline_response - @overload - def create_or_update( - self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ResourceGroup: - """Creates or updates a resource group. + return ItemPaged(get_next, extract_data) - :param resource_group_name: The name of the resource group to create or update. Can include - alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. 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: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.ResourceManagementClient`'s + :attr:`tags` 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: ResourceManagementClientConfiguration = 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 create_or_update( - self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO[bytes]], **kwargs: Any - ) -> _models.ResourceGroup: - """Creates or updates a resource group. + def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: + """Gets the entire set of tags on a resource or subscription. - :param resource_group_name: The name of the resource group to create or update. Can include - alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. Is either a - ResourceGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroup or IO[bytes] - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + Gets the entire set of tags on a resource or subscription. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :return: TagsResource. The TagsResource is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.TagsResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4087,53 +4526,55 @@ def create_or_update( } 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.ResourceGroup] = kwargs.pop("cls", None) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ResourceGroup") + cls: ClsType[_models.TagsResource] = kwargs.pop("cls", None) - _request = build_resource_groups_create_or_update_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, + _request = build_tags_get_at_scope_request( + scope=scope, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGroup", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagsResource, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _delete_initial( - self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any + def _create_or_update_at_scope_initial( + self, scope: str, parameters: Union[_models.TagsResource, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4143,21 +4584,31 @@ def _delete_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_resource_groups_delete_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - force_deletion_types=force_deletion_types, - api_version=api_version, + 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_tags_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -4173,258 +4624,161 @@ def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + 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["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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, force_deletion_types: Optional[str] = None, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a resource group. - - When you delete a resource group, all of its resources are also deleted. Deleting a resource - group deletes all of its template deployments and currently stored operations. - - :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. Required. - :type resource_group_name: str - :param force_deletion_types: The resource types you want to force delete. Currently, only the - following is supported: - forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets. - Default value is None. - :type force_deletion_types: str - :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( - resource_group_name=resource_group_name, - force_deletion_types=force_deletion_types, - api_version=api_version, - 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 - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[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 + @overload + def begin_create_or_update_at_scope( + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TagsResource]: + """Creates or updates the entire set of tags on a resource or subscription. - @distributed_trace - def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: - """Gets a resource group. + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. - :param resource_group_name: The name of the resource group to get. The name is case - insensitive. Required. - :type resource_group_name: str - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Required. + :type parameters: ~azure.mgmt.resource.resources.models.TagsResource + :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 TagsResource. The TagsResource is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] :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 = 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.ResourceGroup] = kwargs.pop("cls", None) - - _request = build_resource_groups_get_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ResourceGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore @overload - def update( - self, - resource_group_name: str, - parameters: _models.ResourceGroupPatchable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResourceGroup: - """Updates a resource group. + def begin_create_or_update_at_scope( + self, scope: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TagsResource]: + """Creates or updates the entire set of tags on a resource or subscription. - Resource groups can be updated through a simple PATCH operation to a group address. The format - of the request is the same as that for creating a resource group. If a field is unspecified, - the current value is retained. + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. - :param resource_group_name: The name of the resource group to update. The name is case - insensitive. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroupPatchable + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Required. + :type parameters: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :return: An instance of LROPoller that returns TagsResource. The TagsResource is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ResourceGroup: - """Updates a resource group. + def begin_create_or_update_at_scope( + self, scope: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TagsResource]: + """Creates or updates the entire set of tags on a resource or subscription. - Resource groups can be updated through a simple PATCH operation to a group address. The format - of the request is the same as that for creating a resource group. If a field is unspecified, - the current value is retained. + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. - :param resource_group_name: The name of the resource group to update. The name is case - insensitive. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. Required. + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param 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: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :return: An instance of LROPoller that returns TagsResource. The TagsResource is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( - self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO[bytes]], **kwargs: Any - ) -> _models.ResourceGroup: - """Updates a resource group. + def begin_create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.TagsResource]: + """Creates or updates the entire set of tags on a resource or subscription. - Resource groups can be updated through a simple PATCH operation to a group address. The format - of the request is the same as that for creating a resource group. If a field is unspecified, - the current value is retained. + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. - :param resource_group_name: The name of the resource group to update. The name is case - insensitive. Required. - :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. Is either a - ResourceGroupPatchable type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ResourceGroupPatchable or IO[bytes] - :return: ResourceGroup or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.ResourceGroup + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Is one of the following types: TagsResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.TagsResource or JSON or IO[bytes] + :return: An instance of LROPoller that returns TagsResource. The TagsResource is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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.ResourceGroup] = 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, "ResourceGroupPatchable") - - _request = build_resource_groups_update_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + cls: ClsType[_models.TagsResource] = 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_at_scope_initial( + scope=scope, + 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) - deserialized = self._deserialize("ResourceGroup", pipeline_response.http_response) + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.TagsResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } - return deserialized # type: ignore + 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.TagsResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.TagsResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _export_template_initial( - self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO[bytes]], **kwargs: Any + def _update_at_scope_initial( + self, scope: str, parameters: Union[_models.TagsPatchResource, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4435,31 +4789,30 @@ def _export_template_initial( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" - _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ExportTemplateRequest") + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_resource_groups_export_template_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, + _request = build_tags_update_at_scope_request( + scope=scope, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -4475,94 +4828,141 @@ def _export_template_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_export_template( + def begin_update_at_scope( self, - resource_group_name: str, - parameters: _models.ExportTemplateRequest, + scope: str, + parameters: _models.TagsPatchResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ResourceGroupExportResult]: - """Captures the specified resource group as a template. + ) -> LROPoller[_models.TagsResource]: + """Selectively updates the set of tags on a resource or subscription. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Parameters for exporting the template. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ExportTemplateRequest + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Required. + :type parameters: ~azure.mgmt.resource.resources.models.TagsPatchResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + :return: An instance of LROPoller that returns TagsResource. The TagsResource is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_export_template( - self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ResourceGroupExportResult]: - """Captures the specified resource group as a template. + def begin_update_at_scope( + self, scope: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TagsResource]: + """Selectively updates the set of tags on a resource or subscription. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Parameters for exporting the template. Required. + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Required. + :type parameters: JSON + :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 TagsResource. The TagsResource is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_at_scope( + self, scope: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TagsResource]: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param 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: An instance of LROPoller that returns either ResourceGroupExportResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + :return: An instance of LROPoller that returns TagsResource. The TagsResource is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_export_template( - self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.ResourceGroupExportResult]: - """Captures the specified resource group as a template. + def begin_update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.TagsResource]: + """Selectively updates the set of tags on a resource or subscription. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Parameters for exporting the template. Is either a ExportTemplateRequest - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.ExportTemplateRequest or IO[bytes] - :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.ResourceGroupExportResult] + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: str + :param parameters: Is one of the following types: TagsPatchResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.resource.resources.models.TagsPatchResource or JSON or IO[bytes] + :return: An instance of LROPoller that returns TagsResource. The TagsResource is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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.ResourceGroupExportResult] = kwargs.pop("cls", None) + cls: ClsType[_models.TagsResource] = 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._export_template_initial( - resource_group_name=resource_group_name, + raw_result = self._update_at_scope_initial( + scope=scope, parameters=parameters, - api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -4573,53 +4973,36 @@ def begin_export_template( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response.http_response) + response = pipeline_response.http_response + deserialized = _deserialize(_models.TagsResource, 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, lro_options={"final-state-via": "location"}, **kwargs) + 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.ResourceGroupExportResult].from_continuation_token( + return LROPoller[_models.TagsResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.ResourceGroupExportResult]( + return LROPoller[_models.TagsResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def list( - self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.ResourceGroup"]: - """Gets all the resource groups for a subscription. - - :param filter: The filter to apply on the operation.\\ :code:`
`\\ :code:`
`You can - filter by tag names and values. For example, to filter for a tag name and value, use - $filter=tagName eq 'tag1' and tagValue eq 'Value1'. Default value is None. - :type filter: str - :param top: The number of results to return. If null is passed, returns all resource groups. - Default value is None. - :type top: int - :return: An iterator like instance of either ResourceGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.ResourceGroup] - :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.ResourceGroupListResult] = kwargs.pop("cls", None) - + def _delete_at_scope_initial(self, scope: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4628,79 +5011,104 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_tags_delete_at_scope_request( + scope=scope, + 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) - def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceGroupListResult", 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) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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.CloudError, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, 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")) - return pipeline_response + deserialized = response.iter_bytes() if _decompress else response.iter_raw() - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized # type: ignore -class TagsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @distributed_trace + def begin_delete_at_scope(self, scope: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the entire set of tags on a resource or subscription. + + Deletes the entire set of tags on a resource or subscription. + + :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. + :type scope: 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_at_scope_initial( + scope=scope, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.resources.ResourceManagementClient`'s - :attr:`tags` attribute. - """ + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - models = _models + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } - 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: ResourceManagementClientConfiguration = 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") + 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 delete_value( # pylint: disable=inconsistent-return-statements @@ -4716,7 +5124,7 @@ def delete_value( # pylint: disable=inconsistent-return-statements :type tag_name: str :param tag_value: The value of the tag to delete. Required. :type tag_value: str - :return: None or the result of cls(response) + :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @@ -4729,20 +5137,22 @@ def delete_value( # pylint: disable=inconsistent-return-statements error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -4753,7 +5163,11 @@ def delete_value( # pylint: disable=inconsistent-return-statements if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore @@ -4769,7 +5183,7 @@ def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) - :type tag_name: str :param tag_value: The value of the tag to create. Required. :type tag_value: str - :return: TagValue or the result of cls(response) + :return: TagValue. The TagValue is compatible with MutableMapping :rtype: ~azure.mgmt.resource.resources.models.TagValue :raises ~azure.core.exceptions.HttpResponseError: """ @@ -4782,22 +5196,25 @@ def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) - error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagValue] = kwargs.pop("cls", None) _request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -4805,10 +5222,22 @@ def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TagValue", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagValue, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4826,7 +5255,7 @@ def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: :param tag_name: The name of the tag to create. Required. :type tag_name: str - :return: TagDetails or the result of cls(response) + :return: TagDetails. The TagDetails is compatible with MutableMapping :rtype: ~azure.mgmt.resource.resources.models.TagDetails :raises ~azure.core.exceptions.HttpResponseError: """ @@ -4839,21 +5268,24 @@ def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagDetails] = kwargs.pop("cls", None) _request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -4861,10 +5293,22 @@ def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TagDetails", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4881,7 +5325,7 @@ def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=incon :param tag_name: The name of the tag. Required. :type tag_name: str - :return: None or the result of cls(response) + :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @@ -4894,19 +5338,21 @@ def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=incon error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -4917,7 +5363,11 @@ def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=incon if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore @@ -4931,15 +5381,14 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.TagDetails"]: subscription. In case of a large number of tags, this operation may return a previously cached result. - :return: An iterator like instance of either TagDetails or the result of cls(response) + :return: An iterator like instance of TagDetails :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.TagDetails] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.TagsListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.TagDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4954,11 +5403,16 @@ def prepare_request(next_link=None): _request = build_tags_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 @@ -4971,18 +5425,29 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + 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 = self._deserialize("TagsListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagDetails], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -4995,15 +5460,270 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) - def _create_or_update_at_scope_initial( - self, scope: str, parameters: Union[_models.TagsResource, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: + +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.ResourceManagementClient`'s + :attr:`providers` 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: ResourceManagementClientConfiguration = 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 list_at_tenant_scope(self, *, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.Provider"]: + """Gets all resource providers for the tenant. + + :keyword expand: The properties to include in the results. Default value is None. + :paramtype expand: str + :return: An iterator like instance of Provider + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Provider]] = 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_providers_list_at_tenant_scope_request( + expand=expand, + 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.Provider], + 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.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. + :type resource_provider_namespace: str + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider + :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.Provider] = kwargs.pop("cls", None) + + _request = build_providers_unregister_request( + resource_provider_namespace=resource_provider_namespace, + 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.CloudError, + 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.Provider, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements + self, resource_provider_namespace: str, group_id: str, **kwargs: Any + ) -> None: + """Registers a management group with a resource provider. Use this operation to register a + resource provider with resource types that can be deployed at the management group scope. It + does not recursively register subscriptions within the management group. Instead, you must + register subscriptions individually. + + :param resource_provider_namespace: The management group ID.The namespace of the resource + provider to register. Required. + :type resource_provider_namespace: str + :param group_id: Required. + :type group_id: 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_providers_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def provider_permissions( + self, resource_provider_namespace: str, **kwargs: Any + ) -> _models.ProviderPermissionListResult: + """Get the provider permissions. + + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :return: ProviderPermissionListResult. The ProviderPermissionListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ProviderPermissionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5012,170 +5732,146 @@ def _create_or_update_at_scope_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "TagsResource") + cls: ClsType[_models.ProviderPermissionListResult] = kwargs.pop("cls", None) - _request = build_tags_create_or_update_at_scope_request( - scope=scope, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, + _request = build_providers_provider_permissions_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProviderPermissionListResult, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload - def begin_create_or_update_at_scope( - self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TagsResource]: - """Creates or updates the entire set of tags on a resource or subscription. - - This operation allows adding or replacing the entire set of tags on the specified resource or - subscription. The specified entity can have a maximum of 50 tags. + def register( + self, + resource_provider_namespace: str, + properties: Optional[_models.ProviderRegistrationRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Required. - :type parameters: ~azure.mgmt.resource.resources.models.TagsResource + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Default value is None. + :type properties: ~azure.mgmt.resource.resources.models.ProviderRegistrationRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update_at_scope( - self, scope: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TagsResource]: - """Creates or updates the entire set of tags on a resource or subscription. + def register( + self, + resource_provider_namespace: str, + properties: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. - This operation allows adding or replacing the entire set of tags on the specified resource or - subscription. The specified entity can have a maximum of 50 tags. + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Default value is None. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Required. - :type parameters: IO[bytes] + @overload + def register( + self, + resource_provider_namespace: str, + properties: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Default value is None. + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update_at_scope( - self, scope: str, parameters: Union[_models.TagsResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.TagsResource]: - """Creates or updates the entire set of tags on a resource or subscription. - - This operation allows adding or replacing the entire set of tags on the specified resource or - subscription. The specified entity can have a maximum of 50 tags. + def register( + self, + resource_provider_namespace: str, + properties: Optional[Union[_models.ProviderRegistrationRequest, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Is either a TagsResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.TagsResource or IO[bytes] - :return: An instance of LROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Is one of the following types: + ProviderRegistrationRequest, JSON, IO[bytes] Default value is None. + :type properties: ~azure.mgmt.resource.resources.models.ProviderRegistrationRequest or JSON or + IO[bytes] + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider :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.TagsResource] = 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_at_scope_initial( - scope=scope, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TagsResource", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.TagsResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.TagsResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_at_scope_initial( - self, scope: str, parameters: Union[_models.TagsPatchResource, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5185,193 +5881,176 @@ def _update_at_scope_initial( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + content_type = content_type if properties else None + cls: ClsType[_models.Provider] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None + content_type = content_type or "application/json" if properties else None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(properties, (IOBase, bytes)): + _content = properties else: - _json = self._serialize.body(parameters, "TagsPatchResource") + if properties is not None: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None - _request = build_tags_update_at_scope_request( - scope=scope, - api_version=api_version, + _request = build_providers_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, content_type=content_type, - json=_json, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Provider, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_update_at_scope( - self, - scope: str, - parameters: _models.TagsPatchResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TagsResource]: - """Selectively updates the set of tags on a resource or subscription. - - This operation allows replacing, merging or selectively deleting tags on the specified resource - or subscription. The specified entity can have a maximum of 50 tags at the end of the - operation. The 'replace' option replaces the entire set of existing tags with a new set. The - 'merge' option allows adding tags with new names and updating the values of tags with existing - names. The 'delete' option allows selectively deleting tags based on given names or name/value - pairs. - - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Required. - :type parameters: ~azure.mgmt.resource.resources.models.TagsPatchResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_at_scope( - self, scope: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TagsResource]: - """Selectively updates the set of tags on a resource or subscription. - - This operation allows replacing, merging or selectively deleting tags on the specified resource - or subscription. The specified entity can have a maximum of 50 tags at the end of the - operation. The 'replace' option replaces the entire set of existing tags with a new set. The - 'merge' option allows adding tags with new names and updating the values of tags with existing - names. The 'delete' option allows selectively deleting tags based on given names or name/value - pairs. - - :param scope: The resource scope. Required. - :type scope: str - :param 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: An instance of LROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_update_at_scope( - self, scope: str, parameters: Union[_models.TagsPatchResource, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.TagsResource]: - """Selectively updates the set of tags on a resource or subscription. - - This operation allows replacing, merging or selectively deleting tags on the specified resource - or subscription. The specified entity can have a maximum of 50 tags at the end of the - operation. The 'replace' option replaces the entire set of existing tags with a new set. The - 'merge' option allows adding tags with new names and updating the values of tags with existing - names. The 'delete' option allows selectively deleting tags based on given names or name/value - pairs. + def list(self, *, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.Provider"]: + """Gets all resource providers for a subscription. - :param scope: The resource scope. Required. - :type scope: str - :param parameters: Is either a TagsPatchResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.resources.models.TagsPatchResource or IO[bytes] - :return: An instance of LROPoller that returns either TagsResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.models.TagsResource] + :keyword expand: The properties to include in the results. For example, use &$expand=metadata + in the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. Default value is None. + :paramtype expand: str + :return: An iterator like instance of Provider + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.models.Provider] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} + _params = 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.TagsResource] = 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_at_scope_initial( - scope=scope, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[List[_models.Provider]] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TagsResource", pipeline_response.http_response) + 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_providers_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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.Provider], + deserialized.get("value", []), + ) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.TagsResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + 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 ) - return LROPoller[_models.TagsResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response - @distributed_trace - def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: - """Gets the entire set of tags on a resource or subscription. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - Gets the entire set of tags on a resource or subscription. + return pipeline_response - :param scope: The resource scope. Required. - :type scope: str - :return: TagsResource or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.models.TagsResource + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :keyword expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. Default value is None. + :paramtype expand: str + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5383,20 +6062,25 @@ def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.TagsResource] = kwargs.pop("cls", None) + cls: ClsType[_models.Provider] = kwargs.pop("cls", None) - _request = build_tags_get_at_scope_request( - scope=scope, - api_version=api_version, + _request = build_providers_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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 ) @@ -5404,17 +6088,43 @@ def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TagsResource", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Provider, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _delete_at_scope_initial(self, scope: str, **kwargs: Any) -> Iterator[bytes]: + @distributed_trace + def get_at_tenant_scope( + self, resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: + """Gets the specified resource provider at the tenant level. + + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :keyword expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. Default value is None. + :paramtype expand: str + :return: Provider. The Provider is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.Provider + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5424,88 +6134,139 @@ def _delete_at_scope_initial(self, scope: str, **kwargs: Any) -> Iterator[bytes] error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.Provider] = kwargs.pop("cls", None) - _request = build_tags_delete_at_scope_request( - scope=scope, - api_version=api_version, + _request = build_providers_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + 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 + _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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Provider, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_delete_at_scope(self, scope: str, **kwargs: Any) -> LROPoller[None]: - """Deletes the entire set of tags on a resource or subscription. - Deletes the entire set of tags on a resource or subscription. +class ProviderResourceTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param scope: The resource scope. Required. - :type scope: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.ResourceManagementClient`'s + :attr:`provider_resource_types` 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: ResourceManagementClientConfiguration = 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 list( + self, resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ProviderResourceTypeListResult: + """List the resource types for a specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :keyword expand: The $expand query parameter. Default value is None. + :paramtype expand: str + :return: ProviderResourceTypeListResult. The ProviderResourceTypeListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.resources.models.ProviderResourceTypeListResult :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = 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_at_scope_initial( - scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.ProviderResourceTypeListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _request = build_provider_resource_types_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + 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) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + _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.CloudError, + response, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + 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.ProviderResourceTypeListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/_patch.py index 2be8919280c2..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/operations/_patch.py @@ -3,14 +3,13 @@ # 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/resources/azure-mgmt-resource/generated_samples/resources/create_resource_group.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/create_resource_group.py index 34a901800905..7a18e95c7374 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/create_resource_group.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/create_resource_group.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.resource_groups.create_or_update( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/CreateResourceGroup.json +# x-ms-original-file: 2025-04-01/CreateResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/delete_tags_resource.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/delete_tags_resource.py index 83985fe4c81d..d9795bb8f965 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/delete_tags_resource.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/delete_tags_resource.py @@ -3,7 +3,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. # -------------------------------------------------------------------------- @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/DeleteTagsResource.json +# x-ms-original-file: 2025-04-01/DeleteTagsResource.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/delete_tags_subscription.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/delete_tags_subscription.py index 0549b8e17bf9..6f332322a327 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/delete_tags_subscription.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/delete_tags_subscription.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -36,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/DeleteTagsSubscription.json +# x-ms-original-file: 2025-04-01/DeleteTagsSubscription.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group.py index 852ea6428601..49eb3b147be5 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.resource_groups.begin_export_template( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/ExportResourceGroup.json +# x-ms-original-file: 2025-04-01/ExportResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group_as_bicep.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group_as_bicep.py index 864717d214fa..cfc11909cfe4 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group_as_bicep.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group_as_bicep.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.resource_groups.begin_export_template( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/ExportResourceGroupAsBicep.json +# x-ms-original-file: 2025-04-01/ExportResourceGroupAsBicep.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group_with_filtering.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group_with_filtering.py index 8706c7813eb1..c228a4d7ca9f 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group_with_filtering.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/export_resource_group_with_filtering.py @@ -3,7 +3,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. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.resource_groups.begin_export_template( @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/ExportResourceGroupWithFiltering.json +# x-ms-original-file: 2025-04-01/ExportResourceGroupWithFiltering.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/force_delete_vms_and_vmss_in_resource_group.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/force_delete_vms_and_vmss_in_resource_group.py index ee44eec281b4..e95e7f9b1611 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/force_delete_vms_and_vmss_in_resource_group.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/force_delete_vms_and_vmss_in_resource_group.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.resource_groups.begin_delete( @@ -36,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json +# x-ms-original-file: 2025-04-01/ForceDeleteVMsAndVMSSInResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/force_delete_vms_in_resource_group.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/force_delete_vms_in_resource_group.py index 3b88b5f37b2b..3c87403e1fe5 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/force_delete_vms_in_resource_group.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/force_delete_vms_in_resource_group.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.resource_groups.begin_delete( @@ -36,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/ForceDeleteVMsInResourceGroup.json +# x-ms-original-file: 2025-04-01/ForceDeleteVMsInResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_named_provider_at_tenant.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_named_provider_at_tenant.py index 0c5d8d1d8db9..c2d688f357ab 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_named_provider_at_tenant.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_named_provider_at_tenant.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/GetNamedProviderAtTenant.json +# x-ms-original-file: 2025-04-01/GetNamedProviderAtTenant.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider.py index 1a59e0aed0c3..f8d818304ed6 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.providers.get( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/GetProvider.json +# x-ms-original-file: 2025-04-01/GetProvider.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider_permissions.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider_permissions.py index 49768879b50e..bedb3a00b4dc 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider_permissions.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider_permissions.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.providers.provider_permissions( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/GetProviderPermissions.json +# x-ms-original-file: 2025-04-01/GetProviderPermissions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider_resource_types.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider_resource_types.py index 09b79e84918f..1294cc81a65f 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider_resource_types.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_provider_resource_types.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.provider_resource_types.list( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/GetProviderResourceTypes.json +# x-ms-original-file: 2025-04-01/GetProviderResourceTypes.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_providers.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_providers.py index 45cd0c24f0b0..6be07ef9fa42 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_providers.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_providers.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = ResourceManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.providers.list() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/GetProviders.json +# x-ms-original-file: 2025-04-01/GetProviders.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_tags_resource.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_tags_resource.py index da345eced31d..4b21fd977062 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_tags_resource.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_tags_resource.py @@ -3,7 +3,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. # -------------------------------------------------------------------------- @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/GetTagsResource.json +# x-ms-original-file: 2025-04-01/GetTagsResource.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_tags_subscription.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_tags_subscription.py index 96a34449d125..b151ac9e28fd 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_tags_subscription.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/get_tags_subscription.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/GetTagsSubscription.json +# x-ms-original-file: 2025-04-01/GetTagsSubscription.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/patch_tags_resource.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/patch_tags_resource.py index b417ea491133..a7d9c9c65c12 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/patch_tags_resource.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/patch_tags_resource.py @@ -3,7 +3,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. # -------------------------------------------------------------------------- @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/PatchTagsResource.json +# x-ms-original-file: 2025-04-01/PatchTagsResource.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/patch_tags_subscription.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/patch_tags_subscription.py index e37b8be07295..f1a7437bbee6 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/patch_tags_subscription.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/patch_tags_subscription.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/PatchTagsSubscription.json +# x-ms-original-file: 2025-04-01/PatchTagsSubscription.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/put_tags_resource.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/put_tags_resource.py index 3e707043612f..100dc27be905 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/put_tags_resource.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/put_tags_resource.py @@ -3,7 +3,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. # -------------------------------------------------------------------------- @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/PutTagsResource.json +# x-ms-original-file: 2025-04-01/PutTagsResource.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_samples/resources/put_tags_subscription.py b/sdk/resources/azure-mgmt-resource/generated_samples/resources/put_tags_subscription.py index 256e10804d90..158e51e727f4 100644 --- a/sdk/resources/azure-mgmt-resource/generated_samples/resources/put_tags_subscription.py +++ b/sdk/resources/azure-mgmt-resource/generated_samples/resources/put_tags_subscription.py @@ -1,9 +1,8 @@ -# 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. # -------------------------------------------------------------------------- @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/resources/stable/2025-04-01/examples/PutTagsSubscription.json +# x-ms-original-file: 2025-04-01/PutTagsSubscription.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/conftest.py b/sdk/resources/azure-mgmt-resource/generated_tests/conftest.py index 82b5f79fbbd0..68bdc697fd08 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/conftest.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/conftest.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. # -------------------------------------------------------------------------- import os diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_operations.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_operations.py index a8b3fa566ec4..c5f9c040dda6 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_operations.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_operations.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. # -------------------------------------------------------------------------- import pytest @@ -21,9 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_operations_list(self, resource_group): - response = self.client.operations.list( - api_version="2025-04-01", - ) + response = self.client.operations.list() result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_operations_async.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_operations_async.py index dde882343d59..7a073a75feed 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_operations_async.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_operations_async.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. # -------------------------------------------------------------------------- import pytest @@ -22,9 +22,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_operations_list(self, resource_group): - response = self.client.operations.list( - api_version="2025-04-01", - ) + response = self.client.operations.list() result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_provider_resource_types_operations.py index 236acf6a6d9c..e0674972cf4f 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_provider_resource_types_operations.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_provider_resource_types_operations.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. # -------------------------------------------------------------------------- import pytest @@ -23,7 +23,6 @@ def setup_method(self, method): def test_provider_resource_types_list(self, resource_group): response = self.client.provider_resource_types.list( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_provider_resource_types_operations_async.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_provider_resource_types_operations_async.py index ed8e30c283dd..952e20d6247d 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_provider_resource_types_operations_async.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_provider_resource_types_operations_async.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. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def setup_method(self, method): async def test_provider_resource_types_list(self, resource_group): response = await self.client.provider_resource_types.list( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_providers_operations.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_providers_operations.py index 986c00b7bda8..30b67091605a 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_providers_operations.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. # -------------------------------------------------------------------------- import pytest @@ -18,12 +18,19 @@ class TestResourceManagementProvidersOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ResourceManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_providers_list_at_tenant_scope(self, resource_group): + response = self.client.providers.list_at_tenant_scope() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_providers_unregister(self, resource_group): response = self.client.providers.unregister( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -35,7 +42,6 @@ def test_providers_register_at_management_group_scope(self, resource_group): response = self.client.providers.register_at_management_group_scope( resource_provider_namespace="str", group_id="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -46,7 +52,6 @@ def test_providers_register_at_management_group_scope(self, resource_group): def test_providers_provider_permissions(self, resource_group): response = self.client.providers.provider_permissions( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -57,7 +62,6 @@ def test_providers_provider_permissions(self, resource_group): def test_providers_register(self, resource_group): response = self.client.providers.register( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -66,19 +70,7 @@ def test_providers_register(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_providers_list(self, resource_group): - response = self.client.providers.list( - api_version="2025-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_providers_list_at_tenant_scope(self, resource_group): - response = self.client.providers.list_at_tenant_scope( - api_version="2025-04-01", - ) + response = self.client.providers.list() result = [r for r in response] # please add some check logic here by yourself # ... @@ -88,7 +80,6 @@ def test_providers_list_at_tenant_scope(self, resource_group): def test_providers_get(self, resource_group): response = self.client.providers.get( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -99,7 +90,6 @@ def test_providers_get(self, resource_group): def test_providers_get_at_tenant_scope(self, resource_group): response = self.client.providers.get_at_tenant_scope( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_providers_operations_async.py index fee1472e7a07..7323a81777af 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_providers_operations_async.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_providers_operations_async.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. # -------------------------------------------------------------------------- import pytest @@ -19,12 +19,19 @@ class TestResourceManagementProvidersOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ResourceManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_providers_list_at_tenant_scope(self, resource_group): + response = self.client.providers.list_at_tenant_scope() + 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_providers_unregister(self, resource_group): response = await self.client.providers.unregister( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -36,7 +43,6 @@ async def test_providers_register_at_management_group_scope(self, resource_group response = await self.client.providers.register_at_management_group_scope( resource_provider_namespace="str", group_id="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -47,7 +53,6 @@ async def test_providers_register_at_management_group_scope(self, resource_group async def test_providers_provider_permissions(self, resource_group): response = await self.client.providers.provider_permissions( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -58,7 +63,6 @@ async def test_providers_provider_permissions(self, resource_group): async def test_providers_register(self, resource_group): response = await self.client.providers.register( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -67,19 +71,7 @@ async def test_providers_register(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_providers_list(self, resource_group): - response = self.client.providers.list( - api_version="2025-04-01", - ) - 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_providers_list_at_tenant_scope(self, resource_group): - response = self.client.providers.list_at_tenant_scope( - api_version="2025-04-01", - ) + response = self.client.providers.list() result = [r async for r in response] # please add some check logic here by yourself # ... @@ -89,7 +81,6 @@ async def test_providers_list_at_tenant_scope(self, resource_group): async def test_providers_get(self, resource_group): response = await self.client.providers.get( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -100,7 +91,6 @@ async def test_providers_get(self, resource_group): async def test_providers_get_at_tenant_scope(self, resource_group): response = await self.client.providers.get_at_tenant_scope( resource_provider_namespace="str", - api_version="2025-04-01", ) # please add some check logic here by yourself diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resource_groups_operations.py index da3ebbc4ebcc..22b02bdf7770 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resource_groups_operations.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. # -------------------------------------------------------------------------- import pytest @@ -18,12 +18,21 @@ class TestResourceManagementResourceGroupsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ResourceManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_resource_groups_get(self, resource_group): + response = self.client.resource_groups.get( + resource_group_name=resource_group.name, + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_resource_groups_check_existence(self, resource_group): response = self.client.resource_groups.check_existence( resource_group_name=resource_group.name, - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -40,32 +49,17 @@ def test_resource_groups_create_or_update(self, resource_group): "managedBy": "str", "name": "str", "properties": {"provisioningState": "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", }, - api_version="2025-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_resource_groups_begin_delete(self, resource_group): - response = self.client.resource_groups.begin_delete( - resource_group_name=resource_group.name, - api_version="2025-04-01", - ).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_resource_groups_get(self, resource_group): - response = self.client.resource_groups.get( - resource_group_name=resource_group.name, - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -82,7 +76,6 @@ def test_resource_groups_update(self, resource_group): "properties": {"provisioningState": "str"}, "tags": {"str": "str"}, }, - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -90,11 +83,9 @@ def test_resource_groups_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_resource_groups_begin_export_template(self, resource_group): - response = self.client.resource_groups.begin_export_template( + def test_resource_groups_begin_delete(self, resource_group): + response = self.client.resource_groups.begin_delete( resource_group_name=resource_group.name, - parameters={"options": "str", "outputFormat": "str", "resources": ["str"]}, - api_version="2025-04-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -103,9 +94,18 @@ def test_resource_groups_begin_export_template(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_resource_groups_list(self, resource_group): - response = self.client.resource_groups.list( - api_version="2025-04-01", - ) + response = self.client.resource_groups.list() result = [r for r in response] # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_resource_groups_begin_export_template(self, resource_group): + response = self.client.resource_groups.begin_export_template( + resource_group_name=resource_group.name, + parameters={"options": "str", "outputFormat": "str", "resources": ["str"]}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resource_groups_operations_async.py index 9c97538a263d..5402af1af6de 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resource_groups_operations_async.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resource_groups_operations_async.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. # -------------------------------------------------------------------------- import pytest @@ -19,12 +19,21 @@ class TestResourceManagementResourceGroupsOperationsAsync(AzureMgmtRecordedTestC def setup_method(self, method): self.client = self.create_mgmt_client(ResourceManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_resource_groups_get(self, resource_group): + response = await self.client.resource_groups.get( + 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_resource_groups_check_existence(self, resource_group): response = await self.client.resource_groups.check_existence( resource_group_name=resource_group.name, - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -41,34 +50,17 @@ async def test_resource_groups_create_or_update(self, resource_group): "managedBy": "str", "name": "str", "properties": {"provisioningState": "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", }, - api_version="2025-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_resource_groups_begin_delete(self, resource_group): - response = await ( - await self.client.resource_groups.begin_delete( - resource_group_name=resource_group.name, - api_version="2025-04-01", - ) - ).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_resource_groups_get(self, resource_group): - response = await self.client.resource_groups.get( - resource_group_name=resource_group.name, - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -85,7 +77,6 @@ async def test_resource_groups_update(self, resource_group): "properties": {"provisioningState": "str"}, "tags": {"str": "str"}, }, - api_version="2025-04-01", ) # please add some check logic here by yourself @@ -93,12 +84,10 @@ async def test_resource_groups_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resource_groups_begin_export_template(self, resource_group): + async def test_resource_groups_begin_delete(self, resource_group): response = await ( - await self.client.resource_groups.begin_export_template( + await self.client.resource_groups.begin_delete( resource_group_name=resource_group.name, - parameters={"options": "str", "outputFormat": "str", "resources": ["str"]}, - api_version="2025-04-01", ) ).result() # call '.result()' to poll until service return final result @@ -108,9 +97,20 @@ async def test_resource_groups_begin_export_template(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_resource_groups_list(self, resource_group): - response = self.client.resource_groups.list( - api_version="2025-04-01", - ) + response = self.client.resource_groups.list() 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_resource_groups_begin_export_template(self, resource_group): + response = await ( + await self.client.resource_groups.begin_export_template( + resource_group_name=resource_group.name, + parameters={"options": "str", "outputFormat": "str", "resources": ["str"]}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resources_operations.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resources_operations.py index f9a03c41d101..2431c5918585 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resources_operations.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. # -------------------------------------------------------------------------- import pytest @@ -23,7 +23,6 @@ def setup_method(self, method): def test_resources_list_by_resource_group(self, resource_group): response = self.client.resources.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2025-04-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -35,7 +34,6 @@ def test_resources_begin_move_resources(self, resource_group): response = self.client.resources.begin_move_resources( source_resource_group_name="str", parameters={"resources": ["str"], "targetResourceGroup": "str"}, - api_version="2025-04-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -47,7 +45,6 @@ def test_resources_begin_validate_move_resources(self, resource_group): response = self.client.resources.begin_validate_move_resources( source_resource_group_name="str", parameters={"resources": ["str"], "targetResourceGroup": "str"}, - api_version="2025-04-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -55,23 +52,9 @@ def test_resources_begin_validate_move_resources(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_resources_list(self, resource_group): - response = self.client.resources.list( - api_version="2025-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_resources_check_existence(self, resource_group): - response = self.client.resources.check_existence( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", + def test_resources_check_existence_by_id(self, resource_group): + response = self.client.resources.check_existence_by_id( + resource_id="str", api_version="str", ) @@ -80,29 +63,20 @@ def test_resources_check_existence(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_resources_begin_delete(self, resource_group): - response = self.client.resources.begin_delete( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", + def test_resources_get_by_id(self, resource_group): + response = self.client.resources.get_by_id( + resource_id="str", api_version="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_resources_begin_create_or_update(self, resource_group): - response = self.client.resources.begin_create_or_update( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - api_version="str", + def test_resources_begin_create_or_update_by_id(self, resource_group): + response = self.client.resources.begin_create_or_update_by_id( + resource_id="str", parameters={ "extendedLocation": {"name": "str", "type": "str"}, "id": "str", @@ -119,9 +93,18 @@ def test_resources_begin_create_or_update(self, resource_group): "plan": {"name": "str", "product": "str", "promotionCode": "str", "publisher": "str", "version": "str"}, "properties": {}, "sku": {"capacity": 0, "family": "str", "model": "str", "name": "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", }, + api_version="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -129,14 +112,9 @@ def test_resources_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_resources_begin_update(self, resource_group): - response = self.client.resources.begin_update( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - api_version="str", + def test_resources_begin_update_by_id(self, resource_group): + response = self.client.resources.begin_update_by_id( + resource_id="str", parameters={ "extendedLocation": {"name": "str", "type": "str"}, "id": "str", @@ -153,9 +131,18 @@ def test_resources_begin_update(self, resource_group): "plan": {"name": "str", "product": "str", "promotionCode": "str", "publisher": "str", "version": "str"}, "properties": {}, "sku": {"capacity": 0, "family": "str", "model": "str", "name": "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", }, + api_version="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -163,24 +150,24 @@ def test_resources_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_resources_get(self, resource_group): - response = self.client.resources.get( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", + def test_resources_begin_delete_by_id(self, resource_group): + response = self.client.resources.begin_delete_by_id( + resource_id="str", api_version="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_resources_check_existence_by_id(self, resource_group): - response = self.client.resources.check_existence_by_id( - resource_id="str", + def test_resources_check_existence(self, resource_group): + response = self.client.resources.check_existence( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", api_version="str", ) @@ -189,21 +176,28 @@ def test_resources_check_existence_by_id(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_resources_begin_delete_by_id(self, resource_group): - response = self.client.resources.begin_delete_by_id( - resource_id="str", + def test_resources_get(self, resource_group): + response = self.client.resources.get( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", api_version="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_resources_begin_create_or_update_by_id(self, resource_group): - response = self.client.resources.begin_create_or_update_by_id( - resource_id="str", - api_version="str", + def test_resources_begin_create_or_update(self, resource_group): + response = self.client.resources.begin_create_or_update( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", parameters={ "extendedLocation": {"name": "str", "type": "str"}, "id": "str", @@ -220,9 +214,18 @@ def test_resources_begin_create_or_update_by_id(self, resource_group): "plan": {"name": "str", "product": "str", "promotionCode": "str", "publisher": "str", "version": "str"}, "properties": {}, "sku": {"capacity": 0, "family": "str", "model": "str", "name": "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", }, + api_version="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -230,10 +233,13 @@ def test_resources_begin_create_or_update_by_id(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_resources_begin_update_by_id(self, resource_group): - response = self.client.resources.begin_update_by_id( - resource_id="str", - api_version="str", + def test_resources_begin_update(self, resource_group): + response = self.client.resources.begin_update( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", parameters={ "extendedLocation": {"name": "str", "type": "str"}, "id": "str", @@ -250,9 +256,18 @@ def test_resources_begin_update_by_id(self, resource_group): "plan": {"name": "str", "product": "str", "promotionCode": "str", "publisher": "str", "version": "str"}, "properties": {}, "sku": {"capacity": 0, "family": "str", "model": "str", "name": "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", }, + api_version="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -260,11 +275,23 @@ def test_resources_begin_update_by_id(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_resources_get_by_id(self, resource_group): - response = self.client.resources.get_by_id( - resource_id="str", + def test_resources_begin_delete(self, resource_group): + response = self.client.resources.begin_delete( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", api_version="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_resources_list(self, resource_group): + response = self.client.resources.list() + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resources_operations_async.py index de94c5b3b71f..f7c8147831d1 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resources_operations_async.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_resources_operations_async.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. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def setup_method(self, method): async def test_resources_list_by_resource_group(self, resource_group): response = self.client.resources.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2025-04-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -37,7 +36,6 @@ async def test_resources_begin_move_resources(self, resource_group): await self.client.resources.begin_move_resources( source_resource_group_name="str", parameters={"resources": ["str"], "targetResourceGroup": "str"}, - api_version="2025-04-01", ) ).result() # call '.result()' to poll until service return final result @@ -51,7 +49,6 @@ async def test_resources_begin_validate_move_resources(self, resource_group): await self.client.resources.begin_validate_move_resources( source_resource_group_name="str", parameters={"resources": ["str"], "targetResourceGroup": "str"}, - api_version="2025-04-01", ) ).result() # call '.result()' to poll until service return final result @@ -60,23 +57,9 @@ async def test_resources_begin_validate_move_resources(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_list(self, resource_group): - response = self.client.resources.list( - api_version="2025-04-01", - ) - 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_resources_check_existence(self, resource_group): - response = await self.client.resources.check_existence( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", + async def test_resources_check_existence_by_id(self, resource_group): + response = await self.client.resources.check_existence_by_id( + resource_id="str", api_version="str", ) @@ -85,32 +68,21 @@ async def test_resources_check_existence(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_begin_delete(self, resource_group): - response = await ( - await self.client.resources.begin_delete( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - api_version="str", - ) - ).result() # call '.result()' to poll until service return final result + async def test_resources_get_by_id(self, resource_group): + response = await self.client.resources.get_by_id( + resource_id="str", + api_version="str", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_begin_create_or_update(self, resource_group): + async def test_resources_begin_create_or_update_by_id(self, resource_group): response = await ( - await self.client.resources.begin_create_or_update( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - api_version="str", + await self.client.resources.begin_create_or_update_by_id( + resource_id="str", parameters={ "extendedLocation": {"name": "str", "type": "str"}, "id": "str", @@ -140,9 +112,18 @@ async def test_resources_begin_create_or_update(self, resource_group): "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", }, + api_version="str", ) ).result() # call '.result()' to poll until service return final result @@ -151,15 +132,10 @@ async def test_resources_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_begin_update(self, resource_group): + async def test_resources_begin_update_by_id(self, resource_group): response = await ( - await self.client.resources.begin_update( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - api_version="str", + await self.client.resources.begin_update_by_id( + resource_id="str", parameters={ "extendedLocation": {"name": "str", "type": "str"}, "id": "str", @@ -189,9 +165,18 @@ async def test_resources_begin_update(self, resource_group): "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", }, + api_version="str", ) ).result() # call '.result()' to poll until service return final result @@ -200,8 +185,21 @@ async def test_resources_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_get(self, resource_group): - response = await self.client.resources.get( + async def test_resources_begin_delete_by_id(self, resource_group): + response = await ( + await self.client.resources.begin_delete_by_id( + resource_id="str", + api_version="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_resources_check_existence(self, resource_group): + response = await self.client.resources.check_existence( resource_group_name=resource_group.name, resource_provider_namespace="str", parent_resource_path="str", @@ -215,9 +213,13 @@ async def test_resources_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_check_existence_by_id(self, resource_group): - response = await self.client.resources.check_existence_by_id( - resource_id="str", + async def test_resources_get(self, resource_group): + response = await self.client.resources.get( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", api_version="str", ) @@ -226,24 +228,14 @@ async def test_resources_check_existence_by_id(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_begin_delete_by_id(self, resource_group): - response = await ( - await self.client.resources.begin_delete_by_id( - resource_id="str", - api_version="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_resources_begin_create_or_update_by_id(self, resource_group): + async def test_resources_begin_create_or_update(self, resource_group): response = await ( - await self.client.resources.begin_create_or_update_by_id( - resource_id="str", - api_version="str", + await self.client.resources.begin_create_or_update( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", parameters={ "extendedLocation": {"name": "str", "type": "str"}, "id": "str", @@ -273,9 +265,18 @@ async def test_resources_begin_create_or_update_by_id(self, resource_group): "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", }, + api_version="str", ) ).result() # call '.result()' to poll until service return final result @@ -284,11 +285,14 @@ async def test_resources_begin_create_or_update_by_id(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_begin_update_by_id(self, resource_group): + async def test_resources_begin_update(self, resource_group): response = await ( - await self.client.resources.begin_update_by_id( - resource_id="str", - api_version="str", + await self.client.resources.begin_update( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", parameters={ "extendedLocation": {"name": "str", "type": "str"}, "id": "str", @@ -318,9 +322,18 @@ async def test_resources_begin_update_by_id(self, resource_group): "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", }, + api_version="str", ) ).result() # call '.result()' to poll until service return final result @@ -329,11 +342,25 @@ async def test_resources_begin_update_by_id(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_resources_get_by_id(self, resource_group): - response = await self.client.resources.get_by_id( - resource_id="str", - api_version="str", - ) + async def test_resources_begin_delete(self, resource_group): + response = await ( + await self.client.resources.begin_delete( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="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_resources_list(self, resource_group): + response = self.client.resources.list() + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_tags_operations.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_tags_operations.py index 77efcfaafb6d..71a3ce532cd4 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_tags_operations.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. # -------------------------------------------------------------------------- import pytest @@ -20,11 +20,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tags_delete_value(self, resource_group): - response = self.client.tags.delete_value( - tag_name="str", - tag_value="str", - api_version="2025-04-01", + def test_tags_get_at_scope(self, resource_group): + response = self.client.tags.get_at_scope( + scope="str", ) # please add some check logic here by yourself @@ -32,78 +30,86 @@ def test_tags_delete_value(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tags_create_or_update_value(self, resource_group): - response = self.client.tags.create_or_update_value( - tag_name="str", - tag_value="str", - api_version="2025-04-01", - ) + def test_tags_begin_create_or_update_at_scope(self, resource_group): + response = self.client.tags.begin_create_or_update_at_scope( + scope="str", + parameters={ + "properties": {"tags": {"str": "str"}}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "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_tags_create_or_update(self, resource_group): - response = self.client.tags.create_or_update( - tag_name="str", - api_version="2025-04-01", - ) + def test_tags_begin_update_at_scope(self, resource_group): + response = self.client.tags.begin_update_at_scope( + scope="str", + parameters={"operation": "str", "properties": {"tags": {"str": "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_tags_delete(self, resource_group): - response = self.client.tags.delete( - tag_name="str", - api_version="2025-04-01", - ) + def test_tags_begin_delete_at_scope(self, resource_group): + response = self.client.tags.begin_delete_at_scope( + scope="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_tags_list(self, resource_group): - response = self.client.tags.list( - api_version="2025-04-01", + def test_tags_delete_value(self, resource_group): + response = self.client.tags.delete_value( + tag_name="str", + tag_value="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tags_begin_create_or_update_at_scope(self, resource_group): - response = self.client.tags.begin_create_or_update_at_scope( - scope="str", - parameters={"properties": {"tags": {"str": "str"}}, "id": "str", "name": "str", "type": "str"}, - api_version="2025-04-01", - ).result() # call '.result()' to poll until service return final result + def test_tags_create_or_update_value(self, resource_group): + response = self.client.tags.create_or_update_value( + tag_name="str", + tag_value="str", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tags_begin_update_at_scope(self, resource_group): - response = self.client.tags.begin_update_at_scope( - scope="str", - parameters={"operation": "str", "properties": {"tags": {"str": "str"}}}, - api_version="2025-04-01", - ).result() # call '.result()' to poll until service return final result + def test_tags_create_or_update(self, resource_group): + response = self.client.tags.create_or_update( + tag_name="str", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tags_get_at_scope(self, resource_group): - response = self.client.tags.get_at_scope( - scope="str", - api_version="2025-04-01", + def test_tags_delete(self, resource_group): + response = self.client.tags.delete( + tag_name="str", ) # please add some check logic here by yourself @@ -111,11 +117,8 @@ def test_tags_get_at_scope(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tags_begin_delete_at_scope(self, resource_group): - response = self.client.tags.begin_delete_at_scope( - scope="str", - api_version="2025-04-01", - ).result() # call '.result()' to poll until service return final result - + def test_tags_list(self, resource_group): + response = self.client.tags.list() + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_tags_operations_async.py index 79efc8d75432..f850bf2d01db 100644 --- a/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_tags_operations_async.py +++ b/sdk/resources/azure-mgmt-resource/generated_tests/test_resource_management_tags_operations_async.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. # -------------------------------------------------------------------------- import pytest @@ -21,11 +21,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tags_delete_value(self, resource_group): - response = await self.client.tags.delete_value( - tag_name="str", - tag_value="str", - api_version="2025-04-01", + async def test_tags_get_at_scope(self, resource_group): + response = await self.client.tags.get_at_scope( + scope="str", ) # please add some check logic here by yourself @@ -33,82 +31,92 @@ async def test_tags_delete_value(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tags_create_or_update_value(self, resource_group): - response = await self.client.tags.create_or_update_value( - tag_name="str", - tag_value="str", - api_version="2025-04-01", - ) + async def test_tags_begin_create_or_update_at_scope(self, resource_group): + response = await ( + await self.client.tags.begin_create_or_update_at_scope( + scope="str", + parameters={ + "properties": {"tags": {"str": "str"}}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "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_tags_create_or_update(self, resource_group): - response = await self.client.tags.create_or_update( - tag_name="str", - api_version="2025-04-01", - ) + async def test_tags_begin_update_at_scope(self, resource_group): + response = await ( + await self.client.tags.begin_update_at_scope( + scope="str", + parameters={"operation": "str", "properties": {"tags": {"str": "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_tags_delete(self, resource_group): - response = await self.client.tags.delete( - tag_name="str", - api_version="2025-04-01", - ) + async def test_tags_begin_delete_at_scope(self, resource_group): + response = await ( + await self.client.tags.begin_delete_at_scope( + scope="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_tags_list(self, resource_group): - response = self.client.tags.list( - api_version="2025-04-01", + async def test_tags_delete_value(self, resource_group): + response = await self.client.tags.delete_value( + tag_name="str", + tag_value="str", ) - 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_tags_begin_create_or_update_at_scope(self, resource_group): - response = await ( - await self.client.tags.begin_create_or_update_at_scope( - scope="str", - parameters={"properties": {"tags": {"str": "str"}}, "id": "str", "name": "str", "type": "str"}, - api_version="2025-04-01", - ) - ).result() # call '.result()' to poll until service return final result + async def test_tags_create_or_update_value(self, resource_group): + response = await self.client.tags.create_or_update_value( + tag_name="str", + tag_value="str", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tags_begin_update_at_scope(self, resource_group): - response = await ( - await self.client.tags.begin_update_at_scope( - scope="str", - parameters={"operation": "str", "properties": {"tags": {"str": "str"}}}, - api_version="2025-04-01", - ) - ).result() # call '.result()' to poll until service return final result + async def test_tags_create_or_update(self, resource_group): + response = await self.client.tags.create_or_update( + tag_name="str", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tags_get_at_scope(self, resource_group): - response = await self.client.tags.get_at_scope( - scope="str", - api_version="2025-04-01", + async def test_tags_delete(self, resource_group): + response = await self.client.tags.delete( + tag_name="str", ) # please add some check logic here by yourself @@ -116,13 +124,8 @@ async def test_tags_get_at_scope(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tags_begin_delete_at_scope(self, resource_group): - response = await ( - await self.client.tags.begin_delete_at_scope( - scope="str", - api_version="2025-04-01", - ) - ).result() # call '.result()' to poll until service return final result - + async def test_tags_list(self, resource_group): + response = self.client.tags.list() + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/resources/azure-mgmt-resource/pyproject.toml b/sdk/resources/azure-mgmt-resource/pyproject.toml index c30a680d2e02..bc3f8c854ae7 100644 --- a/sdk/resources/azure-mgmt-resource/pyproject.toml +++ b/sdk/resources/azure-mgmt-resource/pyproject.toml @@ -13,17 +13,16 @@ authors = [ description = "Microsoft Azure Resource Management Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", ] -requires-python = ">=3.9" +requires-python = ">=3.10" keywords = [ "azure", "azure sdk", @@ -42,7 +41,7 @@ dynamic = [ repository = "https://github.com/Azure/azure-sdk-for-python" [tool.setuptools.dynamic.version] -attr = "azure.mgmt.resource._version.VERSION" +attr = "azure.mgmt.resource.resources._version.VERSION" [tool.setuptools.dynamic.readme] file = [ @@ -60,6 +59,7 @@ exclude = [ "doc*", "azure", "azure.mgmt", + "azure.mgmt.resource", ] [tool.setuptools.package-data] @@ -78,7 +78,7 @@ verifytypes = false package_name = "azure-mgmt-resource" package_pprint_name = "Resource Management" package_doc_id = "resources?view=azure-python-preview" -is_stable = true +is_stable = false need_msrestazure = false need_azuremgmtcore = true sample_link = "" diff --git a/sdk/resources/azure-mgmt-resource/tsp-location.yaml b/sdk/resources/azure-mgmt-resource/tsp-location.yaml new file mode 100644 index 000000000000..39e7ada6215e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/resources/resource-manager/Microsoft.Resources/resources +commit: a70a8a6457e2f1d56fea576a652196346ba42c14 +repo: Azure/azure-rest-api-specs +additionalDirectories: